]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add option to set job age for job status summary graph on dashboard page
authorMarcin Haba <marcin.haba@bacula.pl>
Thu, 17 Feb 2022 06:52:54 +0000 (07:52 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Thu, 17 Feb 2022 06:52:54 +0000 (07:52 +0100)
18 files changed:
gui/baculum/protected/Web/JavaScript/statistics.js
gui/baculum/protected/Web/Lang/en/messages.mo
gui/baculum/protected/Web/Lang/en/messages.po
gui/baculum/protected/Web/Lang/ja/messages.mo
gui/baculum/protected/Web/Lang/ja/messages.po
gui/baculum/protected/Web/Lang/pl/messages.mo
gui/baculum/protected/Web/Lang/pl/messages.po
gui/baculum/protected/Web/Lang/pt/messages.mo
gui/baculum/protected/Web/Lang/pt/messages.po
gui/baculum/protected/Web/Lang/ru/messages.mo
gui/baculum/protected/Web/Lang/ru/messages.po
gui/baculum/protected/Web/Pages/ApplicationSettings.page
gui/baculum/protected/Web/Pages/ApplicationSettings.php
gui/baculum/protected/Web/Pages/JobView.page
gui/baculum/protected/Web/Portlets/DirectiveListTemplate.php
gui/baculum/protected/Web/Portlets/DirectiveTemplate.php
gui/baculum/protected/Web/Portlets/ResourceMonitor.php
gui/baculum/protected/Web/Portlets/ResourceMonitor.tpl

index 4e9ce7690d0c71ddbd78441d6c61cc487e8f5e47..3861c40ae650e363ec2a34b6639af12ced5e45d6 100644 (file)
@@ -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';
                                }
index cf15095c4bf069cc68f7852be635d5c590032d4f..bfe392414a6855ba2fe57a19839d75432a3876ca 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ
index e63c6e0f29dc1d2d852c7d86216cf8d0d0dc8a15..ebe254a18b41b82af61a8227e99cc3a7b13a1b44 100644 (file)
@@ -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"
index 8a4545749e5e0112714f545a71dcbc3ad6a24b03..2b8a19c6cfba9b3af16b5c360ed19cb66a4ce250 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ
index a1c6dcd8b92afe82053c5ea0a3111b3cff35d907..937e470f8eaede59d2d0dc158476a8aa27583897 100644 (file)
@@ -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"
index 0f9d6475459b5460bc786cff06ccbab18bc1bd36..a0e3183e6f26f7bc20328414565030ea52fb10aa 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ
index ba0bef4ef265184cd98c4b3830f1f46c1afa3ae0..8b710a5347a233a337df38403fa70a5b095c5ec4 100644 (file)
@@ -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"
index 307aa5e932808a572a576daac8f916704f08fcd0..e6a9184a494e864a9ea224d84d9f3bb7e1b57761 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ
index c77ed59f5f2a0b8942a7088326a1d62c2a88ed61..bab41feb7320916f35bf0cb5c881c8ceb7eb9451 100644 (file)
@@ -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"
index c81500b89dd9f6d1e3e264e7bda6850e5f59323b..c4a543f8fe89d59a865c77121d5bd8cb1a33fa1f 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ru/messages.mo and b/gui/baculum/protected/Web/Lang/ru/messages.mo differ
index 24a08bd3ebba36aa23a5263d2cc7a05a55cc0866..ad1aad9a458b51b14b4accb45ea554f2cff43654 100644 (file)
@@ -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"
index 8f195b4dbe95b8bd822090bcc6b1d10abfc56bb1..7bf4aed33241809d597638034756b4cb94ff788f 100644 (file)
@@ -9,8 +9,8 @@
                </h5>
        </header>
        <div class="w3-container w3-row w3-padding">
-               <div class="w3-third w3-col"><%[ Enable debug ]%></div>
-               <div class="w3-third w3-col">
+               <div class="w3-quarter w3-col"><%[ Enable debug ]%></div>
+               <div class="w3-quarter w3-col">
                        <com:TCheckBox
                                ID="Debug"
                                CssClass="w3-check"
@@ -19,8 +19,8 @@
                </div>
        </div>
        <div class="w3-container w3-row w3-padding">
-               <div class="w3-third w3-col"><%[ Max. number of jobs visible in tables ]%></div>
-               <div class="w3-third w3-col">
+               <div class="w3-quarter w3-col"><%[ Max. number of jobs visible in tables ]%></div>
+               <div class="w3-quarter w3-col">
                        <com:TTextBox
                                ID="MaxJobs"
                                CssClass="w3-input w3-border w3-show-inline-block"
@@ -46,8 +46,8 @@
                </div>
        </div>
        <div class="w3-container w3-row w3-padding">
-               <div class="w3-third w3-col"><%[ Show size values as: ]%></div>
-               <div class="w3-third w3-col">
+               <div class="w3-quarter w3-col"><%[ Show size values as: ]%></div>
+               <div class="w3-quarter w3-col">
                        <p><com:TRadioButton
                                ID="DecimalBytes"
                                CssClass="w3-radio"
@@ -62,8 +62,8 @@
                </div>
        </div>
        <div class="w3-container w3-row w3-padding">
-               <div class="w3-third w3-col"><%[ Show time in job log: ]%></div>
-               <div class="w3-third w3-col">
+               <div class="w3-quarter w3-col"><%[ Show time in job log: ]%></div>
+               <div class="w3-quarter w3-col">
                        <com:TCheckBox
                                ID="TimeInJobLog"
                                CssClass="w3-check"
@@ -71,8 +71,8 @@
                </div>
        </div>
        <div class="w3-container w3-row w3-padding">
-               <div class="w3-third w3-col"><%[ Date and time format: ]%></div>
-               <div class="w3-third w3-col">
+               <div class="w3-quarter w3-col"><%[ Date and time format: ]%></div>
+               <div class="w3-quarter w3-col">
                        <com:TTextBox
                                ID="DateTimeFormat"
                                CssClass="w3-input w3-border w3-show-inline-block"
                </script>
        </div>
        <div class="w3-container w3-row w3-padding">
-               <div class="w3-third w3-col"><%[ Enable Bacula messages log window: ]%></div>
-               <div class="w3-third w3-col">
+               <div class="w3-quarter w3-col"><%[ Enable Bacula messages log window: ]%></div>
+               <div class="w3-quarter w3-col">
                        <com:TCheckBox
                                ID="EnableMessagesLog"
                                CssClass="w3-check"
                        </div>
                </div>
        </div>
+       <div class="w3-container w3-row w3-padding">
+               <com:Application.Web.Portlets.DirectiveTimePeriod
+                       ID="JobAgeOnJobStatusGraph"
+                       DirectiveName="Age"
+                       Label="<%[ Job age on the job status graph ]%>"
+                       Show="true"
+                       Required="false"
+                       ShowResetButton="false"
+                       ShowRemoveButton="false"
+                       TimeFormat="hour"
+                       Doc="<%[ 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. ]%>"
+               />
+       </div>
        <div class="w3-center">
                <com:TActiveLinkButton
                        CssClass="w3-button w3-green"
index 76fbc34cc7107c736ea6bf8f2690a75f9aa03756..133267b4ec6afcba3e1051093fc684c89b254a5b 100644 (file)
@@ -52,6 +52,12 @@ class ApplicationSettings extends BaculumWebPage {
                                $this->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);
                }
        }
index df2d17591db14a26c9ebbbec3aba912a58e90e30..ff29b07f7b6a67cb20aa0721f9017ddad9d62efe 100644 (file)
@@ -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,
index 1d1332cc9b495f935249cb81047eefe02076345f..fa24447684388eed2fd25da1cdcf4a24f70c4dd5 100644 (file)
@@ -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, '');
        }
 }
 ?>
index 3158058341049df02685ba8a89091d90d295e38d..7d25e5327bc4ba67ef6e6cd094903eb510b08316 100644 (file)
@@ -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, '');
        }
 }
 ?>
index deecb79a4971500a056fb0ac93b46caa86572221..62ef659fa196704e61b5bc81b5d870be089275d2 100644 (file)
@@ -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'];
+                       }
+               }
+       }
 }
index 7fa8defd495f20c48a760e544cd74932476fe501..b06ec80d38dc159aad65bd98b188c6f337b4f61b 100644 (file)
@@ -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);
                                }