chromesetting
杨树林 5 years ago
parent 8bee1c9bc3
commit 1b4f80c04d

@ -1,12 +1,15 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import {Redirect} from 'react-router'; import {Redirect} from 'react-router';
import {List, Typography, Tag, Modal, Radio, Checkbox, Table, Pagination} from 'antd'; import {List, Typography, Tag, Modal, Radio, Checkbox, Table, Pagination,Upload,notification} from 'antd';
import { NoneData } from 'educoder' import { NoneData } from 'educoder'
import TPMRightSection from './component/TPMRightSection'; import TPMRightSection from './component/TPMRightSection';
import TPMNav from './component/TPMNav'; import TPMNav from './component/TPMNav';
import axios from 'axios'; import axios from 'axios';
import './tpmmodel/tpmmodel.css' import './tpmmodel/tpmmodel.css'
import {getUploadActionUrl} from 'educoder';
const confirm = Modal.confirm;
class TPMDataset extends Component { class TPMDataset extends Component {
constructor(props) { constructor(props) {
@ -70,6 +73,10 @@ class TPMDataset extends Component {
limit: 5, limit: 5,
selectedRowKeys: [], selectedRowKeys: [],
mylistansum:30, mylistansum:30,
collaboratorList:[],
fileList:[],
file:null,
} }
} }
@ -93,7 +100,23 @@ class TPMDataset extends Component {
getdatas = () => { getdatas = () => {
let id=this.props.match.params.shixunId;
let collaborators=`/shixuns/${id}/jupyter_data_sets.json`;
axios.get(collaborators).then((response)=> {
if(response.status===200){
if (response.data.status === 403||response.data.status === 401||response.data.status === 500) {
}else{
this.setState({
collaboratorList: response.data
});
}
}
}).catch((error)=>{
console.log(error)
});
} }
@ -129,9 +152,81 @@ class TPMDataset extends Component {
return className; return className;
} }
// 附件相关 START
handleChange = (info) => {
if(info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
let {fileList} = this.state;
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
console.log("handleChange1");
// if(fileList.length===0){
let fileLists = info.fileList;
this.setState({
// fileList:appendFileSizeToUploadFileAll(fileList),
fileList: fileLists,
deleteisnot: false
});
// }
}
}
}
onAttachmentRemove = (file) => {
if(!file.percent || file.percent == 100){
confirm({
title: '确定要删除这个附件吗?',
okText: '确定',
cancelText: '取消',
// content: 'Some descriptions',
onOk: () => {
console.log("665")
this.deleteAttachment(file)
},
onCancel() {
console.log('Cancel');
},
});
return false;
}
}
deleteAttachment = (file) => {
console.log(file);
let id=file.response ==undefined ? file.id : file.response.id
const url = `/attachements/destroy_files.json`
axios.delete(url, {
id:[id],
})
.then((response) => {
if (response.data) {
const { status } = response.data;
if (status == 0) {
// console.log('--- success')
this.setState((state) => {
const index = state.fileList.indexOf(file);
const newFileList = state.fileList.slice();
newFileList.splice(index, 1);
return {
fileList: newFileList,
deleteisnot:true
};
});
}
}
})
.catch(function (error) {
console.log(error);
});
}
render() { render() {
const {tpmLoading, shixun, user, match} = this.props; const {tpmLoading, shixun, user, match} = this.props;
const {columns, datas, page, limit, selectedRowKeys,mylistansum} = this.state; const {columns, datas, page, limit, selectedRowKeys,mylistansum,fileList} = this.state;
const rowSelection = { const rowSelection = {
selectedRowKeys, selectedRowKeys,
onChange: this.onSelectChange, onChange: this.onSelectChange,
@ -140,6 +235,55 @@ class TPMDataset extends Component {
// disabled: record.name === 'Disabled User', // Column configuration not to be checked // disabled: record.name === 'Disabled User', // Column configuration not to be checked
// name: record.name, // name: record.name,
// }), // }),
let id=this.props.match.params.shixunId;
const uploadProps = {
width: 600,
fileList,
data:{
attachtype: 2,
container_id:this.props.match.params.shixunId,
container_type: "Shixun",
},
multiple: true,
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
action: `${getUploadActionUrl()}`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
beforeUpload: (file, fileList) => {
if (this.state.fileList.length >= 1) {
return false
}
// console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 50;
if (!isLt150M) {
// this.props.showNotification(`文件大小必须小于50MB`);
notification.open(
{
message: '提示',
description:
'文件大小必须小于50MB',
}
)
}
if(this.state.file !== undefined){
console.log("763")
this.setState({
file:file
})
}else {
this.setState({
file:file
})
}
console.log("handleChange2");
return isLt150M;
},
}
return ( return (
<React.Fragment> <React.Fragment>
<div className="tpmComment educontent clearfix mt30 mb80"> <div className="tpmComment educontent clearfix mt30 mb80">
@ -157,7 +301,18 @@ class TPMDataset extends Component {
<div className="sortinxdirection"> <div className="sortinxdirection">
<div className="tpmwidth"><Checkbox onChange={this.mysonChange}>全选</Checkbox></div> <div className="tpmwidth"><Checkbox onChange={this.mysonChange}>全选</Checkbox></div>
<div className="tpmwidth xaxisreverseorder"> <div className="tpmwidth xaxisreverseorder">
<div className="deletebuttom intermediatecenter "><p className="deletebuttomtest">上传文件</p></div> <style>
{
`
.ant-upload-list{
display:none
}
`
}
</style>
<div className="deletebuttom intermediatecenter "> <Upload {...uploadProps}><p className="deletebuttomtest">
上传文件</p> </Upload></div>
{ {
mylistansum>0? mylistansum>0?
<div <div

@ -19,9 +19,7 @@ import 'antd/lib/pagination/style/index.css';
import '../shixunchildCss/Challenges.css' import '../shixunchildCss/Challenges.css'
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import axios from 'axios'; import axios from 'axios';
import AccountProfile from"../../../user/AccountProfile"; import AccountProfile from"../../../user/AccountProfile";
const $ = window.$; const $ = window.$;
@ -134,11 +132,21 @@ class Challengesjupyter extends Component {
modifyjupyter=()=>{ modifyjupyter=()=>{
// var ifr =window.parent.frames["frame"].document; // var ifr =window.parent.frames["frame"].document;
// console.log(ifr); // console.log(ifr);
// var data = JSON.stringify({
var ifr = window.document.getElementById("ifr1"); //
// 'location': window.location
//
// // etc
//
// });
// let parentDomain = window.location.hostname;
// console.log("domain",parentDomain); //localhost
// document.domain = data;
// document.domain = 'https://47519.test-jupyter.educoder.net';
var ifr = document.getElementById("ifr1");
console.log("modifyjupyter"); console.log("modifyjupyter");
console.log(ifr); console.log(ifr);
const iframe = window.document.getElementById('ifr1'); const iframe = document.getElementById('ifr1');
console.log("modifyjupyter"); console.log("modifyjupyter");
const frameWindow = iframe.contentWindow; const frameWindow = iframe.contentWindow;
console.log(frameWindow); console.log(frameWindow);
@ -336,7 +344,7 @@ class Challengesjupyter extends Component {
{/*https://48888.jupyter.educoder.net/tree?*/} {/*https://48888.jupyter.educoder.net/tree?*/}
<div className="pb47"> <div className="pb47">
<iframe src="http://121.41.4.83:48888/tree?" scrolling="no" id="ifr1" name="frame" width="100%" height="700" frameborder="0" <iframe src="http://121.41.4.83:48888/notebooks/Untitled.ipynb?kernel_name=python3" sandbox="allow-same-origin allow-scripts allow-top-navigation " scrolling="no" id="ifr1" name="frame" width="100%" height="700" frameborder="0"
></iframe> ></iframe>

Loading…
Cancel
Save