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 069D960BE8 for ; Fri, 25 Sep 2020 10:44:41 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 32755193D0 for ; Fri, 25 Sep 2020 10:43:47 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 id 8EEC419389 for ; Fri, 25 Sep 2020 10:43:41 +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 5AC244556D for ; Fri, 25 Sep 2020 10:43:41 +0200 (CEST) From: Hannes Laimer To: pbs-devel@lists.proxmox.com Date: Fri, 25 Sep 2020 10:43:24 +0200 Message-Id: <20200925084330.75484-9-h.laimer@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200925084330.75484-1-h.laimer@proxmox.com> References: <20200925084330.75484-1-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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. [record.data, rec.data] Subject: [pbs-devel] [PATCH v1 proxmox-backup 08/14] ui: add verify job 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: Fri, 25 Sep 2020 08:44:41 -0000 Signed-off-by: Hannes Laimer --- www/Makefile | 1 + www/NavigationTree.js | 6 + www/config/VerifyView.js | 273 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 280 insertions(+) create mode 100644 www/config/VerifyView.js diff --git a/www/Makefile b/www/Makefile index 90a98b74..48d06266 100644 --- a/www/Makefile +++ b/www/Makefile @@ -16,6 +16,7 @@ JSSRC= \ config/RemoteView.js \ config/ACLView.js \ config/SyncView.js \ + config/VerifyView.js \ config/DataStoreConfig.js \ window/UserEdit.js \ window/UserPassword.js \ diff --git a/www/NavigationTree.js b/www/NavigationTree.js index 0fd9458d..21b9b2a6 100644 --- a/www/NavigationTree.js +++ b/www/NavigationTree.js @@ -42,6 +42,12 @@ Ext.define('PBS.store.NavigationStore', { path: 'pbsSyncJobView', leaf: true, }, + { + text: gettext('Verify Jobs'), + iconCls: 'fa fa-check-circle', + path: 'pbsVerifyJobView', + leaf: true, + }, { text: gettext('Subscription'), iconCls: 'fa fa-support', diff --git a/www/config/VerifyView.js b/www/config/VerifyView.js new file mode 100644 index 00000000..e8722eb9 --- /dev/null +++ b/www/config/VerifyView.js @@ -0,0 +1,273 @@ +Ext.define('pbs-verify-jobs-status', { + extend: 'Ext.data.Model', + fields: [ + 'id', 'store', 'outdated-after', 'schedule', + 'next-run', 'last-run-upid', 'last-run-state', 'last-run-endtime', + { + name: 'duration', + calculate: function(data) { + let endtime = data['last-run-endtime']; + if (!endtime) return undefined; + let task = Proxmox.Utils.parse_task_upid(data['last-run-upid']); + return endtime - task.starttime; + }, + }, + ], + idProperty: 'id', + proxy: { + type: 'proxmox', + url: '/api2/json/admin/verify', + }, +}); + +Ext.define('PBS.config.VerifyJobView', { + extend: 'Ext.grid.GridPanel', + alias: 'widget.pbsVerifyJobView', + + stateful: true, + stateId: 'grid-verify-jobs', + + title: gettext('Verify Jobs'), + + controller: { + xclass: 'Ext.app.ViewController', + + addVerifyJob: function() { + let me = this; + Ext.create('PBS.window.VerifyJobEdit', { + listeners: { + destroy: function() { + me.reload(); + }, + }, + }).show(); + }, + + editVerifyJob: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (selection.length < 1) return; + + Ext.create('PBS.window.VerifyJobEdit', { + id: selection[0].data.id, + listeners: { + destroy: function() { + me.reload(); + }, + }, + }).show(); + }, + + openTaskLog: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (selection.length < 1) return; + + let upid = selection[0].data['last-run-upid']; + if (!upid) return; + + Ext.create('Proxmox.window.TaskViewer', { + upid + }).show(); + }, + + runVerifyJob: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (selection.length < 1) return; + + let id = selection[0].data.id; + Proxmox.Utils.API2Request({ + method: 'POST', + url: `/admin/verify/${id}/run`, + success: function(response, opt) { + Ext.create('Proxmox.window.TaskViewer', { + upid: response.result.data, + taskDone: function(success) { + me.reload(); + }, + }).show(); + }, + failure: function(response, opt) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + }, + }); + }, + + render_verify_status: function(value, metadata, record) { + if (!record.data['last-run-upid']) { + return '-'; + } + + if (!record.data['last-run-endtime']) { + metadata.tdCls = 'x-grid-row-loading'; + return ''; + } + + let parsed = Proxmox.Utils.parse_task_status(value); + let text = value; + let icon = ''; + switch (parsed) { + case 'unknown': + icon = 'question faded'; + text = Proxmox.Utils.unknownText; + break; + case 'error': + icon = 'times critical'; + text = Proxmox.Utils.errorText + ': ' + value; + break; + case 'warning': + icon = 'exclamation warning'; + break; + case 'ok': + icon = 'check good'; + text = gettext("OK"); + } + + return ` ${text}`; + }, + + render_next_run: function(value, metadat, record) { + if (!value) return '-'; + + let now = new Date(); + let next = new Date(value*1000); + + if (next < now) { + return gettext('pending'); + } + return Proxmox.Utils.render_timestamp(value); + }, + + render_optional_timestamp: function(value, metadata, record) { + if (!value) return '-'; + return Proxmox.Utils.render_timestamp(value); + }, + + reload: function() { this.getView().getStore().rstore.load(); }, + + init: function(view) { + Proxmox.Utils.monStoreErrors(view, view.getStore().rstore); + }, + }, + + listeners: { + activate: 'reload', + itemdblclick: 'editVerifyJob', + }, + + store: { + type: 'diff', + autoDestroy: true, + autoDestroyRstore: true, + sorters: 'id', + rstore: { + type: 'update', + storeid: 'pbs-verify-jobs-status', + model: 'pbs-verify-jobs-status', + autoStart: true, + interval: 5000, + }, + }, + + tbar: [ + { + xtype: 'proxmoxButton', + text: gettext('Add'), + handler: 'addVerifyJob', + selModel: false, + }, + { + xtype: 'proxmoxButton', + text: gettext('Edit'), + handler: 'editVerifyJob', + disabled: true, + }, + { + xtype: 'proxmoxStdRemoveButton', + baseurl: '/config/verify/', + callback: 'reload', + }, + '-', + { + xtype: 'proxmoxButton', + text: gettext('Log'), + handler: 'openTaskLog', + enableFn: (rec) => !!rec.data['last-run-upid'], + disabled: true, + }, + { + xtype: 'proxmoxButton', + text: gettext('Run now'), + handler: 'runVerifyJob', + disabled: true, + }, + ], + + viewConfig: { + trackOver: false, + }, + + columns: [ + { + header: gettext('Verify Job'), + width: 100, + sortable: true, + renderer: Ext.String.htmlEncode, + dataIndex: 'id', + }, + { + header: gettext('Datastore'), + width: 100, + sortable: true, + dataIndex: 'store', + }, + { + header: gettext('Days valid'), + width: 50, + sortable: true, + dataIndex: 'outdated-after', + }, + { + header: gettext('Schedule'), + sortable: true, + dataIndex: 'schedule', + }, + { + header: gettext('Status'), + dataIndex: 'last-run-state', + flex: 1, + renderer: 'render_verify_status', + }, + { + header: gettext('Last Verification'), + sortable: true, + minWidth: 200, + renderer: 'render_optional_timestamp', + dataIndex: 'last-run-endtime', + }, + { + text: gettext('Duration'), + dataIndex: 'duration', + width: 60, + renderer: Proxmox.Utils.render_duration, + }, + { + header: gettext('Next Run'), + sortable: true, + minWidth: 200, + renderer: 'render_next_run', + dataIndex: 'next-run', + }, + { + header: gettext('Comment'), + hidden: true, + sortable: true, + renderer: Ext.String.htmlEncode, + dataIndex: 'comment', + }, + ], +}); -- 2.20.1