From 6fda0077ddbefbe4e09631ec261dfb707997fc8b Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 17 Nov 2022 18:50:30 +0800 Subject: [PATCH] fix issue --- templates/admin/cloudbrain/list.tmpl | 2 + templates/repo/debugjob/index.tmpl | 2 + templates/user/dashboard/cloudbrains.tmpl | 10 +++-- web_src/js/features/cloudrbanin.js | 37 +++++++++++++------ .../vuepages/pages/notebook/debug/index.vue | 37 +++++++------------ 5 files changed, 48 insertions(+), 40 deletions(-) diff --git a/templates/admin/cloudbrain/list.tmpl b/templates/admin/cloudbrain/list.tmpl index b6dfec77d..92ca35c5b 100755 --- a/templates/admin/cloudbrain/list.tmpl +++ b/templates/admin/cloudbrain/list.tmpl @@ -238,6 +238,7 @@ {{$.i18n.Tr "repo.debug"}} {{else}} + {{if not .BootFile}} {{end}} + {{end}} {{end}} diff --git a/templates/repo/debugjob/index.tmpl b/templates/repo/debugjob/index.tmpl index 20aacfb01..4eb74d1c8 100755 --- a/templates/repo/debugjob/index.tmpl +++ b/templates/repo/debugjob/index.tmpl @@ -266,6 +266,7 @@ {{$.i18n.Tr "repo.debug"}} {{else}} + {{if not .BootFile}} {{end}} + {{end}} {{else}} {{if eq .Status "RUNNING" "WAITING" "CREATING" "STARTING"}} diff --git a/templates/user/dashboard/cloudbrains.tmpl b/templates/user/dashboard/cloudbrains.tmpl index e3527b25e..fe7689944 100755 --- a/templates/user/dashboard/cloudbrains.tmpl +++ b/templates/user/dashboard/cloudbrains.tmpl @@ -124,7 +124,8 @@ style="width: 8% !important;"> + data-jobid="{{$JobID}}" data-version="{{.VersionName}}" + data-bootfile="{{.BootFile}}"> {{.Status}} @@ -185,7 +186,6 @@ {{.Repo.OwnerName}}/{{.Repo.Alias}} -
{{if eq .JobType "DEBUG"}}
@@ -199,6 +199,7 @@ {{$.i18n.Tr "repo.debug"}} {{else}} + {{if not .BootFile}} {{end}} + {{end}}
{{end}} @@ -228,7 +230,7 @@ + data-jobid="{{$JobID}}" data-bootfile="{{.BootFile}}"> {{$.i18n.Tr "repo.stop"}} @@ -236,7 +238,7 @@ + data-jobid="{{$JobID}}" data-version="{{.VersionName}}" data-bootfile="{{.BootFile}}"> {{$.i18n.Tr "repo.stop"}} {{end}} diff --git a/web_src/js/features/cloudrbanin.js b/web_src/js/features/cloudrbanin.js index 5a95dfe6c..e6166ab7c 100644 --- a/web_src/js/features/cloudrbanin.js +++ b/web_src/js/features/cloudrbanin.js @@ -24,6 +24,8 @@ export default async function initCloudrain() { const repoPath = job.dataset.repopath; // const computeResource = job.dataset.resource const versionname = job.dataset.version; + const bootfile = job.dataset.bootfile; + console.log("bootfile---",bootfile) const status_text = $(`#${ID}-text`).text(); const finalState = [ "STOPPED", @@ -99,11 +101,16 @@ export default async function initCloudrain() { "SUCCEEDED", ].includes(status) ) { - $("#ai-debug-" + ID) - .removeClass("disabled") - .addClass("blue") - .text(debug_again_button) - .css("margin", "0"); + if (!bootfile) { + $("#ai-debug-" + ID) + .removeClass("disabled") + .addClass("blue") + .text(debug_again_button) + .css("margin", "0"); + } else { + $("#ai-debug-" + ID).remove() + } + } if (["RUNNING", "WAITING"].includes(status)) { $("#ai-stop-" + ID) @@ -289,7 +296,8 @@ export default async function initCloudrain() { assertDelete(this); } }); - function stopDebug(ID, stopUrl) { + function stopDebug(ID, stopUrl,bootFile) { + console.log("---------=-=-=-==--===") $.ajax({ type: "POST", url: stopUrl, @@ -301,11 +309,15 @@ export default async function initCloudrain() { .addClass(res.status); $("#" + ID + "-text").text(res.status); if (res.status === "STOPPED") { - $("#ai-debug-" + ID) - .removeClass("disabled") - .addClass("blue") - .text(debug_again_button) - .css("margin", "0"); + if (!bootFile) { + $("#ai-debug-" + ID) + .removeClass("disabled") + .addClass("blue") + .text(debug_again_button) + .css("margin", "0"); + } else { + $("#ai-debug-" + ID).remove() + } $("#ai-image-" + ID) .removeClass("blue") .addClass("disabled"); @@ -344,7 +356,8 @@ export default async function initCloudrain() { $(".ui.basic.ai_stop").click(function () { const ID = this.dataset.jobid; const repoPath = this.dataset.repopath; - stopDebug(ID, repoPath); + const bootFile = this.dataset.bootfile + stopDebug(ID, repoPath,bootFile); }); function stopVersion(version_name, ID, repoPath) { diff --git a/web_src/vuepages/pages/notebook/debug/index.vue b/web_src/vuepages/pages/notebook/debug/index.vue index 793e44a0f..c2b36ce67 100644 --- a/web_src/vuepages/pages/notebook/debug/index.vue +++ b/web_src/vuepages/pages/notebook/debug/index.vue @@ -200,8 +200,8 @@ export default { }, methods: { handleClose(done) { - console.log("close") this.initSelect = true + this.alertCb = false }, selectResource(index) { this.getNotebookInfo() @@ -244,7 +244,6 @@ export default { }, getCb2NotebookInfo(path,id){ getCb2Notebook(path,id).then((res)=>{ - console.log(res) if(res.status===200){ if(res.data.JobStatus==="RUNNING"){ this.btnStatus[2]=2 @@ -257,32 +256,23 @@ export default { }, stopDebug(index){ this.btnStatus[index]=3 - if(index===2){ - stopNotebook(this.deubgUrlNpuStop).then((res)=>{ - console.log(res) - if(res.data.result_code==='0'){ - this.btnStatus[index]=0 - Message.success("停止任务成功") - }else{ - Message.error(res.data.error_msg) - } - }) - }else{ - stopNotebook(this.deubgUrlGpuStop).then((res)=>{ - console.log(res) - }) - } + let url = index===2 ? this.deubgUrlNpuStop :this.deubgUrlGpuStop + stopNotebook(url).then((res)=>{ + if(res.data.result_code==='0'){ + this.btnStatus[index]=0 + Message.success("停止任务成功") + }else{ + Message.error(res.data.error_msg) + } + }) }, createTask(index){ this.btnStatus[index]=1 const data = {type:index,...this.fileInfo} let repoPath = `repos/${this.fileInfo.owner_name}/${this.fileInfo.project_name}` createNotebook(data).then((res)=>{ - console.log("=========",res) if(res.data.code===0 && res.status===200){ - // this.btnStatus[index]=2 if(index===2){ - console.log("index",index) timerCb2 = setInterval(() => { setTimeout(this.getCb2NotebookInfo(repoPath,res.data.message), 0) }, 10000) @@ -296,10 +286,12 @@ export default { }else if(res.data.code===1 && res.status===403){ this.btnStatus[index]=0 + }else if(res.data.code==2){ + this.btnStatus[index]=0 + this.alertCb = true }else{ this.btnStatus[index]=0 Message.error(res.data.message) - this.alertCb = true } }).catch((err)=>{ this.btnStatus[index]=0 @@ -332,14 +324,11 @@ export default { }, mounted() { this.getNotebookInfo() - // this.dialogVisible = true - console.log("-----------aaaaa--"); const selfData = document.querySelector('#__vue-self-data') this.fileInfo.file = selfData.getAttribute('data-file') this.fileInfo.branch_name = selfData.getAttribute('data-branch') this.fileInfo.owner_name = selfData.getAttribute('data-owner') this.fileInfo.project_name = selfData.getAttribute('data-project') - console.log(this.fileInfo) let that = this; document .querySelector("#notebook-debug")