mirror of
https://github.com/newnius/YAO-portal.git
synced 2025-06-06 07:11:54 +00:00
update
This commit is contained in:
parent
dbfe0c5bb7
commit
75657a7d6d
@ -15,21 +15,20 @@ class WorkspaceManager
|
||||
public static function add(CRObject $workspace)
|
||||
{
|
||||
$name = $workspace->get('name');
|
||||
$content = $workspace->get('content');
|
||||
$virtual_cluster = $workspace->getInt('virtual_cluster');
|
||||
$permission = $workspace->getInt('permission');
|
||||
$type = $workspace->get('type');
|
||||
$git_repo = $workspace->get('git_repo');
|
||||
$created_at = $workspace->getInt('created_at', time());
|
||||
$updated_at = $workspace->getInt('updated_at', time());
|
||||
$created_by = $workspace->get('created_by');
|
||||
|
||||
$key_values = array(
|
||||
'name' => '?', 'content' => '?', 'virtual_cluster' => '?', 'permission' => '?',
|
||||
'name' => '?', 'type' => '?', 'git_repo' => '?',
|
||||
'created_at' => '?', 'updated_at' => '?', 'created_by' => '?'
|
||||
);
|
||||
$builder = new SQLBuilder();
|
||||
$builder->insert(self::$table, $key_values);
|
||||
$sql = $builder->build();
|
||||
$params = array($name, $content, $virtual_cluster, $permission, $created_at, $updated_at, $created_by);
|
||||
$params = array($name, $type, $git_repo, $created_at, $updated_at, $created_by);
|
||||
return (new MysqlPDO())->execute($sql, $params);
|
||||
}
|
||||
|
||||
@ -87,19 +86,19 @@ class WorkspaceManager
|
||||
{
|
||||
$id = $workspace->getInt('id');
|
||||
$name = $workspace->get('name');
|
||||
$content = $workspace->get('content');
|
||||
$permission = $workspace->getInt('permission');
|
||||
$type = $workspace->get('type');
|
||||
$git_repo = $workspace->get('git_repo');
|
||||
$updated_at = $workspace->getInt('updated_at', time());
|
||||
|
||||
$key_values = array(
|
||||
'name' => '?', 'content' => '?', 'permission' => '?', 'updated_at' => '?'
|
||||
'name' => '?', 'type' => '?', 'git_repo' => '?', 'updated_at' => '?'
|
||||
);
|
||||
$where = array('id' => '?');
|
||||
$builder = new SQLBuilder();
|
||||
$builder->update(self::$table, $key_values);
|
||||
$builder->where($where);
|
||||
$sql = $builder->build();
|
||||
$params = array($name, $content, $permission, $updated_at, $id);
|
||||
$params = array($name, $type, $git_repo, $updated_at, $id);
|
||||
return (new MysqlPDO())->execute($sql, $params);
|
||||
}
|
||||
|
||||
|
@ -63,3 +63,24 @@ function agent_list(CRObject $rule)
|
||||
$res['errno'] = $res['agents'] === null ? Code::FAIL : Code::SUCCESS;
|
||||
return $res;
|
||||
}
|
||||
|
||||
function resource_list()
|
||||
{
|
||||
if (!AccessController::hasAccess(Session::get('role', 'visitor'), 'system.summary')) {
|
||||
$res['errno'] = Code::NO_PRIVILEGE;
|
||||
return $res;
|
||||
}
|
||||
|
||||
$spider = new Spider();
|
||||
$spider->doGet(YAO_SCHEDULER_ADDR . '?action=resource_list');
|
||||
$msg = json_decode($spider->getBody(), true);
|
||||
|
||||
if ($msg['code'] !== 0) {
|
||||
$res['errno'] = $msg['code'] !== null ? $msg['code'] : Code::UNKNOWN_ERROR;
|
||||
$res['msg'] = $msg['error'];
|
||||
return $res;
|
||||
}
|
||||
$res['resources'] = $msg['resources'];
|
||||
$res['errno'] = Code::SUCCESS;
|
||||
return $res;
|
||||
}
|
||||
|
19
ajax.php
19
ajax.php
@ -128,6 +128,10 @@ switch ($action) {
|
||||
$res = agent_remove($job);
|
||||
break;
|
||||
|
||||
case 'resource_list':
|
||||
$res = resource_list();
|
||||
break;
|
||||
|
||||
case 'workspace_list':
|
||||
$rule = new CRObject();
|
||||
$rule->set('offset', cr_get_GET('offset'));
|
||||
@ -138,9 +142,8 @@ switch ($action) {
|
||||
case 'workspace_add':
|
||||
$workspace = new CRObject();
|
||||
$workspace->set('name', cr_get_POST('name'));
|
||||
$workspace->set('content', cr_get_POST('content'));
|
||||
$workspace->set('virtual_cluster', cr_get_POST('virtual_cluster'));
|
||||
$workspace->set('permission', cr_get_POST('permission'));
|
||||
$workspace->set('type', cr_get_POST('type'));
|
||||
$workspace->set('git_repo', cr_get_POST('git_repo'));
|
||||
$res = workspace_add($workspace);
|
||||
break;
|
||||
|
||||
@ -148,9 +151,8 @@ switch ($action) {
|
||||
$workspace = new CRObject();
|
||||
$workspace->set('id', cr_get_POST('id'));
|
||||
$workspace->set('name', cr_get_POST('name'));
|
||||
$workspace->set('content', cr_get_POST('content'));
|
||||
$workspace->set('virtual_cluster', cr_get_POST('virtual_cluster'));
|
||||
$workspace->set('permission', cr_get_POST('permission'));
|
||||
$workspace->set('type', cr_get_POST('type'));
|
||||
$workspace->set('git_repo', cr_get_POST('git_repo'));
|
||||
$res = workspace_update($workspace);
|
||||
break;
|
||||
|
||||
@ -177,6 +179,11 @@ switch ($action) {
|
||||
$res = oauth_get_url();
|
||||
break;
|
||||
|
||||
case 'user_login':
|
||||
$user = new CRObject();
|
||||
$res = user_login($user);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ require_once('config.inc.php');
|
||||
<div class="footer">
|
||||
<ul class="breadcrumb">
|
||||
<li>©2018 <a href="<?= BASE_URL ?>/">YAO</a></li>
|
||||
<li><a href="https://blog.newnius.com/" target="_blank">Newnius</a></li>
|
||||
<li><a href="<?= BASE_URL ?>/help#TOS">TOS</a></li>
|
||||
<li><a href="<?= BASE_URL ?>/help#privacy">Privacy</a></li>
|
||||
<li><a href="<?= BASE_URL ?>/help#feedback">Feedback</a></li>
|
||||
|
4
help.php
4
help.php
@ -67,9 +67,7 @@ require_once('secure.inc.php');
|
||||
<div id="feedback" class="panel panel-default">
|
||||
<div class="panel-heading">Feedback</div>
|
||||
<div class="panel-body">
|
||||
<p>Contact with
|
||||
<a href="mailto:<?= FEEDBACK_EMAIL ?>?subject=From LS"><?= FEEDBACK_EMAIL ?></a>
|
||||
</p>
|
||||
<p>This is feedback.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -16,7 +16,7 @@ require_once('secure.inc.php');
|
||||
<div class="container">
|
||||
|
||||
<div id="main" class="form ui-widget load-overlay container">
|
||||
<h2>YAO-Yet Another Octopus</h2>
|
||||
<h2 style="text-align: center">YAO---Yet Another Octopus</h2>
|
||||
</div>
|
||||
</div> <!-- /container -->
|
||||
<!--This div exists to avoid footer from covering main body-->
|
||||
|
53
install.php
53
install.php
@ -17,9 +17,7 @@ MysqlPDO::configure($config);
|
||||
create_table_user();
|
||||
create_table_workspace();
|
||||
create_table_cluster();
|
||||
create_table_job();
|
||||
create_table_agent();
|
||||
create_table_resource();
|
||||
create_table_model();
|
||||
create_table_log();
|
||||
|
||||
@ -61,14 +59,12 @@ function create_table_workspace()
|
||||
'CREATE TABLE `yao_workspace`(
|
||||
`id` int AUTO_INCREMENT,
|
||||
PRIMARY KEY(`id`),
|
||||
`name` varchar(64) NOT NULL,
|
||||
`content` json NOT NULL,
|
||||
`name` VARCHAR(64) NOT NULL,
|
||||
`type` VARCHAR(16) NOT NULL,
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT NOT NULL,
|
||||
`virtual_cluster` varchar(64) NOT NULL,
|
||||
INDEX(`virtual_cluster`),
|
||||
`git_repo` varchar(256),
|
||||
`created_by` int NOT NULL,
|
||||
`permission` int, /* [0, 1, 2] * 10 + [0, 1, 2] => [-, r, w] * [-, r, w] */
|
||||
`version` int NOT NULL DEFAULT 0 /* for upgrade purpose */
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci',
|
||||
);
|
||||
@ -88,30 +84,12 @@ function create_table_cluster()
|
||||
`reserved_nodes` json NOT NULL,
|
||||
`quota_per_day` int NOT NULL,
|
||||
`quota_used` int NOT NULL,
|
||||
|
||||
`version` int NOT NULL DEFAULT 0 /* for upgrade purpose */
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci',
|
||||
);
|
||||
execute_sqls($sqls);
|
||||
}
|
||||
|
||||
function create_table_resource()
|
||||
{
|
||||
$sqls = array(
|
||||
// 'DROP `yao_resource`' => 'DROP TABLE IF EXISTS `yao_resource`',
|
||||
'CREATE `yao_resource`' =>
|
||||
'CREATE TABLE `yao_resource`(
|
||||
`id` int AUTO_INCREMENT,
|
||||
PRIMARY KEY(`id`),
|
||||
`ip` bigint NOT NULL,
|
||||
`type` int NOT NULL, /* 0-CPU, 1-GPU */
|
||||
`model` VARCHAR(64) NOT NULL, /* eg. i7, P100 */
|
||||
`memory` int NOT NULL /* MB */
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci',
|
||||
);
|
||||
execute_sqls($sqls);
|
||||
}
|
||||
|
||||
function create_table_agent()
|
||||
{
|
||||
$sqls = array(
|
||||
@ -149,31 +127,6 @@ function create_table_model()
|
||||
execute_sqls($sqls);
|
||||
}
|
||||
|
||||
function create_table_job()
|
||||
{
|
||||
$sqls = array(
|
||||
// 'DROP `yao_job`' => 'DROP TABLE IF EXISTS `yao_job`',
|
||||
'CREATE `yao_job`' =>
|
||||
'CREATE TABLE `yao_job`(
|
||||
`id` int AUTO_INCREMENT,
|
||||
PRIMARY KEY(`id`),
|
||||
`name` varchar(64) NOT NULL,
|
||||
`image` varchar(256) NOT NULL,
|
||||
`tasks` json NOT NULL,
|
||||
`workspace` int NOT NULL,
|
||||
`virtual_cluster` int NOT NULL DEFAULT 0,
|
||||
`priority` int NOT NULL DEFAULT 0,
|
||||
`run_before` bigint,
|
||||
`status` int NOT NULL DEFAULT 0,/* 0-submitted, 1-running, 2-finished, 3-failed, 4-stopped */
|
||||
`created_at` BIGINT NOT NULL,
|
||||
`updated_at` BIGINT,
|
||||
`created_by` int,
|
||||
`version` int NOT NULL DEFAULT 0 /* for upgrade purpose */
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci',
|
||||
);
|
||||
execute_sqls($sqls);
|
||||
}
|
||||
|
||||
function create_table_log()
|
||||
{
|
||||
$sqls = array(
|
||||
|
@ -22,13 +22,6 @@ function job_submit(CRObject $job)
|
||||
}
|
||||
$job->set('created_by', Session::get('uid'));
|
||||
$job->set('created_at', time());
|
||||
// $res['errno'] = JobManager::add($job) ? Code::SUCCESS : Code::UNKNOWN_ERROR;
|
||||
// $log = new CRObject();
|
||||
// $log->set('scope', Session::get('uid'));
|
||||
// $log->set('tag', 'job.submit');
|
||||
// $content = array('job' => $job, 'response' => $res['errno']);
|
||||
// $log->set('content', json_encode($content));
|
||||
// CRLogger::log($log);
|
||||
|
||||
/* notify YAO-scheduler */
|
||||
$spider = new Spider();
|
||||
@ -54,8 +47,14 @@ function job_submit(CRObject $job)
|
||||
if ($msg['code'] !== 0) {
|
||||
$res['errno'] = Code::FAIL;
|
||||
$res['msg'] = $msg['error'];
|
||||
return $res;
|
||||
}
|
||||
|
||||
$log = new CRObject();
|
||||
$log->set('scope', Session::get('uid'));
|
||||
$log->set('tag', 'job.submit');
|
||||
$content = array('job' => $job, 'response' => $res['errno']);
|
||||
$log->set('content', json_encode($content));
|
||||
CRLogger::log($log);
|
||||
return $res;
|
||||
}
|
||||
|
||||
@ -108,7 +107,7 @@ function job_list(CRObject $rule)
|
||||
|
||||
|
||||
if ($msg['code'] !== 0) {
|
||||
$res['errno'] = $msg['code'];
|
||||
$res['errno'] = $msg['code'] !== null ? $msg['code'] : Code::UNKNOWN_ERROR;
|
||||
$res['msg'] = $msg['error'];
|
||||
return $res;
|
||||
}
|
||||
@ -121,10 +120,6 @@ function job_list(CRObject $rule)
|
||||
}
|
||||
}
|
||||
$res['errno'] = Code::SUCCESS;
|
||||
|
||||
//$res['jobs'] = JobManager::gets($rule);
|
||||
//$res['count'] = JobManager::count($rule);
|
||||
//$res['errno'] = $res['jobs'] === null ? Code::FAIL : Code::SUCCESS;
|
||||
return $res;
|
||||
}
|
||||
|
||||
@ -162,7 +157,7 @@ function summary_get()
|
||||
$msg = json_decode($spider->getBody(), true);
|
||||
|
||||
if ($msg['code'] !== 0) {
|
||||
$res['errno'] = $msg['code'];
|
||||
$res['errno'] = $msg['code'] !== null ? $msg['code'] : Code::UNKNOWN_ERROR;
|
||||
$res['msg'] = $msg['error'];
|
||||
return $res;
|
||||
}
|
||||
|
39
modals.php
39
modals.php
@ -31,6 +31,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- node GPU detail modal -->
|
||||
<div class="modal fade" id="modal-resource-gpu-detail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content panel-info">
|
||||
<div class="modal-header panel-heading">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<h4 class="modal-title">GPUs on this node</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<pre id="modal-resource-gpu-detail-content"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- task logs modal -->
|
||||
<div class="modal fade" id="modal-task-logs" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
@ -68,8 +85,7 @@
|
||||
<label>Workspace</label>
|
||||
<div class="form-group form-group-lg">
|
||||
<label for="form-job-workspace" class="sr-only">Workspace</label>
|
||||
<input id="form-job-workspace" type="text" class="form-control"
|
||||
placeholder="git repo" required/>
|
||||
<select id="form-job-workspace" class="form-control"></select>
|
||||
</div>
|
||||
<label>Virtual Cluster</label>
|
||||
<div class="form-group form-group-lg">
|
||||
@ -106,7 +122,9 @@
|
||||
<div class="col-md-6">
|
||||
<label>Docker Image</label>
|
||||
<select class="form-control form-control task-image" required>
|
||||
<option value="quickdeploy/yao-tensorflow:1.12" selected>quickdeploy/yao-tensorflow:1.12</option>
|
||||
<option value="quickdeploy/yao-tensorflow:1.12" selected>
|
||||
quickdeploy/yao-tensorflow:1.12
|
||||
</option>
|
||||
<option value="nvidia/cuda:9.0-base">nvidia/cuda:9.0-base</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -228,17 +246,18 @@
|
||||
<input type="text" id="form-workspace-name" class="form-control" maxlength="64"
|
||||
placeholder="" required/>
|
||||
</div>
|
||||
<label>Virtual Cluster</label>
|
||||
<label>Type</label>
|
||||
<div class="form-group form-group-lg">
|
||||
<label for="form-workspace-virtual-cluster" class="sr-only">Virtual Cluster</label>
|
||||
<select id="form-workspace-virtual-cluster" class="form-control">
|
||||
<option value="0">default</option>
|
||||
<label for="form-workspace-type" class="sr-only">Type</label>
|
||||
<select id="form-workspace-type" class="form-control">
|
||||
<option value="git">git</option>
|
||||
</select>
|
||||
</div>
|
||||
<label>Permission</label>
|
||||
<label>Repo</label>
|
||||
<div class="form-group form-group-lg">
|
||||
<label for="form-workspace-permission" class="sr-only">Token</label>
|
||||
<input type="number" id="form-workspace-permission" class="form-control" placeholder=""/>
|
||||
<label for="form-workspace-git-repo" class="sr-only">Git Repo</label>
|
||||
<input type="text" id="form-workspace-git-repo" class="form-control"
|
||||
placeholder="http://192.168.100.100:3000/newnius/tf.git"/>
|
||||
</div>
|
||||
<div>
|
||||
<input type="hidden" id="form-workspace-submit-type"/>
|
||||
|
@ -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) {
|
||||
|
22
ucenter.php
22
ucenter.php
@ -55,7 +55,7 @@ $entries = array(
|
||||
array('jobs', 'Jobs'),
|
||||
array('workspaces', 'Workspaces'),
|
||||
array('resources', 'Resources'),
|
||||
array('logs', 'Logs'),
|
||||
array('logs', 'Activities'),
|
||||
array('admin', 'Administration'),
|
||||
array('agents', '->Agents'),
|
||||
array('clusters', '->Virtual Clusters'),
|
||||
@ -119,23 +119,26 @@ foreach ($entries as $entry) {
|
||||
<div class="panel-heading">Summary</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4" style="height: 200px">CPU
|
||||
<div class="col-md-4">
|
||||
<canvas id="summary-chart-cpu"></canvas>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
Jobs
|
||||
<canvas id="summary-chart-jobs"></canvas>
|
||||
</div>
|
||||
<div class="col-md-4">Mem
|
||||
<div class="col-md-4">
|
||||
<canvas id="summary-chart-mem"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">GPU CPU</div>
|
||||
<div class="col-md-4">GPUs
|
||||
<div class="col-md-4">
|
||||
<canvas id="summary-chart-gpu-util"></canvas>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<canvas id="summary-chart-gpu"></canvas>
|
||||
</div>
|
||||
<div class="col-md-4">GPU Mem</div>
|
||||
<div class="col-md-4">
|
||||
<canvas id="summary-chart-gpu-mem"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -194,7 +197,7 @@ foreach ($entries as $entry) {
|
||||
<?php } elseif ($page_type === 'logs' || $page_type === 'logs_all') { ?>
|
||||
<div id="logs">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">日志</div>
|
||||
<div class="panel-heading">Activities</div>
|
||||
<div class="panel-body">
|
||||
<div class="table-responsive">
|
||||
<div id="toolbar"></div>
|
||||
@ -258,9 +261,10 @@ foreach ($entries as $entry) {
|
||||
<script src="https://cdn.jsdelivr.net/npm/tableexport.jquery.plugin@1.10.1/tableExport.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
|
||||
|
||||
<script src="static/workspace.js"></script>
|
||||
<script src="static/job.js"></script>
|
||||
<script src="static/agent.js"></script>
|
||||
<script src="static/workspace.js"></script>
|
||||
<script src="static/resource.js"></script>
|
||||
<script src="static/summary.js"></script>
|
||||
<script src="static/ucenter.js"></script>
|
||||
</body>
|
||||
|
@ -68,3 +68,34 @@ function oauth_get_url()
|
||||
$res['url'] = $url;
|
||||
return $res;
|
||||
}
|
||||
|
||||
function user_login($user)
|
||||
{
|
||||
/* mock */
|
||||
$info = array('open_id' => 'admin', 'role' => 'normal', 'nickname' => 'Admin');
|
||||
$open_id = ($info !== null && isset($info['open_id'])) ? $info['open_id'] : null;
|
||||
$email = ($info !== null && isset($info['email'])) ? $info['email'] : null;
|
||||
$role = ($info !== null && isset($info['role'])) ? $info['role'] : 'normal';
|
||||
$nickname = ($info !== null && isset($info['nickname'])) ? $info['nickname'] : 'u2913';
|
||||
|
||||
$user = new CRObject();
|
||||
$user->set('open_id', $open_id);
|
||||
$user->set('email', $email);
|
||||
$user->set('role', $role);
|
||||
$res = user_get($user);
|
||||
|
||||
if ($res['errno'] === 0) {
|
||||
$user = $res['user'];
|
||||
Session::put('uid', $user['uid']);
|
||||
Session::put('role', $user['role']);
|
||||
Session::put('nickname', $nickname);
|
||||
|
||||
$log = new CRObject();
|
||||
$log->set('scope', $user['uid']);
|
||||
$log->set('tag', 'user.login');
|
||||
$content = array('uid' => $user['uid'], 'response' => $res['errno']);
|
||||
$log->set('content', json_encode($content));
|
||||
CRLogger::log($log);
|
||||
}
|
||||
return $res;
|
||||
}
|
Loading…
Reference in New Issue
Block a user