|
|
|
@ -4,19 +4,19 @@
|
|
|
|
|
* @Github:
|
|
|
|
|
* @Date: 2019-12-11 08:35:23
|
|
|
|
|
* @LastEditors: tangjiang
|
|
|
|
|
* @LastEditTime: 2019-12-12 11:26:33
|
|
|
|
|
* @LastEditTime: 2019-12-12 18:00:03
|
|
|
|
|
*/
|
|
|
|
|
import './index.scss';
|
|
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
import SplitPane from 'react-split-pane';
|
|
|
|
|
import { Button } from 'antd';
|
|
|
|
|
import { Button, Modal } from 'antd';
|
|
|
|
|
import {
|
|
|
|
|
connect
|
|
|
|
|
} from 'react-redux';
|
|
|
|
|
import UserInfo from '../../developer/components/userInfo';
|
|
|
|
|
import actions from '../../../redux/actions';
|
|
|
|
|
import LeftPane from './leftPane';
|
|
|
|
|
|
|
|
|
|
import RightPane from './rightPane';
|
|
|
|
|
function JupyterTPI (props) {
|
|
|
|
|
|
|
|
|
|
// 获取 identifier 值
|
|
|
|
@ -24,31 +24,128 @@ function JupyterTPI (props) {
|
|
|
|
|
match: {
|
|
|
|
|
params = {}
|
|
|
|
|
},
|
|
|
|
|
getJupyterTpiDataSet,
|
|
|
|
|
getJupyterTpiUrl
|
|
|
|
|
url,
|
|
|
|
|
loading, // 保存按钮状态
|
|
|
|
|
jupyter_info,
|
|
|
|
|
getJupyterInfo,
|
|
|
|
|
syncJupyterCode,
|
|
|
|
|
jupyter_tpi_url_state,
|
|
|
|
|
// getJupyterTpiDataSet,
|
|
|
|
|
getJupyterTpiUrl,
|
|
|
|
|
saveJupyterTpi,
|
|
|
|
|
changeLoadingState,
|
|
|
|
|
changeGetJupyterUrlState
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
const {identifier} = params;
|
|
|
|
|
console.log('props: ====>>>>', identifier);
|
|
|
|
|
|
|
|
|
|
const {identifier} = params;
|
|
|
|
|
const [userInfo, setUserInfo] = useState({});
|
|
|
|
|
const [jupyterInfo, setJupyterInfo] = useState({});
|
|
|
|
|
const [updateTip, setUpdateTip] = useState(true);
|
|
|
|
|
const [myIdentifier, setMyIdentifier] = useState('');
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// 获取数据集
|
|
|
|
|
console.log('useEffect: ====>>>>', identifier);
|
|
|
|
|
getJupyterTpiDataSet(identifier);
|
|
|
|
|
// 获取jupyter地址
|
|
|
|
|
/* 先调用 jupyter的 TPI 接口,
|
|
|
|
|
* 获取 用户信息,
|
|
|
|
|
* 实训的 identifier, 状态, 名称, 是否被修改等信息
|
|
|
|
|
*/
|
|
|
|
|
getJupyterInfo(identifier);
|
|
|
|
|
}, [identifier]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// 设置jupyter信息
|
|
|
|
|
setJupyterInfo(jupyter_info || {});
|
|
|
|
|
const {user, tpm_modified, myshixun_identifier} = jupyter_info;
|
|
|
|
|
if (user) {
|
|
|
|
|
setUserInfo(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (myshixun_identifier) {
|
|
|
|
|
setMyIdentifier(myshixun_identifier);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 同步代码
|
|
|
|
|
if (tpm_modified && updateTip && myshixun_identifier) {
|
|
|
|
|
setUpdateTip(false);
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
title: '更新通知',
|
|
|
|
|
content: (<div className="update_notice">
|
|
|
|
|
<p className="update_txt">关卡任务的代码文件有更新啦</p>
|
|
|
|
|
<p className="update_txt">更新操作将保留已完成的评测记录和成绩</p>
|
|
|
|
|
<p className="update_txt">还未完成评测的任务代码,请自行保存</p>
|
|
|
|
|
</div>),
|
|
|
|
|
okText: '确定',
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
onOk () {
|
|
|
|
|
syncJupyterCode(myshixun_identifier, '同步成功');
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}, [props]);
|
|
|
|
|
|
|
|
|
|
// 重置实训
|
|
|
|
|
const handleClickResetTpi = () => {
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
title: '重置实训',
|
|
|
|
|
content: (
|
|
|
|
|
<p style={{ lineHeight: '24px' }}>
|
|
|
|
|
你在本文件中修改的内容将丢失,<br />
|
|
|
|
|
是否确定重新加载初始代码?
|
|
|
|
|
</p>
|
|
|
|
|
),
|
|
|
|
|
okText: '确定',
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
onOk () {
|
|
|
|
|
console.log('调用重置代码....', myIdentifier);
|
|
|
|
|
if (myIdentifier) {
|
|
|
|
|
syncJupyterCode(myIdentifier, '重置成功');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 退出实训
|
|
|
|
|
const handleClickQuitTpi = () => {
|
|
|
|
|
// console.log(jupyterInfo);
|
|
|
|
|
const { identifier } = jupyterInfo;
|
|
|
|
|
props.history.push(`/shixuns/${identifier}/challenges`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 重新获取 jupyter url
|
|
|
|
|
const handleOnReloadUrl = (id) => {
|
|
|
|
|
// console.log('jupyter 信息: ', jupyterInfo);
|
|
|
|
|
// 改变加载状态值
|
|
|
|
|
changeGetJupyterUrlState(-1);
|
|
|
|
|
getJupyterTpiUrl({identifier: myIdentifier});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保存代码
|
|
|
|
|
const handleOnSave = () => {
|
|
|
|
|
// 改变按钮状态
|
|
|
|
|
changeLoadingState(true);
|
|
|
|
|
saveJupyterTpi();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="jupyter_area">
|
|
|
|
|
<div className="jupyter_header">
|
|
|
|
|
<UserInfo userInfo={{}} />
|
|
|
|
|
<UserInfo userInfo={userInfo} />
|
|
|
|
|
<p className="jupyter_title">
|
|
|
|
|
<span className="title_desc">MySQL数据库编程开发实训(基础篇)</span>
|
|
|
|
|
<span className="title_time">时间</span>
|
|
|
|
|
<span className="title_desc" style={{ marginTop: '20px' }}>{jupyterInfo.name}</span>
|
|
|
|
|
<span className="title_time"></span>
|
|
|
|
|
</p>
|
|
|
|
|
<p className="jupyter_btn">
|
|
|
|
|
{/* sync | poweroff */}
|
|
|
|
|
<Button className="btn_common" type="link" icon="sync">重置实训</Button>
|
|
|
|
|
<Button className="btn_common" type="link" icon="poweroff">退出实训</Button>
|
|
|
|
|
<Button
|
|
|
|
|
className="btn_common"
|
|
|
|
|
type="link"
|
|
|
|
|
icon="sync"
|
|
|
|
|
onClick={handleClickResetTpi}
|
|
|
|
|
>重置实训</Button>
|
|
|
|
|
<Button
|
|
|
|
|
className="btn_common"
|
|
|
|
|
type="link"
|
|
|
|
|
icon="poweroff"
|
|
|
|
|
onClick={handleClickQuitTpi}
|
|
|
|
|
>退出实训</Button>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="jupyter_ctx">
|
|
|
|
@ -57,7 +154,14 @@ function JupyterTPI (props) {
|
|
|
|
|
<LeftPane dataSets={[]} />
|
|
|
|
|
</div>
|
|
|
|
|
<SplitPane split="vertical" defaultSize="100%" allowResize={false}>
|
|
|
|
|
<div>右侧内容</div>
|
|
|
|
|
<RightPane
|
|
|
|
|
identifier={myIdentifier}
|
|
|
|
|
status={jupyter_tpi_url_state}
|
|
|
|
|
url={url}
|
|
|
|
|
loading={loading}
|
|
|
|
|
onReloadUrl={handleOnReloadUrl}
|
|
|
|
|
onSave={handleOnSave}
|
|
|
|
|
/>
|
|
|
|
|
<div />
|
|
|
|
|
</SplitPane>
|
|
|
|
|
</SplitPane>
|
|
|
|
@ -67,17 +171,31 @@ function JupyterTPI (props) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => {
|
|
|
|
|
const {jupyter_tpi_url, jupyter_data_set, jupyter_identifier} = state.jupyterReducer;
|
|
|
|
|
const {
|
|
|
|
|
jupyter_info,
|
|
|
|
|
jupyter_tpi_url,
|
|
|
|
|
jupyter_data_set,
|
|
|
|
|
jupyter_tpi_url_state
|
|
|
|
|
} = state.jupyterReducer;
|
|
|
|
|
const { loading } = state.commonReducer;
|
|
|
|
|
return {
|
|
|
|
|
loading,
|
|
|
|
|
jupyter_info,
|
|
|
|
|
url: jupyter_tpi_url,
|
|
|
|
|
dataSets: jupyter_data_set,
|
|
|
|
|
identifier: jupyter_identifier
|
|
|
|
|
jupyter_tpi_url_state
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
getJupyterTpiDataSet: (identifier) => dispatch(actions.getJupyterTpiDataSet(identifier)),
|
|
|
|
|
getJupyterTpiUrl: (identifier) => dispatch(actions.getJupyterTpiUrl(identifier))
|
|
|
|
|
changeGetJupyterUrlState: (status) => dispatch(actions.changeGetJupyterUrlState(status)),
|
|
|
|
|
getJupyterInfo: (identifier) => dispatch(actions.getJupyterInfo(identifier)),
|
|
|
|
|
// 重置代码
|
|
|
|
|
syncJupyterCode: (identifier, msg) => dispatch(actions.syncJupyterCode(identifier, msg)),
|
|
|
|
|
// getJupyterTpiDataSet: (identifier) => dispatch(actions.getJupyterTpiDataSet(identifier)),
|
|
|
|
|
getJupyterTpiUrl: (identifier) => dispatch(actions.getJupyterTpiUrl(identifier)),
|
|
|
|
|
saveJupyterTpi: () => dispatch(actions.saveJupyterTpi()),
|
|
|
|
|
changeLoadingState: (flag) => dispatch(actions.changeLoadingState(flag))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
|