From c173b5ecf2ec31365f7e63b1b477b30c3acf35b1 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 29 Dec 2021 18:23:08 +0800 Subject: [PATCH] fix issue --- .../repo/modelarts/inferencejob/index.tmpl | 72 ++++++++- .../repo/modelarts/inferencejob/new.tmpl | 1 + .../repo/modelarts/inferencejob/show.tmpl | 141 +++++++++++++++++- 3 files changed, 203 insertions(+), 11 deletions(-) diff --git a/templates/repo/modelarts/inferencejob/index.tmpl b/templates/repo/modelarts/inferencejob/index.tmpl index 445bcdd58..382bdeb5d 100644 --- a/templates/repo/modelarts/inferencejob/index.tmpl +++ b/templates/repo/modelarts/inferencejob/index.tmpl @@ -154,10 +154,10 @@ -
+
{{$.CsrfTokenHtml}} {{if .CanDel}} - + {{$.i18n.Tr "repo.delete"}} {{else}} @@ -165,7 +165,7 @@ {{$.i18n.Tr "repo.delete"}} {{end}} - +
@@ -221,7 +221,7 @@ function loadJobStatus() { if(['IMAGE_FAILED','SUBMIT_FAILED','DELETE_FAILED','KILLED','COMPLETED','FAILED','CANCELED','LOST','START_FAILED'].includes(status_text)){ return } - $.get(`/api/v1/repos/${repoPath}/modelarts/train-job/${jobID}?version_name=${versionname}`, (data) => { + $.get(`/api/v1/repos/${repoPath}/modelarts/inference-job/${jobID}?version_name=${versionname}`, (data) => { const jobID = data.JobID const status = data.JobStatus const duration = data.JobDuration @@ -237,4 +237,68 @@ function loadJobStatus() { }); }); }; +function deleteVersion(version_name,jobID){ + const url = '/api/v1/repos/{{$.RepoRelPath}}/modelarts/inference-job/'+jobID+'/del_version' + $.post(url,{version_name:version_name},(data)=>{ + if(data.StatusOK===0){ + location.reload() + } + }).fail(function(err) { + console.log(err); + }); +} +function stopVersion(version_name,jobID){ + const url = '/api/v1/repos/{{$.RepoRelPath}}/modelarts//inference-job/'+jobID+'/stop_version' + $.post(url,{version_name:version_name},(data)=>{ + if(data.StatusOK===0){ + $('#'+version_name+'-stop').removeClass('blue') + $('#'+version_name+'-stop').addClass('disabled') + refreshStatus(version_name,jobID) + } + }).fail(function(err) { + console.log(err); + }); +} +function refreshStatus(version_name,jobID){ + + const url = '/api/v1/repos/{{$.RepoRelPath}}/modelarts/inference-job/'+jobID+'?version_name='+version_name + $.get(url,(data)=>{ + + + $(`#${jobID}-icon`).attr("class",data.JobStatus) + // detail status and duration + + $(`#${jobID}-text`).text(data.JobStatus) + + + }).fail(function(err) { + console.log(err); + }); + +} +function assertDelete(obj,version_name,jobID) { + if (obj.style.color == "rgb(204, 204, 204)") { + return + } else { + // var delId = obj.parentNode.id + flag = 1; + $('.ui.basic.modal') + .modal({ + onDeny: function() { + flag = false + }, + onApprove: function() { + // document.getElementById(delId).submit() + deleteVersion(version_name,jobID) + flag = true + }, + onHidden: function() { + if (flag == false) { + $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut(); + } + } + }) + .modal('show') + } +} diff --git a/templates/repo/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index a959566bd..3a9a910cc 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -263,6 +263,7 @@ {{template "base/footer" .}} \ No newline at end of file