]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Implement second part ideas and fixes proposed by Wanderlei Huttel
authorMarcin Haba <marcin.haba@bacula.pl>
Thu, 2 Aug 2018 19:03:44 +0000 (21:03 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Thu, 2 Aug 2018 19:08:32 +0000 (21:08 +0200)
1) Fix last 10 job table on mobile devices
2) Show/hide responsive button only when it is needed on:
  - Volumes in pool page
  - Jobs for Client page
  - Jobs on volume page
3) Fix support for compression "Gzip" value in FileSet resource

gui/baculum/protected/Web/Data/data_desc.json
gui/baculum/protected/Web/JavaScript/misc.js
gui/baculum/protected/Web/Pages/ClientView.page
gui/baculum/protected/Web/Pages/Dashboard.page
gui/baculum/protected/Web/Pages/PoolView.page
gui/baculum/protected/Web/Pages/VolumeView.page
gui/baculum/themes/Baculum-v2/css/baculum.css

index 11a092d5b33bbed479959867cb7d8af9ebe7587c..afbc5276b911c43cc6fe70118bb3a62a84d00629 100644 (file)
                                                "ValueType": "str",
                                                "DefaultValue": 0,
                                                "FieldType": "ComboBox",
-                                               "Data": ["Gzip1", "Gzip2", "Gzip3", "Gzip4", "Gzip5", "Gzip6", "Gzip7", "Gzip8", "Gzip9", "Lzo"]
+                                               "Data": ["Gzip", "Gzip1", "Gzip2", "Gzip3", "Gzip4", "Gzip5", "Gzip6", "Gzip7", "Gzip8", "Gzip9", "Lzo"]
                                        },
                                        "Signature": {
                                                "Required": false,
index e527cf22d452cecbcd0547486cba82226008ce17..3f646cd363064096aabfeb3d69d1bd8959ff5412 100644 (file)
@@ -304,6 +304,100 @@ var JobType = {
        }
 };
 
+var oLastJobsList = {
+       last_jobs_table: null,
+       ids: {
+               last_jobs_list: 'last_jobs_list',
+               last_jobs_list_body: 'lats_jobs_list_body'
+       },
+       init: function(data) {
+               this.destroy();
+               this.set_table(data);
+       },
+       destroy: function() {
+               if (this.last_jobs_table) {
+                       this.last_jobs_table.destroy();
+               }
+       },
+       set_table: function(data) {
+               this.last_jobs_table = $('#' + this.ids.last_jobs_list).DataTable({
+                       data: data,
+                       bInfo: false,
+                       paging: false,
+                       searching: false,
+                       deferRender: true,
+                       columns: [
+                               {
+                                       className: 'details-control',
+                                       orderable: false,
+                                       data: null,
+                                       defaultContent: '<button type="button" class="w3-button w3-blue"><i class="fa fa-angle-down"></i></button>'
+                               },
+                               {
+                                       data: 'jobid',
+                                       responsivePriority: 1
+                               },
+                               {
+                                       data: 'name',
+                                       responsivePriority: 2
+                               },
+                               {
+                                       data: 'level',
+                                       render: function(data, type, row) {
+                                               return JobLevel.get_level(data);
+                                       },
+                                       responsivePriority: 3
+                               },
+                               {
+                                       data: 'starttime',
+                                       responsivePriority: 5
+                               },
+                               {
+                                       data: 'jobstatus',
+                                       render: function (data, type, row) {
+                                               var ret;
+                                               if (type == 'display') {
+                                                       ret = JobStatus.get_icon(data).outerHTML;
+                                               } else {
+                                                       ret = data;
+                                               }
+                                               return ret;
+                                       },
+                                       responsivePriority: 4
+                               }
+                       ],
+                       responsive: {
+                               details: {
+                                       type: 'column'
+                               }
+                       },
+                       columnDefs: [{
+                               className: 'control',
+                               orderable: false,
+                               targets: 0
+                       },
+                       {
+                               className: "dt-center",
+                               targets: [ 1, 3, 4, 5 ]
+                       }],
+                       order: [1, 'desc']
+               });
+               this.set_events();
+       },
+       set_events: function() {
+               var self = this;
+               $('#' + this.ids.last_jobs_list + ' tbody').on('click', 'tr', function (e) {
+                       var node_name = e.target.nodeName.toUpperCase();
+                       if (node_name === 'BUTTON' || node_name === 'SVG' || node_name === 'PATH') {
+                               // clicking on button doesn't cause directing to job details
+                               return;
+                       }
+                       var data = self.last_jobs_table.row(this).data();
+                       document.location.href = '/web/job/history/' + data.jobid + '/'
+               });
+       }
+};
+
 var Dashboard = {
        stats: null,
        txt: null,
@@ -318,8 +412,7 @@ var Dashboard = {
                jobs: {
                        no: 'job_no',
                        most: 'job_most',
-                       most_count: 'job_most_count',
-                       all: 'all_jobs'
+                       most_count: 'job_most_count'
                },
                jobtotals: {
                        total_bytes: 'jobs_total_bytes',
@@ -336,6 +429,7 @@ var Dashboard = {
                },
                pie_summary: 'jobs_summary_graph'
        },
+       last_jobs_table: null,
        dbtype: {
                pgsql: 'PostgreSQL',
                mysql: 'MySQL',
@@ -372,39 +466,9 @@ var Dashboard = {
                document.getElementById(this.ids.clients.jobs).textContent = occupancy;
        },
        update_job_access: function() {
-               var job_table= document.getElementById(this.ids.jobs.all);
-               job_table.innerHTML = '';
-               var last_jobs = this.stats.jobs.slice(0, 10);
-               var add_job_dest_page = function(i) {
-                       tr.addEventListener('click', function(e) {
-                               var url = '/web/job/history/%jobid/'.replace('%jobid', last_jobs[i].jobid);
-                               document.location.href = url;
-                       });
-               }
-               for (var i = 0; i < last_jobs.length; i++) {
-                       var tr = document.createElement('TR');
-                       tr.style.cursor = 'pointer';
-                       add_job_dest_page(i);
-                       var td_jobid = document.createElement('TD');
-                       var td_name = document.createElement('TD');
-                       var td_level = document.createElement('TD');
-                       var td_starttime = document.createElement('TD');
-                       var td_jobstatus = document.createElement('TD');
-                       td_jobid.textContent = last_jobs[i].jobid;
-                       td_name.textContent = Strings.get_short_label(last_jobs[i].name);
-                       td_level.textContent = last_jobs[i].level;
-                       td_level.className = 'w3-center';
-                       td_starttime.textContent = last_jobs[i].starttime;
-                       td_starttime.className = 'w3-center';
-                       td_jobstatus.appendChild(JobStatus.get_icon(last_jobs[i].jobstatus));
-                       td_jobstatus.className = 'w3-center';
-                       tr.appendChild(td_jobid);
-                       tr.appendChild(td_name);
-                       tr.appendChild(td_level);
-                       tr.appendChild(td_starttime);
-                       tr.appendChild(td_jobstatus);
-                       job_table.appendChild(tr);
-               }
+               // get last 10 jobs
+               var data = this.stats.jobs.slice(0, 10);
+               oLastJobsList.init(data);
        },
        update_jobs: function() {
                var jobs = this.stats.jobs_occupancy;
index 15ae5585d933cdf13d60a0b9e25312c40c797378..78522b163db5115bc9aac89e382d8c96e6599bfc 100644 (file)
@@ -10,7 +10,7 @@
        <div class="w3-bar w3-green w3-margin-bottom">
                <a class="w3-bar-item w3-button tab_btn" href="<%=$this->Service->constructUrl('ClientList')%>"><i class="fa fa-angle-left"></i></a>
                <button id="btn_client_actions" type="button" class="w3-bar-item w3-button tab_btn w3-grey" onclick="W3Tabs.open(this.id, 'client_actions'); clear_node('#new_client div.directive_value');"><%[ Actions ]%></button>
-               <button id="btn_client_jobs" type="button" class="w3-bar-item w3-button tab_btn" onclick="W3Tabs.open(this.id, 'client_jobs'); clear_node('#new_client  div.directive_value');"><%[ Jobs for Client ]%></button>
+               <button id="btn_client_jobs" type="button" class="w3-bar-item w3-button tab_btn" onclick="W3Tabs.open(this.id, 'client_jobs'); clear_node('#new_client  div.directive_value');oJobForClientList.table.responsive.recalc();"><%[ Jobs for Client ]%></button>
                <com:TLinkButton
                        CssClass="w3-bar-item w3-button tab_btn"
                        Attributes.onclick="W3Tabs.open(this.id, 'client_config'); clear_node('#new_client  div.directive_value'); return false;"
@@ -65,6 +65,7 @@ var oJobForClientList = {
        },
        clientid: 0,
        data: [],
+       table: null,
        init: function(clientid) {
                this.clientid = clientid;
                this.prepare_data();
@@ -78,7 +79,7 @@ var oJobForClientList = {
                }
        },
        set_table: function() {
-               var table = $('#' + this.ids.job_list).DataTable({
+               this.table = $('#' + this.ids.job_list).DataTable({
                        data: this.data,
                        deferRender: true,
                        columns: [
index 9d5cd107bccb7e50e6f1dc039885ea9d37f54883..2b9cd7f64c5cf7bb9d07e0b8e9f6877146803383 100644 (file)
                        </div>
                        <div class="w3-twothird">
                                <h5><%[ Last 10 jobs ]%></h5>
-                               <table class="w3-table w3-striped w3-hoverable w3-white w3-margin-bottom">
+                               <table id="last_jobs_list" class="w3-table w3-striped w3-hoverable w3-white w3-margin-bottom" style="width: 100%">
                                        <thead>
                                                <tr>
+                                                       <th></th>
                                                        <th><%[ JobId ]%></th>
                                                        <th><%[ Name ]%></th>
-                                                       <th class="w3-center"><%[ Level ]%></th>
-                                                       <th class="w3-center"><%[ Start time ]%></th>
-                                                       <th class="w3-center"><%[ Job status ]%></th>
+                                                       <th><%[ Level ]%></th>
+                                                       <th><%[ Start time ]%></th>
+                                                       <th><%[ Job status ]%></th>
                                                </tr>
                                        </thead>
-                                       <tbody id="all_jobs">
+                                       <tbody id="last_jobs_list_body">
                                        </tbody>
                                </table>
                                <button type="button" class="w3-button w3-dark-grey w3-right w3-margin-bottom" onclick="document.location.href='<%=$this->Service->constructUrl('JobHistoryList')%>'"><%[ More jobs ]%> &nbsp;<i class="fa fa-arrow-right"></i></button>
index 47094ff0de57a70c343d6fffe4da49d041115157..c4c37f1d6b404832c5c3965b26b69001a6f1d8e9 100644 (file)
@@ -10,7 +10,7 @@
        <div class="w3-bar w3-green w3-margin-bottom">
                <a class="w3-bar-item w3-button tab_btn" href="<%=$this->Service->constructUrl('PoolList')%>"><i class="fa fa-angle-left"></i></a>
                <button id="btn_pool_actions" type="button" class="w3-bar-item w3-button tab_btn w3-grey" onclick="W3Tabs.open(this.id, 'pool_actions');"><%[ Actions ]%></button>
-               <button id="btn_volumes_in_pool" type="button" class="w3-bar-item w3-button tab_btn" onclick="W3Tabs.open(this.id, 'volumes_in_pool');"><%[ Volumes in pool ]%></button>
+               <button id="btn_volumes_in_pool" type="button" class="w3-bar-item w3-button tab_btn" onclick="W3Tabs.open(this.id, 'volumes_in_pool');oVolumeList.table.responsive.recalc();"><%[ Volumes in pool ]%></button>
                <com:TLinkButton
                        CssClass="w3-bar-item w3-button tab_btn"
                        Attributes.onclick="W3Tabs.open(this.id, 'pool_config'); return false;"
                                        <th><%[ Actions ]%></th>
                                </tr>
                        </thead>
-                       <tbody id="pool_list_body">
+                       <tbody id="volume_list_body">
                        </tbody>
                </table>
        </div>
@@ -148,6 +148,7 @@ $(function() {
        Formatters.set_formatters();
 });
 var oVolumeList = {
+       table: null,
        ids: {
                volume_list: 'volume_list',
                volume_list_body: 'volume_list_body'
@@ -156,7 +157,7 @@ var oVolumeList = {
                this.set_table();
        },
        set_table: function() {
-               var table = $('#' + this.ids.volume_list).DataTable({
+               this.table = $('#' + this.ids.volume_list).DataTable({
                        data: <%=json_encode($this->volumes_in_pool)%>,
                        deferRender: true,
                        columns: [
index c3db559edf90286e0abec3b620cfdcc4b4b11099..c27717823e83bce3cfabc5630e8fb5ab49087c94 100644 (file)
@@ -10,7 +10,7 @@
        <div class="w3-bar w3-green w3-margin-bottom">
                <a class="w3-bar-item w3-button tab_btn" href="<%=$this->Service->constructUrl('VolumeList')%>"><i class="fa fa-angle-left"></i></a>
                <button id="btn_volume_actions" type="button" class="w3-bar-item w3-button tab_btn w3-grey" onclick="W3Tabs.open(this.id, 'volume_actions');"><%[ Actions ]%></button>
-               <button id="btn_jobs_on_volume" type="button" class="w3-bar-item w3-button tab_btn" onclick="W3Tabs.open(this.id, 'jobs_on_volume');"><%[ Jobs on volume ]%></button>
+               <button id="btn_jobs_on_volume" type="button" class="w3-bar-item w3-button tab_btn" onclick="W3Tabs.open(this.id, 'jobs_on_volume');oJobsOnVolumeList.table.responsive.recalc();"><%[ Jobs on volume ]%></button>
                <button id="btn_volume_config" type="button" class="w3-bar-item w3-button tab_btn" onclick="W3Tabs.open(this.id, 'volume_config');"><%[ Configure volume ]%></button>
        </div>
        <div class="w3-container tab_item" id="volume_actions">
        </div>
 <script type="text/javascript">
 var oJobsOnVolumeList = {
+       table: null,
        ids: {
                jobs_on_volume_list: 'jobs_on_volume_list',
                jobs_on_volume_list_body: 'jobs_on_volume_list_body'
@@ -357,7 +358,7 @@ var oJobsOnVolumeList = {
                this.set_table();
        },
        set_table: function() {
-               var table = $('#' + this.ids.jobs_on_volume_list).DataTable({
+               this.table = $('#' + this.ids.jobs_on_volume_list).DataTable({
                        data: <%=json_encode($this->jobs_on_volume)%>,
                        deferRender: true,
                        columns: [
index 675ec098b296c496c45f6d1c02b7176ddff48de5..e048eb86ac390e34d02322dcee7ab5874bf441b0 100644 (file)
@@ -118,3 +118,7 @@ div.details_card {
 div.config_directives {
        padding: 10px;
 }
+
+#last_jobs_list tbody tr {
+       cursor: pointer;
+}