diff --git a/public/react/src/modules/modals/Bottomsubmit.js b/public/react/src/modules/modals/Bottomsubmit.js new file mode 100644 index 000000000..fe5d897f2 --- /dev/null +++ b/public/react/src/modules/modals/Bottomsubmit.js @@ -0,0 +1,48 @@ +import React, {Component} from 'react'; + +class Bottomsubmit extends Component { + constructor(props) { + super(props) + + this.state = { + + } + } + + + + + render() { + + return ( +
+ +
+
+ + +
+
+
+ + ); + } +} + + + +export default Bottomsubmit; + + + + + + diff --git a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js index 060f71f9c..ccab94ea1 100644 --- a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js +++ b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js @@ -1,33 +1,482 @@ -import React, { Component } from 'react'; +import React, {Component} from 'react'; -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Icon,DatePicker,Breadcrumb,Upload,Button,notification, Tooltip,Tabs} from 'antd'; +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'; import axios from 'axios'; -import './css/TPMsettings.css'; +import TPMMDEditor from "../challengesnew/TPMMDEditor"; + -import { getImageUrl, toPath, getUrl ,appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder'; +import {getImageUrl, toPath, getUrl, appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder'; +import {TPMIndexHOC} from "../TPMIndexHOC"; +import './css/TPMsettings.css'; + +import '../newshixuns/css/Newshixuns.css'; -export default class Shixuninformation extends Component { +class Shixuninformation extends Component { constructor(props) { super(props) + this.contentMdRef = React.createRef(); this.state = { - + NAME_COUNT: 60, + shixunmemoMDvalue: "", + language: "java", } } + getshixunmemoMDvalue = (value, e) => { + + this.setState({ + shixunmemoMDvalue: value + }) + } + render() { + const {getFieldDecorator} = this.props.form; + const {newshixunlist, languagewrite, systemenvironment, testcoderunmode, fileList, postapplytitle, postapplyvisible, shixunmemoMDvalue} = this.state; + const {shixun_service_configs}=this.props; + let operateauthority = this.props.identity === 1 ? true : this.props.identity < 5 && this.state.status == 0 ? true : false; + const uploadProps = { + width: 600, + fileList, + 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 (
- 1111 +
+ + {getFieldDecorator('name', { + rules: [{ + required: true, message: '请输入选题名称', + }, { + max: 60, message: '请输入名称,最大限制60个字符', + }, { + whitespace: true, message: '请勿输入空格' + }], + })( + + )} + + + + + + + + + {getFieldDecorator('select', { + rules: [{required: true, message: '请选择难易度'}], + })( +
+ + +
+ )} + (实训的难易程度) +
+ + +
+ + {getFieldDecorator('selectleft', { + rules: [{required: true, message: '请选择主类别'}], + })( +
+ + + +
+ )} +
+
+ + + +
+ {getFieldDecorator('selectright', { + rules: [{required: true, message: '请选择小类别'}], + })( +
+ +
+ )} + +
+
+ 已安装软件:hadoop3.1.0、jdk1.8; +
+
+ 说明:添加了hadoop3.1.0、jdk1.8的源码包,添加了hadoop3.1.0、jdk1.8的源码包 +
+
+
+
+
+ +
+
+ 没有实验环境? + 申请新建 +
+ + + + {getFieldDecorator('select', { + rules: [{required: true, message: '请选择评测脚本'}], + })( +
+ + +
+ )} + + 使用自定义脚本 + + + + +
+ +
+
+
+
+ +
+
+
+ + + + (若需要对学员隐藏部分版本库内容时,请选中;选中即启用私密版本库,请将需要对学员隐藏的文件存储在私密版本库) + +
+ + {this.props.identity<3?
+

服务配置

+ { shixun_service_configs&&shixun_service_configs.map((item,key)=>{ + + return( +
+
+
+ {item.name} + {/*this.Deselectlittle(item.mirror_repository_id)}>*/} +
+
+ +
+ this.setConfigsInputs(e,key,1)} + className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" /> +
+
+
+
+ +
+ this.setConfigsInputs(e,key,2)} + className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" /> +
+
+
+
+ +
+ this.setConfigsInputs(e,key,3)} + className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" /> +
+
+
+
+ +
+ this.setConfigsInputs(e,key,4)} + className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" /> +
+ +
+
+
+
+ ) + + })} +
:""} + + + {postapplyvisible === true ? : ""} + + +
+
  • + + +
  • +
    {this.state.languagewritetype === true ? "请填写该镜像语言" : ""}
    +
  • + + +
  • +
    {this.state.systemenvironmenttype === true ? "请填写该镜像语言系统环境" : ""}
    +
  • + + + +
  • +
    {this.state.testcoderunmodetype === true ? "请填写该镜像测试代码运行方式" : ""}
    +
  • + +
    + + + 上传附件 + (单个文件50M以内) + + +
    + +
  • +
    + {this.state.attachmentidstype === true ? "请上传附件" : ""} +
    +
  • + this.sendhideModaly()} + >取消 + +
  • +
    +
    + {/**/} +
    + + + +
    +

    新建申请已提交,请等待管理员的审核

    +
  • 我们将在1-2个工作日内与您联系 +
  • +
    +
    + 知道啦 +
    +
    +
    +
    ); } } +const TopShixuninformation = Form.create({name: 'newshixun'})(Shixuninformation); + +export default TopShixuninformation; + + diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js index b189cb4f3..be016385f 100644 --- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js @@ -18,12 +18,13 @@ import { Tabs } from 'antd'; -import Shixuninformation from './Shixuninformation'; +import TopShixuninformation from './Shixuninformation'; import Configuration from './Configuration'; import LearningSettings from './LearningSettings'; +import Bottomsubmit from "../../modals/Bottomsubmit"; import moment from 'moment'; @@ -33,320 +34,22 @@ import './css/TPMsettings.css'; import {getImageUrl, toPath, getUrl, appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder'; -let path = getUrl("/editormd/lib/") - -const $ = window.$; const {TabPane} = Tabs; -let timeout; - -let currentValue; - -const Option = Select.Option; - -const confirm = Modal.confirm; // 处理整点 半点 -// 取传入时间往后的第一个半点 -export function handleDateStrings(dateString) { - if (!dateString) return dateString; - const ar = dateString.split(':') - if (ar[1] == '00' || ar[1] == '30') { - return dateString - } - const miniute = parseInt(ar[1]); - if (miniute < 30 || miniute == 60) { - return [ar[0], '30'].join(':') - } - if (miniute < 60) { - // 加一个小时 - const tempStr = [ar[0], '00'].join(':'); - const format = "YYYY-MM-DD HH:mm"; - const _moment = moment(tempStr, format) - _moment.add(1, 'hours') - return _moment.format(format) - } - - return dateString -} - -// 恢复数据 -function md_rec_data(k, mdu, id, editor) { - if (window.sessionStorage.getItem(k + mdu) !== null) { - editor.setValue(window.sessionStorage.getItem(k + mdu)); - md_clear_data(k, mdu, id); - } -} - -// 保存数据 -function md_add_data(k, mdu, d) { - window.sessionStorage.setItem(k + mdu, d); -} - -// 清空保存的数据 -function md_clear_data(k, mdu, id) { - window.sessionStorage.removeItem(k + mdu); - var id1 = "#e_tip_" + id; - var id2 = "#e_tips_" + id; - if (k == 'content') { - $(id2).html(""); - } else { - $(id1).html(""); - } -} - -function md_elocalStorage(editor, mdu, id) { - if (window.sessionStorage) { - var oc = window.sessionStorage.getItem('content' + mdu); - if (oc !== null) { - $("#e_tips_" + id).data('editor', editor); - var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; - $("#e_tips_" + id).html(h); - } - setInterval(function () { - var d = new Date(); - var h = d.getHours(); - var m = d.getMinutes(); - var s = d.getSeconds(); - h = h < 10 ? '0' + h : h; - m = m < 10 ? '0' + m : m; - s = s < 10 ? '0' + s : s; - if (editor.getValue().trim() != "") { - md_add_data("content", mdu, editor.getValue()); - var id1 = "#e_tip_" + id; - var id2 = "#e_tips_" + id; - - $(id1).html(" 数据已于 " + h + ':' + m + ':' + s + " 保存 "); - $(id2).html(""); - } - }, 10000); - - } else { - $("#e_tip_" + id).after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); - } -} - -function create_editorMD(id, width, high, placeholder, imageUrl, initValue, callback) { - var editorName = window.editormd(id, { - width: width, - height: high, - path: path, // "/editormd/lib/" - markdown: initValue, - syncScrolling: "single", - tex: true, - tocm: true, - emoji: true, - taskList: true, - codeFold: true, - searchReplace: true, - htmlDecode: "style,script,iframe", - sequenceDiagram: true, - autoFocus: false, - placeholder: placeholder, - toolbarIcons: function () { - // Or return editormd.toolbarModes[name]; // full, simple, mini - // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"] - }, - toolbarCustomIcons: { - testIcon: "
    ", - testIcon1: "
    " - }, - //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 - saveHTMLToTextarea: true, - // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 - dialogMaskOpacity: 0.6, - imageUpload: true, - imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], - imageUploadURL: imageUrl,//url - onload: function () { - // this.previewing(); - $("#" + id + " [type=\"latex\"]").bind("click", function () { - editorName.cm.replaceSelection("```latex"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("```"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line - 1, 0); - }); - - $("#" + id + " [type=\"inline\"]").bind("click", function () { - editorName.cm.replaceSelection("`$$$$`"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line, __Cursor.ch - 3); - editorName.cm.focus(); - }); - $("[type=\"inline\"]").attr("title", "行内公式"); - $("[type=\"latex\"]").attr("title", "多行公式"); - - callback && callback() - } - }); - return editorName; -} -function updatamakedown(id) { - setTimeout(() => { - var shixunDescr = window.editormd.markdownToHTML(id, { - htmlDecode: "style,script,iframe", - taskList: true, - tex: true, - flowChart: true, - sequenceDiagram: true - }); - $("#" + id + " p:first").addClass("ReactMarkdown"); - $('#collaborators_list_info').show() - }, 200) -} - -function range(start, end) { - const result = []; - for (let i = start; i < end; i++) { - result.push(i); - } - return result; -} - -function disabledDateTime() { - return { - // disabledHours: () => range(0, 24).splice(4, 20), - disabledMinutes: () => range(1, 30).concat(range(31, 60)), - // disabledSeconds: () => [0, 60], - }; -} - -function disabledDate(current) { - return current && current < moment().endOf('day').subtract(1, 'days'); -} - export default class TPMsettings extends Component { constructor(props) { super(props) this.state = { - fileList: [], - commandLine: 0, - Openpublic: 0, - settingsData: undefined, - webssh: 0, - use_scope: 0, - shixunsstatus: 0, - shixunsID: undefined, - exec_time: undefined, - trainee: undefined, - can_copy: undefined, - task_pass: undefined, - test_set_permission: undefined, - code_edit_permission: undefined, - hide_code: undefined, - code_hidden: undefined, - forbid_copy: undefined, - vnc: undefined, - name: undefined, - scope_partment: undefined, - scopetype: false, - departmentslist: undefined, - description: '', - evaluate_script: undefined, - standard_scripts: undefined, - choice_main_type: "", - choice_small_type: [], - choice_standard_scripts: undefined, - editordescriptios: undefined, - editorevaluate_scripts: undefined, - choice_standard_scriptssum: undefined, - visibleTemplate: false, - Executiveordervalue: "", - Compilecommandvalue: "", - Executivetyoe: false, - postapplyvisible: false, - sendsure_applyvalue: undefined, - postapplytitle: false, - shixunnametype: false, - shixunmaintype: false, - evaluate_scripttype: false, - exec_timetype: false, - traineetype: false, - standard_scriptsModal: false, - standard_scriptsModals: false, - SelectTheCommandtype: false, - multi_webssh: false, - status: 0, - opers: false, - operss: false, - testscripttiptype: false, - opersss: false, - operateshixunstype: false, - opening_time: "", - opensmail: false, - scope_partmenttype: false, - newuse_scope: undefined, - scope_partments: 0, - shixun_service_configs: undefined, - shixun_service_configlist: undefined, - pod_exist_time: undefined, - pod_exist_timetype: false, - shixunmemoMDvalue: "", - language: "", - deleteisnot: true - } - } - descriptionMD = (initValue, id) => { - - this.contentChanged = false; - const placeholder = ""; -// amp; -// 编辑时要传memoId - const imageUrl = `/api/attachments.json`; -// 创建editorMd - - const description_editormd = create_editorMD(id, '100%', 400, placeholder, imageUrl, initValue, () => { - setTimeout(() => { - description_editormd.resize() - description_editormd.cm && description_editormd.cm.refresh() - }, 500) - - if (initValue != undefined) { - description_editormd.setValue(initValue) - } - description_editormd.cm.on("change", (_cm, changeObj) => { - console.log('....contentChanged') - this.contentChanged = true; - }) - }); - md_elocalStorage(description_editormd, `MemoQuestion_${id}`, `${id}Question`); - this.description_editormd = description_editormd; - window.description_editormd = description_editormd; + } } - evaluate_scriptMD = (initValue, id) => { - this.contentChanged = false; - const placeholder = ""; -// amp; -// 编辑时要传memoId - const imageUrl = `/api/attachments.json`; -// 创建editorMd - - const evaluate_script_editormd = create_editorMD(id, '100%', 400, placeholder, imageUrl, initValue, () => { - setTimeout(() => { - evaluate_script_editormd.resize() - evaluate_script_editormd.cm && evaluate_script_editormd.cm.refresh() - }, 500) - if (initValue != undefined) { - evaluate_script_editormd.setValue(initValue) - } - evaluate_script_editormd.cm.on("change", (_cm, changeObj) => { - console.log('....contentChanged') - this.contentChanged = true; - }) - }); - md_elocalStorage(evaluate_script_editormd, `MemoQuestion_${id}`, `${id}Question`); - this.evaluate_script_editormd = evaluate_script_editormd; - window.evaluate_script_editormd = evaluate_script_editormd; - } componentDidMount() { @@ -426,7 +129,7 @@ export default class TPMsettings extends Component { // this.evaluate_scriptMD(response.data.shixun.evaluate_script, "shixunmemoMD"); - this.descriptionMD(response.data.shixun.description, "shixundescription"); + // this.descriptionMD(response.data.shixun.description, "shixundescription"); // this.bigClass() // if (response.data.shixun.status === 2) { @@ -457,1221 +160,46 @@ export default class TPMsettings extends Component { } - SelectshixunCommand = (e) => { - // console.log( e.target.value) - const webssh = e.target.value - if (webssh == 2) { - this.setState({ - webssh: webssh, - SelectTheCommandtype: true, - multi_webssh: false - }); - } else { - if (this.state.init_is_secret_repository && !this.state.vnc && this.state.is_secret_repository == true) { - this.confirmDeleteSecretRepo({ - onOk: () => { - this.setState({ - webssh: webssh, - SelectTheCommandtype: false, - multi_webssh: false - }); - } - }) - } else { - if (!this.state.vnc) { - this.setState({ - is_secret_repository: false, - }) - } - this.setState({ - webssh: webssh, - SelectTheCommandtype: false, - multi_webssh: false - }); - } - } - - // this.setState({ - // webssh: webssh, - // }); - // if(webssh===2){ - // this.setState({ - // SelectTheCommandtype: true, - // multi_webssh:false - // }); - // }else{ - // this.setState({ - // SelectTheCommandtype: false, - // multi_webssh:false - // }); - // } - } - - SelectOpenpublic = (e) => { - this.setState({ - Openpublic: e.target.value - }); - } - - can_copy = (e) => { - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - can_copy: sum, - }); - - } - - task_pass = (e) => { - - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - task_pass: sum, - }); - } - - test_set_permission = (e) => { - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - test_set_permission: sum, - }); - - } - - hide_code = (e) => { - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - hide_code: sum, - }); - - } - code_edit_permission = (e) => { - this.setState({ - code_edit_permission: e.target.checked - }) - } - code_hidden = (e) => { - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - code_hidden: sum, - }); - - } - confirmDeleteSecretRepo = ({title, onOk}) => { - confirm({ - title: title ||
    -
    已创建的私密版本库及其内容,将在“保存”时被删除。
    -
    是否确认取消勾选?
    -
    , - okText: '确定', - cancelText: '取消', - onOk: () => { - this.setState({is_secret_repository: false}) - onOk && onOk() - }, - onCancel() { - }, - }); - } - is_secret_repository = (e) => { - const checked = e.target.checked - if (!checked) { - if (this.state.init_is_secret_repository) { - this.confirmDeleteSecretRepo({}) - } else { - this.setState({is_secret_repository: false}) - } - } else { - this.setState({is_secret_repository: true}) - } - } - forbid_copy = (e) => { - let sum = "" - if (e.target.checked === false) { - sum = 0 - } else if (e.target.checked === true) { - sum = 1 - } - this.setState({ - forbid_copy: sum, - }); - } - shixun_vnc_evaluate = (e) => { - this.setState({ - vnc_evaluate: e.target.checked, - }); - - } - - shixun_vnc = (e) => { - // let sum = "" - // if (e.target.checked === false) { - // sum = 0 - // } else if (e.target.checked === true) { - // sum = 1 - // } - const vnc = e.target.checked; - if (!vnc) { - if (this.state.init_is_secret_repository && this.state.webssh != 2 && this.state.is_secret_repository == true) { - this.confirmDeleteSecretRepo({ - onOk: () => { - this.setState({ - vnc: e.target.checked, - vnc_evaluate: false, - }); - } - }) - } else { - if (this.state.webssh != 2) { - this.setState({ - is_secret_repository: false - }) - } - this.setState({ - vnc: e.target.checked, - vnc_evaluate: false, - }); - } - } else { - this.setState({ - vnc: e.target.checked, - vnc_evaluate: false, - }); - } - } - shixunsname = (e) => { - // let {shixunsstatus}=this.state; - // if(shixunsstatus>0){ - // return - // } - this.setState({ - name: e.target.value, - shixunnametype: false - }) - } - - bigClass = (value) => { - // choice_main_type - // choice_small_type - let {settingsData, shixun_service_configs, choice_main_type, choice_small_type} = this.state; - - let list = [] - list.push(choice_main_type) - choice_small_type.map((item, key) => { - list.push(item) - }) - - let newshixun_service_configs = shixun_service_configs; - - let newshixun_service_configsagin = [] - - newshixun_service_configs.map((item, key) => { - list.map((its, index) => { - if (item.mirror_repository_id === its) { - newshixun_service_configsagin.push(item) - } - }) - }) - - - settingsData.shixun.main_type.some((item, key) => { - if (item.id === value) { - newshixun_service_configsagin[0] = { - mirror_repository_id: value, - name: item.type_name, - cpu_limit: 1, - lower_cpu_limit: 0.1, - memory_limit: 1024, - request_limit: 10 - } - return true - } - } - ) - let url = `/shixuns/get_mirror_script.json?mirror_id=` + value; - axios.get(url).then((response) => { - if (response.status === 200) { - // console.log(response.data) - this.setState({ - choice_main_type: value, - standard_scripts: response.data, - choice_standard_scripts: null, - shixun_service_configs: newshixun_service_configsagin, - shixun_service_configlist: newshixun_service_configsagin, - }) - } - }).catch((error) => { - console.log(error) - }); - - - } - Deselectlittle = (value) => { - - let {shixun_service_configs, choice_small_type} = this.state; - let newshixun_service_configs = shixun_service_configs; - let newchoice_small_type = choice_small_type; - - newshixun_service_configs.some((item, key) => { - if (item.mirror_repository_id === value) { - newshixun_service_configs.splice(key, 1) - return true - } - } - ) - - newchoice_small_type.some((item, key) => { - if (item === value) { - newchoice_small_type.splice(key, 1) - return true - } - } - ) - - - this.setState({ - choice_small_type: newchoice_small_type, - shixun_service_configs: newshixun_service_configs, - shixun_service_configlist: newshixun_service_configs, - }) - } - littleClass = (value) => { - - let {settingsData, shixun_service_configs, choice_small_type, choice_main_type} = this.state; - let newshixun_service_configs = shixun_service_configs; - let newchoice_small_type = choice_small_type; - // if(Array.isArray(value)===true){ - // value.map((item,key)=>{ - // settingsData.shixun.small_type.some((items,keys)=> { - // if (items.id === item) { - // newshixun_service_configs.push({ - // mirror_repository_id:value, - // name:items.type_name, - // cpu_limit:1, - // lower_cpu_limit:0.1, - // memory_limit:1024, - // request_limit:10 - // }) - // return true - // } - // } - // ) - // }) - // } - - let list = [] - list.push(choice_main_type) - choice_small_type.map((item, key) => { - list.push(item) - }) - - let newshixun_service_configsagin = [] - - newshixun_service_configs.map((item, key) => { - list.map((its, index) => { - if (item.mirror_repository_id === its) { - newshixun_service_configsagin.push(item) - } - }) - }) - - settingsData.shixun.small_type.some((items, keys) => { - if (items.id === value) { - newshixun_service_configsagin.push({ - mirror_repository_id: value, - name: items.type_name, - cpu_limit: 1, - lower_cpu_limit: 0.1, - memory_limit: 1024, - request_limit: 10 - }) - return true - } - } - ) - - newchoice_small_type.push(value) - - this.setState({ - choice_small_type: newchoice_small_type, - shixun_service_configs: newshixun_service_configsagin, - shixun_service_configlist: newshixun_service_configsagin, - }) - } - onPodExistTimeChange = (e) => { - this.setState({ - pod_exist_time: e.target.value, - pod_exist_timetype: false, - }) - } - Timevalue = (e) => { - this.setState({ - exec_time: e.target.value - }) - } - SelectOpenpublic = (e) => { - this.setState({ - scopetype: false, - use_scope: e.target.value, - }); - if (e.target.value === 1) { - this.setState({ - scopetype: true - }); - } - - } - deleteScopeInput = (key) => { - let {scope_partment} = this.state; - let datalist = scope_partment; - datalist.splice(key, 1); - this.setState({ - scope_partment: datalist - }); - } - - shixunScopeInput = (e) => { - let {scope_partment} = this.state; - let datalist = scope_partment; - if (datalist === undefined) { - datalist = [] - } - - datalist.push(e) - // else { - // datalist[id] = e - // } - this.setState({ - scope_partment: datalist - }); - } - // adduse_scopeinput = () => { - // let {scope_partment} = this.state; - // let array = scope_partment; - // let newarray = "" - // array.push(newarray) - // this.setState({ - // scope_partment: array, - // }); - // } - submit_edit_shixun = () => { - if (this.saving == true) return; - this.saving = true; - if (this.state.status === -1) { - this.props.showSnackbar("该实训已被删除,保存失败!"); - return - } - - let { - name, choice_main_type, choice_small_type, choice_standard_scripts, scope_partment, choice_standard_scriptssum, vnc_evaluate, - evaluate_script, webssh, use_scope, trainee, can_copy, task_pass, test_set_permission, hide_code, code_hidden, forbid_copy, vnc, multi_webssh, - opening_time, shixunmemoMDvalue, shixun_service_configlist, is_secret_repository, code_edit_permission - } = this.state; - - let newshixun_service_configlist = shixun_service_configlist.map(v => { - let v1 = Object.assign({}, v); - delete v1.name; - return v1 - }); - - // let operateauthority= - // this.props.identity===1?true:this.props.identity<5&&this.state.status==0?true:false; - // this.props.identity<5&&this.state.status==0||this.props.identity===1&&this.state.status==2||this.props.identity===1&&this.state.status==1; - - const description_editormd = this.description_editormd.getValue(); - - let evaluate_script_editormd; - - if (this.state.status == 0 || this.state.status == 1 || this.state.status == 2 && this.props.identity === 1) { - // evaluate_script_editormd = this.evaluate_script_editormd.getValue(); - evaluate_script_editormd = shixunmemoMDvalue - } else { - evaluate_script_editormd = evaluate_script; - } - - - if (name === "") { - this.setState({ - shixunnametype: true - }) - $('html').animate({ - scrollTop: 10 - }, 1000); - return - } - if (choice_main_type === "") { - this.setState({ - shixunmaintype: true - }) - $('html').animate({ - scrollTop: 800 - }, 1000); - return - } - if (evaluate_script_editormd === "") { - this.setState({ - evaluate_scripttype: true - }) - $('html').animate({ - scrollTop: 1200 - }, 1000); - return - } - if (use_scope === 1) { - - if (scope_partment === undefined || scope_partment.length === 0) { - this.setState({ - scope_partmenttype: true - }) - $('html').animate({ - scrollTop: 2500 - }, 1000); - this.props.showSnackbar("公开程度,指定单位为空"); - return - } - } - // if (exec_time === "") { - // this.setState({ - // exec_timetype: true - // }) - // $('html').animate({ - // scrollTop: 1500 - // }, 1000); - // return - // } - - // if (!pod_exist_time) { - // this.setState({ - // pod_exist_timetype: true - // }) - // $("html, body").animate({ scrollTop: $('#pod_exist_time').offset().top - 100 }, 1000) - // return - // } - - if (trainee === "") { - this.setState({ - traineetype: true - }) - return - } - - let id = this.props.match.params.shixunId; - - let newmulti_webssh = multi_webssh; - - - if (newmulti_webssh === null) { - newmulti_webssh = false - } - - //exec_time: exec_time, - let Url = `/shixuns/` + id + `.json`; - let data = { - shixun: { - - name: name, - webssh: webssh, - use_scope: use_scope, - can_copy: can_copy, - vnc: vnc === null ? undefined : vnc, - vnc_evaluate: vnc_evaluate === null ? undefined : vnc_evaluate, - test_set_permission: test_set_permission, - code_hidden: code_hidden, - code_edit_permission: code_edit_permission, - trainee: trainee, - task_pass: task_pass, - hide_code: hide_code, - forbid_copy: forbid_copy, - multi_webssh: newmulti_webssh, - opening_time: opening_time, - mirror_script_id: choice_standard_scriptssum === undefined ? choice_standard_scripts : choice_standard_scriptssum, - }, - shixun_info: { - description: description_editormd, - evaluate_script: evaluate_script_editormd, - }, - is_secret_repository: is_secret_repository, - main_type: choice_main_type, - small_type: choice_small_type, - scope_partment: scope_partment, - shixun_service_configs: newshixun_service_configlist - } - - axios.put(Url, data).then((response) => { - // console.log(response) - this.saving = false; - if (response.status) { - if (response.data.status === -1) { - this.props.showSnackbar(response.data.message); - return - } else { - window.location.href = "/shixuns/" + response.data.shixun_identifier + "/challenges"; - } - } - - }).catch((error) => { - console.log(error) - this.saving = false; - }) - - - } - 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})); - } - - - shixunsclose = () => { - let id = this.props.match.params.shixunId; - let cul = `/shixuns/` + id + `/close.json`; - axios.post(cul).then((response) => { - if (response.data.status === 1) { - this.props.showSnackbar("操作成功"); - this.setState({ - operateshixunstype: false, - }); - - window.location.href = "/shixuns/" + id + "/challenges"; - } - }).catch((error) => { - console.log(error) - }) - } - - shixunsdel = () => { - let id = this.props.match.params.shixunId; - let cul = `/shixuns/` + id + `.json`; - - axios.delete(cul).then((response) => { - if (response.data.status === 1) { - this.props.showSnackbar("操作成功"); - this.setState({ - operateshixunstype: false, - }); - - window.location.href = "/shixuns"; - } - }).catch((error) => { - console.log(error) - }) - } - - Executiveorder = (e) => { - this.setState({ - Executiveordervalue: e.target.value - }) - } - - Compilecommand = (e) => { - this.setState({ - Compilecommandvalue: e.target.value - }) - } - - handleCancelTemplate = (e) => { - this.setState({ - Executiveordervalue: "", - Compilecommandvalue: "", - visibleTemplate: false - }) - } - - hideModalTemplate = (e) => { - let id = this.props.match.params.shixunId; - let {Executiveordervalue, Compilecommandvalue} = this.state; - - if (Executiveordervalue === "") { - this.setState({ - Executivetyoe: true, - }); - return - } - // Executiveordervalue=String(Executiveordervalue); - // Compilecommandvalue=String(Compilecommandvalue); - let trl = `/shixuns/${id}/get_custom_script.json?compile=${Executiveordervalue}&excutive=${Compilecommandvalue}` - axios.get(trl).then((response) => { - // this.evaluate_scriptMD(response.data.shixun_script, "shixunmemoMD"); - this.setState({ - shixunmemoMDvalue: response.data.shixun_script - }) - }).catch((error) => { - console.log(error) - }); - this.setState({ - visibleTemplate: false - }) - } - - showModal = () => { - this.setState({ - visibleTemplate: true, - }); - } - Selecttrainee = (value) => { - this.setState({ - trainee: value, - }); - } - - post_apply = () => { - this.setState({ - postapplyvisible: true - }) - } - - sendsure_applyvalues = (e) => { - this.setState({ - sendsure_applyvalue: e.target.value - }) - } - - setlanguagewrite = (e) => { - this.setState({ - languagewrite: e.target.value - }) - } - - setsystemenvironment = (e) => { - this.setState({ - systemenvironment: e.target.value - }) - } - - settestcoderunmode = (e) => { - this.setState({ - testcoderunmode: e.target.value - }) - - } - - sendsure_apply = () => { - let {languagewrite, systemenvironment, testcoderunmode} = this.state; - // console.log("点击确定") - // console.log("languagewrite"+languagewrite); - // console.log("systemenvironment"+systemenvironment); - // console.log("testcoderunmode"+testcoderunmode); - - // let attachment_ids = undefined - // if (this.state.fileList) { - // attachment_ids = this.state.fileList.map(item => { - // return item.response ? item.response.id : item.id - // }) - // } - if (languagewrite === undefined || languagewrite === "") { - // this.props.showNotification(`请填写该镜像是基于什么语言`); - this.setState({ - languagewritetype: true - }) - return - } - if (systemenvironment === undefined || systemenvironment === "") { - // this.props.showNotification(`请填写该镜像是基于什么语言系统环境`); - this.setState({ - systemenvironmenttype: true - }) - return; - - } - if (testcoderunmode === undefined || testcoderunmode === "") { - // this.props.showNotification(`请填写该镜像中测试代码运行方式`); - this.setState({ - testcoderunmodetype: true - }) - return; - } - var attachment_ids = undefined; - if (this.state.fileList) { - attachment_ids = this.state.fileList.map(item => { - return item.response ? item.response.id : item.id - }) - } - - if (attachment_ids === undefined || attachment_ids.length === 0) { - - // notification.open( - // { - // message: '提示', - // description: - // '请上传附件!', - // - // } - // ) - this.setState({ - attachmentidstype: true - }) - return; - } - // console.log("attachment_ids"+attachment_ids); - - // alert(languagewrite +" "+systemenvironment +" "+testcoderunmode + " "+attachment_ids); - - var data = { - language: languagewrite, - runtime: systemenvironment, - run_method: testcoderunmode, - attachment_id: attachment_ids[0], - } - var url = `/shixuns/apply_shixun_mirror.json`; - axios.post(url, data - ).then((response) => { - - try { - if (response.data) { - // const { id } = response.data; - // if (id) { - if (this.state.file !== undefined) { - console.log("549"); - // this.deleteAttachment(this.state.file); - this.setState({ - file: undefined, - deleteisnot: true, - languagewrite: "", - systemenvironment: "", - testcoderunmode: "", - fileList: [] - }) - } else { - this.setState({ - file: undefined, - deleteisnot: true, - languagewrite: "", - systemenvironment: "", - testcoderunmode: "", - fileList: [] - }) - } - // this.props.showNotification('提交成功!'); - notification.open( - { - message: '提示', - description: - '提交成功!', - - } - ) - this.sendhideModaly() - // this.props.history.push(`/courses/${cid}/graduation_topics`); - // } - } - } catch (e) { - - } - - }) - - } - - sendhideModaly = () => { - this.setState({ - postapplyvisible: false, - }) - if (this.state.file !== undefined) { - console.log("580"); - // this.deleteAttachment(this.state.file); - this.setState({ - file: undefined, - deleteisnot: true, - languagewrite: "", - systemenvironment: "", - testcoderunmode: "", - fileList: [] - }) - } else { - this.setState({ - file: undefined, - deleteisnot: true, - languagewrite: "", - systemenvironment: "", - testcoderunmode: "", - fileList: [] - }) - } - } - - yeshidemodel = () => { - this.setState({ - postapplytitle: false - }) - } - - SelectScput = (value, e) => { - this.setState({ - choice_standard_scriptssum: value, - language: e.props.name, - choice_standard_scripts: {id: e.props.value, value: ""}, - standard_scriptsModal: true - }) - } - - hidestandard_scriptsModal = () => { - this.setState({ - standard_scriptsModal: false, - standard_scriptsModals: false - }) - } - - get_mirror_script = () => { - let {choice_standard_scriptssum} = this.state; - let id = this.props.match.params.shixunId; - let pul = "/shixuns/" + id + "/get_script_contents.json?script_id=" + choice_standard_scriptssum; - axios.get(pul).then((response) => { - if (response.status === 200) { - // this.evaluate_scriptMD(response.data.content, "shixunmemoMD"); - this.setState({ - standard_scriptsModal: false, - standard_scriptsModals: true, - shixunmemoMDvalue: response.data.content - }) - } - - }).catch((error) => { - console.log(error) - }) - } - - - SelectTheCommandonChange = (e) => { - this.setState({ - multi_webssh: e.target.checked - }) - } - - bigopen = () => { - this.setState({ - opers: true - }) - - } - - bigopens = () => { - this.setState({ - opers: false, - operss: false, - opersss: false, - opensmail: false - }) - - } - bigopensmal = (e) => { - this.setState({ - opensmail: true - }) - - } - sbigopen = (e) => { - this.setState({ - operss: true - }) - - } - - sbigopens = () => { - this.setState({ - operss: false - }) - } - sbigopenss = (e) => { - this.setState({ - opersss: true - }) - - } - - sbigopensss = () => { - this.setState({ - opersss: false - }) - } - testscripttip = (val) => { - if (val === 0) { - this.setState({ - testscripttiptype: true - }) - } else if (val === 1) { - this.setState({ - testscripttiptype: false - }) - } - } - - operateshixuns = (value) => { - this.setState({ - operateshixunstype: true, - delType: value - }) - } - - hideoperateshixuns = () => { - this.setState({ - operateshixunstype: false - }) - } - onChangeTimePicker = (value, dateString) => { - this.setState({ - opening_time: dateString === "" ? "" : moment(handleDateStrings(dateString)) - }) - } - - getshixunmemoMDvalue = (value, e) => { - - this.setState({ - shixunmemoMDvalue: value - }) - } - - setConfigsInputs = (e, keys, str) => { - - let {shixun_service_configs} = this.state; - let newshixun_service_configs = shixun_service_configs; - newshixun_service_configs.map((item, key) => { - if (key === keys) { - switch (str) { - case 1: - item.cpu_limit = e.target.value - break; - case 2: - item.lower_cpu_limit = e.target.value - break; - case 3: - item.memory_limit = e.target.value - break; - case 4: - item.request_limit = e.target.value - break; - } - } - }) - - this.setState({ - shixun_service_configs: newshixun_service_configs, - shixun_service_configlist: newshixun_service_configs, - }) - - } - - handleChange = (info) => { - 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: 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 = `/attachments/${id}.json` - axios.delete(url, {}) - .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() { - let { - postapplyvisible, - postapplytitle, - shixunnametype, - shixunmaintype, - evaluate_scripttype, - traineetype, - standard_scripts, - name, - settingsData, - webssh, - is_secret_repository, - use_scope, - shixunsID, - can_copy, - choice_standard_scripts, - Executiveordervalue, - Executivetyoe, - Compilecommandvalue, - task_pass, - test_set_permission, - hide_code, - forbid_copy, - code_edit_permission, - code_hidden, - vnc, - vnc_evaluate, - scopetype, - scope_partment, - departmentslist, - trainee, - choice_main_type, - choice_small_type, - standard_scriptsModal, - standard_scriptsModals, - SelectTheCommandtype, - testscripttiptype, - operateshixunstype, - opening_time, - scope_partmenttype, - newuse_scope, - scope_partments, - shixunmemoMDvalue, delType, - shixun_service_configs, - fileList, - } = this.state; - - let options; - - if (departmentslist != undefined) { - options = this.state.departmentslist.map((d, k) => { - return ( - - ) - }) - } - const uploadProps = { - width: 600, - fileList, - 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; - }, - } - const dateFormat = 'YYYY-MM-DD HH:mm:ss'; - let operateauthority = this.props.identity === 1 ? true : this.props.identity < 5 && this.state.status == 0 ? true : false; - const operations = ; return ( -
    - - - - - - - - - - - +
    + +
    + + + +
    + }> + + + + + + + + + + +
    + + +
    ); } diff --git a/public/react/src/modules/tpm/TPMsettings/css/TPMsettings.css b/public/react/src/modules/tpm/TPMsettings/css/TPMsettings.css index 8047bbde8..a15f7bcf0 100644 --- a/public/react/src/modules/tpm/TPMsettings/css/TPMsettings.css +++ b/public/react/src/modules/tpm/TPMsettings/css/TPMsettings.css @@ -111,3 +111,18 @@ a.newuse_scope-btn { .ml82{ margin-left:82px; } + +.Permanentban{ + color:#5091FF !important; + border-color: #5091FF !important; +} + +/*tab*/ +.ant-tabs-nav{ + padding-bottom:18px; + padding-top: 18px; +} + +.ant-tabs-extra-content{ + margin-top: 18px; +} \ No newline at end of file diff --git a/public/react/src/modules/tpm/TPMsettings/oldTPMsettings.js b/public/react/src/modules/tpm/TPMsettings/oldTPMsettings.js index 7acaf98d6..7b05980e0 100644 --- a/public/react/src/modules/tpm/TPMsettings/oldTPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/oldTPMsettings.js @@ -353,10 +353,10 @@ export default class TPMsettings extends Component { task_pass: response.data.shixun.task_pass, test_set_permission: response.data.shixun.test_set_permission, hide_code: response.data.shixun.hide_code, - code_edit_permission: response.data.shixun.code_edit_permission, + code_edit_permission: response.data.shixun.code_edit_permission, code_hidden: response.data.shixun.code_hidden, is_secret_repository: response.data.shixun.is_secret_repository, - init_is_secret_repository: response.data.shixun.is_secret_repository, + init_is_secret_repository: response.data.shixun.is_secret_repository, forbid_copy: response.data.shixun.forbid_copy, vnc: response.data.shixun.vnc, vnc_evaluate: response.data.shixun.vnc_evaluate, diff --git a/public/react/src/modules/tpm/newshixuns/Newshixuns.js b/public/react/src/modules/tpm/newshixuns/Newshixuns.js index 7dcb1fa51..90d839436 100644 --- a/public/react/src/modules/tpm/newshixuns/Newshixuns.js +++ b/public/react/src/modules/tpm/newshixuns/Newshixuns.js @@ -18,6 +18,8 @@ import './css/Newshixuns.css'; import TPMMDEditor from "../challengesnew/TPMMDEditor"; +import Bottomsubmit from "../../modals/Bottomsubmit"; + let path = getUrl("/editormd/lib/"); const $ = window.$; @@ -330,15 +332,7 @@ class Newshixuns extends Component { } return (
    - +
    @@ -449,10 +443,7 @@ class Newshixuns extends Component { }) } - - 没有实验环境? - 申请新建 - +
    )}
    @@ -504,7 +495,11 @@ class Newshixuns extends Component { - +
    +
    + 没有实验环境? + 申请新建 +
    {postapplyvisible===true?