public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/2] prune-simulator: allow setting a date on which prune happens
@ 2022-09-14 10:50 Matthias Heiserer
  2022-09-14 10:50 ` [pbs-devel] [PATCH proxmox-backup 2/2] prune-simulator: allow setting a time " Matthias Heiserer
  2022-09-16 10:08 ` [pbs-devel] [PATCH proxmox-backup 1/2] prune-simulator: allow setting a date " Fiona Ebner
  0 siblings, 2 replies; 5+ messages in thread
From: Matthias Heiserer @ 2022-09-14 10:50 UTC (permalink / raw)
  To: pbs-devel

With this applied, the prune simulator will be more flexible, which might clear
up questions such as these:
https://forum.proxmox.com/threads/pbs-prune-simulator-monthly-backups.115081

In order to have the configuration window not take up too much space,
I added another column and moved the border slightly to the left, so the options
part looks off-centered.

Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
---
 .../prune-simulator/prune-simulator_source.js | 92 ++++++++++++-------
 1 file changed, 58 insertions(+), 34 deletions(-)

diff --git a/docs/prune-simulator/prune-simulator_source.js b/docs/prune-simulator/prune-simulator_source.js
index 84d3461c..137cf1b3 100644
--- a/docs/prune-simulator/prune-simulator_source.js
+++ b/docs/prune-simulator/prune-simulator_source.js
@@ -330,6 +330,8 @@ Ext.onReady(function() {
 
 		let params = view.getValues();
 
+		NOW.setTime(Date.parse(params.currentDate));
+
 		let [hourSpec, minuteSpec] = params['schedule-time'].split(':');
 
 		if (!hourSpec || !minuteSpec) {
@@ -661,48 +663,70 @@ Ext.onReady(function() {
 			{ xtype: "panel", width: 1, border: 1 },
 			{
 			    xtype: 'form',
-			    layout: 'anchor',
-			    flex: 1,
+			    layout: 'hbox',
+			    flex: 1.2,
 			    border: false,
 			    title: 'Simulated Backup Schedule',
 			    defaults: {
-				labelWidth: 120,
+				defaults: {
+				    labelWidth: 120,
+				},
 			    },
 			    bodyPadding: 10,
 			    items: [
 				{
-				    xtype: 'prunesimulatorDayOfWeekSelector',
-				    name: 'schedule-weekdays',
-				    fieldLabel: 'Day of week',
-				    value: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'],
-				    allowBlank: false,
-				    multiSelect: true,
-				    padding: '0 0 0 10',
+				    xtype: 'container',
+				    layout: 'anchor',
+				    items: [
+					{
+					    xtype: 'prunesimulatorDayOfWeekSelector',
+					    name: 'schedule-weekdays',
+					    fieldLabel: 'Day of week',
+					    value: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'],
+					    allowBlank: false,
+					    multiSelect: true,
+					    padding: '0 0 0 10',
+					},
+					{
+					    xtype: 'prunesimulatorCalendarEvent',
+					    name: 'schedule-time',
+					    allowBlank: false,
+					    value: '0/6:00',
+					    fieldLabel: 'Backup schedule',
+					    padding: '0 0 0 10',
+					},
+					{
+					    xtype: 'numberfield',
+					    name: 'numberOfWeeks',
+					    allowBlank: false,
+					    fieldLabel: 'Number of weeks',
+					    minValue: 1,
+					    value: 15,
+					    maxValue: 260, // five years
+					    padding: '0 0 0 10',
+					},
+					{
+					    xtype: 'button',
+					    name: 'schedule-button',
+					    text: 'Update Schedule',
+					    formBind: true,
+					    handler: 'reloadFull',
+					},
+				    ],
 				},
 				{
-				    xtype: 'prunesimulatorCalendarEvent',
-				    name: 'schedule-time',
-				    allowBlank: false,
-				    value: '0/6:00',
-				    fieldLabel: 'Backup schedule',
-				    padding: '0 0 0 10',
-				},
-				{
-				    xtype: 'numberfield',
-				    name: 'numberOfWeeks',
-				    allowBlank: false,
-				    fieldLabel: 'Number of weeks',
-				    minValue: 1,
-				    value: 15,
-				    maxValue: 260, // five years
-				    padding: '0 0 0 10',
-				},
-				{
-				    xtype: 'button',
-				    name: 'schedule-button',
-				    text: 'Update Schedule',
-				    formBind: true,
-				    handler: 'reloadFull',
+				    xtype: 'container',
+				    layout: 'anchor',
+				    items: [
+					{
+					    xtype: 'datefield',
+					    name: 'currentDate',
+					    fieldLabel: 'Today',
+					    allowBlank: false,
+					    padding: '0 0 0 10',
+					    value: new Date(),
+					},
+				    ],
 				},
 			    ],
 			},
@@ -734,7 +758,7 @@ Ext.onReady(function() {
 			    xtype: 'prunesimulatorPruneList',
 			    store: me.pruneStore,
 			    reference: 'pruneList',
-			    flex: 1,
+			    flex: 1.2,
 			},
 		    ],
 		},
-- 
2.30.2





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 2/2] prune-simulator: allow setting a time on which prune happens
  2022-09-14 10:50 [pbs-devel] [PATCH proxmox-backup 1/2] prune-simulator: allow setting a date on which prune happens Matthias Heiserer
@ 2022-09-14 10:50 ` Matthias Heiserer
  2022-09-16 10:08   ` Fiona Ebner
  2022-09-16 10:08 ` [pbs-devel] [PATCH proxmox-backup 1/2] prune-simulator: allow setting a date " Fiona Ebner
  1 sibling, 1 reply; 5+ messages in thread
From: Matthias Heiserer @ 2022-09-14 10:50 UTC (permalink / raw)
  To: pbs-devel

In addition to the previous patch, this allows setting the time (hours/minutes)
on which the pruning is simulated.

Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
---
 .../prune-simulator/prune-simulator_source.js | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/docs/prune-simulator/prune-simulator_source.js b/docs/prune-simulator/prune-simulator_source.js
index 137cf1b3..6ddbec0a 100644
--- a/docs/prune-simulator/prune-simulator_source.js
+++ b/docs/prune-simulator/prune-simulator_source.js
@@ -330,7 +330,10 @@ Ext.onReady(function() {
 
 		let params = view.getValues();
 
+		const time = view.lookup("currentTime").getValue();
 		NOW.setTime(Date.parse(params.currentDate));
+		NOW.setHours(time.getHours());
+		NOW.setMinutes(time.getMinutes());
 
 		let [hourSpec, minuteSpec] = params['schedule-time'].split(':');
 
@@ -458,9 +461,10 @@ Ext.onReady(function() {
 		    let weekday = parseInt(Ext.Date.format(daysDate, 'w'), 10);
 		    if (weekdayFlags[weekday]) {
 			timesOnSingleDay.forEach(function(time) {
-			    backups.push({
-				backuptime: Ext.Date.subtract(new Date(time), Ext.Date.DAY, i),
-			    });
+			    const backuptime = Ext.Date.subtract(new Date(time), Ext.Date.DAY, i);
+			    if (backuptime < NOW) {
+				backups.push({ backuptime: backuptime });
+			    }
 			});
 		    }
 		}
@@ -726,6 +730,15 @@ Ext.onReady(function() {
 					    padding: '0 0 0 10',
 					    value: new Date(),
 					},
+					{
+					    xtype: 'timefield',
+					    name: 'currentTime',
+					    reference: 'currentTime',
+					    fieldLabel: 'Time of prune',
+					    allowBlank: false,
+					    padding: '0 0 0 10',
+					    value: new Date(),
+					},
 				    ],
 				},
 			    ],
-- 
2.30.2





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup 1/2] prune-simulator: allow setting a date on which prune happens
  2022-09-14 10:50 [pbs-devel] [PATCH proxmox-backup 1/2] prune-simulator: allow setting a date on which prune happens Matthias Heiserer
  2022-09-14 10:50 ` [pbs-devel] [PATCH proxmox-backup 2/2] prune-simulator: allow setting a time " Matthias Heiserer
@ 2022-09-16 10:08 ` Fiona Ebner
  1 sibling, 0 replies; 5+ messages in thread
From: Fiona Ebner @ 2022-09-16 10:08 UTC (permalink / raw)
  To: pbs-devel, Matthias Heiserer

Nit: maybe use "allow setting a custom date" for the commit title. It
affects the simulated schedule too, not just pruning.

Am 14.09.22 um 12:50 schrieb Matthias Heiserer:
> With this applied, the prune simulator will be more flexible, which might clear
> up questions such as these:
> https://forum.proxmox.com/threads/pbs-prune-simulator-monthly-backups.115081
> 
> In order to have the configuration window not take up too much space,
> I added another column and moved the border slightly to the left, so the options
> part looks off-centered.
> 

For me, the right side of the time fields is cut off for both new
options (both in Firefox and Chromium).

> Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
> ---
>  .../prune-simulator/prune-simulator_source.js | 92 ++++++++++++-------
>  1 file changed, 58 insertions(+), 34 deletions(-)
> 
> diff --git a/docs/prune-simulator/prune-simulator_source.js b/docs/prune-simulator/prune-simulator_source.js
> index 84d3461c..137cf1b3 100644
> --- a/docs/prune-simulator/prune-simulator_source.js
> +++ b/docs/prune-simulator/prune-simulator_source.js
> @@ -330,6 +330,8 @@ Ext.onReady(function() {
>  
>  		let params = view.getValues();
>  
> +		NOW.setTime(Date.parse(params.currentDate));

NOW is currently declared as const and I guess it works, because it's a
Date object, but I'd rather just drop the variable and add a viewModel
entry instead. That also avoids a (I guess irrelevant in practice) race
between the "new Date()" calls for the two new timefields.

If it makes things easier, feel free to combine the patches into one.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup 2/2] prune-simulator: allow setting a time on which prune happens
  2022-09-14 10:50 ` [pbs-devel] [PATCH proxmox-backup 2/2] prune-simulator: allow setting a time " Matthias Heiserer
@ 2022-09-16 10:08   ` Fiona Ebner
  2022-09-19 10:24     ` Matthias Heiserer
  0 siblings, 1 reply; 5+ messages in thread
From: Fiona Ebner @ 2022-09-16 10:08 UTC (permalink / raw)
  To: pbs-devel, Matthias Heiserer

Same nit for the commit title.

Am 14.09.22 um 12:50 schrieb Matthias Heiserer:
> @@ -726,6 +730,15 @@ Ext.onReady(function() {
>  					    padding: '0 0 0 10',
>  					    value: new Date(),
>  					},
> +					{
> +					    xtype: 'timefield',
> +					    name: 'currentTime',
> +					    reference: 'currentTime',
> +					    fieldLabel: 'Time of prune',

I don't really like using "Time of prune" here, because the setting also
affects the schedule and doesn't feel in line with "Today". How about
"Today's time" or simply "Time"? Or we could use "Current date" and
"Current time".

There's AM/PM times in the drop-down suggestions here, which clashes
with the 24 hour format used in the rest of the simulator. Let's try to
keep it consistent.

> +					    allowBlank: false,
> +					    padding: '0 0 0 10',
> +					    value: new Date(),
> +					},
>  				    ],
>  				},
>  			    ],




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup 2/2] prune-simulator: allow setting a time on which prune happens
  2022-09-16 10:08   ` Fiona Ebner
@ 2022-09-19 10:24     ` Matthias Heiserer
  0 siblings, 0 replies; 5+ messages in thread
From: Matthias Heiserer @ 2022-09-19 10:24 UTC (permalink / raw)
  To: Fiona Ebner, pbs-devel

On 16.09.2022 12:08, Fiona Ebner wrote:
> Same nit for the commit title.
> 
> Am 14.09.22 um 12:50 schrieb Matthias Heiserer:
>> @@ -726,6 +730,15 @@ Ext.onReady(function() {
>>   					    padding: '0 0 0 10',
>>   					    value: new Date(),
>>   					},
>> +					{
>> +					    xtype: 'timefield',
>> +					    name: 'currentTime',
>> +					    reference: 'currentTime',
>> +					    fieldLabel: 'Time of prune',
> 
> I don't really like using "Time of prune" here, because the setting also
> affects the schedule and doesn't feel in line with "Today". How about
> "Today's time" or simply "Time"? Or we could use "Current date" and
> "Current time".
I think just "Time" works best. I'll also rename the date field to 
"Date" to keep it consistent (and because it makes more sense; from the 
view of the user, its not the current date, but the date which is used 
for the simulation).
> 
> There's AM/PM times in the drop-down suggestions here, which clashes
> with the 24 hour format used in the rest of the simulator. Let's try to
> keep it consistent.
> 
Of course, good catch
>> +					    allowBlank: false,
>> +					    padding: '0 0 0 10',
>> +					    value: new Date(),
>> +					},
>>   				    ],
>>   				},
>>   			    ],





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-19 10:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 10:50 [pbs-devel] [PATCH proxmox-backup 1/2] prune-simulator: allow setting a date on which prune happens Matthias Heiserer
2022-09-14 10:50 ` [pbs-devel] [PATCH proxmox-backup 2/2] prune-simulator: allow setting a time " Matthias Heiserer
2022-09-16 10:08   ` Fiona Ebner
2022-09-19 10:24     ` Matthias Heiserer
2022-09-16 10:08 ` [pbs-devel] [PATCH proxmox-backup 1/2] prune-simulator: allow setting a date " Fiona Ebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal