mirror of
https://github.com/newnius/YAO-portal.git
synced 2025-12-13 00:56:44 +00:00
update
This commit is contained in:
@@ -30,7 +30,6 @@ function register_events_agent() {
|
||||
$("#modal-msg").modal('show');
|
||||
}
|
||||
$('#table-agent').bootstrapTable("refresh");
|
||||
|
||||
});
|
||||
ajax.fail(function (jqXHR, textStatus) {
|
||||
$("#modal-msg-content").html("Request failed : " + jqXHR.statusText);
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
function register_events_job() {
|
||||
$('#btn-job-add').click(function (e) {
|
||||
cb = function (workspaces) {
|
||||
$('#form-job-workspace').children().remove();
|
||||
$.each(workspaces, function (i, workspace) {
|
||||
var newGroupOption = '<option value="' + workspace.git_repo + '">' + workspace.name + '</option>';
|
||||
$('#form-job-workspace').append(newGroupOption);
|
||||
});
|
||||
|
||||
};
|
||||
wordspace_gets(null, cb);
|
||||
$('#modal-job').modal('show');
|
||||
});
|
||||
|
||||
@@ -158,7 +167,7 @@ var workspaceFormatter = function (workspace) {
|
||||
};
|
||||
|
||||
var clusterFormatter = function (cluster) {
|
||||
return cluster;
|
||||
return 'default';
|
||||
};
|
||||
|
||||
var priorityFormatter = function (status) {
|
||||
@@ -219,8 +228,9 @@ function jobOperateFormatter(value, row, index) {
|
||||
|
||||
window.jobOperateEvents = {
|
||||
'click .config': function (e, value, row, index) {
|
||||
row.tasks = JSON.parse(row.tasks);
|
||||
var formattedData = JSON.stringify(row, null, '\t');
|
||||
var tmp = jQuery.extend(true, {}, row);
|
||||
tmp.tasks = JSON.parse(tmp.tasks);
|
||||
var formattedData = JSON.stringify(tmp, null, '\t');
|
||||
$('#modal-job-description-content').text(formattedData);
|
||||
$('#modal-job-description').modal('show');
|
||||
},
|
||||
|
||||
105
static/resource.js
Executable file
105
static/resource.js
Executable file
@@ -0,0 +1,105 @@
|
||||
function register_events_resource() {
|
||||
|
||||
}
|
||||
|
||||
function load_resources() {
|
||||
$("#table-resource").bootstrapTable({
|
||||
url: window.config.BASE_URL + '/service?action=resource_list',
|
||||
responseHandler: resourceResponseHandler,
|
||||
sidePagination: 'server',
|
||||
cache: true,
|
||||
striped: true,
|
||||
pagination: false,
|
||||
pageSize: 10,
|
||||
pageList: [10, 25, 50, 100, 200],
|
||||
search: false,
|
||||
showColumns: true,
|
||||
showRefresh: true,
|
||||
showToggle: false,
|
||||
showPaginationSwitch: true,
|
||||
minimumCountColumns: 2,
|
||||
clickToSelect: false,
|
||||
sortName: 'nobody',
|
||||
sortOrder: 'desc',
|
||||
smartDisplay: true,
|
||||
mobileResponsive: true,
|
||||
showExport: true,
|
||||
columns: [{
|
||||
field: 'id',
|
||||
title: 'ID',
|
||||
align: 'center',
|
||||
valign: 'middle',
|
||||
visible: false
|
||||
}, {
|
||||
field: 'host',
|
||||
title: 'Node',
|
||||
align: 'center',
|
||||
valign: 'middle',
|
||||
escape: true
|
||||
}, {
|
||||
field: 'CPU',
|
||||
title: 'CPU',
|
||||
align: 'center',
|
||||
valign: 'middle'
|
||||
}, {
|
||||
field: 'MEM',
|
||||
title: 'MEM',
|
||||
align: 'center',
|
||||
valign: 'middle',
|
||||
escape: true,
|
||||
visible: true
|
||||
}, {
|
||||
field: 'GPU',
|
||||
title: 'GPU',
|
||||
align: 'center',
|
||||
valign: 'middle',
|
||||
escape: true,
|
||||
visible: true
|
||||
}, {
|
||||
field: 'operate',
|
||||
title: 'Operate',
|
||||
align: 'center',
|
||||
events: resourceOperateEvents,
|
||||
formatter: resourceOperateFormatter
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
function resourceResponseHandler(res) {
|
||||
if (res['errno'] === 0) {
|
||||
var tmp = {};
|
||||
tmp["rows"] = [];
|
||||
$.each(res["resources"], function (i, node) {
|
||||
var item = {
|
||||
'host': node.host,
|
||||
'CPU': '-',
|
||||
'MEM': '-',
|
||||
'GPU': node.status.length,
|
||||
'status': node.status
|
||||
};
|
||||
tmp["rows"].push(item);
|
||||
});
|
||||
|
||||
return tmp['rows'];
|
||||
}
|
||||
$("#modal-msg-content").html(res["msg"]);
|
||||
$("#modal-msg").modal('show');
|
||||
return [];
|
||||
}
|
||||
|
||||
function resourceOperateFormatter(value, row, index) {
|
||||
var div = '<div class="btn-group" role="group" aria-label="...">';
|
||||
div += '<button class="btn btn-default view"><i class="glyphicon glyphicon-eye-open"></i> </button>';
|
||||
div += '</div>';
|
||||
return div;
|
||||
}
|
||||
|
||||
|
||||
window.resourceOperateEvents = {
|
||||
'click .view': function (e, value, row, index) {
|
||||
var tmp = jQuery.extend(true, {}, row.status);
|
||||
var formattedData = JSON.stringify(tmp, null, '\t');
|
||||
$('#modal-resource-gpu-detail-content').text(formattedData);
|
||||
$('#modal-resource-gpu-detail').modal('show');
|
||||
}
|
||||
};
|
||||
@@ -14,12 +14,17 @@ $(function () {
|
||||
$("#btn-oauth-login").click(function (e) {
|
||||
e.preventDefault();
|
||||
var ajax = $.ajax({
|
||||
url: window.config.BASE_URL + "/service?action=oauth_get_url",
|
||||
url: window.config.BASE_URL + "/service?action=user_login",
|
||||
type: 'POST',
|
||||
data: {}
|
||||
});
|
||||
ajax.done(function (res) {
|
||||
window.location.href = res['url'];
|
||||
if (res["errno"] !== 0) {
|
||||
$("#modal-msg-content").html(res["msg"]);
|
||||
$("#modal-msg").modal('show');
|
||||
} else {
|
||||
window.location.pathname = "/ucenter";
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ function summary_render() {
|
||||
var ctx_mem = document.getElementById('summary-chart-mem').getContext('2d');
|
||||
var ctx_jobs = document.getElementById('summary-chart-jobs').getContext('2d');
|
||||
var ctx_gpu = document.getElementById('summary-chart-gpu').getContext('2d');
|
||||
var ctx_gpu_util = document.getElementById('summary-chart-gpu-util').getContext('2d');
|
||||
var ctx_gpu_mem = document.getElementById('summary-chart-gpu-mem').getContext('2d');
|
||||
|
||||
var ajax = $.ajax({
|
||||
url: window.config.BASE_URL + "/service?action=summary_get",
|
||||
@@ -19,7 +21,7 @@ function summary_render() {
|
||||
$("#modal-msg").modal('show');
|
||||
}
|
||||
|
||||
|
||||
/* CPU Load */
|
||||
ctx_cpu.canvas.height = 200;
|
||||
new Chart(ctx_cpu, {
|
||||
"type": "line",
|
||||
@@ -34,15 +36,19 @@ function summary_render() {
|
||||
}]
|
||||
},
|
||||
"options": {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'GPU Load'
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
maintainAspectRatio:false
|
||||
|
||||
maintainAspectRatio: false
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* Jobs */
|
||||
var data = {
|
||||
datasets: [{
|
||||
data: Object.values(res['jobs']),
|
||||
@@ -56,12 +62,69 @@ function summary_render() {
|
||||
type: 'pie',
|
||||
data: data,
|
||||
options: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Jobs'
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* Mem Using */
|
||||
ctx_mem.canvas.height = 200;
|
||||
new Chart(ctx_mem, {
|
||||
"type": "line",
|
||||
"data": {
|
||||
"labels": ["January", "February", "March", "April", "May", "June", "July"],
|
||||
"datasets": [{
|
||||
"label": "My First Data set",
|
||||
"data": [2, 0.5, 1.5, 0.81, 1.56, 1.55, 1.40],
|
||||
"fill": true,
|
||||
"borderColor": "rgb(75, 192, 192)",
|
||||
"lineTension": 0.1
|
||||
}]
|
||||
},
|
||||
"options": {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'MEM Using'
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
maintainAspectRatio: false
|
||||
}
|
||||
});
|
||||
|
||||
/* GPU Util */
|
||||
ctx_gpu_util.canvas.height = 200;
|
||||
new Chart(ctx_gpu_util, {
|
||||
"type": "line",
|
||||
"data": {
|
||||
"labels": ["January", "February", "March", "April", "May", "June", "July"],
|
||||
"datasets": [{
|
||||
"label": "My First Data set",
|
||||
"data": [2, 0.5, 1.5, 0.81, 1.56, 1.55, 1.40],
|
||||
"fill": true,
|
||||
"borderColor": "rgb(75, 192, 192)",
|
||||
"lineTension": 0.1
|
||||
}]
|
||||
},
|
||||
"options": {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'GPU Utilization'
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
maintainAspectRatio: false
|
||||
}
|
||||
});
|
||||
|
||||
/* GPUs */
|
||||
var data2 = {
|
||||
datasets: [{
|
||||
data: Object.values(res['gpu']),
|
||||
@@ -75,11 +138,42 @@ function summary_render() {
|
||||
type: 'pie',
|
||||
data: data2,
|
||||
options: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'GPUs'
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* GPU Mem Using */
|
||||
ctx_gpu_mem.canvas.height = 200;
|
||||
new Chart(ctx_gpu_mem, {
|
||||
"type": "line",
|
||||
"data": {
|
||||
"labels": ["January", "February", "March", "April", "May", "June", "July"],
|
||||
"datasets": [{
|
||||
"label": "My First Data set",
|
||||
"data": [2, 0.5, 1.5, 0.81, 1.56, 1.55, 1.40],
|
||||
"fill": true,
|
||||
"borderColor": "rgb(75, 192, 192)",
|
||||
"lineTension": 0.1
|
||||
}]
|
||||
},
|
||||
"options": {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'GPU MEM Using'
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
maintainAspectRatio: false
|
||||
}
|
||||
});
|
||||
});
|
||||
ajax.fail(function (jqXHR, textStatus) {
|
||||
$("#modal-msg-content").html("Request failed : " + jqXHR.statusText);
|
||||
|
||||
@@ -27,6 +27,10 @@ $(function () {
|
||||
register_events_workspace();
|
||||
load_workspaces('');
|
||||
break;
|
||||
case "resources":
|
||||
register_events_resource();
|
||||
load_resources();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
function register_events_workspace() {
|
||||
$('#btn-workspace-add').click(function (e) {
|
||||
$('#form-workspace-submit-type').val('add');
|
||||
$('#form-workspace-name').val('');
|
||||
$('#form-workspace-git-repo').val('');
|
||||
$('#modal-workspace').modal('show');
|
||||
});
|
||||
|
||||
$("#form-workspace-submit").click(function (e) {
|
||||
var id = $('#form-workspace-id').val();
|
||||
var name = $('#form-workspace-name').val();
|
||||
var content = $('#form-workspace-content').val();
|
||||
var virtual_cluster = $('#form-workspace-virtual-cluster').val();
|
||||
var permission = $('#form-workspace-permission').val();
|
||||
var type = $('#form-workspace-type').val();
|
||||
var git_repo = $('#form-workspace-git-repo').val();
|
||||
|
||||
/* TODO validate form */
|
||||
|
||||
@@ -24,9 +25,8 @@ function register_events_workspace() {
|
||||
data: {
|
||||
id: id,
|
||||
name: name,
|
||||
content: "[]",
|
||||
virtual_cluster: virtual_cluster,
|
||||
permission: permission
|
||||
type: type,
|
||||
git_repo: git_repo
|
||||
}
|
||||
});
|
||||
ajax.done(function (res) {
|
||||
@@ -81,15 +81,17 @@ function load_workspaces(cluster) {
|
||||
valign: 'middle',
|
||||
escape: true
|
||||
}, {
|
||||
field: 'virtual_cluster',
|
||||
title: 'Virtual Cluster',
|
||||
field: 'type',
|
||||
title: 'Type',
|
||||
align: 'center',
|
||||
valign: 'middle'
|
||||
}, {
|
||||
field: 'permission',
|
||||
title: 'Permission',
|
||||
field: 'git_repo',
|
||||
title: 'Git Repo',
|
||||
align: 'center',
|
||||
valign: 'middle'
|
||||
valign: 'middle',
|
||||
escape: true,
|
||||
visible: true
|
||||
}, {
|
||||
field: 'operate',
|
||||
title: 'Operate',
|
||||
@@ -121,15 +123,43 @@ function workspaceOperateFormatter(value, row, index) {
|
||||
return div;
|
||||
}
|
||||
|
||||
function wordspace_gets(cluster, cb) {
|
||||
var ajax = $.ajax({
|
||||
url: window.config.BASE_URL + '/service?action=workspace_list&who=' + cluster,
|
||||
type: 'GET',
|
||||
data: {}
|
||||
});
|
||||
ajax.done(function (res) {
|
||||
if (res["errno"] !== 0) {
|
||||
$("#modal-msg-content").html(res["msg"]);
|
||||
$("#modal-msg").modal('show');
|
||||
} else {
|
||||
if (cb !== undefined) {
|
||||
cb(res['workspaces']);
|
||||
}
|
||||
}
|
||||
});
|
||||
ajax.fail(function (jqXHR, textStatus) {
|
||||
$("#modal-msg-content").html("Request failed : " + jqXHR.statusText);
|
||||
$("#modal-msg").modal('show');
|
||||
});
|
||||
}
|
||||
|
||||
window.workspaceOperateEvents = {
|
||||
'click .view': function (e, value, row, index) {
|
||||
$('#form-workspace-id').val(row.id);
|
||||
$('#form-workspace-submit-type').val('view');
|
||||
$('#form-workspace-name').val(row.name);
|
||||
$('#form-workspace-type').val(row.type);
|
||||
$('#form-workspace-git-repo').val(row.git_repo);
|
||||
$('#modal-workspace').modal('show');
|
||||
},
|
||||
'click .edit': function (e, value, row, index) {
|
||||
$('#form-workspace-id').val(row.id);
|
||||
$('#form-workspace-submit-type').val('view');
|
||||
$('#form-workspace-name').val(row.name);
|
||||
$('#form-workspace-type').val(row.type);
|
||||
$('#form-workspace-git-repo').val(row.git_repo);
|
||||
$('#modal-workspace').modal('show');
|
||||
},
|
||||
'click .remove': function (e, value, row, index) {
|
||||
|
||||
Reference in New Issue
Block a user