From a9359c4c8be508f264e3af09c91baa385d5e5fa1 Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Sat, 26 Jun 2021 10:06:05 +0200 Subject: [PATCH] baculum: Add new columns to job list page - idea proposed by Sergey Zhidkov Changes: - new job list columns: = Job type = Enabled = Max. concur. jobs = Priority --- gui/baculum/protected/Web/Pages/JobList.page | 34 ++++++++++++++++---- gui/baculum/protected/Web/Pages/JobList.php | 18 +++++++---- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/gui/baculum/protected/Web/Pages/JobList.page b/gui/baculum/protected/Web/Pages/JobList.page index 43a891889..8e976d361 100644 --- a/gui/baculum/protected/Web/Pages/JobList.page +++ b/gui/baculum/protected/Web/Pages/JobList.page @@ -24,7 +24,10 @@ <%[ Status ]%> <%[ Name ]%> - <%[ Director ]%> + <%[ Type ]%> + <%[ Enabled ]%> + Max. concur. jobs + <%[ Priority ]%> <%[ Actions ]%> @@ -34,7 +37,10 @@ <%[ Status ]%> <%[ Name ]%> - <%[ Director ]%> + <%[ Type ]%> + <%[ Enabled ]%> + Max. concur. jobs + <%[ Priority ]%> <%[ Actions ]%> @@ -103,7 +109,23 @@ var oJobList = { }.bind(this) }, {data: 'job'}, - {data: 'director'}, + { + data: 'type', + render: function(data, type, row) { + return JobType.get_type(data); + } + }, + { + data: 'enabled', + render: function(data, type, row) { + return (data == 1 ? '<%[ Yes ]%>' : '<%[ No ]%>'); + } + }, + {data: 'maxjobs'}, + { + data: 'priority', + visible: false + }, { data: 'job', render: function(data, type, row) { @@ -133,11 +155,11 @@ var oJobList = { }, { className: "dt-center", - targets: [ 1, 4 ] + targets: [ 1, 3, 4, 5, 6, 7 ] }], order: [2, 'asc'], initComplete: function () { - this.api().columns([2, 3]).every(function () { + this.api().columns([2, 3, 4, 5, 6]).every(function () { var column = this; var select = $('') .appendTo($(column.footer()).empty()) @@ -149,7 +171,7 @@ var oJobList = { .search(val ? '^' + val + '$' : '', true, false) .draw(); }); - column.data().unique().sort().each(function (d, j) { + column.cells('', column[0]).render('display').unique().sort().each(function(d, j) { if (column.search() == '^' + dtEscapeRegex(d) + '$') { select.append(''); } else { diff --git a/gui/baculum/protected/Web/Pages/JobList.php b/gui/baculum/protected/Web/Pages/JobList.php index 760c38892..f32cab5b5 100644 --- a/gui/baculum/protected/Web/Pages/JobList.php +++ b/gui/baculum/protected/Web/Pages/JobList.php @@ -42,12 +42,18 @@ class JobList extends BaculumWebPage { return; } $result = $this->getModule('api')->get( - array('jobs', 'resnames'), null, true, self::USE_CACHE - )->output; - $jobs = array(); - foreach ($result as $director => $job_list) { - for ($i = 0; $i < count($job_list); $i++) { - $jobs[] = array('director' => $director, 'job' => $job_list[$i]); + ['jobs', 'show', '?output=json'], null, true, self::USE_CACHE + ); + $jobs = []; + if ($result->error === 0) { + for ($i = 0; $i < count($result->output); $i++) { + $jobs[] = [ + 'job' => $result->output[$i]->name, + 'enabled' => $result->output[$i]->enabled, + 'priority' => $result->output[$i]->priority, + 'type' => chr($result->output[$i]->jobtype), + 'maxjobs' => $result->output[$i]->maxjobs + ]; } } $this->jobs = $jobs; -- 2.47.3