From: Marcin Haba Date: Thu, 17 Feb 2022 06:52:54 +0000 (+0100) Subject: baculum: Add option to set job age for job status summary graph on dashboard page X-Git-Tag: Release-11.0.6~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92a6104eb10f39c07bec43207182c9a84a6b9fe2;p=thirdparty%2Fbacula.git baculum: Add option to set job age for job status summary graph on dashboard page --- diff --git a/gui/baculum/protected/Web/JavaScript/statistics.js b/gui/baculum/protected/Web/JavaScript/statistics.js index 4e9ce7690..3861c40ae 100644 --- a/gui/baculum/protected/Web/JavaScript/statistics.js +++ b/gui/baculum/protected/Web/JavaScript/statistics.js @@ -7,7 +7,7 @@ var Statistics = { clients_occupancy: {}, pools_occupancy: {}, jobs_summary: [], - grab_statistics: function(data, jobstates) { + grab_statistics: function(data, opts) { this.jobs = data.jobs; this.clients = data.clients; this.pools = data.pools; @@ -25,7 +25,14 @@ var Statistics = { running: [] }; var status_type; + const start_time = new Date(Date.now() - (opts.job_age * 1000)); + const start_time_ts = start_time.getTime(); + let job_time_ts; for (var i = 0; i < jobs_count; i++) { + job_time_ts = iso_date_to_timestamp(this.jobs[i].starttime); + if (opts.job_age > 0 && job_time_ts < start_time_ts) { + continue; + } if (typeof(clients_occupancy[this.jobs[i].clientid]) === 'undefined') { clients_occupancy[this.jobs[i].clientid] = 1; } else { @@ -43,8 +50,8 @@ var Statistics = { } else { jobs_occupancy[this.jobs[i].name] += 1; } - if (jobstates.hasOwnProperty(this.jobs[i].jobstatus)) { - status_type = jobstates[this.jobs[i].jobstatus].type; + if (opts.job_states.hasOwnProperty(this.jobs[i].jobstatus)) { + status_type = opts.job_states[this.jobs[i].jobstatus].type; if (status_type == 'ok' && this.jobs[i].joberrors > 0) { status_type = 'warning'; } diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index cf15095c4..bfe392414 100644 Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/en/messages.po b/gui/baculum/protected/Web/Lang/en/messages.po index e63c6e0f2..ebe254a18 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -3949,3 +3949,12 @@ msgstr "From" msgid "To" msgstr "To" + +msgid "Job age on the job status graph" +msgstr "Job age on the job status graph" + +msgid "Set age for jobs to display the job summary pie graph on the dashboard page. Setting zero means displaying the graph for all jobs without limitation." +msgstr "Set age for jobs to display the job summary pie graph on the dashboard page. Setting zero means displaying the graph for all jobs without limitation." + +msgid "last %time %unit" +msgstr "last %time %unit" diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index 8a4545749..2b8a19c6c 100644 Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/ja/messages.po b/gui/baculum/protected/Web/Lang/ja/messages.po index a1c6dcd8b..937e470f8 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -4035,3 +4035,12 @@ msgstr "From" msgid "To" msgstr "To" + +msgid "Job age on the job status graph" +msgstr "Job age on the job status graph" + +msgid "Set age for jobs to display the job summary pie graph on the dashboard page. Setting zero means displaying the graph for all jobs without limitation." +msgstr "Set age for jobs to display the job summary pie graph on the dashboard page. Setting zero means displaying the graph for all jobs without limitation." + +msgid "last %time %unit" +msgstr "last %time %unit" diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index 0f9d64754..a0e3183e6 100644 Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pl/messages.po b/gui/baculum/protected/Web/Lang/pl/messages.po index ba0bef4ef..8b710a534 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -3959,3 +3959,12 @@ msgstr "From" msgid "To" msgstr "To" + +msgid "Job age on the job status graph" +msgstr "Job age on the job status graph" + +msgid "Set age for jobs to display the job summary pie graph on the dashboard page. Setting zero means displaying the graph for all jobs without limitation." +msgstr "Set age for jobs to display the job summary pie graph on the dashboard page. Setting zero means displaying the graph for all jobs without limitation." + +msgid "last %time %unit" +msgstr "last %time %unit" diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index 307aa5e93..e6a9184a4 100644 Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pt/messages.po b/gui/baculum/protected/Web/Lang/pt/messages.po index c77ed59f5..bab41feb7 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -3961,3 +3961,12 @@ msgstr "De" msgid "To" msgstr "Para" + +msgid "Job age on the job status graph" +msgstr "Job age on the job status graph" + +msgid "Set age for jobs to display the job summary pie graph on the dashboard page. Setting zero means displaying the graph for all jobs without limitation." +msgstr "Set age for jobs to display the job summary pie graph on the dashboard page. Setting zero means displaying the graph for all jobs without limitation." + +msgid "last %time %unit" +msgstr "last %time %unit" diff --git a/gui/baculum/protected/Web/Lang/ru/messages.mo b/gui/baculum/protected/Web/Lang/ru/messages.mo index c81500b89..c4a543f8f 100644 Binary files a/gui/baculum/protected/Web/Lang/ru/messages.mo and b/gui/baculum/protected/Web/Lang/ru/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/ru/messages.po b/gui/baculum/protected/Web/Lang/ru/messages.po index 24a08bd3e..ad1aad9a4 100644 --- a/gui/baculum/protected/Web/Lang/ru/messages.po +++ b/gui/baculum/protected/Web/Lang/ru/messages.po @@ -3960,3 +3960,12 @@ msgstr "От" msgid "To" msgstr "Кому" + +msgid "Job age on the job status graph" +msgstr "Job age on the job status graph" + +msgid "Set age for jobs to display the job summary pie graph on the dashboard page. Setting zero means displaying the graph for all jobs without limitation." +msgstr "Set age for jobs to display the job summary pie graph on the dashboard page. Setting zero means displaying the graph for all jobs without limitation." + +msgid "last %time %unit" +msgstr "last %time %unit" diff --git a/gui/baculum/protected/Web/Pages/ApplicationSettings.page b/gui/baculum/protected/Web/Pages/ApplicationSettings.page index 8f195b4db..7bf4aed33 100644 --- a/gui/baculum/protected/Web/Pages/ApplicationSettings.page +++ b/gui/baculum/protected/Web/Pages/ApplicationSettings.page @@ -9,8 +9,8 @@
-
<%[ Enable debug ]%>
-
+
<%[ Enable debug ]%>
+
-
<%[ Max. number of jobs visible in tables ]%>
-
+
<%[ Max. number of jobs visible in tables ]%>
+
-
<%[ Show size values as: ]%>
-
+
<%[ Show size values as: ]%>
+

-
<%[ Show time in job log: ]%>
-
+
<%[ Show time in job log: ]%>
+
-
<%[ Date and time format: ]%>
-
+
<%[ Date and time format: ]%>
+
-
<%[ Enable Bacula messages log window: ]%>
-
+
<%[ Enable Bacula messages log window: ]%>
+
+
+ +
DateTimeFormat->Text = WebConfig::DEF_DATE_TIME_FORMAT; } $this->EnableMessagesLog->Checked = $this->getModule('web_config')->isMessagesLogEnabled(); + if (key_exists('job_age_on_job_status_graph', $this->web_config['baculum'])) { + $this->JobAgeOnJobStatusGraph->setDirectiveValue($this->web_config['baculum']['job_age_on_job_status_graph']); + } else { + $this->JobAgeOnJobStatusGraph->setDirectiveValue(0); + } + $this->JobAgeOnJobStatusGraph->createDirective(); } } @@ -65,6 +71,7 @@ class ApplicationSettings extends BaculumWebPage { $this->web_config['baculum']['time_in_job_log'] = ($this->TimeInJobLog->Checked === true) ? 1 : 0; $this->web_config['baculum']['date_time_format'] = $this->DateTimeFormat->Text; $this->web_config['baculum']['enable_messages_log'] = ($this->EnableMessagesLog->Checked === true) ? 1 : 0; + $this->web_config['baculum']['job_age_on_job_status_graph'] = $this->JobAgeOnJobStatusGraph->getValue(); $this->getModule('web_config')->setConfig($this->web_config); } } diff --git a/gui/baculum/protected/Web/Pages/JobView.page b/gui/baculum/protected/Web/Pages/JobView.page index df2d17591..ff29b07f7 100644 --- a/gui/baculum/protected/Web/Pages/JobView.page +++ b/gui/baculum/protected/Web/Pages/JobView.page @@ -251,7 +251,10 @@ var oJobGraphs = { prepare_job_summary: function() { this.destroy_job_summary(); - Statistics.grab_statistics(oData, JobStatus.get_states()); + Statistics.grab_statistics(oData, { + job_states: JobStatus.get_states(), + job_age: 0 + }); this.graphs.job_summary = new GraphPieClass({ jobs: Statistics.jobs_summary, container_id: this.ids.jobs_summary_graph, diff --git a/gui/baculum/protected/Web/Portlets/DirectiveListTemplate.php b/gui/baculum/protected/Web/Portlets/DirectiveListTemplate.php index 1d1332cc9..fa2444768 100644 --- a/gui/baculum/protected/Web/Portlets/DirectiveListTemplate.php +++ b/gui/baculum/protected/Web/Portlets/DirectiveListTemplate.php @@ -47,6 +47,7 @@ class DirectiveListTemplate extends ConfigListTemplate implements IActiveControl const GROUP_NAME = 'GroupName'; const IS_DIRECTIVE_CREATED = 'IsDirectiveCreated'; const COPY_MODE = 'CopyMode'; + const DOC = 'Doc'; public $doc; @@ -76,7 +77,7 @@ class DirectiveListTemplate extends ConfigListTemplate implements IActiveControl if (!$this->getPage()->IsCallBack && !$this->getPage()->IsPostBack) { $this->display_directive = $this->getShow(); } - $this->setDoc(); + $this->createDoc(); } public function onLoad($param) { @@ -208,15 +209,28 @@ class DirectiveListTemplate extends ConfigListTemplate implements IActiveControl $this->setViewState(self::COPY_MODE, $copy_mode, false); } - public function setDoc() { - $component_type = $this->getComponentType(); - $resource_type = $this->getResourceType(); - $directive_name = $this->getDirectiveName(); - $this->doc = $this->Application->getModule('doc_dir')->getDoc( - $component_type, - $resource_type, - $directive_name - ); + public function createDoc() { + $doc = $this->getDoc(); + if (!empty($doc)) { + $this->doc = $doc; + } else { + $component_type = $this->getComponentType(); + $resource_type = $this->getResourceType(); + $directive_name = $this->getDirectiveName(); + $this->doc = $this->Application->getModule('doc_dir')->getDoc( + $component_type, + $resource_type, + $directive_name + ); + } + } + + public function setDoc($doc) { + $this->setViewState(self::DOC, $doc); + } + + public function getDoc() { + return $this->getViewState(self::DOC, ''); } } ?> diff --git a/gui/baculum/protected/Web/Portlets/DirectiveTemplate.php b/gui/baculum/protected/Web/Portlets/DirectiveTemplate.php index 315805834..7d25e5327 100644 --- a/gui/baculum/protected/Web/Portlets/DirectiveTemplate.php +++ b/gui/baculum/protected/Web/Portlets/DirectiveTemplate.php @@ -56,6 +56,7 @@ class DirectiveTemplate extends DirectiveControlTemplate implements IDirectiveFi const DISABLED = 'Disabled'; const SHOW_RESET_BUTTON = 'ShowResetButton'; const SHOW_REMOVE_BUTTON = 'ShowRemoveButton'; + const DOC = 'Doc'; public $doc; @@ -122,7 +123,7 @@ class DirectiveTemplate extends DirectiveControlTemplate implements IDirectiveFi $this->createDirective(); $this->setIsDirectiveCreated(true); $this->copyAttributes(); - $this->setDoc(); + $this->createDoc(); } // show directives existing in config or all @@ -327,15 +328,28 @@ class DirectiveTemplate extends DirectiveControlTemplate implements IDirectiveFi $this->setViewState(self::SHOW_REMOVE_BUTTON, $show); } - public function setDoc() { - $component_type = $this->getComponentType(); - $resource_type = $this->getResourceType(); - $directive_name = $this->getDirectiveName(); - $this->doc = $this->Application->getModule('doc_dir')->getDoc( - $component_type, - $resource_type, - $directive_name - ); + public function createDoc() { + $doc = $this->getDoc(); + if (!empty($doc)) { + $this->doc = $doc; + } else { + $component_type = $this->getComponentType(); + $resource_type = $this->getResourceType(); + $directive_name = $this->getDirectiveName(); + $this->doc = $this->Application->getModule('doc_dir')->getDoc( + $component_type, + $resource_type, + $directive_name + ); + } + } + + public function setDoc($doc) { + $this->setViewState(self::DOC, $doc); + } + + public function getDoc() { + return $this->getViewState(self::DOC, ''); } } ?> diff --git a/gui/baculum/protected/Web/Portlets/ResourceMonitor.php b/gui/baculum/protected/Web/Portlets/ResourceMonitor.php index deecb79a4..62ef659fa 100644 --- a/gui/baculum/protected/Web/Portlets/ResourceMonitor.php +++ b/gui/baculum/protected/Web/Portlets/ResourceMonitor.php @@ -30,4 +30,17 @@ Prado::using('Application.Web.Portlets.Portlets'); * @package Baculum Web */ class ResourceMonitor extends Portlets { + + public $job_age_on_job_status_graph = 0; + + public function onInit($param) { + if (get_class($this->Service->getRequestedPage()) == 'Dashboard') { + $web_config = $this->getModule('web_config')->getConfig(); + + // set job age for job status summary graph + if (isset($web_config['baculum']['job_age_on_job_status_graph'])) { + $this->job_age_on_job_status_graph = $web_config['baculum']['job_age_on_job_status_graph']; + } + } + } } diff --git a/gui/baculum/protected/Web/Portlets/ResourceMonitor.tpl b/gui/baculum/protected/Web/Portlets/ResourceMonitor.tpl index 7fa8defd4..b06ec80d3 100644 --- a/gui/baculum/protected/Web/Portlets/ResourceMonitor.tpl +++ b/gui/baculum/protected/Web/Portlets/ResourceMonitor.tpl @@ -30,9 +30,21 @@ $(function() { oData = response; if ('<%=get_class($this->Service->getRequestedPage())%>' == 'Dashboard') { - Statistics.grab_statistics(oData, JobStatus.get_states()); + const job_age_on_job_status_graph = <%=$this->job_age_on_job_status_graph%>; + Statistics.grab_statistics(oData, { + job_states: JobStatus.get_states(), + job_age: job_age_on_job_status_graph + }); + let age_label = ''; + if (job_age_on_job_status_graph > 0) { + const job_age = Units.format_time_period(job_age_on_job_status_graph); + const job_age_unit = job_age.format + (job_age.value > 1 ? 's' : ''); + const label_format = ' - <%[ last %time %unit ]%>'; + age_label = label_format.replace('%time', job_age.value); + age_label = age_label.replace('%unit', job_age_unit); + } Dashboard.set_text({ - js_sum_title: '<%[ Job status summary ]%>' + js_sum_title: '<%[ Job status summary ]%>' + age_label }); Dashboard.update_all(Statistics); }