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 2AE2D7EAAB for ; Thu, 11 Nov 2021 12:07:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BC7E19DC7 for ; Thu, 11 Nov 2021 12:07:15 +0100 (CET) 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 id DACA39B20 for ; Thu, 11 Nov 2021 12:07:11 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B370643417 for ; Thu, 11 Nov 2021 12:07:11 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Thu, 11 Nov 2021 12:07:08 +0100 Message-Id: <20211111110709.633855-8-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211111110709.633855-1-d.csapak@proxmox.com> References: <20211111110709.633855-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.174 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment PROLO_LEO1 0.1 Meta Catches all Leo drug variations so far SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager 4/5] ui: dc/Backup: add schedule simulator button X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Nov 2021 11:07:16 -0000 so that a user can simply simulate the schedule Signed-off-by: Dominik Csapak --- www/manager6/Makefile | 1 + www/manager6/dc/Backup.js | 15 +++ www/manager6/window/ScheduleSimulator.js | 118 +++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 www/manager6/window/ScheduleSimulator.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index 489233f8..a92651a9 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -111,6 +111,7 @@ JSSRC= \ window/StartupEdit.js \ window/DownloadUrlToStorage.js \ window/UploadToStorage.js \ + window/ScheduleSimulator.js \ window/Wizard.js \ ha/Fencing.js \ ha/GroupEdit.js \ diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js index c25a127e..31600817 100644 --- a/www/manager6/dc/Backup.js +++ b/www/manager6/dc/Backup.js @@ -701,6 +701,21 @@ Ext.define('PVE.dc.BackupView', { edit_btn, detail_btn, '-', + { + xtype: 'proxmoxButton', + selModel: null, + text: gettext('Simulate Schedule'), + handler: () => { + let record = sm.getSelection()[0]; + let schedule; + if (record) { + schedule = record.data.schedule; + } + Ext.create('PVE.window.ScheduleSimulator', { + schedule, + }).show(); + }, + }, run_btn, '->', noBackupJobWarning, diff --git a/www/manager6/window/ScheduleSimulator.js b/www/manager6/window/ScheduleSimulator.js new file mode 100644 index 00000000..14b32100 --- /dev/null +++ b/www/manager6/window/ScheduleSimulator.js @@ -0,0 +1,118 @@ +Ext.define('PVE.window.ScheduleSimulator', { + extend: 'Ext.window.Window', + + title: gettext('Simulate Schedule'), + + controller: { + xclass: 'Ext.app.ViewController', + close: function() { this.getView().close(); }, + simulate: function() { + let me = this; + let schedule = me.lookup('schedule').getValue(); + if (!schedule) { + return; + } + let number = me.lookup('number').getValue() || 10; + Proxmox.Utils.API2Request({ + url: '/cluster/jobs/schedule-analyze', + method: 'GET', + params: { + schedule, + number, + }, + failure: function(response, opts) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + }, + success: function(response) { + let schedules = response.result.data; + me.lookup('grid').getStore().setData(schedules); + }, + }); + }, + + scheduleChanged: function(field, value) { + this.lookup('simulateBtn').setDisabled(!value); + }, + + renderTimestamp: function(value) { + let date = new Date(value*1000); + return date.toLocaleString(); + }, + + init: function(view) { + let me = this; + if (view.schedule) { + me.lookup('schedule').setValue(view.schedule); + } + }, + }, + + bodyPadding: 10, + modal: true, + resizable: false, + width: 600, + + layout: 'fit', + + items: [ + { + xtype: 'inputpanel', + column1: [ + { + xtype: 'pveCalendarEvent', + reference: 'schedule', + fieldLabel: gettext('Schedule'), + listeners: { + change: 'scheduleChanged', + }, + }, + { + xtype: 'proxmoxintegerfield', + minValue: 1, + maxValue: 100, + value: 10, + reference: 'number', + fieldLabel: gettext('Number'), + }, + { + xtype: 'button', + reference: 'simulateBtn', + text: gettext('Simulate'), + handler: 'simulate', + align: 'right', + disabled: true, + }, + ], + + column2: [ + { + xtype: 'grid', + reference: 'grid', + emptyText: Proxmox.Utils.NoneText, + scrollable: true, + height: 300, + columns: [ + { + text: gettext('Local Time'), + renderer: 'renderTimestamp', + dataIndex: 'timestamp', + flex: 1, + }, + ], + store: { + fields: ['timestamp'], + data: [], + sorter: 'timestamp', + }, + }, + ], + }, + ], + + buttons: [ + { + text: gettext('OK'), + handler: 'close', + }, + ], +}); -- 2.30.2