| @@ -274,10 +274,14 @@ | |||||
| {{if .CanDel}} | {{if .CanDel}} | ||||
| <a class="ti-action-menu-item" onclick="deleteVersion({{.VersionName}})" | |||||
| <a class='ti-action-menu-item delete-show-version {{if eq .Status "CREATING" "STOPPING" "WAITING" "STARTING" "RUNNING" "KILLING" "INIT"}}disabled {{end}}' | |||||
| id="{{.VersionName}}-delete" | |||||
| data-jobid="{{.JobID}}" | |||||
| data-repopath="{{$.RepoRelPath}}/modelarts/train-job" | |||||
| data-version = "{{.VersionName}}" | |||||
| style="color: #FF4D4F;">{{$.i18n.Tr "repo.delete"}}</a> | style="color: #FF4D4F;">{{$.i18n.Tr "repo.delete"}}</a> | ||||
| {{else}} | {{else}} | ||||
| <a class="ti-action-menu-item disabled" onclick="deleteVersion({{.VersionName}})" | |||||
| <a class="ti-action-menu-item disabled" | |||||
| style="color: #FF4D4F;">{{$.i18n.Tr "repo.delete"}}</a> | style="color: #FF4D4F;">{{$.i18n.Tr "repo.delete"}}</a> | ||||
| {{end}} | {{end}} | ||||
| </div> | </div> | ||||
| @@ -896,35 +900,7 @@ | |||||
| $('#name').val(modelName) | $('#name').val(modelName) | ||||
| $('#version').val("0.0.1") | $('#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') | |||||
| } | |||||
| @@ -213,6 +213,35 @@ export default async function initCloudrainSow() { | |||||
| }); | }); | ||||
| e.stopPropagation(); | 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) { | function refreshStatusShow(version_name, ID, repoPath) { | ||||
| $.get( | $.get( | ||||
| `/api/v1/repos/${repoPath}/${ID}?version_name=${version_name}`, | `/api/v1/repos/${repoPath}/${ID}?version_name=${version_name}`, | ||||
| @@ -182,6 +182,15 @@ export default async function initCloudrain() { | |||||
| "CREATE_FAILED", | "CREATE_FAILED", | ||||
| "STOPPED", | "STOPPED", | ||||
| ]; | ]; | ||||
| let deleteArray = [ | |||||
| "KILLED", | |||||
| "FAILED", | |||||
| "START_FAILED", | |||||
| "COMPLETED", | |||||
| "SUCCEEDED", | |||||
| "CREATE_FAILED", | |||||
| "STOPPED", | |||||
| ]; | |||||
| $.get( | $.get( | ||||
| `/api/v1/repos/${repoPath}/${jobID}?version_name=${versionname}`, | `/api/v1/repos/${repoPath}/${jobID}?version_name=${versionname}`, | ||||
| (data) => { | (data) => { | ||||
| @@ -194,6 +203,10 @@ export default async function initCloudrain() { | |||||
| if (stopArray.includes(data.JobStatus)) { | if (stopArray.includes(data.JobStatus)) { | ||||
| $("#" + versionname + "-stop").addClass("disabled"); | $("#" + versionname + "-stop").addClass("disabled"); | ||||
| } | } | ||||
| if (deleteArray.includes(data.JobStatus)) { | |||||
| $(`#${versionname}-delete`).removeClass("disabled"); | |||||
| $(`#${versionname}-delete`).addClass("blue"); | |||||
| } | |||||
| if (data.JobStatus === "COMPLETED") { | if (data.JobStatus === "COMPLETED") { | ||||
| $("#" + versionname + "-create-model") | $("#" + versionname + "-create-model") | ||||
| .removeClass("disabled") | .removeClass("disabled") | ||||