From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E9952EB7A for ; Wed, 27 Sep 2023 15:06:14 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D225BC3FA for ; Wed, 27 Sep 2023 15:06:14 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 27 Sep 2023 15:06:14 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id CD04748E42 for ; Wed, 27 Sep 2023 15:06:13 +0200 (CEST) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Wed, 27 Sep 2023 15:06:07 +0200 Message-Id: <20230927130608.166028-1-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.368 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [rec.id, record.data] Subject: [pbs-devel] [PATCH proxmox-backup v4 1/2] close #4723: ui: new gc view X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Sep 2023 13:06:15 -0000 Moved GCView to different file and enhanced it with last, next run, status and duration. Added button to show task log. Changed `render_task_status()` to also take in account upids stored in other 'rows'. Signed-off-by: Gabriel Goller --- update v4: - separate commits for ui/api - added 'show task log' button update v3: - ui: removed `required` attribute on items to get the sorting right - made `pending_chunks` and `removed_chunks` options, so that they are not shown when no gc run exists update v2: - skip serializing if value is `None` - return just the schedule if `upid` doesn't exist (means no gc has been run) - ui: removed default values on timestamps - ui: removed flex and minHeight properties www/Makefile | 1 + www/Utils.js | 12 ++-- www/config/GCView.js | 129 ++++++++++++++++++++++++++++++++++++ www/datastore/PruneAndGC.js | 91 +------------------------ 4 files changed, 138 insertions(+), 95 deletions(-) create mode 100644 www/config/GCView.js diff --git a/www/Makefile b/www/Makefile index 04c12b31..b67fd73f 100644 --- a/www/Makefile +++ b/www/Makefile @@ -62,6 +62,7 @@ JSSRC= \ config/SyncView.js \ config/VerifyView.js \ config/PruneView.js \ + config/GCView.js \ config/WebauthnView.js \ config/CertificateView.js \ config/NodeOptionView.js \ diff --git a/www/Utils.js b/www/Utils.js index 2eca600e..66293b17 100644 --- a/www/Utils.js +++ b/www/Utils.js @@ -199,14 +199,14 @@ Ext.define('PBS.Utils', { return fingerprint.substring(0, 23); }, - render_task_status: function(value, metadata, record) { - if (!record.data['last-run-upid']) { - return '-'; + render_task_status: function(value, metadata, record, rowIndex, colIndex, store) { + if (!record.data['last-run-upid'] && !store.getById('last-run-upid')?.data.value) { + return '-'; } - if (!record.data['last-run-endtime']) { - metadata.tdCls = 'x-grid-row-loading'; - return ''; + if (!record.data['last-run-endtime'] && !store.getById('last-run-endtime')?.data.value) { + metadata.tdCls = 'x-grid-row-loading'; + return ''; } let parsed = Proxmox.Utils.parse_task_status(value); diff --git a/www/config/GCView.js b/www/config/GCView.js new file mode 100644 index 00000000..b8f8812e --- /dev/null +++ b/www/config/GCView.js @@ -0,0 +1,129 @@ +Ext.define('PBS.Datastore.GCOptions', { + extend: 'Proxmox.grid.ObjectGrid', + alias: 'widget.pbsGCJobView', + mixins: ['Proxmox.Mixin.CBind'], + + onlineHelp: 'maintenance_pruning', + + cbindData: function(initial) { + let me = this; + + me.datastore = encodeURIComponent(me.datastore); + me.url = `/api2/json/admin/datastore/${me.datastore}/gc_info`; + me.editorConfig = { + url: `/api2/extjs/config/datastore/${me.datastore}`, + }; + return {}; + }, + + controller: { + xclass: 'Ext.app.ViewController', + + edit: function() { + this.getView().run_editor(); + }, + + garbageCollect: function() { + let me = this; + let view = me.getView(); + Proxmox.Utils.API2Request({ + url: `/admin/datastore/${view.datastore}/gc`, + method: 'POST', + failure: function(response) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + }, + success: function(response, options) { + Ext.create('Proxmox.window.TaskViewer', { + upid: response.result.data, + }).show(); + }, + }); + }, + + showTaskLog: function() { + let me = this; + + let upid = me.getView().getStore().getById('last-run-upid')?.data.value; + if (!upid) return; + + Ext.create('Proxmox.window.TaskViewer', { + upid, + }).show(); + }, + }, + + tbar: [ + { + xtype: 'proxmoxButton', + text: gettext('Edit'), + enableFn: (rec) => rec.id === 'schedule', + disabled: true, + handler: 'edit', + }, + '-', + { + xtype: 'proxmoxButton', + selModel: null, + text: gettext('Start Garbage Collection'), + handler: 'garbageCollect', + }, + { + xtype: 'proxmoxButton', + text: gettext('Show Task Log'), + enableFn: (rec) => !!rec.store.getById('last-run-upid')?.data.value, + disabled: true, + handler: 'showTaskLog', + }, + ], + + listeners: { + activate: function() { this.rstore.startUpdate(); }, + destroy: function() { this.rstore.stopUpdate(); }, + deactivate: function() { this.rstore.stopUpdate(); }, + itemdblclick: 'edit', + }, + + rows: { + "schedule": { + required: true, + defaultValue: Proxmox.Utils.NoneText, + header: gettext('Schedule'), + editor: { + xtype: 'proxmoxWindowEdit', + title: gettext('GC Schedule'), + onlineHelp: 'maintenance_gc', + items: { + xtype: 'pbsCalendarEvent', + name: 'gc-schedule', + fieldLabel: gettext("GC Schedule"), + emptyText: Proxmox.Utils.NoneText, + deleteEmpty: true, + }, + }, + }, + "last-run-state": { + required: true, + header: gettext('State'), + renderer: PBS.Utils.render_task_status, + }, + "duration": { + header: gettext('Duration'), + renderer: Proxmox.Utils.render_duration, + }, + "last-run-endtime": { + header: gettext('Last Run'), + renderer: PBS.Utils.render_optional_timestamp, + }, + "next-run": { + header: gettext('Next Run'), + renderer: PBS.Utils.render_next_task_run, + }, + "pending-chunks": { + header: gettext('Pending Chunks'), + }, + "removed-chunks": { + header: gettext('Removed Chunks'), + }, + "last-run-upid": { visible: false }, + }, +}); diff --git a/www/datastore/PruneAndGC.js b/www/datastore/PruneAndGC.js index aab98dad..3b9878a3 100644 --- a/www/datastore/PruneAndGC.js +++ b/www/datastore/PruneAndGC.js @@ -1,88 +1,3 @@ -Ext.define('PBS.Datastore.GCOptions', { - extend: 'Proxmox.grid.ObjectGrid', - alias: 'widget.pbsDatastoreGCOpts', - mixins: ['Proxmox.Mixin.CBind'], - - onlineHelp: 'maintenance_pruning', - - cbindData: function(initial) { - let me = this; - - me.datastore = encodeURIComponent(me.datastore); - me.url = `/api2/json/config/datastore/${me.datastore}`; - me.editorConfig = { - url: `/api2/extjs/config/datastore/${me.datastore}`, - }; - return {}; - }, - - controller: { - xclass: 'Ext.app.ViewController', - - edit: function() { this.getView().run_editor(); }, - - garbageCollect: function() { - let me = this; - let view = me.getView(); - Proxmox.Utils.API2Request({ - url: `/admin/datastore/${view.datastore}/gc`, - method: 'POST', - failure: function(response) { - Ext.Msg.alert(gettext('Error'), response.htmlStatus); - }, - success: function(response, options) { - Ext.create('Proxmox.window.TaskViewer', { - upid: response.result.data, - }).show(); - }, - }); - }, - }, - - tbar: [ - { - xtype: 'proxmoxButton', - text: gettext('Edit'), - disabled: true, - handler: 'edit', - }, - '-', - { - xtype: 'proxmoxButton', - text: gettext('Start Garbage Collection'), - selModel: null, - handler: 'garbageCollect', - }, - ], - - listeners: { - activate: function() { this.rstore.startUpdate(); }, - destroy: function() { this.rstore.stopUpdate(); }, - deactivate: function() { this.rstore.stopUpdate(); }, - itemdblclick: 'edit', - }, - - rows: { - "gc-schedule": { - required: true, - defaultValue: Proxmox.Utils.NoneText, - header: gettext('Garbage Collection Schedule'), - editor: { - xtype: 'proxmoxWindowEdit', - title: gettext('GC Schedule'), - onlineHelp: 'maintenance_gc', - items: { - xtype: 'pbsCalendarEvent', - name: 'gc-schedule', - fieldLabel: gettext("GC Schedule"), - emptyText: Proxmox.Utils.noneText, - deleteEmpty: true, - }, - }, - }, - }, -}); - Ext.define('PBS.Datastore.PruneAndGC', { extend: 'Ext.panel.Panel', alias: 'widget.pbsDatastorePruneAndGC', @@ -99,9 +14,9 @@ Ext.define('PBS.Datastore.PruneAndGC', { }, items: [ { - xtype: 'pbsDatastoreGCOpts', + xtype: 'pbsGCJobView', title: gettext('Garbage Collection'), - itemId: 'datastore-gc', + itemId: 'datastore-gc-jobs', nodename: 'localhost', cbind: { datastore: '{datastore}', @@ -111,8 +26,6 @@ Ext.define('PBS.Datastore.PruneAndGC', { xtype: 'pbsPruneJobView', nodename: 'localhost', itemId: 'datastore-prune-jobs', - flex: 1, - minHeight: 200, cbind: { datastore: '{datastore}', }, -- 2.39.2