]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Make job status pie chart clickable and direct to job history page with...
authorMarcin Haba <marcin.haba@bacula.pl>
Thu, 8 Jul 2021 18:52:23 +0000 (20:52 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:25 +0000 (09:03 +0100)
16 files changed:
gui/baculum/protected/Web/JavaScript/graph.js
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/Layouts/Main.tpl
gui/baculum/protected/Web/Pages/Dashboard.page
gui/baculum/protected/Web/Pages/JobHistoryList.page
gui/baculum/themes/Baculum-v2/css/baculum.css

index e4655ea6f89231217e43a56ea822d74048c997b1..3928c06102f2a169ca32fd44ecfe609c865b7de9 100644 (file)
@@ -1247,7 +1247,7 @@ var GraphPieClass = jQuery.klass({
                        outlineWidth: 0,
                        color: 'black'
                },
-               xaxis: { showLabels : false,},
+               xaxis: { showLabels : false },
                yaxis: { showLabels : false },
                pie: {
                        show : true,
@@ -1263,15 +1263,18 @@ var GraphPieClass = jQuery.klass({
                        position : 'sw'
                },
                legend: {
+                       noColumns: 3,
                        position : 'se',
                        backgroundColor : '#D2E8FF',
-                       margin: 0
+                       margin: 0,
+                       labelFormatter: PieGraph.pie_legend_formatter.bind(PieGraph)
                }
        },
        initialize: function(prop) {
                this.jobs = prop.jobs;
                this.title = prop.hasOwnProperty('title') ? prop.title : null;
                this.container = document.getElementById(prop.container_id);
+               this.legend_container = prop.hasOwnProperty('legend_container_id') ? $('#' + prop.legend_container_id) : null;
                this.series = this.prepare_series();
                this.draw_grah();
        },
@@ -1299,7 +1302,15 @@ var GraphPieClass = jQuery.klass({
                if (this.title) {
                        graph_options.title = this.title;
                }
+               if (this.legend_container) {
+                       graph_options.legend.container = this.legend_container;
+               }
                this.pie = Flotr.draw(this.container, this.series, graph_options);
+               Flotr.EventAdapter.observe(this.container, 'flotr:click', PieGraph.pie_mouse_handler.bind(PieGraph));
+       },
+       destroy: function() {
+               Flotr.EventAdapter.stopObserving(this.container, 'flotr:click');
+               this.pie.destroy();
        }
 });
 
index e11b6e5f4759ac1b593a38ce4f411483d123cae4..49f505936e750681b4ce1c8bdf76b79d8faa9930 100644 (file)
@@ -251,6 +251,23 @@ var PieGraph  = {
        },
        pie_track_formatter: function(e) {
                return e.series.label;
+       },
+       pie_legend_formatter: function(label) {
+               var type = label.split(' ')[0];
+               var a = document.createElement('A');
+               a.href = this.get_addr_by_type(type);
+               a.className = 'raw';
+               text = document.createTextNode(label);
+               a.appendChild(text);
+               return a.outerHTML;
+       },
+       pie_mouse_handler: function(e) {
+               var type = e.hit.series.label.split(' ')[0];
+               window.location.href = this.get_addr_by_type(type);
+               return false;
+       },
+       get_addr_by_type: function(type) {
+               return '/web/job/history/?type=' + type;
        }
 }
 
@@ -792,6 +809,7 @@ var Dashboard = {
        stats: null,
        txt: null,
        pie: null,
+       txt: null,
        noval: '-',
        ids: {
                clients: {
@@ -817,7 +835,10 @@ var Dashboard = {
                        most: 'pool_most',
                        jobs: 'pool_jobs'
                },
-               pie_summary: 'jobs_summary_graph'
+               pie_summary: {
+                       container_id: 'jobs_summary_graph',
+                       legend_container_id: 'jobs_summary_legend'
+               }
        },
        last_jobs_table: null,
        dbtype: {
@@ -825,6 +846,9 @@ var Dashboard = {
                mysql: 'MySQL',
                sqlite: 'SQLite'
        },
+       set_text: function(txt) {
+               this.txt = txt;
+       },
        update_all: function(statistics) {
                this.stats = statistics;
                this.update_pie_jobstatus();
@@ -912,11 +936,13 @@ var Dashboard = {
        },
        update_pie_jobstatus: function() {
                if (this.pie != null) {
-                       this.pie.pie.destroy();
+                       this.pie.destroy();
                }
                this.pie = new GraphPieClass({
                        jobs: this.stats.jobs_summary,
-                       container_id: this.ids.pie_summary
+                       container_id: this.ids.pie_summary.container_id,
+                       legend_container_id: this.ids.pie_summary.legend_container_id,
+                       title: this.txt.js_sum_title
                });
        }
 };
index aedf50ac247098fc0ab4b84192f24238da51267a..741e68b627776cb6e7c32b237f26e0033de5bfca 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 0932befe9730a32a768b12cc53133421dac31bc0..cfe53407db4449af621e6bd378b6661f4e3bd59e 100644 (file)
@@ -3397,3 +3397,24 @@ msgstr "Console details"
 
 msgid "Configure console"
 msgstr "Configure console"
+
+msgid "Mode:"
+msgstr "Mode:"
+
+msgid "Reset table mode"
+msgstr "Reset table mode"
+
+msgid "Jobs terminated normally"
+msgstr "Jobs terminated normally"
+
+msgid "Jobs with warning"
+msgstr "Jobs with warning"
+
+msgid "Jobs finished with error"
+msgstr "Jobs finished with error"
+
+msgid "Jobs running"
+msgstr "Jobs running"
+
+msgid "Jobs canceled"
+msgstr "Jobs canceled"
index e3c3064bc97c9331bee5fb2999e7ef701cfb4003..1e93d2ca56f307febf5419eef264035a01146443 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 d639c1fa6df2de9bba40be5a53957ddb9cace3d7..2aa489a0b3ac1183d25c419614c8a096d002c97a 100644 (file)
@@ -3483,3 +3483,24 @@ msgstr "Console details"
 
 msgid "Configure console"
 msgstr "Configure console"
+
+msgid "Mode:"
+msgstr "Mode:"
+
+msgid "Reset table mode"
+msgstr "Reset table mode"
+
+msgid "Jobs terminated normally"
+msgstr "Jobs terminated normally"
+
+msgid "Jobs with warning"
+msgstr "Jobs with warning"
+
+msgid "Jobs finished with error"
+msgstr "Jobs finished with error"
+
+msgid "Jobs running"
+msgstr "Jobs running"
+
+msgid "Jobs canceled"
+msgstr "Jobs canceled"
index d236c6683624f836e4a40923739af9bcb3657df5..0f1329e8467cd7c073815af3b43cae0d7293f689 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 8ad4d3ca671f3b75250ef346d03b98af6cdd7395..284a0a93e925f724658068f876bd3725093e1915 100644 (file)
@@ -3407,3 +3407,24 @@ msgstr "Szczegóły konsoli"
 
 msgid "Configure console"
 msgstr "Konfiguruj konsolę"
+
+msgid "Mode:"
+msgstr "Tryb:"
+
+msgid "Reset table mode"
+msgstr "Resetuj tryb tabeli"
+
+msgid "Jobs terminated normally"
+msgstr "Zadania zakończone normalnie"
+
+msgid "Jobs with warning"
+msgstr "Zadania z ostrzeżeniami"
+
+msgid "Jobs finished with error"
+msgstr "Zadania zakończone z błędem"
+
+msgid "Jobs running"
+msgstr "Zadania uruchomione"
+
+msgid "Jobs canceled"
+msgstr "Zadania anulowane"
index d688921473b4a9487d84fbf0e8b22c6c68e179df..464bbd021241c7f521b8b0ea92cdda0fc909745b 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 b541ae36048e426966a0fcd207820b760f5e69c9..c29be76d8d6351ae53cd241e60d394a53af133c9 100644 (file)
@@ -3408,3 +3408,23 @@ msgstr "Detalhes do console"
 msgid "Configure console"
 msgstr "Configurar console"
 
+msgid "Mode:"
+msgstr "Mode:"
+
+msgid "Reset table mode"
+msgstr "Reset table mode"
+
+msgid "Jobs terminated normally"
+msgstr "Jobs terminated normally"
+
+msgid "Jobs with warning"
+msgstr "Jobs with warning"
+
+msgid "Jobs finished with error"
+msgstr "Jobs finished with error"
+
+msgid "Jobs running"
+msgstr "Jobs running"
+
+msgid "Jobs canceled"
+msgstr "Jobs canceled"
index 445a72cdaf28d568ab5db58b2a4e6dea8f3896d9..daf5f1346399cf4a1c0acea16fda5c47523ade08 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 d613c169dc7a8e7ef3c0a1c8f8582043ff8c87dd..2e813ffa7c96cb0da95430837e50a250f4efd5ae 100644 (file)
@@ -3399,6 +3399,26 @@ msgstr "Графический статус клиента поддержива
 msgid "Status request timed out. The most probably the Bacula director is not available or it is not running."
 msgstr "Истекло время ожидания запроса. Вероятно, клиент Bacula не доступен или не запущен."
 
+msgid "Mode:"
+msgstr "Mode:"
+
+msgid "Reset table mode"
+msgstr "Reset table mode"
+
+msgid "Jobs terminated normally"
+msgstr "Jobs terminated normally"
+
+msgid "Jobs with warning"
+msgstr "Jobs with warning"
+
+msgid "Jobs finished with error"
+msgstr "Jobs finished with error"
+
+msgid "Jobs running"
+msgstr "Jobs running"
+
+msgid "Jobs canceled"
+msgstr "Jobs canceled"
 msgid "To use the console page please configure bbconsjson binary file path on the API side."
 msgstr "Чтобы использовать страницу консоли, настройте путь к бинарным файлам bbconsjson на стороне API."
 
index 2bc50e70dda0edf8731dbe44be7c31ffd78ebdff..6dec2ea794348be25cc9d0d0808162f06c4195b5 100644 (file)
@@ -113,6 +113,9 @@ $(function() {
                                oData = response;
                                if ('<%=get_class($this->Service->getRequestedPage())%>' == 'Dashboard') {
                                        Statistics.grab_statistics(oData, JobStatus.get_states());
+                                       Dashboard.set_text({
+                                               js_sum_title: '<%[ Job status summary ]%>'
+                                       });
                                        Dashboard.update_all(Statistics);
                                }
 
index b2dea844d69071be2e867fb761d7fca658ac3d41..af7d017b361db19a84bdf928dd0540d080f67296 100644 (file)
@@ -63,9 +63,9 @@
        <div class="w3-panel">
                <div class="w3-row-padding" style="margin:0 -16px">
                        <div class="w3-third">
-                               <h5><%[ Job status summary ]%></h5>
                                <div class="dashboard_graph">
                                        <div id="jobs_summary_graph"></div>
+                                       <div id="jobs_summary_legend"></div>
                                </div>
                                <div class="w3-card-4 w3-padding-16 w3-margin-top w3-margin-bottom">
                                        <header class="w3-container w3-light-grey w3-half w3-left">
index 36110e23f9a33fd7b659e2bb7ca649b599883808..5df42fdd46b6855b5f037dd12f67ef3282d43c89 100644 (file)
@@ -189,7 +189,8 @@ var oJobHistoryList = {
        ],
        ids: {
                job_list: 'job_list',
-               job_list_body: 'job_list_body'
+               job_list_body: 'job_list_body',
+               table_mode: 'table_mode'
        },
        data: [],
        table: null,
@@ -201,6 +202,7 @@ var oJobHistoryList = {
                        this.set_table();
                        this.set_bulk_actions();
                        this.set_events();
+                       this.set_filters();
                }
        },
        set_events: function() {
@@ -221,7 +223,7 @@ var oJobHistoryList = {
                this.table = $('#' + this.ids.job_list).DataTable({
                        data: this.data,
                        deferRender: true,
-                       dom: 'lB<"table_toolbar">frtip',
+                       dom: 'lB<"table_toolbar"><"#table_mode">frtip',
                        stateSave: true,
                        buttons: [
                                'copy', 'csv', 'colvis'
@@ -439,7 +441,7 @@ var oJobHistoryList = {
                                                .search(val ? '^' + val + '$' : '', true, false)
                                                .draw();
                                        });
-                                       if (column[0][0] == 14) {
+                                       if (column[0][0] == 14) { // NOTE: this column is used also in filters (@see oJobHistoryList.set_mode())
                                                column.data().unique().sort().each(function (d, j) {
                                                        if (column.search() == '^' + dtEscapeRegex(d) + '$') {
                                                                select.append('<option value="' + d + '" title="' + JobStatus.get_desc(d) + '" selected>' + d + '</option>');
@@ -465,6 +467,80 @@ var oJobHistoryList = {
                        actions: '<%[ Actions ]%>',
                        ok: '<%[ OK ]%>'
                });
+       },
+       set_mode: function(type) {
+               var types = {
+                       ok: '<%[ Jobs terminated normally ]%>',
+                       warning: '<%[ Jobs with warning ]%>',
+                       error: '<%[ Jobs finished with error ]%>',
+                       running: '<%[ Jobs running ]%>',
+                       cancel: '<%[ Jobs canceled ]%>'
+               }
+               var container = document.getElementById(this.ids.table_mode);
+               var mode = document.createTextNode(' <%[ Mode: ]%> ' + types[type] + ' ');
+               container.appendChild(mode);
+               var label = document.createTextNode(' <%[ Reset table mode ]%>');
+               var a = document.createElement('A');
+               a.className = 'w3-button w3-green';
+               a.href = 'javascript:void(0)';
+               a.addEventListener('click', function(e) {
+                       $.fn.dataTable.ext.search.pop();
+                       this.table.columns().search('').draw();
+                       container.style.display = 'none';
+               }.bind(this));
+               var img = document.createElement('I');
+               img.className = 'fas fa-sync-alt';
+               a.appendChild(img);
+               a.appendChild(label);
+               container.appendChild(a);
+       },
+       set_filters: function() {
+               var jss = '';
+               var type = get_url_param('type');
+               var search_func;
+               switch (type) {
+                       case 'ok':
+                               search_func = function(settings, search_data, index, row_data, counter) {
+                                       var jobstatus = search_data[14];
+                                       var joberrors = search_data[18];
+                                       return (JobStatus.is_ok(jobstatus) && joberrors == 0);
+                               };
+                       break;
+                       case 'error':
+                               search_func = function(settings, search_data, index, row_data, counter) {
+                                       var jobstatus = search_data[14];
+                                       return JobStatus.is_error(jobstatus);
+                               };
+                       break;
+                       case 'warning':
+                               search_func = function(settings, search_data, index, row_data, counter) {
+                                       var jobstatus = search_data[14];
+                                       var joberrors = search_data[18];
+                                       return ((JobStatus.is_ok(jobstatus) && joberrors > 0) || JobStatus.is_warning(jobstatus));
+                               };
+                       break;
+                       case 'cancel':
+                               search_func = function(settings, search_data, index, row_data, counter) {
+                                       var jobstatus = search_data[14];
+                                       return JobStatus.is_cancel(jobstatus);
+                               };
+                       break;
+                       case 'running':
+                               search_func = function(settings, search_data, index, row_data, counter) {
+                                       var jobstatus = search_data[14];
+                                       return (JobStatus.is_running(jobstatus) || JobStatus.is_waiting(jobstatus));
+                               };
+                       break;
+               }
+               var container = document.getElementById(this.ids.table_mode);
+               if (search_func) {
+                       $.fn.dataTable.ext.search.push(search_func);
+                       this.table.columns().search('').draw();
+                       this.set_mode(type);
+                       container.style.display = '';
+               } else {
+                       container.style.display = 'none';
+               }
        }
 };
 MonitorParams = {jobs: null};
index 4eb40e2d6011954365b917c288c021b11e24adf9..ed38aeff4c3cb13ae48edd5ed3f03dd5011e59ff 100644 (file)
@@ -6,6 +6,7 @@
 #jobs_summary_graph {
        height: 380px;
        z-index: 0;
+       cursor: pointer;
 }
 
 .monospace {