]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add job status weather on job list page
authorMarcin Haba <marcin.haba@bacula.pl>
Sat, 30 Jan 2021 19:17:37 +0000 (20:17 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:24 +0000 (09:03 +0100)
14 files changed:
gui/baculum/protected/Web/JavaScript/misc.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/JobHistoryList.page
gui/baculum/protected/Web/Pages/JobList.page
gui/baculum/themes/Baculum-v2/css/baculum.css

index 516105e28e9a7041011961fc007f37682c26e8a0..ec5698e973542ee5a75e015dbf9788a60febb562 100644 (file)
@@ -920,6 +920,20 @@ var MsgEnvelope = {
        }
 };
 
+var Weather = {
+       icons: [
+               'weather_sunny.png',
+               'weather_sun_behind_small_cloud.png',
+               'weather_sun_behind_large_cloud.png',
+               'weather_sun_behind_rain_cloud.png',
+               'weather_cloud_with_rain.png',
+               'weather_cloud_with_lighting_and_rain.png'
+       ],
+       get_weather_icon(idx) {
+               return this.icons[idx];
+       }
+};
+
 var W3SideBar = {
        ids: {
                sidebar: 'sidebar',
index 8bcba4f1bbec9155f561289e03d910e76436f31b..cd34cb87e57df6f67e34fa908d35e3631ec42806 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 e8a00749473ac115a0e79e1d3bd0b5e1d15034a3..ad856d8decda16f2834d1bf178c627e2a3120bd0 100644 (file)
@@ -3202,3 +3202,9 @@ msgstr "Truncate log"
 
 msgid "Messages"
 msgstr "Messages"
+
+msgid "Last %errors/%count jobs finished with error."
+msgstr "Last %errors/%count jobs finished with error."
+
+msgid "All last %count jobs finished successfully."
+msgstr "All last %count jobs finished successfully."
index 2f9f65b36039b652fcfaa1fcaad3bba920c3cd66..fa72c70d854ff8fa0c41db89f2bcf66b2d14567d 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 3f40e3251ea8b22ece6ef025ef679e6cd7bdfd85..f69f6561ee73ae6a58660b278adf9ee803ee90c5 100644 (file)
@@ -3288,3 +3288,9 @@ msgstr "Truncate log"
 
 msgid "Messages"
 msgstr "Messages"
+
+msgid "Last %errors/%count jobs finished with error."
+msgstr "Last %errors/%count jobs finished with error."
+
+msgid "All last %count jobs finished successfully."
+msgstr "All last %count jobs finished successfully."
index 781cd396bc72d9e9e4452a63e447766a6288d92c..ea8e492e12bb352f841c239cd195c91dafc5548d 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 132a3c4736b83c8586805eaab670437ebc30a58e..7d77e9985eebb1295a3b8c9ca7286b95711350ed 100644 (file)
@@ -3213,3 +3213,9 @@ msgstr "Przytnij dziennik"
 
 msgid "Messages"
 msgstr "Wiadomości"
+
+msgid "Last %errors/%count jobs finished with error."
+msgstr "Ostatnie %errors/%count zadań zakończyło się błędem."
+
+msgid "All last %count jobs finished successfully."
+msgstr "Wszystkie ostatnie %count zadań zakończyło się pomyślnie."
index c06cc1ad901764129d5c69307ce999f2f3882728..02b84df54a6c8ef60f5fb6ed1fc6be3fef37361a 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 e5f77bb314ea833f6805e964a79653d18586fec9..29e76371cb37fa6cfd7209005a8a9ade81df6c0e 100644 (file)
@@ -3212,3 +3212,9 @@ msgstr "Truncate log"
 
 msgid "Messages"
 msgstr "Messages"
+
+msgid "Last %errors/%count jobs finished with error."
+msgstr "Last %errors/%count jobs finished with error."
+
+msgid "All last %count jobs finished successfully."
+msgstr "All last %count jobs finished successfully."
index 3fb88d8f1923be4f33b6e1940afa1e21e6ff2e75..128d8f25717c6a4d6a6ff2a9727360f17044912b 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 3f0e3276239c1c17fa21af6c380fdddb4136107e..b47763d690b68563c9a6135c8009bd9848de00e4 100644 (file)
@@ -3212,3 +3212,9 @@ msgstr "Truncate log"
 
 msgid "Messages"
 msgstr "Messages"
+
+msgid "Last %errors/%count jobs finished with error."
+msgstr "Last %errors/%count jobs finished with error."
+
+msgid "All last %count jobs finished successfully."
+msgstr "All last %count jobs finished successfully."
index e2f30d7c80f766d14f1a855bc686349906d6b224..5e3d8cf3fa80b1101bb23c7f1c830870b0aea73d 100644 (file)
@@ -149,7 +149,7 @@ function hide_btn_loader(jobid) {
        }
 }
 
-var oJobList = {
+var oJobHistoryList = {
        table: null,
        table_toolbar: null,
        actions: [
@@ -469,7 +469,7 @@ var oJobList = {
 };
 MonitorParams = {jobs: null};
 $(function() {
-       MonitorCallsInterval.push(function() { oJobList.init(); });
+       MonitorCallsInterval.push(function() { oJobHistoryList.init(); });
 });
 
 /**
@@ -496,7 +496,7 @@ var bulk_actions_output_id = '<%=$this->SourceTemplateControl->BulkActions->Bulk
        </prop:ClientSide.OnLoading>
        <prop:ClientSide.OnComplete>
                oBulkActionsModal.show_loader(false);
-               oJobList.table_toolbar.style.display = 'none';
+               oJobHistoryList.table_toolbar.style.display = 'none';
                oMonitor();
        </prop:ClientSide.OnComplete>
 </com:TCallback>
index 180142230ce482e19cb71246746d67181316b898..9973ae4fabcb850bd972b1e240dc02405f71c9d3 100644 (file)
@@ -22,6 +22,7 @@
                        <thead>
                                <tr>
                                        <th></th>
+                                       <th><%[ Status ]%></th>
                                        <th><%[ Name ]%></th>
                                        <th><%[ Director ]%></th>
                                        <th><%[ Actions ]%></th>
@@ -31,6 +32,7 @@
                        <tfoot>
                                <tr>
                                        <th></th>
+                                       <th><%[ Status ]%></th>
                                        <th><%[ Name ]%></th>
                                        <th><%[ Director ]%></th>
                                        <th><%[ Actions ]%></th>
        </div>
        <com:Application.Web.Portlets.RunJob ID="RunJobModal" />
 <script type="text/javascript">
-var oJobHistoryList = {
+var oJobList = {
        ids: {
                job_history_list: 'job_history_list',
                job_history_list_body: 'job_history_list_body'
        },
+       css: {
+               weather_icon: 'job_weather_icon'
+       },
+       table: null,
+       job_weather: {},
        init: function() {
                this.set_table();
        },
        set_table: function() {
-               var table = $('#' + this.ids.job_history_list).DataTable({
+               this.table = $('#' + this.ids.job_history_list).DataTable({
                        data: <%=json_encode($this->jobs)%>,
                        deferRender: true,
                        dom: 'lBfrtip',
@@ -64,11 +71,42 @@ var oJobHistoryList = {
                                        data: null,
                                        defaultContent: '<button type="button" class="w3-button w3-blue"><i class="fa fa-angle-down"></i></button>'
                                },
+                               {
+                                       data: 'job',
+                                       render: function(data, type, row) {
+                                               var ret = '';
+                                               if (Object.keys(this.job_weather).length > 0) {
+                                                       if (type == 'display' || type == 'filter') {
+                                                               if (!this.job_weather.hasOwnProperty(data)) {
+                                                                       // for jobs that haven't been never running
+                                                                       this.job_weather[data] = {count: 0, error: 0};
+                                                               }
+                                                               var icon = Weather.get_weather_icon(this.job_weather[data].error);
+                                                               var img = document.createElement('IMG');
+                                                               img.src = '<%=$this->getPage()->getTheme()->getBaseUrl()%>/' + icon;
+                                                               img.className = this.css.weather_icon;
+                                                               var title;
+                                                               if (this.job_weather[data].error > 0) {
+                                                                       title = '<%[ Last %errors/%count jobs finished with error. ]%>';
+                                                               } else {
+                                                                       title = '<%[ All last %count jobs finished successfully. ]%>';
+                                                               }
+                                                               title = title.replace('%errors', this.job_weather[data].error);
+                                                               title = title.replace('%count', this.job_weather[data].count);
+                                                               img.title = title;
+                                                               ret = img.outerHTML;
+                                                       } else if (type == 'sort') {
+                                                               ret = this.job_weather[data].error;
+                                                       }
+                                               }
+                                               return ret;
+                                       }.bind(this)
+                               },
                                {data: 'job'},
                                {data: 'director'},
                                {
                                        data: 'job',
-                                       render: function (data, type, row) {
+                                       render: function(data, type, row) {
                                                var btn = document.createElement('BUTTON');
                                                btn.className = 'w3-button w3-green';
                                                btn.type = 'button';
@@ -95,11 +133,11 @@ var oJobHistoryList = {
                        },
                        {
                                className: "dt-center",
-                               targets: [ 3 ]
+                               targets: [ 4 ]
                        }],
-                       order: [1, 'asc'],
+                       order: [2, 'asc'],
                        initComplete: function () {
-                               this.api().columns([1, 2]).every(function () {
+                               this.api().columns([2, 3]).every(function () {
                                        var column = this;
                                        var select = $('<select><option value=""></option></select>')
                                        .appendTo($(column.footer()).empty())
@@ -121,8 +159,29 @@ var oJobHistoryList = {
                                });
                        }
                });
+       },
+       set_weather: function() {
+               var jobs = oData.terminated_jobs;
+               var jobs_len = jobs.length;
+               for (var i = 0; i < jobs_len; i++) {
+                       if (!this.job_weather.hasOwnProperty(jobs[i].name)) {
+                               this.job_weather[jobs[i].name] = {count: 0, error: 0};
+                       }
+                       if (this.job_weather[jobs[i].name].count >= 5) {
+                               continue;
+                       }
+                       this.job_weather[jobs[i].name].count++;
+                       if (JobStatus.is_error(jobs[i].jobstatus)) {
+                               this.job_weather[jobs[i].name].error++;
+                       }
+               }
+               this.table.rows().invalidate('data').draw(false);
        }
 };
-oJobHistoryList.init();
+oJobList.init();
+MonitorParams = {jobs: null};
+$(function() {
+       MonitorCalls.push(oJobList.set_weather.bind(oJobList));
+});
 </script>
 </com:TContent>
index 38ad6a4dd8926eb409166b543eb258ecea3eeab4..c9bf052dd870ead1184d607a47b4c313aa69b631 100644 (file)
@@ -526,3 +526,11 @@ table.component td:nth-of-type(1) {
 .blink {
   animation: blinker 4s linear infinite;
 }
+
+img.job_weather_icon {
+       display: block;
+       margin: 0 auto;
+       height: 32px;
+       width: 32px;
+       cursor: help;
+}