From: Marcin Haba Date: Thu, 2 Aug 2018 19:03:44 +0000 (+0200) Subject: baculum: Implement second part ideas and fixes proposed by Wanderlei Huttel X-Git-Tag: Release-9.2.1~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=801ff1ac5446ee5fbbf90d406555594b0ebd95d6;p=thirdparty%2Fbacula.git baculum: Implement second part ideas and fixes proposed by Wanderlei Huttel 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 --- diff --git a/gui/baculum/protected/Web/Data/data_desc.json b/gui/baculum/protected/Web/Data/data_desc.json index 11a092d5b3..afbc5276b9 100644 --- a/gui/baculum/protected/Web/Data/data_desc.json +++ b/gui/baculum/protected/Web/Data/data_desc.json @@ -1191,7 +1191,7 @@ "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, diff --git a/gui/baculum/protected/Web/JavaScript/misc.js b/gui/baculum/protected/Web/JavaScript/misc.js index e527cf22d4..3f646cd363 100644 --- a/gui/baculum/protected/Web/JavaScript/misc.js +++ b/gui/baculum/protected/Web/JavaScript/misc.js @@ -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: '' + }, + { + 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; diff --git a/gui/baculum/protected/Web/Pages/ClientView.page b/gui/baculum/protected/Web/Pages/ClientView.page index 15ae5585d9..78522b163d 100644 --- a/gui/baculum/protected/Web/Pages/ClientView.page +++ b/gui/baculum/protected/Web/Pages/ClientView.page @@ -10,7 +10,7 @@
- +
<%[ Last 10 jobs ]%>
- +
+ - - - + + + - +
<%[ JobId ]%> <%[ Name ]%><%[ Level ]%><%[ Start time ]%><%[ Job status ]%><%[ Level ]%><%[ Start time ]%><%[ Job status ]%>
diff --git a/gui/baculum/protected/Web/Pages/PoolView.page b/gui/baculum/protected/Web/Pages/PoolView.page index 47094ff0de..c4c37f1d6b 100644 --- a/gui/baculum/protected/Web/Pages/PoolView.page +++ b/gui/baculum/protected/Web/Pages/PoolView.page @@ -10,7 +10,7 @@
- + <%[ Actions ]%> - +
@@ -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: [ diff --git a/gui/baculum/protected/Web/Pages/VolumeView.page b/gui/baculum/protected/Web/Pages/VolumeView.page index c3db559edf..c27717823e 100644 --- a/gui/baculum/protected/Web/Pages/VolumeView.page +++ b/gui/baculum/protected/Web/Pages/VolumeView.page @@ -10,7 +10,7 @@
- +
@@ -349,6 +349,7 @@