diff --git a/templates/repo/modelarts/trainjob/show.tmpl b/templates/repo/modelarts/trainjob/show.tmpl index e5873d540..239763de1 100755 --- a/templates/repo/modelarts/trainjob/show.tmpl +++ b/templates/repo/modelarts/trainjob/show.tmpl @@ -274,10 +274,14 @@ {{if .CanDel}} - {{$.i18n.Tr "repo.delete"}} {{else}} - {{$.i18n.Tr "repo.delete"}} {{end}} @@ -896,35 +900,7 @@ $('#name').val(modelName) $('#version').val("0.0.1") } - function deleteVersion(version_name) { - stopBubbling(arguments.callee.caller.arguments[0]) - let flag = 1; - $('.ui.basic.modal').modal({ - onDeny: function () { - flag = false - }, - onApprove: function () { - $.post(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/del_version`, { version_name: version_name }, (data) => { - if (data.VersionListCount === 0) { - location.href = `/${userName}/${repoPath}/modelarts/train-job` - } else { - $('#accordion' + version_name).remove() - } - - }).fail(function (err) { - console.log(err); - }); - flag = true - }, - onHidden: function () { - if (flag == false) { - $('.alert').html('您已取消操作').removeClass('alert-success').addClass('alert-danger').show().delay(1500).fadeOut(); - } - } - }) - .modal('show') - - } + diff --git a/web_src/js/features/cloudbrainShow.js b/web_src/js/features/cloudbrainShow.js index 691ac57c4..9c68722a7 100644 --- a/web_src/js/features/cloudbrainShow.js +++ b/web_src/js/features/cloudbrainShow.js @@ -213,6 +213,35 @@ export default async function initCloudrainSow() { }); e.stopPropagation(); }); + $(".delete-show-version").click(function (e) { + const ID = this.dataset.jobid; + const repoPath = this.dataset.repopath; + const version_name = this.dataset.version; + const url = `/api/v1/repos/${repoPath}/${ID}/del_version`; + $(".ui.basic.modal") + .modal({ + onApprove: function () { + $.post(url, { version_name: version_name }, (data) => { + console.log(data); + if (data.StatusOK === 0) { + if (data.VersionListCount === 0) { + location.href = `/${repoPath}`; + } else { + $("#accordion" + version_name).remove(); + } + refreshStatusShow(version_name, ID, repoPath); + } else { + return; + } + }).fail(function (err) { + console.log(err); + }); + }, + }) + .modal("show"); + + e.stopPropagation(); + }); function refreshStatusShow(version_name, ID, repoPath) { $.get( `/api/v1/repos/${repoPath}/${ID}?version_name=${version_name}`, diff --git a/web_src/js/features/cloudrbanin.js b/web_src/js/features/cloudrbanin.js index 445f70be3..2df780233 100644 --- a/web_src/js/features/cloudrbanin.js +++ b/web_src/js/features/cloudrbanin.js @@ -182,6 +182,15 @@ export default async function initCloudrain() { "CREATE_FAILED", "STOPPED", ]; + let deleteArray = [ + "KILLED", + "FAILED", + "START_FAILED", + "COMPLETED", + "SUCCEEDED", + "CREATE_FAILED", + "STOPPED", + ]; $.get( `/api/v1/repos/${repoPath}/${jobID}?version_name=${versionname}`, (data) => { @@ -194,6 +203,10 @@ export default async function initCloudrain() { if (stopArray.includes(data.JobStatus)) { $("#" + versionname + "-stop").addClass("disabled"); } + if (deleteArray.includes(data.JobStatus)) { + $(`#${versionname}-delete`).removeClass("disabled"); + $(`#${versionname}-delete`).addClass("blue"); + } if (data.JobStatus === "COMPLETED") { $("#" + versionname + "-create-model") .removeClass("disabled")