调整jupyter 上传功能

chromesetting
杨树林 5 years ago
parent 2bf80316e9
commit f1ae306ec1

@ -75,6 +75,10 @@ export function getUploadActionUrltwo(id) {
return `${getUrlmys()}/api/shixuns/${id}/upload_data_sets.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}` 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) { export function getUploadActionUrlOfAuth(id) {
return `${getUrl()}/api/users/accounts/${id}/auth_attachment.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}` return `${getUrl()}/api/users/accounts/${id}/auth_attachment.json${isDev ? `?debug=${window._debugType || 'admin'}` : ''}`
} }

@ -3,7 +3,7 @@
// export { default as OrderStateUtil } from '../routes/Order/components/OrderStateUtil'; // 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 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'; , getTaskUrlById as getTaskUrlById, TEST_HOST ,htmlEncode as htmlEncode } from './UrlTool';
export { default as queryString } from './UrlTool2'; export { default as queryString } from './UrlTool2';

@ -1,7 +1,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { markdownToHTML, configShareForCustom,getImageUrl} from 'educoder' import { markdownToHTML, configShareForCustom,getImageUrl,getUploadActionUrlthree,appendFileSizeToUploadFileAll} from 'educoder'
import { Divider, Tooltip } from 'antd'; import { Divider, Tooltip,Upload} from 'antd';
import LoadingSpin from '../../../../common/LoadingSpin'; import LoadingSpin from '../../../../common/LoadingSpin';
import 'antd/lib/pagination/style/index.css'; import 'antd/lib/pagination/style/index.css';
import '../shixunchildCss/Challenges.css'; import '../shixunchildCss/Challenges.css';
@ -26,6 +26,7 @@ class Challengesjupyter extends Component {
opentitletype:true, opentitletype:true,
isopentitletype:"Less", isopentitletype:"Less",
enlarge:false, 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() { render() {
let{ChallengesDataList,booljupyterurls,enlarge}=this.state; let{ChallengesDataList,booljupyterurls,enlarge,fileList}=this.state;
let id = this.props.match.params.shixunId; 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; 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) { }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 ( return (
<React.Fragment> <React.Fragment>
<div className=""> <div className="">
@ -408,10 +470,23 @@ class Challengesjupyter extends Component {
marginLeft: '30px', marginLeft: '30px',
}} onClick={()=>this.onclki(true)}></i> }} onClick={()=>this.onclki(true)}></i>
} }
<div className="challenbaocun" ><p <style>
className="challenbaocuntest" onClick={()=>this.Importingfiles()}>导入</p> {
`
.ant-upload-list{
display:none
}
`
}
</style>
<Upload {...uploadProps}>
<div className="challenbaocun" type="upload">
<p
className="challenbaocuntest" type="upload" onClick={()=>this.Importingfiles()}>导入</p>
</div> </div>
</Upload>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save