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/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 f3150db7f..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 diff --git a/public/react/src/modules/tpm/TPMDataset.js b/public/react/src/modules/tpm/TPMDataset.js index 68f6a5e37..ed58211f8 100644 --- a/public/react/src/modules/tpm/TPMDataset.js +++ b/public/react/src/modules/tpm/TPMDataset.js @@ -75,7 +75,7 @@ class TPMDataset extends Component { mylistansum:30, collaboratorList:[], fileList:[], - fileListimg:[], + fileListimgs:[], file:null, datalist:[], data_sets_count:0, @@ -226,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,25 +289,32 @@ class TPMDataset extends Component { handleChange = (info) => { if(info.file.status == "done" || info.file.status == "uploading" || info.file.status === 'removed'){ let fileList = info.fileList; - // try { - // for(var list of fileList ){ - // console.log(list) - // this.state.fileListimg.push(list); - // } - // }catch (e) { - // - // } + + 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); - console.log("TPMDatasetTPMDatasetTPMDataset"); - console.log(fileListimg); const isLt150M = file.size / 1024 / 1024 < 150; if (!isLt150M) { this.props.showNotification('文件大小必须小于150MB!'); @@ -422,7 +452,6 @@ class TPMDataset extends Component { return isLt150M; }, }; - return (