From 17a37512e872a89403089beff895d74f6967ddf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 12 Dec 2019 19:52:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 4 +- public/react/src/modules/tpm/TPMIndex.js | 6 +- .../modules/tpm/TPMsettings/Configuration.js | 380 +++++++++++++----- .../tpm/TPMsettings/Shixuninformation.js | 144 +++---- .../modules/tpm/TPMsettings/TPMsettings.js | 38 +- .../tpm/TPMsettings/css/TPMsettings.css | 9 + .../react/src/modules/tpm/component/TPMNav.js | 6 +- 7 files changed, 392 insertions(+), 195 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index fb4b33fae..bb6e28b90 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -51,8 +51,8 @@ export function initAxiosInterceptors(props) { // proxy = "https://testeduplus2.educoder.net" //proxy="http://47.96.87.25:48080" proxy="https://pre-newweb.educoder.net" - proxy="https://test-newweb.educoder.net" - proxy="https://test-jupyterweb.educoder.net" + proxy="https://test-newweb.educoder.net" + proxy="https://test-jupyterweb.educoder.net" //proxy="http://192.168.2.63:3001" // 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求; diff --git a/public/react/src/modules/tpm/TPMIndex.js b/public/react/src/modules/tpm/TPMIndex.js index ba7fb25e3..4dc27ef8c 100644 --- a/public/react/src/modules/tpm/TPMIndex.js +++ b/public/react/src/modules/tpm/TPMIndex.js @@ -20,9 +20,9 @@ import TPMRepositoryComponent from './TPMRepositoryComponent'; import TPMRepositoryCommits from './shixunchild/Repository/TPMRepositoryCommits'; -//import TPMsettings from './TPMsettings/TPMsettings'; +import TPMsettings from './TPMsettings/TPMsettings'; -import TPMsettings from './TPMsettings/oldTPMsettings'; +//import TPMsettings from './TPMsettings/oldTPMsettings'; import TPMChallengeComponent from './TPMChallengeContainer'; import TPMPropaedeuticsComponent from './TPMPropaedeuticsComponent'; @@ -153,7 +153,7 @@ class TPMIndex extends Component { componentDidMount = () => { let id = this.props.match.params.shixunId; - console.log('props', this.props); + // console.log('props', this.props); // let collaborators = `/shixuns/` + id + `/propaedeutics.json`; // // axios.get(collaborators).then((response) => { diff --git a/public/react/src/modules/tpm/TPMsettings/Configuration.js b/public/react/src/modules/tpm/TPMsettings/Configuration.js index 2089d1939..c7156abe8 100644 --- a/public/react/src/modules/tpm/TPMsettings/Configuration.js +++ b/public/react/src/modules/tpm/TPMsettings/Configuration.js @@ -1,9 +1,15 @@ -import React, { Component } from 'react'; - -import MonacoEditor from 'react-monaco-editor'; +import React, {Component} from 'react'; //MonacoDiffEditor 对比模式 -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Icon,DatePicker,Breadcrumb,Upload,Button,notification, Tooltip} from 'antd'; +import { + Badge, + Select, + Radio, + Checkbox, + Modal, + DatePicker, + Button, +} from 'antd'; // import "antd/dist/antd.css"; @@ -15,12 +21,9 @@ import axios from 'axios'; import './css/TPMsettings.css'; -import { getImageUrl, toPath, getUrl ,appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder'; +import {getImageUrl, toPath, getUrl, appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder'; import {handleDateStrings} from "./oldTPMsettings"; - -let origin = getUrl(); - -let path = getUrl("/editormd/lib/") +import Bottomsubmit from "../../modals/Bottomsubmit"; const $ = window.$; @@ -40,6 +43,7 @@ function range(start, end) { } return result; } + function disabledDateTime() { return { // disabledHours: () => range(0, 24).splice(4, 20), @@ -57,119 +61,311 @@ export default class Shixuninformation extends Component { constructor(props) { super(props) this.state = { + can_copy:false, + use_scope:0, + opening_time:null, + opentime:false, + oldscope_partment:[], + scope_partment:[] + } + } + + componentDidMount() { + if (this.props.data) { + + this.setState({ + can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false :this.props.data.shixun.can_copy, + use_scope:this.props.data && this.props.data.shixun.use_scope, + opening_time: this.props.data && this.props.data.shixun.opening_time, + opentime:!this.props.data && this.props.data.shixun.opening_time?false:true, + oldscope_partment:this.props.data&&this.props.data.shixun.scope_partment, + }) + + } + let departmentsUrl = `/shixuns/departments.json`; + axios.get(departmentsUrl).then((response) => { + if (response.status === 200) { + if (response.data.message === undefined) { + this.setState({ + departmentslist: response.data.shools_name + }); + } + } + }).catch((error) => { + console.log(error) + }); + } + + + componentDidUpdate(prevProps, prevState) { + if (prevProps.data != this.props.data) { + if (this.props.data) { + + this.setState({ + can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false :this.props.data.shixun.can_copy, + use_scope:this.props.data && this.props.data.shixun.use_scope, + opening_time: this.props.data && this.props.data.shixun.opening_time, + opentime:!this.props.data && this.props.data.shixun.opening_time?false:true, + oldscope_partment:this.props.data&&this.props.data.shixun.scope_partment, + }) + } } } - onChangeTimePicker =(value, dateString)=> { + onChangeTimePicker = (value, dateString) => { this.setState({ - opening_time: dateString=== ""?"":moment(handleDateStrings(dateString)) + opening_time: dateString === "" ? "" :handleDateStrings(dateString) + }) + } + + onSubmits = () => { + let {can_copy,use_scope,scope_partment,opening_time }=this.state; + + let id = this.props.match.params.shixunId; + let url=`/shixuns/${id}/update_permission_setting.json`; + axios.post(url, + { + scope_partment:scope_partment, + shixun:{ + can_copy: can_copy, + use_scope:use_scope, + opening_time:opening_time + } + } + ).then((response) => { + if(response.data.status===-1){ + + }else{ + this.props.getdatas() + this.props.showNotification("保存成功") + } + }).catch((error) => { + console.log(error) + + }) + } + CheckboxonChange=(e)=>{ + this.setState({ + can_copy:e.target.checked + }) + } + SelectOpenpublic=(e)=>{ + this.setState({ + use_scope: e.target.value + }); + } + + shixunScopeInput = (e) => { + let {scope_partment,oldscope_partment} = this.state; + let datalist = scope_partment; + if (datalist===undefined) { + datalist=[] + } + + datalist.push(e) + + let scopetype=false; + + scope_partment.map((item,key)=>{ + if(item===e){ + scopetype=true + } }) + + oldscope_partment.map((item,key)=>{ + if(item===e){ + scopetype=true + } + }) + + if(scopetype===false){ + this.setState({ + scope_partment: datalist + }); + }else{ + this.props.showNotification("请勿指定相同的单位") + } + } + shixunsfetch = (value, callback) => { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + currentValue = value; + + function fake() { + let departmentsUrl = `/shixuns/departments.json?q=` + currentValue; + axios.get(departmentsUrl).then((response) => { + callback(response.data.shools_name); + }).catch((error) => { + console.log(error) + }); + } + timeout = setTimeout(fake, 300); + } + + shixunHandleSearch = (value) => { + this.shixunsfetch(value, departmentslist => this.setState({departmentslist})); + } + + deleteScopeInput = (key) => { + let {scope_partment} = this.state; + let datalist = scope_partment; + datalist.splice(key, 1); + this.setState({ + scope_partment: datalist + }); + } + + setopentime=(e)=>{ + this.setState({ + opentime:e.target.checked + }) + } render() { - let {can_copy}=this.state; - let options; - if (this.props.departmentslist != undefined) { - options = this.props.departmentslist.map((d, k) => { + let options; + if (this.state.departmentslist != undefined) { + options = this.state.departmentslist.map((d, k) => { return ( ) }) } + + const dateFormat = 'YYYY-MM-DD HH:mm'; + return ( -
-
- 复制: - - - - -
+
+
+
+ 复制: + + + + +
-
-

公开程度

- - 对所有公开 (选中则所有已被试用授权的用户可以学习) - 对指定单位公开 (选中则下方指定单位的已被试用授权的用户可以学习) - - -
-
-
-
-
- +
+ {this.props.data && this.props.data.shixun.use_scope === 0 &&this.props.data && this.props.data.shixun.status === 2?"":
+ 公开程度: + + + 对所有单位公开 (实训发布后,所有用户可见) + 对指定单位公开 (实训发布后,仅对下方指定单位的用户可见) + + +
+
+
+
+
+ +
+ (请通过搜索并选中单位名称进行添加)
- (搜索并选中添加单位名称)
-
-
-
- { - this.props.scope_partment===undefined?"":this.props.scope_partment.map((item,key)=>{ - - return( -
  • {item} - this.deleteScopeInput(key)} - > - {this.props.identity===1?"x":this.state.status===2&&this.props.scope_partment===this.props.scope_partments||this.state.status===1&&this.props.scope_partment===this.props.scope_partments?"":"×"} - -
  • - ) - }) - } +
    +
    + { + this.state.oldscope_partment.map((item,key)=>{ + return ( +
  • + +
  • + ) + }) + } + { + this.state.scope_partment === undefined ? "" : this.state.scope_partment.map((item, key) => { + + return ( +
  • + this.deleteScopeInput(key)}> + + +
  • + ) + }) + } +
    +
    + + + 请选择需要公开的单位 + +
    - - - 请选择需要公开的单位 - - - -
    - 开启时间: - - - - -
    + +
    } + +
    + 开启时间: + + + +
    + {this.state.opentime===false?"":
    + +
    } +
    + +
    + {this.props.identity < 5 ? + : ""}
    ); } diff --git a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js index 02a58cda6..61f8c6bd8 100644 --- a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js +++ b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js @@ -5,19 +5,12 @@ import MonacoEditor from 'react-monaco-editor'; import { Input, Select, - Radio, Checkbox, - Popconfirm, - message, Modal, Icon, - DatePicker, - Breadcrumb, Upload, Button, - notification, Tooltip, - Tabs, Form } from 'antd'; @@ -72,6 +65,7 @@ class Shixuninformation extends Component { simichecked: this.props.data.shixun.is_secret_repository, shixun_service_configs: this.props.data.shixun.shixun_service_configs, standard_scripts:this.props.data.shixun.standard_scripts, + shixun_service_configlist:this.props.data.shixun.shixun_service_configs, }) if(this.props.data.shixun.choice_standard_scripts===null){ @@ -241,15 +235,8 @@ class Shixuninformation extends Component { fileList: [] }) } + this.props.showNotification("提交成功") - notification.open( - { - message: '提示', - description: - '提交成功!', - - } - ) this.sendhideModaly() } @@ -371,11 +358,14 @@ class Shixuninformation extends Component { mainvalues:e.props.name }) let list = [] - list.push(this.props.data.shixun.choice_main_type) - this.props.data.shixun.choice_small_type.map((item, key) => { + list.push(this.state.choice_main_type) + this.state.choice_small_type.map((item, key) => { list.push(item) }) - let newshixun_service_configs = this.props.data.shixun.shixun_service_configs; + + + let newshixun_service_configs = this.state.shixun_service_configs; + let newshixun_service_configsagin = []; newshixun_service_configs.map((item, key) => { list.map((its, index) => { @@ -386,6 +376,7 @@ class Shixuninformation extends Component { }) + this.props.data.shixun.main_type.some((item, key) => { if (item.id === value) { newshixun_service_configsagin[0] = { @@ -401,20 +392,16 @@ class Shixuninformation extends Component { } ) + + + this.props.form.setFieldsValue({ selectleft: value, }) + let url = `/shixuns/get_mirror_script.json?mirror_id=` + value; axios.get(url).then((response) => { if (response.status === 200) { - console.log(response.data[0].id) - this.get_mirror_script(response.data[0].id) - this.setState({ - choice_main_type: value, - standard_scripts: response.data, - shixun_service_configs: newshixun_service_configsagin, - shixun_service_configlist: newshixun_service_configsagin, - }) this.setState({ choice_standard_scripts:{id: response.data[0].id, value: ""}, choice_standard_scriptssum:response.data[0].id @@ -422,6 +409,14 @@ class Shixuninformation extends Component { this.props.form.setFieldsValue({ selectscripts:response.data[0].id }) + this.get_mirror_script(response.data[0].id) + this.setState({ + choice_main_type: value, + standard_scripts: response.data, + shixun_service_configs: newshixun_service_configsagin, + shixun_service_configlist: newshixun_service_configsagin, + }) + } }).catch((error) => { console.log(error) @@ -473,10 +468,10 @@ class Shixuninformation extends Component { }) } littleClass = (value,e) => { - let newshixun_service_configs = this.props.data.shixun.shixun_service_configs; - let newchoice_small_type = this.props.data.shixun.choice_small_type; + let newshixun_service_configs = this.state.shixun_service_configs; + let newchoice_small_type = this.state.choice_small_type; let list = [] - list.push(this.props.data.shixun.choice_main_type) + list.push(this.state.choice_main_type) newchoice_small_type.map((item, key) => { list.push(item) }) @@ -647,42 +642,56 @@ class Shixuninformation extends Component { onSubmits=()=>{ const mdContnet = this.contentMdRef.current.getValue().trim(); - console.log(mdContnet) + let{choice_standard_scriptssum,choice_standard_scripts}=this.state; this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { console.log('Received values of form: ', values); + let url = `/shixuns/${this.props.match.params.shixunId}.json`; + let newshixun_service_configlist = this.state.shixun_service_configlist.map(v => { + let v1 = Object.assign({},v); + delete v1.name; + return v1 + }); - // let Url = `/shixuns.json`; - // axios.post(Url, { - // description: mdContnet, - // main_type: values.main_type, - // sub_type: values.sub_type, - // shixun: { - // name: values.name, - // trainee: values.select, - // is_jupyter: values.is_jupyter === "2" ? true : false, - // } - // } - // ).then((response) => { - // if (response.status === 200) { - // window.location.href = "/shixuns/" + response.data.shixun_identifier + "/challenges"; - // // window.open("/shixuns/"+response.data.shixun_identifier+"/challenges"); - // } else { - // this.setState({ - // bottonloading: false - // }) - // } - // }).catch((error) => { - // console.log(error) - // this.setState({ - // bottonloading: false - // }) - // }) + let data={ + main_type:this.state.choice_main_type, + sub_type:this.state.choice_small_type, + is_secret_repository:this.state.simichecked, + shixun:{ + name: values.name, + trainee: this.state.trainee, + is_jupyter: this.props.shixunsDetails.is_jupyter, + mirror_script_id: this.props.shixunsDetails.is_jupyter===true?null:this.state.choice_standard_scriptssum===undefined?this.state.choice_standard_scripts:this.state.choice_standard_scriptssum, + }, + shixun_info: { + description: mdContnet, + evaluate_script: this.props.shixunsDetails.is_jupyter===true?"":this.state.shixunmemoMDvalue + }, + shixun_service_configs:newshixun_service_configlist + } + axios.put(url, data).then((result) => { + if (result) { + if (result.data) { + this.props.getdatas() + if(result.data.shixun_identifier){ + this.props.showNotification("基本信息更新成功") + } + } + } + }).catch((error) => { + // ////console.log(error) + }); } }); } + + Selectthestudent = (value) => { + this.setState({ + trainee: value + }) + } render() { let operateauthority = this.props.identity === 1 ? true : this.props.identity < 5 && this.props.data.shixun.status == 0 ? true : false; @@ -712,14 +721,7 @@ class Shixuninformation extends Component { const isLt150M = file.size / 1024 / 1024 < 50; if (!isLt150M) { // this.props.showNotification(`文件大小必须小于50MB`); - notification.open( - { - message: '提示', - description: - '文件大小必须小于50MB', - - } - ) + this.props.showNotification("文件大小必须小于50MB") } if (this.state.file !== undefined) { this.setState({ @@ -892,7 +894,7 @@ class Shixuninformation extends Component {
    -
    - + } -
    + { this.props.shixunsDetails&&this.props.shixunsDetails.is_jupyter===true?"":
    @@ -989,14 +991,14 @@ class Shixuninformation extends Component { />
    -
    +
    } - 私密版本库: + { this.props.shixunsDetails&&this.props.shixunsDetails.is_jupyter===true?"": 私密版本库: (若需要对学员隐藏部分版本库内容时,请选中;选中即启用私密版本库,请将需要对学员隐藏的文件存储在私密版本库) - + value={this.state.simichecked}>(若需要对学员隐藏部分版本库内容时,请选中;选中保存后表示启用私密版本库,请将需要对学员隐藏的文件存储在私密版本库) + } {this.props.identity < 3 ?

    服务配置

    diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js index 6188fcafb..02ff6a660 100644 --- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js @@ -29,11 +29,13 @@ export default class TPMsettings extends Component { componentDidMount() { + this.getdatas() + } - let id = this.props.match.params.shixunId; + getdatas=()=>{ + let id = this.props.match.params.shixunId; let Url = `/shixuns/` + id + `/settings.json`; - axios.get(Url).then((response) => { // alert(response.data.shixun.choice_standard_scripts) if (response.status === 200) { @@ -58,21 +60,6 @@ export default class TPMsettings extends Component { }); - - let departmentsUrl = `/shixuns/departments.json`; - axios.get(departmentsUrl).then((response) => { - if (response.status === 200) { - if (response.data.message === undefined) { - this.setState({ - departmentslist: response.data.shools_name - }); - } - } - }).catch((error) => { - console.log(error) - }); - - } operateshixuns = (value) => { @@ -126,6 +113,7 @@ export default class TPMsettings extends Component { render() { + let showtabs= this.props.shixunsDetails === undefined ?"":this.props.shixunsDetails.is_jupyter===true?"":"学习页面设置" return (
    @@ -142,7 +130,7 @@ export default class TPMsettings extends Component { ` } - { @@ -170,20 +158,22 @@ export default class TPMsettings extends Component { this.getdatas()} /> this.getdatas()} /> - - - + {/*{ this.props.shixunsDetails===undefined?"":this.props.shixunsDetails.is_jupyter===true?"":*/} + {/* */} + {/*}*/}