1
0
mirror of https://github.com/newnius/YAO-portal.git synced 2025-06-07 07:31:56 +00:00
This commit is contained in:
Newnius 2020-06-24 23:46:23 +08:00
parent 0e0c5a6f1e
commit 3f18c36868

View File

@ -67,37 +67,44 @@ function register_events_job() {
} }
}); });
var ajax = $.ajax({ var roles = ['PS', 'Worker'];
url: "service?action=job_predict_req&role=PS", $.each(roles, function (i, role) {
type: 'POST', var ajax = $.ajax({
data: { url: "service?action=job_predict_req&role=" + role,
name: name, type: 'POST',
workspace: workspace, data: {
cluster: cluster, name: name,
priority: priority, workspace: workspace,
run_before: run_before, cluster: cluster,
locality: locality, priority: priority,
tasks: JSON.stringify(tasks) run_before: run_before,
} locality: locality,
}); tasks: JSON.stringify(tasks)
ajax.done(function (res) { }
if (res["errno"] !== 0) { });
$("#modal-msg-content").html(res["msg"]); ajax.done(function (res) {
$("#modal-msg").modal('show'); if (res["errno"] !== 0) {
} else { $("#modal-msg-content").html(res["msg"]);
console.log(res); $("#modal-msg").modal('show');
} else {
console.log(res);
$('#form-job-tasks').find('.row').each(function () {
if ((role === 'PS' && $(this).find('.task-cpu').eq(0).val() === 1)
|| (role === 'Worker' && $(this).find('.task-cpu').eq(0).val() === 0)) {
$(this).find('.task-cpu').eq(0).val(res['cpu']);
$(this).find('.task-mem').eq(0).val(res['mem']);
$(this).find('.task-gpu-mem').eq(0).val(res['gpu_mem']);
}
});
}
});
ajax.fail(function (jqXHR, textStatus) {
$("#modal-msg-content").html("Request failed : " + jqXHR.statusText);
$("#modal-msg").modal('show');
$('#table-job').bootstrapTable("refresh");
});
$('#form-job-tasks').find('.row').each(function () {
$(this).find('.task-cpu').eq(0).val(res['cpu']);
$(this).find('.task-mem').eq(0).val(res['mem']);
$(this).find('.task-gpu-mem').eq(0).val(res['gpu_mem']);
});
}
});
ajax.fail(function (jqXHR, textStatus) {
$("#modal-msg-content").html("Request failed : " + jqXHR.statusText);
$("#modal-msg").modal('show');
$('#table-job').bootstrapTable("refresh");
}); });
}); });
@ -144,7 +151,6 @@ function register_events_job() {
$('#modal-job').modal('hide'); $('#modal-job').modal('hide');
var ajax = $.ajax({ var ajax = $.ajax({
url: "service?action=job_submit", url: "service?action=job_submit",
type: 'POST', type: 'POST',