|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
|
import { markdownToHTML, configShareForCustom,getImageUrl} from 'educoder'
|
|
|
|
|
import { Divider, Tooltip } from 'antd';
|
|
|
|
|
import { markdownToHTML, configShareForCustom,getImageUrl,getUploadActionUrlthree,appendFileSizeToUploadFileAll} from 'educoder'
|
|
|
|
|
import { Divider, Tooltip,Upload} from 'antd';
|
|
|
|
|
import LoadingSpin from '../../../../common/LoadingSpin';
|
|
|
|
|
import 'antd/lib/pagination/style/index.css';
|
|
|
|
|
import '../shixunchildCss/Challenges.css';
|
|
|
|
@ -26,6 +26,7 @@ class Challengesjupyter extends Component {
|
|
|
|
|
opentitletype:true,
|
|
|
|
|
isopentitletype:"Less",
|
|
|
|
|
enlarge:false,
|
|
|
|
|
fileList:[],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -243,18 +244,46 @@ class Challengesjupyter extends Component {
|
|
|
|
|
enlarge:bool
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
daoruzhon=()=>{
|
|
|
|
|
var _iframe = document.getElementById("frame");
|
|
|
|
|
if(_iframe == null || _iframe == undefined || _iframe == ""){
|
|
|
|
|
console.log("framenull");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
console.log("framego");
|
|
|
|
|
_iframe.contentWindow.postMessage("Parentwindow", "*");
|
|
|
|
|
Importingfiles=()=>{
|
|
|
|
|
// 导入文件
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
handleChange = (info) => {
|
|
|
|
|
if(info.file.status == "done" || info.file.status == "uploading" || info.file.status === 'removed'){
|
|
|
|
|
let fileList = info.fileList;
|
|
|
|
|
this.setState({
|
|
|
|
|
fileList: appendFileSizeToUploadFileAll(fileList),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if(info.file.status === 'done'){
|
|
|
|
|
if(info.file.response){
|
|
|
|
|
if(info.file.response.status===-1||info.file.response.status==="-1"){
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(info.file.response){
|
|
|
|
|
if(info.file.response.status===-1||info.file.response.status==="-1"){
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
if(info.file.response.status===0){
|
|
|
|
|
try {
|
|
|
|
|
this.props.showNotification('上传文件成功!');
|
|
|
|
|
}catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
render() {
|
|
|
|
|
let{ChallengesDataList,booljupyterurls,enlarge}=this.state;
|
|
|
|
|
let{ChallengesDataList,booljupyterurls,enlarge,fileList}=this.state;
|
|
|
|
|
let id = this.props.match.params.shixunId;
|
|
|
|
|
//老师
|
|
|
|
|
const is_teacher = this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false;
|
|
|
|
@ -269,7 +298,35 @@ class Challengesjupyter extends Component {
|
|
|
|
|
}catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
const uploadProps = {
|
|
|
|
|
width: 600,
|
|
|
|
|
fileList,
|
|
|
|
|
multiple: true,
|
|
|
|
|
data:{
|
|
|
|
|
identifier:id,
|
|
|
|
|
},
|
|
|
|
|
//multiple 是否支持多选 查重的时候不能多选 不然弹许多框出来
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/15505
|
|
|
|
|
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
|
|
|
|
|
// showUploadList: false,
|
|
|
|
|
action: `${getUploadActionUrlthree()}`,
|
|
|
|
|
showUploadList:false,
|
|
|
|
|
onChange: this.handleChange,
|
|
|
|
|
beforeUpload: (file) => {
|
|
|
|
|
//上传前的操作
|
|
|
|
|
// console.log('beforeUpload', file.name);
|
|
|
|
|
if(file.name.indexOf('.ipynb') === -1){
|
|
|
|
|
this.props.showNotification('请上传正确格式文件!');
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
const isLt10M = file.size / 1024 / 1024 < 10;
|
|
|
|
|
if (!isLt10M) {
|
|
|
|
|
this.props.showNotification('文件大小必须小于10MB!');
|
|
|
|
|
}
|
|
|
|
|
return isLt10M;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<div className="">
|
|
|
|
@ -413,10 +470,23 @@ class Challengesjupyter extends Component {
|
|
|
|
|
marginLeft: '30px',
|
|
|
|
|
}} onClick={()=>this.onclki(true)}></i>
|
|
|
|
|
}
|
|
|
|
|
<div className="challenbaocun" ><p
|
|
|
|
|
className="challenbaocuntest" onClick={()=>this.daoruzhon()}>导入</p>
|
|
|
|
|
<style>
|
|
|
|
|
{
|
|
|
|
|
`
|
|
|
|
|
.ant-upload-list{
|
|
|
|
|
display:none
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<Upload {...uploadProps}>
|
|
|
|
|
<div className="challenbaocun" type="upload">
|
|
|
|
|
<p
|
|
|
|
|
className="challenbaocuntest" type="upload" onClick={()=>this.Importingfiles()}>导入</p>
|
|
|
|
|
</div>
|
|
|
|
|
</Upload>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
@ -463,7 +533,7 @@ class Challengesjupyter extends Component {
|
|
|
|
|
)
|
|
|
|
|
:
|
|
|
|
|
<iframe src={this.state.jupyter_url} className={enlarge?"fangdatwo":""}
|
|
|
|
|
sandbox="allow-same-origin allow-scripts allow-top-navigation " scrolling="no" id="frame"
|
|
|
|
|
scrolling="no" id="frame"
|
|
|
|
|
name="framename" width="100%" height="700" frameBorder="0"
|
|
|
|
|
></iframe>
|
|
|
|
|
}
|
|
|
|
|