diff --git a/Gemfile b/Gemfile
index 55030971d..55478816f 100644
--- a/Gemfile
+++ b/Gemfile
@@ -103,3 +103,6 @@ gem 'diffy'
# oauth2
gem 'omniauth', '~> 1.9.0'
gem 'omniauth-oauth2', '~> 1.6.0'
+
+# global var
+gem 'request_store'
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 6dd4cd474..bda4bcc6c 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -303,7 +303,7 @@ class ApplicationController < ActionController::Base
current_domain_session = session[:"#{default_yun_session}"]
if current_domain_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
autologin_user
elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?
diff --git a/app/controllers/jupyters_controller.rb b/app/controllers/jupyters_controller.rb
index ab3962cbc..96ebf3452 100644
--- a/app/controllers/jupyters_controller.rb
+++ b/app/controllers/jupyters_controller.rb
@@ -30,5 +30,17 @@ class JupytersController < ApplicationController
render json: {status: 0, url: url, port: port}
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
\ No newline at end of file
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index 9733bbd9f..454929dcc 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -18,7 +18,7 @@ class ShixunsController < ApplicationController
before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy,
: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,
:cancel_apply_public, :cancel_publish, :add_collaborators, :add_file]
before_action :portion_allowed, only: [:copy]
@@ -746,27 +746,27 @@ class ShixunsController < ApplicationController
end
end
if @status == 0
- ActiveRecord::Base.transaction do
- @shixun.update_attributes!(:status => 2)
- apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first
- if apply && apply.status == 0
- @status = 0
- else
- 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
+ @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
+ if apply && apply.status == 0
+ @status = 0
+ else
+ ApplyAction.create(:container_type => "ApplyShixun", :container_id => @shixun.id, :user_id => current_user.id, :status => 0)
+ end
+ end
+ normal_status(0, "申请成功")
+ end
+
# 设置私密版本库的在tpm中的目录
def set_secret_dir
raise("设置路径不能为空") if params[:secret_dir_path].blank?
diff --git a/app/models/laboratory.rb b/app/models/laboratory.rb
index 2ba86ed90..dab2f6f39 100644
--- a/app/models/laboratory.rb
+++ b/app/models/laboratory.rb
@@ -38,12 +38,20 @@ class Laboratory < ApplicationRecord
find_by_identifier(subdomain)
end
- def self.current=(laboratory)
- Thread.current[:current_laboratory] = laboratory
+ # def self.current=(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
def self.current
- Thread.current[:current_laboratory] ||= Laboratory.find(1)
+ RequestStore.store[:current_laboratory] ||= User.anonymous
end
def shixuns
diff --git a/app/models/user.rb b/app/models/user.rb
index eb3ece0a4..a9b2f0b3a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -540,12 +540,20 @@ class User < ApplicationRecord
mail.present?
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)
- Thread.current[:current_user] = user
+ RequestStore.store[:current_user] = user
end
def self.current
- Thread.current[:current_user] ||= User.anonymous
+ RequestStore.store[:current_user] ||= User.anonymous
end
def self.anonymous
diff --git a/app/services/jupyter_service.rb b/app/services/jupyter_service.rb
index 879ac1d93..417aa4aad 100644
--- a/app/services/jupyter_service.rb
+++ b/app/services/jupyter_service.rb
@@ -7,7 +7,7 @@ module JupyterService
shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/jupyter/get"
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}"
res = uri_post uri, params
@@ -45,7 +45,7 @@ module JupyterService
uri = "#{shixun_tomcat}/bridge/jupyter/get"
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
logger.info "test_juypter: #{res}"
@@ -130,4 +130,59 @@ module JupyterService
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
diff --git a/config/routes.rb b/config/routes.rb
index 4203df43a..643972b95 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -31,6 +31,8 @@ Rails.application.routes.draw do
get :save_with_tpm
get :get_info_with_tpi
get :get_info_with_tpm
+ get :reset_with_tpi
+ get :reset_with_tpm
end
end
@@ -276,6 +278,7 @@ Rails.application.routes.draw do
get :cancel_publish
get :cancel_apply_public
get :publish
+ get :apply_public
get :shixun_exec
post :review_shixun
get :review_newest_record
diff --git a/public/react/config/webpack.config.prod.js b/public/react/config/webpack.config.prod.js
index 1fe7a6c93..596843f5f 100644
--- a/public/react/config/webpack.config.prod.js
+++ b/public/react/config/webpack.config.prod.js
@@ -326,8 +326,8 @@ module.exports = {
comments: false
},
compress: {
- drop_debugger: true,
- drop_console: true
+ drop_debugger: false,
+ drop_console: false
}
}
}),
diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js
index 7a6f0fc04..a38489385 100644
--- a/public/react/src/AppConfig.js
+++ b/public/react/src/AppConfig.js
@@ -35,7 +35,7 @@ if (isDev) {
// 老师
// debugType="teacher";
// 学生
-//debugType="student";
+// debugType="student";
window._debugType = debugType;
export function initAxiosInterceptors(props) {
diff --git a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
index 9670e5e0b..a9100f2f3 100644
--- a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
+++ b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js
@@ -494,7 +494,7 @@ class NewShixunModel extends Component{
筛选:
this.belongto("all")}>全部实训
-
this.belongto("mine")}>普通实训
+
this.belongto("mine")}>我的实训
:""
}
{/*{this.props.type==='shixuns'? */}
diff --git a/public/react/src/modules/modals/Modals.js b/public/react/src/modules/modals/Modals.js
index 859e54784..e241f379a 100644
--- a/public/react/src/modules/modals/Modals.js
+++ b/public/react/src/modules/modals/Modals.js
@@ -29,6 +29,9 @@ render() {
body{
overflow: hidden !important;
}
+ .ant-modal-body {
+ padding: 20px 40px;
+ }
`
}
:""}
diff --git a/public/react/src/modules/tpm/TPMBanner.js b/public/react/src/modules/tpm/TPMBanner.js
index af14b25ab..bf33f94a8 100644
--- a/public/react/src/modules/tpm/TPMBanner.js
+++ b/public/react/src/modules/tpm/TPMBanner.js
@@ -1,14 +1,10 @@
import React, {Component} from 'react';
-import {Redirect} from 'react-router';
-
import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom";
-import PropTypes from 'prop-types';
-
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";
@@ -57,6 +53,8 @@ class TPMBanner extends Component {
isSpin: false,
Senttothevcaluetype: 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() {
+
let thiisie = this.IEVersion();
if (thiisie != -1) {
this.setState({
@@ -298,7 +343,10 @@ class TPMBanner extends Component {
ModalCancel = () => {
this.setState({
- Modalstype: false
+ Modalstype: false,
+ Modalstopval: "",
+ modalsMidval:undefined,
+ ModalsBottomval:"",
})
}
ModalSave = () => {
@@ -316,12 +364,48 @@ class TPMBanner extends Component {
this.setState({
Modalstype: true,
Modalstopval: "是否确认撤销发布?",
+ modalsMidval:"撤销发布后,学员将无法进行练习,若您新增关",
+ ModalsBottomval:"卡,学员需要重新体验课程",
ModalCancel: this.ModalCancel,
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 {
evaluation_set_position = response.data.evaluation_set_position
}
- this.setState({
- Issuevisible: true,
- tag_position: response.data.tag_position,
- evaluation_set_position: evaluation_set_position,
- publishboxstatus: response.data.status,
- })
+ if(response.data.status===0){
+ window.location.reload()
+ }else{
+ this.setState({
+ Issuevisible: true,
+ tag_position: response.data.tag_position,
+ evaluation_set_position: evaluation_set_position,
+ publishboxstatus: response.data.status,
+ })
+ }
+
}).catch((error) => {
console.log(error)
});
@@ -449,7 +538,7 @@ class TPMBanner extends Component {
})
// this.shixunexec(response.data.message+".json")
} else if (response.data.status === -1) {
- console.log(response)
+
} else if (response.data.status === -3) {
this.setState({
shixunsmessage: response.data.message,
@@ -521,7 +610,7 @@ class TPMBanner extends Component {
})
// this.shixunexec(response.data.message+".json")
} else if (response.data.status === -1) {
- console.log(response)
+
} else if (response.data.status === -3) {
this.setState({
shixunsmessage: response.data.message,
@@ -700,6 +789,7 @@ class TPMBanner extends Component {
modalCancel={this.state.ModalCancel}
modalSave={this.state.ModalSave}
modalsBottomval={this.state.ModalsBottomval}
+ modalsMidval={this.state.modalsMidval}
loadtype={this.state.Loadtype}
/> : ""}
@@ -908,8 +998,21 @@ class TPMBanner extends Component {
{/*}*/}
{shixunsDetails.shixun_status === 0 && this.props.identity < 5 ?
- 申请发布 : ""
+
+ 您编辑完成后,可以马上使用到自
+ 己的课堂和实训课程哦
+
+
+ }
+ trigger="click"
+ placement="bottom"
+ visible={this.state.openknow}
+ >
+ 发布
+ : ""
}
+ {shixunsDetails.shixun_status === 2 && shixunsDetails.public===0 && this.props.identity < 5 ?
+
+ 申请公开成功后,您的实训将会展示实训列表
+ 平台审核通过,您将获得 1000 金币~
+
+
+ }
+ trigger="click"
+ placement="bottom"
+ visible={this.state.openshowpublictype}
+ >
+
+ : ""
+ }
+
+ {shixunsDetails.shixun_status === 2 && shixunsDetails.public===1 && this.props.identity < 5 ?
+ : ""
+ }
+
{shixunsDetails.shixun_status === 2 && shixunsDetails.public===0 && this.props.identity < 5 ?
撤销发布 : ""
diff --git a/public/react/src/modules/tpm/TPMDataset.js b/public/react/src/modules/tpm/TPMDataset.js
index 918868392..ed58211f8 100644
--- a/public/react/src/modules/tpm/TPMDataset.js
+++ b/public/react/src/modules/tpm/TPMDataset.js
@@ -75,6 +75,7 @@ class TPMDataset extends Component {
mylistansum:30,
collaboratorList:[],
fileList:[],
+ fileListimgs:[],
file:null,
datalist:[],
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) => {
// //console.log('Page: ');
this.setState({
@@ -264,15 +290,28 @@ class TPMDataset extends Component {
if(info.file.status == "done" || info.file.status == "uploading" || info.file.status === 'removed'){
let fileList = info.fileList;
- // for(var list of fileList ){
- // console.log(list)
- // }
+
this.setState({
fileList: appendFileSizeToUploadFileAll(fileList),
});
if(info.file.status === 'done'){
+ console.log("handleChange");
+ console.log(info);
//done 成功就会调用这个方法
this.getdatas();
+ try {
+ // let datas=this.state.fileListimgs;
+ // for(var i=0;i {
+ //上传前的操作
console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) {
@@ -411,7 +452,6 @@ class TPMDataset extends Component {
return isLt150M;
},
};
-
return (
diff --git a/public/react/src/modules/tpm/TPMsettings/Configuration.js b/public/react/src/modules/tpm/TPMsettings/Configuration.js
index 803a6bf89..9bf457993 100644
--- a/public/react/src/modules/tpm/TPMsettings/Configuration.js
+++ b/public/react/src/modules/tpm/TPMsettings/Configuration.js
@@ -69,16 +69,16 @@ export default class Shixuninformation extends Component {
}
componentDidMount() {
- if (this.props.data&&this.props.data.shixun) {
-
- 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,
- use_scope: this.props.data.shixun && this.props.data.shixun.use_scope,
- opening_time: this.props.data.shixun && this.props.data.shixun.opening_time,
- opentime: !this.props.data.shixun && this.props.data.shixun.opening_time ? false : true,
- oldscope_partment:this.props.data.shixun && this.props.data.shixun.scope_partment,
- })
-
+ if (this.props.data) {
+ if (this.props.data.shixun) {
+ this.setState({
+ 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 && 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) => {
@@ -98,15 +98,15 @@ export default class Shixuninformation extends Component {
componentDidUpdate(prevProps, prevState) {
if (prevProps.data != this.props.data) {
if (this.props.data) {
-
- 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,
- use_scope: this.props.data.shixun&& this.props.data.shixun.use_scope,
- opening_time: this.props.data.shixun && this.props.data.shixun.opening_time,
- opentime: !this.props.data.shixun && this.props.data.shixun.opening_time ? false : true,
- oldscope_partment: this.props.data.shixun && this.props.data.shixun.scope_partment,
- })
-
+ if (this.props.data.shixun) {
+ this.setState({
+ 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 && 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,
+ })
+ }
}
}
}
@@ -262,7 +262,7 @@ export default class Shixuninformation extends Component {
- {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 ? "" :
公开程度:
diff --git a/public/react/src/modules/tpm/TPMsettings/LearningSettings.js b/public/react/src/modules/tpm/TPMsettings/LearningSettings.js
index a548f9c71..dfcdda5ba 100644
--- a/public/react/src/modules/tpm/TPMsettings/LearningSettings.js
+++ b/public/react/src/modules/tpm/TPMsettings/LearningSettings.js
@@ -34,35 +34,8 @@ export default class Shixuninformation extends Component {
componentDidMount() {
- if (this.props.data&&this.props.data.shixun) {
-
- this.setState({
- vnc: this.props.data && this.props.data.shixun.vnc,
- code_hidden: this.props.data && this.props.data.shixun.code_hidden,
- forbid_copy: this.props.data && this.props.data.shixun.forbid_copy,
- hide_code: this.props.data && this.props.data.shixun.hide_code,
- task_pass: this.props.data && this.props.data.shixun.task_pass,
- test_set_permission: this.props.data && this.props.data.shixun.test_set_permission,
- is_secret_repository: this.props.data && this.props.data.shixun.is_secret_repository,
- websshshow: this.props.data && this.props.data.shixun.webssh === 0 ? false : true,
- multi_webssh: this.props.data && this.props.data.shixun.multi_webssh,
- opensshRadio: this.props.data && this.props.data.shixun.webssh === 0 ? null : this.props.data && this.props.data.shixun.webssh,
- })
-
- // if(this.props.data && this.props.data.shixun.status===0){
- // this.setState({
- // task_pass:true
- // })
- // }
-
- }
-
- }
-
- componentDidUpdate(prevProps, prevState) {
- if (prevProps.data != this.props.data) {
- if (this.props.data) {
-
+ if (this.props.data ) {
+ if (this.props.data.shixun) {
this.setState({
vnc: this.props.data && this.props.data.shixun.vnc,
code_hidden: this.props.data && this.props.data.shixun.code_hidden,
@@ -84,6 +57,35 @@ export default class Shixuninformation extends Component {
}
}
+
+ }
+
+ componentDidUpdate(prevProps, prevState) {
+ if (prevProps.data != this.props.data) {
+ if (this.props.data) {
+ if (this.props.data.shixun) {
+ this.setState({
+ vnc: this.props.data && this.props.data.shixun.vnc,
+ code_hidden: this.props.data && this.props.data.shixun.code_hidden,
+ forbid_copy: this.props.data && this.props.data.shixun.forbid_copy,
+ hide_code: this.props.data && this.props.data.shixun.hide_code,
+ task_pass: this.props.data && this.props.data.shixun.task_pass,
+ test_set_permission: this.props.data && this.props.data.shixun.test_set_permission,
+ is_secret_repository: this.props.data && this.props.data.shixun.is_secret_repository,
+ websshshow: this.props.data && this.props.data.shixun.webssh === 0 ? false : true,
+ multi_webssh: this.props.data && this.props.data.shixun.multi_webssh,
+ opensshRadio: this.props.data && this.props.data.shixun.webssh === 0 ? null : this.props.data && this.props.data.shixun.webssh,
+ })
+
+ // if(this.props.data && this.props.data.shixun.status===0){
+ // this.setState({
+ // task_pass:true
+ // })
+ // }
+
+ }
+ }
+ }
}
@@ -222,7 +224,7 @@ export default class Shixuninformation extends Component {
}
render() {
- console.log(this.props)
+ // console.log(this.props)
return (
diff --git a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js
index ca12058ba..2fdd30146 100644
--- a/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js
+++ b/public/react/src/modules/tpm/TPMsettings/Shixuninformation.js
@@ -55,39 +55,41 @@ class Shixuninformation extends Component {
componentDidUpdate(prevProps, prevState) {
if (prevProps.data != this.props.data) {
- if (this.props.data&&this.props.data.shixun) {
- this.setState({
- shixunName: this.props.data.shixun&&this.props.data.shixun.name,
- trainee:this.props.data.shixun&&this.props.data.shixun.trainee,
- choice_main_type: this.props.data.shixun&&this.props.data.shixun.choice_main_type,
- choice_small_type: this.props.data.shixun&&this.props.data.shixun.choice_small_type,
- choice_standard_scripts:this.props.data.shixun&&this.props.data.shixun.choice_standard_scripts,
- shixunmemoMDvalue: this.props.data.shixun&&this.props.data.shixun.evaluate_script,
- simichecked: this.props.data.shixun&&this.props.data.shixun.is_secret_repository,
- shixun_service_configs: this.props.data.shixun&&this.props.data.shixun.shixun_service_configs,
- standard_scripts:this.props.data.shixun&&this.props.data.shixun.standard_scripts,
- shixun_service_configlist:this.props.data.shixun&&this.props.data.shixun.shixun_service_configs,
+
+ if (this.props.data ) {
+ if (this.props.data.shixun){
+ this.setState({
+ shixunName: this.props.data && this.props.data.shixun.name,
+ trainee: this.props.data && this.props.data.shixun.trainee,
+ choice_main_type: this.props.data && this.props.data.shixun.choice_main_type,
+ choice_small_type: this.props.data && this.props.data.shixun.choice_small_type,
+ choice_standard_scripts: this.props.data && this.props.data.shixun.choice_standard_scripts,
+ shixunmemoMDvalue: this.props.data && this.props.data.shixun.evaluate_script,
+ simichecked: this.props.data && this.props.data.shixun.is_secret_repository,
+ shixun_service_configs: this.props.data && this.props.data.shixun.shixun_service_configs,
+ standard_scripts: this.props.data && this.props.data.shixun.standard_scripts,
+ 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({
- choice_standard_scripts:{id: this.props.data.shixun&&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_scripts: {id: this.props.data && this.props.data.shixun.standard_scripts[0].id, value: ""},
+ choice_standard_scriptssum: this.props.data && this.props.data.shixun.standard_scripts[0].id
})
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)
- }else{
+ this.get_mirror_script(this.props.data && this.props.data.shixun.standard_scripts[0].id)
+ } else {
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 = ""
- this.props.data.shixun&&this.props.data.shixun.choice_small_type.map((item, key) => {
- this.props.data.shixun.small_type.map((i,k)=>{
- if (item===i.id) {
+ this.props.data && this.props.data.shixun.choice_small_type.map((item, key) => {
+ this.props.data && this.props.data.shixun.small_type.map((i, k) => {
+ if (item === i.id) {
newlist = newlist + `${i.description}`
}
})
@@ -96,23 +98,24 @@ class Shixuninformation extends Component {
subvalues: newlist
})
- this.props.data.shixun&&this.props.data.shixun.main_type.map((item,key)=>{
- if(item.id===this.props.data.shixun&&this.props.data.shixun.choice_main_type){
+ this.props.data && this.props.data.shixun.main_type.map((item, key) => {
+ if (item.id === this.props.data && this.props.data.shixun.choice_main_type) {
this.setState({
- mainvalues:item.description,
+ mainvalues: item.description,
})
}
})
this.props.form.setFieldsValue({
- name:this.props.data.shixun&&this.props.data.shixun.name,
- trainee: this.props.data.shixun&&this.props.data.shixun.trainee,
- selectleft: this.props.data.shixun&&this.props.data.shixun.choice_main_type,
- selectright:this.props.data.shixun&&this.props.data.shixun.choice_small_type,
+ name: this.props.data && this.props.data.shixun.name,
+ trainee: this.props.data && this.props.data.shixun.trainee,
+ selectleft: this.props.data && this.props.data.shixun.choice_main_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);
}
}
+ }
}
getshixunmemoMDvalue = (value, e) => {
@@ -713,7 +716,7 @@ class Shixuninformation extends Component {
}
render() {
- let operateauthority = this.props.identity === 1 ? true : this.props.identity < 5 && this.props.data.shixun.status == 0 ? true : false;
+
// console.log(operateauthority)
const {getFieldDecorator} = this.props.form;
const { fileList, choice_standard_scripts, postapplyvisible, shixunmemoMDvalue} = this.state;
@@ -754,7 +757,7 @@ class Shixuninformation extends Component {
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 (
@@ -841,15 +844,33 @@ class Shixuninformation extends Component {
>
{
- this.props.data === undefined ? "" : this.props.data.shixun&&this.props.data.shixun.main_type.map((item, key) => {
- return (
-
- )
- })
+ 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 (
+
+ )
+ }
+ }):""
+ }
+
+ {
+ 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 (
+
+ )
+ }
+ }):""
}
diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js
index f15141480..2b389245b 100644
--- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js
+++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js
@@ -6,6 +6,8 @@ import {
Modal
} from 'antd';
+import './css/TPMsettings.css';
+
import TopShixuninformation from './Shixuninformation';
import Configuration from './Configuration';
@@ -14,8 +16,6 @@ import LearningSettings from './LearningSettings';
import axios from 'axios';
-import './css/TPMsettings.css';
-
const {TabPane} = Tabs;
// 处理整点 半点
@@ -41,17 +41,17 @@ export default class TPMsettings extends Component {
axios.get(Url).then((response) => {
// alert(response.data.shixun.choice_standard_scripts)
if (response.status === 200) {
+ if(response.data){
+ if (response.data.shixun&&response.data.shixun.scope_partment.length > 0) {
+ this.setState({
+ scopetype: true
+ })
+ }
+ }
this.setState({
data: response.data
})
-
- if (response.data.shixun.scope_partment.length > 0) {
- this.setState({
- scopetype: true
- })
- }
-
}
});
@@ -96,7 +96,8 @@ export default class TPMsettings extends Component {
operateshixunstype: false,
});
- window.location.href = "/shixuns";
+ // window.location.href = "/shixuns";
+ this.props.history.replace( "/shixuns/");
}
}).catch((error) => {
console.log(error)
@@ -113,7 +114,8 @@ export default class TPMsettings extends Component {
operateshixunstype: false,
});
- window.location.href = "/shixuns/" + id + "/challenges";
+ // window.location.href = "/shixuns/" + id + "/challenges";
+ this.props.history.replace( "/shixuns/" + id + "/challenges");
}
}).catch((error) => {
console.log(error)
@@ -128,7 +130,7 @@ export default class TPMsettings extends Component {
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 b="isVNC";
@@ -197,7 +199,7 @@ export default class TPMsettings extends Component {
getdatas={(key) => this.getdatas(key)}
/>
- {this.props.shixunsDetails === undefined ? "" : this.props.shixunsDetails.is_jupyter === false ?
+ {this.props.shixunsDetails === undefined ? "" : this.props.shixunsDetails&&this.props.shixunsDetails.is_jupyter === false ?
{
@@ -535,16 +539,36 @@ class Newshixuns extends Component {
defaultOpen={false}
>
{
- newshixunlist === undefined ? "" : newshixunlist.main_type.map((item, key) => {
- return (
-
- )
- })
+ 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 (
+
+ )
+ }
+
+ }):""
+ }
+ {
+ 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 (
+
+ )
+ }
+
+ }):""
}
diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js
index 73d6328c1..af88fc6a7 100644
--- a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js
+++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js
@@ -79,7 +79,7 @@ class Challengesjupyter extends Component {
setTimeout(() => {
this.setState({
- // jupyter_url:response.data.url,
+ jupyter_url:response.data.url,
jupyter_port:response.data.port,
booljupyterurls:true,
})
@@ -258,7 +258,7 @@ class Challengesjupyter extends Component {
this.modifyjupyter(this.state)}>