diff --git a/public/react/src/common/UrlTool.js b/public/react/src/common/UrlTool.js index bc463e662..d7a49ea63 100644 --- a/public/react/src/common/UrlTool.js +++ b/public/react/src/common/UrlTool.js @@ -75,6 +75,10 @@ export function getUploadActionUrltwo(id) { return `${getUrlmys()}/api/shixuns/${id}/upload_data_sets.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}` } +export function getUploadActionUrlthree() { + + return `${getUrlmys()}/api/jupyters/import_with_tpm.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}` +} export function getUploadActionUrlOfAuth(id) { return `${getUrl()}/api/users/accounts/${id}/auth_attachment.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}` } diff --git a/public/react/src/common/educoder.js b/public/react/src/common/educoder.js index c9aa7ac77..3d11ee3cb 100644 --- a/public/react/src/common/educoder.js +++ b/public/react/src/common/educoder.js @@ -3,7 +3,7 @@ // export { default as OrderStateUtil } from '../routes/Order/components/OrderStateUtil'; export { getImageUrl as getImageUrl, getUrl as getUrl, getUrlmys as getUrlmys, getUrl2 as getUrl2, setImagesUrl as setImagesUrl - , getUploadActionUrl as getUploadActionUrl,getUploadActionUrltwo as getUploadActionUrltwo , getUploadActionUrlOfAuth as getUploadActionUrlOfAuth + , getUploadActionUrl as getUploadActionUrl,getUploadActionUrltwo as getUploadActionUrltwo ,getUploadActionUrlthree as getUploadActionUrlthree, getUploadActionUrlOfAuth as getUploadActionUrlOfAuth , getTaskUrlById as getTaskUrlById, TEST_HOST ,htmlEncode as htmlEncode } from './UrlTool'; export { default as queryString } from './UrlTool2'; diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js index 0c00f2bb2..3a132b814 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js @@ -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:[], } } @@ -247,9 +248,42 @@ class Challengesjupyter extends Component { // 导入文件 } + 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; @@ -264,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 (
@@ -408,10 +470,23 @@ class Challengesjupyter extends Component { marginLeft: '30px', }} onClick={()=>this.onclki(true)}> } -

this.Importingfiles()}>导入

+ + +
+

this.Importingfiles()}>导入

+
+