all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 4/5] ui: dc/Backup: add schedule simulator button
Date: Thu, 11 Nov 2021 12:07:08 +0100	[thread overview]
Message-ID: <20211111110709.633855-8-d.csapak@proxmox.com> (raw)
In-Reply-To: <20211111110709.633855-1-d.csapak@proxmox.com>

so that a user can simply simulate the schedule

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 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





  parent reply	other threads:[~2021-11-11 11:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 11:07 [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH docs 1/3] refactor calendar events into appendix Dominik Csapak
2021-11-11 17:03   ` [pve-devel] applied-series: " Thomas Lamprecht
2021-11-11 11:07 ` [pve-devel] [PATCH docs 2/3] vzdump: change vzdump.cron to pvescheduler Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH docs 3/3] add pvescheduler docs and manpage Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH manager 1/5] ui: dc/Backup: never show id input field, autogenerate id Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH manager 2/5] ui: dc/Backup: fix comment sort Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH manager 3/5] api: cluster: add jobs/schedule-analyze api call Dominik Csapak
2021-11-11 11:07 ` Dominik Csapak [this message]
2021-11-11 11:07 ` [pve-devel] [PATCH manager 5/5] remove pvescheduler manpage generation Dominik Csapak
2021-11-11 20:04 ` [pve-devel] applied-series: [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211111110709.633855-8-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal