|
|
|
@ -9,7 +9,7 @@
|
|
|
|
|
import './index.scss';
|
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
import SplitPane from 'react-split-pane';
|
|
|
|
|
import { Button, Modal,Drawer ,Pagination,Empty,Tooltip,Icon,message} from 'antd';
|
|
|
|
|
import { Button, Modal,Drawer ,Pagination,Empty,Tooltip,Icon,message,Statistic} from 'antd';
|
|
|
|
|
import {
|
|
|
|
|
connect
|
|
|
|
|
} from 'react-redux';
|
|
|
|
@ -18,6 +18,7 @@ import UserInfo from '../../developer/components/userInfo';
|
|
|
|
|
import actions from '../../../redux/actions';
|
|
|
|
|
import LeftPane from './leftPane';
|
|
|
|
|
import RightPane from './rightPane';
|
|
|
|
|
const { Countdown } = Statistic;
|
|
|
|
|
import MyIcon from "../../../common/components/MyIcon";
|
|
|
|
|
function jsCopy(s) {
|
|
|
|
|
var copyEle = document.getElementById(s);
|
|
|
|
@ -62,6 +63,7 @@ function JupyterTPI (props) {
|
|
|
|
|
changeCurrentPage,
|
|
|
|
|
changeshowDrawer,
|
|
|
|
|
drawervisible,
|
|
|
|
|
reset_with_tpi,
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
const emptyCtx = (
|
|
|
|
@ -89,20 +91,37 @@ function JupyterTPI (props) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const stopposttpip=(sum)=>{
|
|
|
|
|
var _iframe = document.getElementById("rightPaneframe");
|
|
|
|
|
if(_iframe == null || _iframe == undefined || _iframe == ""){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(sum===1){
|
|
|
|
|
_iframe.contentWindow.postMessage("stopParent", "*");
|
|
|
|
|
}else{
|
|
|
|
|
_iframe.contentWindow.postMessage("clonsParent", "*");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
addEventListeners()
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
/* 先调用 jupyter的 TPI 接口,
|
|
|
|
|
* 获取 用户信息,
|
|
|
|
|
/* 先调用 jupyter的 TPI 接口,
|
|
|
|
|
* 获取 用户信息,
|
|
|
|
|
* 实训的 identifier, 状态, 名称, 是否被修改等信息
|
|
|
|
|
*/
|
|
|
|
|
addEventListeners()
|
|
|
|
|
getJupyterInfo(identifier);
|
|
|
|
|
}, [identifier]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
|
|
// 设置jupyter信息
|
|
|
|
|
setJupyterInfo(jupyter_info || {});
|
|
|
|
|
const {user, tpm_modified, myshixun_identifier} = jupyter_info;
|
|
|
|
@ -116,10 +135,12 @@ function JupyterTPI (props) {
|
|
|
|
|
|
|
|
|
|
// 同步代码
|
|
|
|
|
if (tpm_modified && updateTip && myshixun_identifier) {
|
|
|
|
|
|
|
|
|
|
setUpdateTip(false);
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
title: '更新通知',
|
|
|
|
|
content: (<div className="update_notice">
|
|
|
|
|
{stopposttpip(1)}
|
|
|
|
|
<p className="update_txt">关卡任务的代码文件有更新啦</p>
|
|
|
|
|
<p className="update_txt">更新操作将保留已完成的评测记录和成绩</p>
|
|
|
|
|
<p className="update_txt">还未完成评测的任务代码,请自行保存</p>
|
|
|
|
@ -128,21 +149,17 @@ function JupyterTPI (props) {
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
onOk () {
|
|
|
|
|
syncJupyterCode(myshixun_identifier, '同步成功');
|
|
|
|
|
}
|
|
|
|
|
},onCancel() {
|
|
|
|
|
stopposttpip(2)
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}, [props]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 重置实训
|
|
|
|
|
const handleClickResetTpi = () => {
|
|
|
|
|
|
|
|
|
|
var _iframe = document.getElementById("rightPaneframe");
|
|
|
|
|
if(_iframe == null || _iframe == undefined || _iframe == ""){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_iframe.contentWindow.postMessage("stopParent", "*");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stopposttpip(1)
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
title: '重置实训',
|
|
|
|
|
content: (
|
|
|
|
@ -160,7 +177,7 @@ function JupyterTPI (props) {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onCancel() {
|
|
|
|
|
_iframe.contentWindow.postMessage("clonsParent", "*");
|
|
|
|
|
stopposttpip(2)
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -168,6 +185,7 @@ function JupyterTPI (props) {
|
|
|
|
|
|
|
|
|
|
// 重置环境
|
|
|
|
|
const handleEnvironmentTpi = () => {
|
|
|
|
|
stopposttpip(1)
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
title: '重置环境',
|
|
|
|
|
content: (
|
|
|
|
@ -179,11 +197,14 @@ function JupyterTPI (props) {
|
|
|
|
|
okText: '确定',
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
onOk () {
|
|
|
|
|
// console.log('调用重置代码....', myIdentifier);
|
|
|
|
|
// if (myIdentifier) {
|
|
|
|
|
// syncJupyterCode(myIdentifier, '重置成功');
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
console.log('调用重置代码....', myIdentifier);
|
|
|
|
|
if (myIdentifier) {
|
|
|
|
|
reset_with_tpi(myIdentifier, '重置成功');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onCancel() {
|
|
|
|
|
stopposttpip(2)
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -265,14 +286,17 @@ function JupyterTPI (props) {
|
|
|
|
|
}
|
|
|
|
|
}, [props]);
|
|
|
|
|
|
|
|
|
|
const deadline = Date.now() + 7200 * 1000; // Moment is also OK
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="jupyter_area">
|
|
|
|
|
<div className="jupyter_header">
|
|
|
|
|
<UserInfo userInfo={userInfo} />
|
|
|
|
|
<p className="jupyter_title">
|
|
|
|
|
<span className="title_desc" style={{ marginTop: '20px' }}>{jupyterInfo.name}</span>
|
|
|
|
|
<span className="title_time"></span>
|
|
|
|
|
<span className="title_desc" style={{ marginTop: '10px' }}>{jupyterInfo.name}</span>
|
|
|
|
|
<span className="title_time jupytertitle_time">
|
|
|
|
|
<Countdown value={deadline} format="HH:mm:ss" />
|
|
|
|
|
</span>
|
|
|
|
|
</p>
|
|
|
|
|
<p className="jupyter_btn">
|
|
|
|
|
{/* sync | poweroff */}
|
|
|
|
@ -384,6 +408,8 @@ const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
getJupyterInfo: (identifier) => dispatch(actions.getJupyterInfo(identifier)),
|
|
|
|
|
// 重置代码
|
|
|
|
|
syncJupyterCode: (identifier, msg) => dispatch(actions.syncJupyterCode(identifier, msg)),
|
|
|
|
|
// 重置代码
|
|
|
|
|
reset_with_tpi: (identifier, msg) => dispatch(actions.reset_with_tpi(identifier, msg)),
|
|
|
|
|
getJupyterTpiDataSet: (identifier, current) => dispatch(actions.getJupyterTpiDataSet(identifier, current)),
|
|
|
|
|
getJupyterTpiUrl: (identifier) => dispatch(actions.getJupyterTpiUrl(identifier)),
|
|
|
|
|
saveJupyterTpi: () => dispatch(actions.saveJupyterTpi()),
|
|
|
|
|