Merge branch 'dev_jupyter' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_jupyter

merge code
chromesetting
tangjiang 5 years ago
commit 6894aa681c

@ -103,3 +103,6 @@ gem 'diffy'
# oauth2 # oauth2
gem 'omniauth', '~> 1.9.0' gem 'omniauth', '~> 1.9.0'
gem 'omniauth-oauth2', '~> 1.6.0' gem 'omniauth-oauth2', '~> 1.6.0'
# global var
gem 'request_store'

@ -303,7 +303,7 @@ class ApplicationController < ActionController::Base
current_domain_session = session[:"#{default_yun_session}"] current_domain_session = session[:"#{default_yun_session}"]
if current_domain_session if current_domain_session
# existing session # existing session
(User.active.find(current_domain_session) rescue nil) User.current = (User.active.find(current_domain_session) rescue nil)
elsif autologin_user = try_to_autologin elsif autologin_user = try_to_autologin
autologin_user autologin_user
elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth? elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?

@ -30,5 +30,17 @@ class JupytersController < ApplicationController
render json: {status: 0, url: url, port: port} render json: {status: 0, url: url, port: port}
end end
def reset_with_tpi
myshixun = Myshixun.find_by(identifier: params[:identifier])
info = jupyter_tpi_reset(myshixun)
render json: {status: 0, url: info[:url], port: info[:port]}
end
def reset_with_tpm
shixun = Shixun.find_by(identifier: params[:identifier])
info = jupyter_tpm_reset(shixun)
render json: {status: 0, url: info[:url], port: info[:port]}
end
end end

@ -18,7 +18,7 @@ class ShixunsController < ApplicationController
before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy, before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy,
:add_file, :jupyter_exec] :add_file, :jupyter_exec]
before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, :apply_public,
:shixun_members_added, :change_manager, :collaborators_delete, :shixun_members_added, :change_manager, :collaborators_delete,
:cancel_apply_public, :cancel_publish, :add_collaborators, :add_file] :cancel_apply_public, :cancel_publish, :add_collaborators, :add_file]
before_action :portion_allowed, only: [:copy] before_action :portion_allowed, only: [:copy]
@ -746,25 +746,25 @@ class ShixunsController < ApplicationController
end end
end end
if @status == 0 if @status == 0
ActiveRecord::Base.transaction do
@shixun.update_attributes!(:status => 2) @shixun.update_attributes!(:status => 2)
end
rescue Exception => e
logger.error("pushlish game #{e}")
end
end
def apply_public
tip_exception(-1, "请先发布实训再申请公开") if @shixun.status != 2
ActiveRecord::Base.transaction do
@shixun.update_attributes!(public: 1)
apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first
if apply && apply.status == 0 if apply && apply.status == 0
@status = 0 @status = 0
else else
ApplyAction.create(:container_type => "ApplyShixun", :container_id => @shixun.id, :user_id => current_user.id, :status => 0) ApplyAction.create(:container_type => "ApplyShixun", :container_id => @shixun.id, :user_id => current_user.id, :status => 0)
#begin
# status = Trustie::Sms.send(mobile: '18711011226', send_type:'publish_shixun' , name: '管理员')
#rescue => e
# Rails.logger.error "发送验证码出错: #{e}"
#end
@status = 1
end
end end
end end
rescue Exception => e normal_status(0, "申请成功")
logger.error("pushlish game #{e}")
end
end end
# 设置私密版本库的在tpm中的目录 # 设置私密版本库的在tpm中的目录

@ -38,12 +38,20 @@ class Laboratory < ApplicationRecord
find_by_identifier(subdomain) find_by_identifier(subdomain)
end end
def self.current=(laboratory) # def self.current=(laboratory)
Thread.current[:current_laboratory] = laboratory # Thread.current[:current_laboratory] = laboratory
# end
#
# def self.current
# Thread.current[:current_laboratory] ||= Laboratory.find(1)
# end
def self.current=(user)
RequestStore.store[:current_laboratory] = user
end end
def self.current def self.current
Thread.current[:current_laboratory] ||= Laboratory.find(1) RequestStore.store[:current_laboratory] ||= User.anonymous
end end
def shixuns def shixuns

@ -540,12 +540,20 @@ class User < ApplicationRecord
mail.present? mail.present?
end end
# def self.current=(user)
# Thread.current[:current_user] = user
# end
#
# def self.current
# Thread.current[:current_user] ||= User.anonymous
# end
def self.current=(user) def self.current=(user)
Thread.current[:current_user] = user RequestStore.store[:current_user] = user
end end
def self.current def self.current
Thread.current[:current_user] ||= User.anonymous RequestStore.store[:current_user] ||= User.anonymous
end end
def self.anonymous def self.anonymous

@ -7,7 +7,7 @@ module JupyterService
shixun_tomcat = edu_setting('cloud_bridge') shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/jupyter/get" uri = "#{shixun_tomcat}/bridge/jupyter/get"
tpiID = "tpm#{shixun.id}" tpiID = "tpm#{shixun.id}"
params = {tpiID: tpiID, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"} params = {tpiID: tpiID, identifier: shixun.identifier, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
logger.info "test_juypter: uri->#{uri}, params->#{params}" logger.info "test_juypter: uri->#{uri}, params->#{params}"
res = uri_post uri, params res = uri_post uri, params
@ -45,7 +45,7 @@ module JupyterService
uri = "#{shixun_tomcat}/bridge/jupyter/get" uri = "#{shixun_tomcat}/bridge/jupyter/get"
tpiID = myshixun.id tpiID = myshixun.id
params = {tpiID: tpiID, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"} params = {tpiID: tpiID, identifier: shixun.identifier, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(shixun))}"}
res = uri_post uri, params res = uri_post uri, params
logger.info "test_juypter: #{res}" logger.info "test_juypter: #{res}"
@ -130,4 +130,59 @@ module JupyterService
end end
##重置jupyter环境
def jupyter_tpi_reset(myshixun)
jupyter_delete_tpi(myshixun)
url = jupyter_url_with_game(myshixun)
port = jupyter_port_with_game(myshixun)
{url: url, port: port}
end
## 重置tpm环境
def jupyter_tpm_reset(shixun)
jupyter_delete_tpm(shixun)
url = jupyter_url_with_shixun(shixun)
port = jupyter_port_with_shixun(shixun)
{url: url, port: port}
end
# 删除pod
def jupyter_delete_tpi(myshixun)
myshixun_id = myshixun.id
digest = myshixun.identifier + edu_setting('bridge_secret_key')
digest_key = Digest::SHA1.hexdigest("#{digest}")
begin
shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/jupyter/delete"
Rails.logger.info("#{current_user} => cloese_jupyter digest is #{digest}")
params = {:tpiID => myshixun_id, :digestKey => digest_key, :identifier => myshixun.identifier}
res = uri_post uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级110")
end
end
end
def jupyter_delete_tpm(shixun)
tpiID = "tpm#{shixun.id}"
digest = shixun.identifier + edu_setting('bridge_secret_key')
digest_key = Digest::SHA1.hexdigest("#{digest}")
begin
shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/jupyter/delete"
Rails.logger.info("#{current_user} => cloese_jupyter digest is #{digest}")
params = {:tpiID => tpiID, :digestKey => digest_key, :identifier => shixun.identifier}
res = uri_post uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级110")
end
end
end
end end

@ -31,6 +31,8 @@ Rails.application.routes.draw do
get :save_with_tpm get :save_with_tpm
get :get_info_with_tpi get :get_info_with_tpi
get :get_info_with_tpm get :get_info_with_tpm
get :reset_with_tpi
get :reset_with_tpm
end end
end end
@ -276,6 +278,7 @@ Rails.application.routes.draw do
get :cancel_publish get :cancel_publish
get :cancel_apply_public get :cancel_apply_public
get :publish get :publish
get :apply_public
get :shixun_exec get :shixun_exec
post :review_shixun post :review_shixun
get :review_newest_record get :review_newest_record

@ -326,8 +326,8 @@ module.exports = {
comments: false comments: false
}, },
compress: { compress: {
drop_debugger: true, drop_debugger: false,
drop_console: true drop_console: false
} }
} }
}), }),

@ -35,7 +35,7 @@ if (isDev) {
// 老师 // 老师
// debugType="teacher"; // debugType="teacher";
// 学生 // 学生
//debugType="student"; // debugType="student";
window._debugType = debugType; window._debugType = debugType;
export function initAxiosInterceptors(props) { export function initAxiosInterceptors(props) {

@ -494,7 +494,7 @@ class NewShixunModel extends Component{
<div className="clearfix sortinxdirection mt30 intermediatecenterysls"> <div className="clearfix sortinxdirection mt30 intermediatecenterysls">
<p className="nandu">筛选</p> <p className="nandu">筛选</p>
<p className={belongtoindex===0?"clickbutstwo ml13":"clickbutstwos ml13"} onClick={()=>this.belongto("all")}>全部实训</p> <p className={belongtoindex===0?"clickbutstwo ml13":"clickbutstwos ml13"} onClick={()=>this.belongto("all")}>全部实训</p>
<p className={belongtoindex===1?"clickbutstwo ml20":"clickbutstwos ml20"} onClick={()=>this.belongto("mine")}>普通实训</p> <p className={belongtoindex===1?"clickbutstwo ml20":"clickbutstwos ml20"} onClick={()=>this.belongto("mine")}>我的实训</p>
</div>:"" </div>:""
} }
{/*{this.props.type==='shixuns'? <Dropdown overlay={menus}>*/} {/*{this.props.type==='shixuns'? <Dropdown overlay={menus}>*/}

@ -28,6 +28,9 @@ render() {
` `
body{ body{
overflow: hidden !important; overflow: hidden !important;
}
.ant-modal-body {
padding: 20px 40px;
} }
` `
} }

@ -1,14 +1,10 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import {Redirect} from 'react-router';
import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom";
import PropTypes from 'prop-types';
import {Rating, Progress} from "@icedesign/base"; import {Rating, Progress} from "@icedesign/base";
import {Modal, Input, Radio, Pagination, message, Spin, Icon, Tooltip, Rate} from 'antd'; import {Modal, Input, Radio, Pagination, message, Spin, Icon, Tooltip, Button,Popover} from 'antd';
import AccountProfile from "../user/AccountProfile"; import AccountProfile from "../user/AccountProfile";
@ -57,6 +53,8 @@ class TPMBanner extends Component {
isSpin: false, isSpin: false,
Senttothevcaluetype: false, Senttothevcaluetype: false,
jupyterbool: false, jupyterbool: false,
openknow:false,
openshowpublictype:false
} }
} }
@ -99,7 +97,54 @@ class TPMBanner extends Component {
} }
} }
openknow=()=>{
let storage=window.localStorage;
this.setState({
openknow:false
})
storage.setItem("shixunopenprocess",true);
}
openshowpublic=()=>{
let storage=window.localStorage;
this.setState({
openshowpublictype:false
})
storage.setItem("openopenpublictype",true);
}
componentDidUpdate(prevProps, prevState) {
if (prevProps != this.props) {
let shixunopenprocess=window.localStorage.shixunopenprocess;
let openopenpublictype=window.localStorage.openopenpublictype;
if(this.props.shixunsDetails.shixun_status === 0 && this.props.identity < 5){
if(shixunopenprocess===undefined||shixunopenprocess===false){
this.setState({
openknow:true
})
}else{
this.setState({
openknow:false
})
}
}
if(this.props.shixunsDetails.shixun_status === 2 && this.props.shixunsDetails.public===0 && this.props.identity < 5){
if(openopenpublictype===undefined||openopenpublictype===false){
this.setState({
openshowpublictype:true
})
}else{
this.setState({
openshowpublictype:false
})
}
}
}
}
componentDidMount() { componentDidMount() {
let thiisie = this.IEVersion(); let thiisie = this.IEVersion();
if (thiisie != -1) { if (thiisie != -1) {
this.setState({ this.setState({
@ -298,7 +343,10 @@ class TPMBanner extends Component {
ModalCancel = () => { ModalCancel = () => {
this.setState({ this.setState({
Modalstype: false Modalstype: false,
Modalstopval: "",
modalsMidval:undefined,
ModalsBottomval:"",
}) })
} }
ModalSave = () => { ModalSave = () => {
@ -316,12 +364,48 @@ class TPMBanner extends Component {
this.setState({ this.setState({
Modalstype: true, Modalstype: true,
Modalstopval: "是否确认撤销发布?", Modalstopval: "是否确认撤销发布?",
modalsMidval:"撤销发布后,学员将无法进行练习,若您新增关",
ModalsBottomval:"卡,学员需要重新体验课程",
ModalCancel: this.ModalCancel, ModalCancel: this.ModalCancel,
ModalSave: this.ModalSave, ModalSave: this.ModalSave,
}) })
} }
openpublic=()=>{
let id = this.props.match.params.shixunId;
let url = `/shixuns/${id}/apply_public.json`;
axios.get(url).then((response) => {
if(response.data.status===0){
window.location.reload()
}
}).catch((error) => {
console.log(error)
});
}
ModalhidenpublicSave=()=>{
let id = this.props.match.params.shixunId;
let url = `/shixuns/${id}/cancel_apply_public.json`;
axios.get(url).then((response) => {
if(response.data.status===0){
window.location.reload()
}
}).catch((error) => {
console.log(error)
});
}
hidenpublic=()=>{
this.setState({
Modalstype: true,
Modalstopval: "是否确认撤销公开?",
modalsMidval:" ",
ModalsBottomval:" ",
ModalCancel: this.ModalCancel,
ModalSave: this.ModalhidenpublicSave,
})
}
/* /*
* 申请发布按钮 * 申请发布按钮
* */ * */
@ -335,12 +419,17 @@ class TPMBanner extends Component {
} else { } else {
evaluation_set_position = response.data.evaluation_set_position evaluation_set_position = response.data.evaluation_set_position
} }
if(response.data.status===0){
window.location.reload()
}else{
this.setState({ this.setState({
Issuevisible: true, Issuevisible: true,
tag_position: response.data.tag_position, tag_position: response.data.tag_position,
evaluation_set_position: evaluation_set_position, evaluation_set_position: evaluation_set_position,
publishboxstatus: response.data.status, publishboxstatus: response.data.status,
}) })
}
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
}); });
@ -449,7 +538,7 @@ class TPMBanner extends Component {
}) })
// this.shixunexec(response.data.message+".json") // this.shixunexec(response.data.message+".json")
} else if (response.data.status === -1) { } else if (response.data.status === -1) {
console.log(response)
} else if (response.data.status === -3) { } else if (response.data.status === -3) {
this.setState({ this.setState({
shixunsmessage: response.data.message, shixunsmessage: response.data.message,
@ -521,7 +610,7 @@ class TPMBanner extends Component {
}) })
// this.shixunexec(response.data.message+".json") // this.shixunexec(response.data.message+".json")
} else if (response.data.status === -1) { } else if (response.data.status === -1) {
console.log(response)
} else if (response.data.status === -3) { } else if (response.data.status === -3) {
this.setState({ this.setState({
shixunsmessage: response.data.message, shixunsmessage: response.data.message,
@ -700,6 +789,7 @@ class TPMBanner extends Component {
modalCancel={this.state.ModalCancel} modalCancel={this.state.ModalCancel}
modalSave={this.state.ModalSave} modalSave={this.state.ModalSave}
modalsBottomval={this.state.ModalsBottomval} modalsBottomval={this.state.ModalsBottomval}
modalsMidval={this.state.modalsMidval}
loadtype={this.state.Loadtype} loadtype={this.state.Loadtype}
/> : ""} /> : ""}
@ -908,8 +998,21 @@ class TPMBanner extends Component {
{/*}*/} {/*}*/}
{shixunsDetails.shixun_status === 0 && this.props.identity < 5 ? {shixunsDetails.shixun_status === 0 && this.props.identity < 5 ?
<Popover
content={
<pre className={"bannerpd201"}>
<div>您编辑完成后可以马上使用到自</div>
<div className={"wechatcenter mt10"}>己的课堂和实训课程哦</div>
<div className={"wechatcenter mt15"}><Button type="primary" onClick={this.openknow} >我知道了</Button></div>
</pre>
}
trigger="click"
placement="bottom"
visible={this.state.openknow}
>
<a onClick={this.applyrelease} className="fr user_default_btn user_blue_btn mr20 font-18 height39" <a onClick={this.applyrelease} className="fr user_default_btn user_blue_btn mr20 font-18 height39"
id="challenge_begin">申请发布</a> : "" id="challenge_begin">发布</a>
</Popover>: ""
} }
<Modal <Modal
@ -972,6 +1075,31 @@ class TPMBanner extends Component {
</Modal> </Modal>
{shixunsDetails.shixun_status === 2 && shixunsDetails.public===0 && this.props.identity < 5 ?
<Popover
content={
<pre className={"bannerpd201"}>
<div>申请公开成功后您的实训将会展示实训列表</div>
<div className={"wechatcenter mt10"}>平台审核通过您将获得<span className={"FF6802"}> 1000 </span></div>
<div className={"wechatcenter mt15"}><Button type="primary" onClick={this.openshowpublic} >我知道了</Button></div>
</pre>
}
trigger="click"
placement="bottom"
visible={this.state.openshowpublictype}
>
<Button type="primary" ghost id="challenge_begin" onClick={this.openpublic} className="fr user_default_btn user_blue_btn mr20 font-18 height39">
申请公开
</Button>
</Popover>: ""
}
{shixunsDetails.shixun_status === 2 && shixunsDetails.public===1 && this.props.identity < 5 ?
<Button type="primary" ghost id="challenge_begin" onClick={this.hidenpublic} className="fr user_default_btn user_blue_btn mr20 font-18 height39">
撤销公开
</Button>: ""
}
{shixunsDetails.shixun_status === 2 && shixunsDetails.public===0 && this.props.identity < 5 ? {shixunsDetails.shixun_status === 2 && shixunsDetails.public===0 && this.props.identity < 5 ?
<a onClick={this.cancel_publish} className="fr user_default_btn user_blue_btn mr20 font-18 height39" <a onClick={this.cancel_publish} className="fr user_default_btn user_blue_btn mr20 font-18 height39"
id="challenge_begin">撤销发布</a> : "" id="challenge_begin">撤销发布</a> : ""

@ -75,6 +75,7 @@ class TPMDataset extends Component {
mylistansum:30, mylistansum:30,
collaboratorList:[], collaboratorList:[],
fileList:[], fileList:[],
fileListimgs:[],
file:null, file:null,
datalist:[], datalist:[],
data_sets_count:0, data_sets_count:0,
@ -225,6 +226,31 @@ class TPMDataset extends Component {
} }
getdatasthree = (page,limit) => {
let id=this.props.match.params.shixunId;
let collaborators=`/shixuns/${id}/jupyter_data_sets.json`;
axios.get(collaborators,{params:{
page:page,
limit:limit,
}}).then((response)=> {
if(response.status===200){
if (response.data.status === 403||response.data.status === 401||response.data.status === 500) {
}else{
}
}
}).catch((error)=>{
});
}
paginationonChanges = (pageNumber) => { paginationonChanges = (pageNumber) => {
// //console.log('Page: '); // //console.log('Page: ');
this.setState({ this.setState({
@ -264,15 +290,28 @@ class TPMDataset extends Component {
if(info.file.status == "done" || info.file.status == "uploading" || info.file.status === 'removed'){ if(info.file.status == "done" || info.file.status == "uploading" || info.file.status === 'removed'){
let fileList = info.fileList; let fileList = info.fileList;
// for(var list of fileList ){
// console.log(list)
// }
this.setState({ this.setState({
fileList: appendFileSizeToUploadFileAll(fileList), fileList: appendFileSizeToUploadFileAll(fileList),
}); });
if(info.file.status === 'done'){ if(info.file.status === 'done'){
console.log("handleChange");
console.log(info);
//done 成功就会调用这个方法 //done 成功就会调用这个方法
this.getdatas(); this.getdatas();
try {
// let datas=this.state.fileListimgs;
// for(var i=0;i<info.fileList.length;i++){
// datas.push(info.fileList[i].originFileObj);
// }
// this.setState({
// fileListimgs:datas,
// })
// console.log("datasdatasdatasdatasdatas");
// console.log(datas);
}catch (e) {
}
// this.props.showNotification(`上传文件成功`); // this.props.showNotification(`上传文件成功`);
} }
@ -400,9 +439,11 @@ class TPMDataset extends Component {
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false, // showUploadList: false,
action: `${getUploadActionUrl()}`, action: `${getUploadActionUrl()}`,
showUploadList:false,
onChange: this.handleChange, onChange: this.handleChange,
onRemove: this.onAttachmentRemove, onRemove: this.onAttachmentRemove,
beforeUpload: (file) => { beforeUpload: (file) => {
//上传前的操作
console.log('beforeUpload', file.name); console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150; const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) { if (!isLt150M) {
@ -411,7 +452,6 @@ class TPMDataset extends Component {
return isLt150M; return isLt150M;
}, },
}; };
return ( return (
<React.Fragment> <React.Fragment>
<div className="tpmComment educontent clearfix mt30 mb80"> <div className="tpmComment educontent clearfix mt30 mb80">

@ -69,16 +69,16 @@ export default class Shixuninformation extends Component {
} }
componentDidMount() { componentDidMount() {
if (this.props.data&&this.props.data.shixun) { if (this.props.data) {
if (this.props.data.shixun) {
this.setState({ this.setState({
can_copy:this.props.data.shixun && this.props.data.shixun.can_copy === undefined ? false : this.props.data.shixun&&this.props.data.shixun.can_copy, can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false : this.props.data && this.props.data.shixun.can_copy,
use_scope: this.props.data.shixun && this.props.data.shixun.use_scope, use_scope: this.props.data && this.props.data.shixun.use_scope,
opening_time: this.props.data.shixun && this.props.data.shixun.opening_time, opening_time: this.props.data && this.props.data.shixun.opening_time,
opentime: !this.props.data.shixun && this.props.data.shixun.opening_time ? false : true, opentime: !this.props.data && this.props.data.shixun.opening_time ? false : true,
oldscope_partment:this.props.data.shixun && this.props.data.shixun.scope_partment, oldscope_partment: this.props.data && this.props.data.shixun.scope_partment,
}) })
}
} }
let departmentsUrl = `/shixuns/departments.json`; let departmentsUrl = `/shixuns/departments.json`;
axios.get(departmentsUrl).then((response) => { axios.get(departmentsUrl).then((response) => {
@ -98,15 +98,15 @@ export default class Shixuninformation extends Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (prevProps.data != this.props.data) { if (prevProps.data != this.props.data) {
if (this.props.data) { if (this.props.data) {
if (this.props.data.shixun) {
this.setState({ this.setState({
can_copy: this.props.data.shixun && this.props.data.shixun.can_copy === undefined ? false : this.props.data.shixun&&this.props.data.shixun.can_copy, can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false : this.props.data && this.props.data.shixun.can_copy,
use_scope: this.props.data.shixun&& this.props.data.shixun.use_scope, use_scope: this.props.data && this.props.data.shixun.use_scope,
opening_time: this.props.data.shixun && this.props.data.shixun.opening_time, opening_time: this.props.data && this.props.data.shixun.opening_time,
opentime: !this.props.data.shixun && this.props.data.shixun.opening_time ? false : true, opentime: !this.props.data && this.props.data.shixun.opening_time ? false : true,
oldscope_partment: this.props.data.shixun && this.props.data.shixun.scope_partment, oldscope_partment: this.props.data && this.props.data.shixun.scope_partment,
}) })
}
} }
} }
} }
@ -262,7 +262,7 @@ export default class Shixuninformation extends Component {
</div> </div>
<div className="edu-back-white mb10 ml30 mt20"> <div className="edu-back-white mb10 ml30 mt20">
{this.props.data.shixun && this.props.data.shixun.use_scope === 0 && this.props.data.shixun && this.props.data.shixun.status === 2 ? "" : {this.props.data && this.props.data.shixun.use_scope === 0 && this.props.data && this.props.data.shixun.status === 2 ? "" :
<div> <div>
<span className="color-grey-6 mt5 fl font-16" style={{minWidth: '45px'}}>公开程度:</span> <span className="color-grey-6 mt5 fl font-16" style={{minWidth: '45px'}}>公开程度:</span>
<span className="fl mt8 ml20"> <span className="fl mt8 ml20">

@ -34,8 +34,8 @@ export default class Shixuninformation extends Component {
componentDidMount() { componentDidMount() {
if (this.props.data&&this.props.data.shixun) { if (this.props.data ) {
if (this.props.data.shixun) {
this.setState({ this.setState({
vnc: this.props.data && this.props.data.shixun.vnc, vnc: this.props.data && this.props.data.shixun.vnc,
code_hidden: this.props.data && this.props.data.shixun.code_hidden, code_hidden: this.props.data && this.props.data.shixun.code_hidden,
@ -56,13 +56,14 @@ export default class Shixuninformation extends Component {
// } // }
} }
}
} }
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (prevProps.data != this.props.data) { if (prevProps.data != this.props.data) {
if (this.props.data) { if (this.props.data) {
if (this.props.data.shixun) {
this.setState({ this.setState({
vnc: this.props.data && this.props.data.shixun.vnc, vnc: this.props.data && this.props.data.shixun.vnc,
code_hidden: this.props.data && this.props.data.shixun.code_hidden, code_hidden: this.props.data && this.props.data.shixun.code_hidden,
@ -85,6 +86,7 @@ export default class Shixuninformation extends Component {
} }
} }
} }
}
onSubmits = () => { onSubmits = () => {
@ -222,7 +224,7 @@ export default class Shixuninformation extends Component {
} }
render() { render() {
console.log(this.props) // console.log(this.props)
return ( return (
<div> <div>
<div className="educontent mb200 edu-back-white padding10-20 pdb30 mb50"> <div className="educontent mb200 edu-back-white padding10-20 pdb30 mb50">

@ -55,39 +55,41 @@ class Shixuninformation extends Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (prevProps.data != this.props.data) { if (prevProps.data != this.props.data) {
if (this.props.data&&this.props.data.shixun) {
if (this.props.data ) {
if (this.props.data.shixun){
this.setState({ this.setState({
shixunName: this.props.data.shixun&&this.props.data.shixun.name, shixunName: this.props.data && this.props.data.shixun.name,
trainee:this.props.data.shixun&&this.props.data.shixun.trainee, trainee: this.props.data && this.props.data.shixun.trainee,
choice_main_type: this.props.data.shixun&&this.props.data.shixun.choice_main_type, choice_main_type: this.props.data && this.props.data.shixun.choice_main_type,
choice_small_type: this.props.data.shixun&&this.props.data.shixun.choice_small_type, choice_small_type: this.props.data && this.props.data.shixun.choice_small_type,
choice_standard_scripts:this.props.data.shixun&&this.props.data.shixun.choice_standard_scripts, choice_standard_scripts: this.props.data && this.props.data.shixun.choice_standard_scripts,
shixunmemoMDvalue: this.props.data.shixun&&this.props.data.shixun.evaluate_script, shixunmemoMDvalue: this.props.data && this.props.data.shixun.evaluate_script,
simichecked: this.props.data.shixun&&this.props.data.shixun.is_secret_repository, simichecked: this.props.data && this.props.data.shixun.is_secret_repository,
shixun_service_configs: this.props.data.shixun&&this.props.data.shixun.shixun_service_configs, shixun_service_configs: this.props.data && this.props.data.shixun.shixun_service_configs,
standard_scripts:this.props.data.shixun&&this.props.data.shixun.standard_scripts, standard_scripts: this.props.data && this.props.data.shixun.standard_scripts,
shixun_service_configlist:this.props.data.shixun&&this.props.data.shixun.shixun_service_configs, shixun_service_configlist: this.props.data && this.props.data.shixun.shixun_service_configs,
}) })
if(this.props.data.shixun&&this.props.data.shixun.choice_standard_scripts===null){ if (this.props.data && this.props.data.shixun.choice_standard_scripts === null) {
this.setState({ this.setState({
choice_standard_scripts:{id: this.props.data.shixun&&this.props.data.shixun.standard_scripts[0].id, value: ""}, choice_standard_scripts: {id: this.props.data && this.props.data.shixun.standard_scripts[0].id, value: ""},
choice_standard_scriptssum:this.props.data.shixun&&this.props.data.shixun.standard_scripts[0].id choice_standard_scriptssum: this.props.data && this.props.data.shixun.standard_scripts[0].id
}) })
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
selectscripts:this.props.data.shixun&&this.props.data.shixun.standard_scripts[0].id selectscripts: this.props.data && this.props.data.shixun.standard_scripts[0].id
}) })
this.get_mirror_script(this.props.data.shixun&&this.props.data.shixun.standard_scripts[0].id) this.get_mirror_script(this.props.data && this.props.data.shixun.standard_scripts[0].id)
}else{ } else {
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
selectscripts:this.props.data.shixun&&this.props.data.shixun.choice_standard_scripts selectscripts: this.props.data && this.props.data.shixun.choice_standard_scripts
}) })
} }
let newlist = "" let newlist = ""
this.props.data.shixun&&this.props.data.shixun.choice_small_type.map((item, key) => { this.props.data && this.props.data.shixun.choice_small_type.map((item, key) => {
this.props.data.shixun.small_type.map((i,k)=>{ this.props.data && this.props.data.shixun.small_type.map((i, k) => {
if (item===i.id) { if (item === i.id) {
newlist = newlist + `${i.description}` newlist = newlist + `${i.description}`
} }
}) })
@ -96,21 +98,22 @@ class Shixuninformation extends Component {
subvalues: newlist subvalues: newlist
}) })
this.props.data.shixun&&this.props.data.shixun.main_type.map((item,key)=>{ this.props.data && this.props.data.shixun.main_type.map((item, key) => {
if(item.id===this.props.data.shixun&&this.props.data.shixun.choice_main_type){ if (item.id === this.props.data && this.props.data.shixun.choice_main_type) {
this.setState({ this.setState({
mainvalues:item.description, mainvalues: item.description,
}) })
} }
}) })
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
name:this.props.data.shixun&&this.props.data.shixun.name, name: this.props.data && this.props.data.shixun.name,
trainee: this.props.data.shixun&&this.props.data.shixun.trainee, trainee: this.props.data && this.props.data.shixun.trainee,
selectleft: this.props.data.shixun&&this.props.data.shixun.choice_main_type, selectleft: this.props.data && this.props.data.shixun.choice_main_type,
selectright:this.props.data.shixun&&this.props.data.shixun.choice_small_type, selectright: this.props.data && this.props.data.shixun.choice_small_type,
}) })
this.contentMdRef.current.setValue(this.props.data.shixun&&this.props.data.shixun.description); this.contentMdRef.current.setValue(this.props.data && this.props.data.shixun.description);
}
} }
} }
} }
@ -713,7 +716,7 @@ class Shixuninformation extends Component {
} }
render() { render() {
let operateauthority = this.props.identity === 1 ? true : this.props.identity < 5 && this.props.data.shixun.status == 0 ? true : false;
// console.log(operateauthority) // console.log(operateauthority)
const {getFieldDecorator} = this.props.form; const {getFieldDecorator} = this.props.form;
const { fileList, choice_standard_scripts, postapplyvisible, shixunmemoMDvalue} = this.state; const { fileList, choice_standard_scripts, postapplyvisible, shixunmemoMDvalue} = this.state;
@ -754,7 +757,7 @@ class Shixuninformation extends Component {
return isLt150M; return isLt150M;
}, },
} }
let operateauthority = this.props.identity === 1 ? true : this.props.identity < 5 && this.props.data&&this.props.data.shixun.status == 0 ? true : false;
return ( return (
<div> <div>
<div className="educontent mb50 edu-back-white padding10-20"> <div className="educontent mb50 edu-back-white padding10-20">
@ -841,7 +844,9 @@ class Shixuninformation extends Component {
> >
{ {
this.props.data === undefined ? "" : this.props.data.shixun&&this.props.data.shixun.main_type.map((item, key) => { this.props.data === undefined ? "" : this.props.shixunsDetails&&this.props.shixunsDetails.is_jupyter === true?this.props.data.shixun&&this.props.data.shixun.main_type.map((item, key) => {
let itemtype=item.type_name.toLowerCase().indexOf('jupyter'.toLowerCase())
if(itemtype>-1) {
return ( return (
<Option value={item.id} key={key} name={item.description}> <Option value={item.id} key={key} name={item.description}>
<Tooltip placement="right" title={item.description === "" ? "无描述" : item.description}> <Tooltip placement="right" title={item.description === "" ? "无描述" : item.description}>
@ -849,7 +854,23 @@ class Shixuninformation extends Component {
</Tooltip> </Tooltip>
</Option> </Option>
) )
}) }
}):""
}
{
this.props.data === undefined ? "" : this.props.shixunsDetails&&this.props.shixunsDetails.is_jupyter === false?this.props.data.shixun&&this.props.data.shixun.main_type.map((item, key) => {
let itemtype=item.type_name.toLowerCase().indexOf('jupyter'.toLowerCase())
if(itemtype===-1) {
return (
<Option value={item.id} key={key} name={item.description}>
<Tooltip placement="right" title={item.description === "" ? "无描述" : item.description}>
{item.type_name}
</Tooltip>
</Option>
)
}
}):""
} }
</Select> </Select>

@ -6,6 +6,8 @@ import {
Modal Modal
} from 'antd'; } from 'antd';
import './css/TPMsettings.css';
import TopShixuninformation from './Shixuninformation'; import TopShixuninformation from './Shixuninformation';
import Configuration from './Configuration'; import Configuration from './Configuration';
@ -14,8 +16,6 @@ import LearningSettings from './LearningSettings';
import axios from 'axios'; import axios from 'axios';
import './css/TPMsettings.css';
const {TabPane} = Tabs; const {TabPane} = Tabs;
// 处理整点 半点 // 处理整点 半点
@ -41,17 +41,17 @@ export default class TPMsettings extends Component {
axios.get(Url).then((response) => { axios.get(Url).then((response) => {
// alert(response.data.shixun.choice_standard_scripts) // alert(response.data.shixun.choice_standard_scripts)
if (response.status === 200) { if (response.status === 200) {
if(response.data){
this.setState({ if (response.data.shixun&&response.data.shixun.scope_partment.length > 0) {
data: response.data
})
if (response.data.shixun.scope_partment.length > 0) {
this.setState({ this.setState({
scopetype: true scopetype: true
}) })
} }
}
this.setState({
data: response.data
})
} }
}); });
@ -96,7 +96,8 @@ export default class TPMsettings extends Component {
operateshixunstype: false, operateshixunstype: false,
}); });
window.location.href = "/shixuns"; // window.location.href = "/shixuns";
this.props.history.replace( "/shixuns/");
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
@ -113,7 +114,8 @@ export default class TPMsettings extends Component {
operateshixunstype: false, operateshixunstype: false,
}); });
window.location.href = "/shixuns/" + id + "/challenges"; // window.location.href = "/shixuns/" + id + "/challenges";
this.props.history.replace( "/shixuns/" + id + "/challenges");
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
@ -128,7 +130,7 @@ export default class TPMsettings extends Component {
render() { render() {
let showtabs = this.props.shixunsDetails === undefined ? "" : this.props.shixunsDetails.is_jupyter === true ? "" : "学习页面设置" let showtabs = this.props.shixunsDetails === undefined ? "" : this.props.shixunsDetails&&this.props.shixunsDetails.is_jupyter === true ? "" : "学习页面设置"
// let a="isvnc"; // let a="isvnc";
// let b="isVNC"; // let b="isVNC";
@ -197,7 +199,7 @@ export default class TPMsettings extends Component {
getdatas={(key) => this.getdatas(key)} getdatas={(key) => this.getdatas(key)}
/> />
</TabPane> </TabPane>
{this.props.shixunsDetails === undefined ? "" : this.props.shixunsDetails.is_jupyter === false ? {this.props.shixunsDetails === undefined ? "" : this.props.shixunsDetails&&this.props.shixunsDetails.is_jupyter === false ?
<TabPane tab={showtabs} key="3"> <TabPane tab={showtabs} key="3">
<LearningSettings <LearningSettings
{...this.state} {...this.state}

@ -32,6 +32,7 @@ class Newshixuns extends Component {
run_method: undefined, run_method: undefined,
postapplyvisible: undefined, postapplyvisible: undefined,
fileList: [], fileList: [],
Radiovalue:"1"
} }
} }
@ -85,6 +86,9 @@ class Newshixuns extends Component {
this.setState({ this.setState({
Radiovalue: e.target.value, Radiovalue: e.target.value,
}); });
this.props.form.setFieldsValue({
is_jupyter: e.target.value,
});
}; };
handleSubmit = (e) => { handleSubmit = (e) => {
@ -535,7 +539,9 @@ class Newshixuns extends Component {
defaultOpen={false} defaultOpen={false}
> >
{ {
newshixunlist === undefined ? "" : newshixunlist.main_type.map((item, key) => { newshixunlist === undefined ? "" : this.state.Radiovalue==="2"?newshixunlist.main_type.map((item, key) => {
let itemtype=item.type_name.toLowerCase().indexOf('jupyter'.toLowerCase())
if(itemtype>-1){
return ( return (
<Option value={item.id} key={key} name={item.description}> <Option value={item.id} key={key} name={item.description}>
<Tooltip placement="right" <Tooltip placement="right"
@ -544,7 +550,25 @@ class Newshixuns extends Component {
</Tooltip> </Tooltip>
</Option> </Option>
) )
}) }
}):""
}
{
newshixunlist === undefined ? "" : this.state.Radiovalue==="1"?newshixunlist.main_type.map((item, key) => {
let itemtype=item.type_name.toLowerCase().indexOf('jupyter'.toLowerCase())
if(itemtype===-1){
return (
<Option value={item.id} key={key} name={item.description}>
<Tooltip placement="right"
title={item.description === "" ? "无描述" : item.description}>
{item.type_name}
</Tooltip>
</Option>
)
}
}):""
} }
</Select> </Select>

@ -79,7 +79,7 @@ class Challengesjupyter extends Component {
setTimeout(() => { setTimeout(() => {
this.setState({ this.setState({
// jupyter_url:response.data.url, jupyter_url:response.data.url,
jupyter_port:response.data.port, jupyter_port:response.data.port,
booljupyterurls:true, booljupyterurls:true,
}) })
@ -258,7 +258,7 @@ class Challengesjupyter extends Component {
<div className="sortinxdirection mt60"> <div className="sortinxdirection mt60">
<div className="renwuxiangssi sortinxdirection"> <div className="renwuxiangssi sortinxdirection">
<div><p className="renwuxiangqdiv">任务详情</p></div> <div><p className="renwuxiangqdiv">任务详情</p></div>
<div><p className="renwuxiangqdivtest ml24 shixunbingbaocun">请将实训题目写在下方并保存</p></div> <div><p className="renwuxiangqdivtest ml1 shixunbingbaocun">请将实训题目写在下方并保存</p></div>
</div> </div>
<div className="renwuxiangssit xaxisreverseorder"> <div className="renwuxiangssit xaxisreverseorder">
<div className="challenbaocun" onClick={() => this.modifyjupyter(this.state)}><p <div className="challenbaocun" onClick={() => this.modifyjupyter(this.state)}><p

@ -112,3 +112,11 @@ a:active{text-decoration:none;}
.width360{ .width360{
width:360px; width:360px;
} }
.bannerpd201{
padding: 20px 20px 10px 20px;
}
.FF6802{
color:#FF6802;
}
Loading…
Cancel
Save