调整jupter 和课堂shixun相关

yslnewtiku
杨树明 5 years ago
parent 2d987c9e3e
commit 939383c457

@ -27,7 +27,7 @@ function onMessageByLocalStorage(eventName, callback) {
}
window.addEventListener("storage", function(ev) {
const cb = localStorageMap[ev.key];
console.log('storage event:', ev)
// console.log('storage event:', ev)
if (cb) {
cb(JSON.parse(ev.newValue))
}

@ -34,6 +34,7 @@ class NewShixunModel extends Component{
getdatalist=(page,type,newstatus,keyword,order,diff,limit,pagetype,sorts)=>{
let newsort=sorts;
let no_jupyter=undefined;
if(this.props.type==="shixuns"&&type==="mine"){
if(this.props&&this.props.user.course_name===undefined){
newsort="created_at";
@ -41,6 +42,12 @@ class NewShixunModel extends Component{
newsort="publish_time";
}
}
if(this.props.type==="shixuns"){
if(this.props&&this.props.user.course_name===undefined){
}else{
no_jupyter=1;
}
}
this.setState({
isspinning:true
})
@ -51,6 +58,7 @@ class NewShixunModel extends Component{
}else{
url="/subject_lists.json";
}
axios.get(url,{params:{
page:page,
type:type,
@ -59,7 +67,8 @@ class NewShixunModel extends Component{
order:order,
diff:diff,
limit:limit,
sort:newsort
sort:newsort,
no_jupyter:no_jupyter
}}).then((response) => {
if(response.data){
if(pagetype===undefined){

@ -383,8 +383,6 @@ class TPMIndex extends Component {
let url = window.location.href;
let flag = url.indexOf("add_file")>-1;
console.log(this.state.openknows)
return (
<div className="newMain clearfix">
{/*头部*/}

@ -88,6 +88,15 @@ function JupyterTPI (props) {
const [myIdentifier, setMyIdentifier] = useState('');
const [renderCtx, setRenderCtx] = useState(() => (emptyCtx));
let newHandletype=false
const newHandle = function (event) {
if(newHandletype===false){
newHandletype=true
saveJupyterTpi(event);
setTimeout(()=>{newHandletype=false},500)
}
}
// 保存代码
const addEventListeners = () => {
window.addEventListener('message', (e) => {
@ -95,12 +104,10 @@ function JupyterTPI (props) {
if(e){
if(e.data){
if(e.data==="jupytermessage"){
saveJupyterTpi();
newHandle()
}
}
}
})
}

@ -15,7 +15,8 @@ import {
fetchSyncJupyterCode,
fetchreset_with_tpi,
fetchSaveJupyterTpi,
fetactive_with_tpi
fetactive_with_tpi,
timeinfo_with_tpis
} from "../../services/jupyterServer";
// 获取 jupyter 相关信息
@ -76,7 +77,9 @@ export const getJupyterTpiUrl = (obj) => {
console.log('获取url', res);
if (res.status === 200) {
const { status, url = '', port } = res.data;
addjypertime(Date.now() +3600 * 1000)
dispatch(updataspinning(false))
setTimeout(()=>{ dispatch(addjypertime(Date.now() +3600 * 1000))},500)
// timeinfo_with_tpi(id,dispatch)
dispatch({
type: types.GET_JUPYTER_TPI_URL,
payload: {
@ -106,7 +109,7 @@ export const syncJupyterCode = (identifier, msg) => {
const {status} = res.data
if (status === 0) {
message.success(msg);
updataspinning(false)
dispatch(updataspinning(false))
setTimeout(() => {
window.location.reload();
}, 300);
@ -131,7 +134,7 @@ export const reset_with_tpi = (identifier, msg) => {
const {status} = res.data
if (status === 0) {
message.success(msg);
updataspinning(false)
dispatch(updataspinning(false))
setTimeout(() => {
window.location.reload();
}, 300);
@ -156,7 +159,7 @@ export const active_with_tpi = (identifier, msg) => {
const {status} = res.data
if (status === 0) {
message.success(msg);
addjypertime(Date.now() + 900 * 1000);
dispatch(addjypertime(Date.now() + 900 * 1000))
}
}
})
@ -171,6 +174,7 @@ export const changeGetJupyterUrlState = (status) => {
payload: status
}
}
// 保存 jupyter tpi
export const saveJupyterTpi = () => {
return (dispatch, getState) => {
@ -234,3 +238,29 @@ export const updataspinning=(type)=>{
}
}
// 获取重置实训后的时间
export const timeinfo_with_tpi = (identifier, dispatch) => {
debugger
const params = {
identifier: identifier
};
debugger
timeinfo_with_tpis(params).then(res => {
debugger
console.log('同步时间成功: ', res);
if (res.data.status === 401) return;
if (res.status === 200) {
const {status} = res.data
console.log(status)
// dispatch(addjypertime(Date.now() +3600 * 1000))
// setTimeout(()=>{ dispatch(addjypertime(Date.now() +3600 * 1000))},500)
// if (status === 0) {
// message.success(msg);
// dispatch(updataspinning(false))
// setTimeout(() => {
// window.location.reload();
// }, 300);
// }
}
})
}

@ -16,7 +16,7 @@ const initialState = {
publishLoading: false, // 发布
isMySource: false,
drawervisible:false,
jupytertime:Date.now() + 3600 * 1000,
jupytertime:0,
spinning:false
}

@ -45,3 +45,10 @@ export async function fetactive_with_tpi(params) {
const url = `/jupyters/active_with_tpi.json`;
return axios.get(url, { params });
}
//获取tpi重置实训的time
export async function timeinfo_with_tpis(params){
const url = `/jupyters/timeinfo_with_tpi.json`;
return axios.get(url, { params });
}
Loading…
Cancel
Save