]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Fix legend in job status pie chart on job view page
authorMarcin Haba <marcin.haba@bacula.pl>
Sat, 10 Jul 2021 13:45:09 +0000 (15:45 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:25 +0000 (09:03 +0100)
Also add filtering by job after clicking on chart parts

gui/baculum/protected/Web/JavaScript/misc.js
gui/baculum/protected/Web/Pages/JobHistoryList.page
gui/baculum/protected/Web/Pages/JobView.page

index bb2156b088fe753ea863003c4a4cab77117974b8..ad15369cb5b58d60b012c83313839d61468accc2 100644 (file)
@@ -267,7 +267,14 @@ var PieGraph  = {
                return false;
        },
        get_addr_by_type: function(type) {
-               return '/web/job/history/?type=' + type;
+               var job_regexp = new RegExp('/job/([^/?]+)/?');
+               var path = decodeURIComponent(window.location.pathname);
+               var result = job_regexp.exec(path);
+               var job = '';
+               if (result) {
+                       job = '&job=' + result[1];
+               }
+               return '/web/job/history/?type=' + type + job;
        }
 }
 
index 5df42fdd46b6855b5f037dd12f67ef3282d43c89..512c749daacc5dc907cc134fe7425f695e0dfb32 100644 (file)
@@ -485,6 +485,16 @@ var oJobHistoryList = {
                a.href = 'javascript:void(0)';
                a.addEventListener('click', function(e) {
                        $.fn.dataTable.ext.search.pop();
+
+                       // reset select filters
+                       this.table.columns().every(function() {
+                               var select = this.footer().querySelector('SELECT');
+                               if (select) {
+                                       select.value = '';
+                                       $(select).trigger('change');
+                               }
+                       })
+
                        this.table.columns().search('').draw();
                        container.style.display = 'none';
                }.bind(this));
@@ -536,6 +546,13 @@ var oJobHistoryList = {
                if (search_func) {
                        $.fn.dataTable.ext.search.push(search_func);
                        this.table.columns().search('').draw();
+                       var job = get_url_param('job');
+                       if (job) {
+                               // set job filter
+                               var select = this.table.column(2).footer().querySelector('SELECT');
+                               select.value = job;
+                               $(select).trigger('change');
+                       }
                        this.set_mode(type);
                        container.style.display = '';
                } else {
index 8b517223f5ec0d61ffe2c44e4d48c7755c671061..dc50c0b9fc3e24dca305f223e7fd0d7019a13798 100644 (file)
@@ -51,6 +51,7 @@
                <div id="job_graph_container">
                        <div>
                                <div id="jobs_summary_graph"></div>
+                               <div id="jobs_summary_legend"></div>
                        </div>
                        <div>
                                <div id="job_size_graph" style="height: 390px"></div>
@@ -63,6 +64,7 @@
 var oJobGraphs = {
        ids: {
                jobs_summary_graph : 'jobs_summary_graph',
+               jobs_summary_legend : 'jobs_summary_legend',
                job_size_graph : 'job_size_graph',
                job_files_graph : 'job_files_graph',
                job_actions: 'job_actions'
@@ -253,6 +255,7 @@ var oJobGraphs = {
                this.graphs.job_summary = new GraphPieClass({
                        jobs: Statistics.jobs_summary,
                        container_id: this.ids.jobs_summary_graph,
+                       legend_container_id: this.ids.jobs_summary_legend,
                        title: this.txt.job_summary.graph_title
                });
        },
@@ -348,7 +351,7 @@ var oJobGraphs = {
        },
        destroy_job_summary: function() {
                if (this.graphs.job_summary) {
-                       this.graphs.job_summary.pie.destroy();
+                       this.graphs.job_summary.destroy();
                }
        }
 };