public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/4] ui: tape/ChangerStatus: only show loading on 'force refresh'
@ 2021-02-22 13:25 Dominik Csapak
  2021-02-22 13:25 ` [pbs-devel] [PATCH proxmox-backup 2/4] ui: tape/ChangerStatus: reload changer status (cached) every 5000ms Dominik Csapak
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dominik Csapak @ 2021-02-22 13:25 UTC (permalink / raw)
  To: pbs-devel

so that we can update in the background without interfering with the
users workflow

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
another alternative would be to have a 'spinning' loading icon
at the top, but i think this is also ok, since the user explicitely
pressed 'reload'

 www/tape/ChangerStatus.js | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index bedeaaec..8e5ee900 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -413,8 +413,10 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    }
 
 	    try {
-		Proxmox.Utils.setErrorMask(view, true);
-		Proxmox.Utils.setErrorMask(me.lookup('content'));
+		if (!use_cache) {
+		    Proxmox.Utils.setErrorMask(view, true);
+		    Proxmox.Utils.setErrorMask(me.lookup('content'));
+		}
 		let status_fut = PBS.Async.api2({
 		    timeout: 5*60*1000,
 		    method: 'GET',
@@ -484,10 +486,15 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 		me.lookup('import_export').getStore().setData(data['import-export']);
 		me.lookup('drives').getStore().setData(data.drive);
 
-		Proxmox.Utils.setErrorMask(view);
+		if (!use_cache) {
+		    Proxmox.Utils.setErrorMask(view);
+		}
+		Proxmox.Utils.setErrorMask(me.lookup('content'));
 	    } catch (err) {
-		Proxmox.Utils.setErrorMask(view);
-		Proxmox.Utils.setErrorMask(me.lookup('content'), err);
+		if (!use_cache) {
+		    Proxmox.Utils.setErrorMask(view);
+		}
+		Proxmox.Utils.setErrorMask(me.lookup('content'), err.toString());
 	    }
 	},
 
-- 
2.20.1





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

* [pbs-devel] [PATCH proxmox-backup 2/4] ui: tape/ChangerStatus: reload changer status (cached) every 5000ms
  2021-02-22 13:25 [pbs-devel] [PATCH proxmox-backup 1/4] ui: tape/ChangerStatus: only show loading on 'force refresh' Dominik Csapak
@ 2021-02-22 13:25 ` Dominik Csapak
  2021-02-22 13:25 ` [pbs-devel] [PATCH proxmox-backup 3/4] ui: tape/ChangerStatus: convert grid stores to DiffStores Dominik Csapak
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2021-02-22 13:25 UTC (permalink / raw)
  To: pbs-devel

so that we can have an updated drive status without having to
press 'reload'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/tape/ChangerStatus.js | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index 8e5ee900..aae13e43 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -395,12 +395,31 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    }).show();
 	},
 
+	scheduleReload: function(time) {
+	    let me = this;
+	    if (me.reloadTimeout === undefined) {
+		me.reloadTimeout = setTimeout(function() {
+		    me.reload();
+		}, time);
+	    }
+	},
+
 	reload: function() {
-	    this.reload_full(true);
+	    let me = this;
+	    if (me.reloadTimeout !== undefined) {
+		clearTimeout(me.reloadTimeout);
+		me.reloadTimeout = undefined;
+	    }
+	    me.reload_full(true);
 	},
 
 	reload_no_cache: function() {
-	    this.reload_full(false);
+	    let me = this;
+	    if (me.reloadTimeout !== undefined) {
+		clearTimeout(me.reloadTimeout);
+		me.reloadTimeout = undefined;
+	    }
+	    me.reload_full(false);
 	},
 
 	reload_full: async function(use_cache) {
@@ -496,6 +515,8 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 		}
 		Proxmox.Utils.setErrorMask(me.lookup('content'), err.toString());
 	    }
+
+	    me.scheduleReload(5000);
 	},
 
 	renderIsLabeled: function(value, mD, record) {
-- 
2.20.1





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

* [pbs-devel] [PATCH proxmox-backup 3/4] ui: tape/ChangerStatus: convert grid stores to DiffStores
  2021-02-22 13:25 [pbs-devel] [PATCH proxmox-backup 1/4] ui: tape/ChangerStatus: only show loading on 'force refresh' Dominik Csapak
  2021-02-22 13:25 ` [pbs-devel] [PATCH proxmox-backup 2/4] ui: tape/ChangerStatus: reload changer status (cached) every 5000ms Dominik Csapak
@ 2021-02-22 13:25 ` Dominik Csapak
  2021-02-22 13:25 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui: tape/ChangerStatus: disable drive buttons when it's blocked Dominik Csapak
  2021-02-23  8:07 ` [pbs-devel] applied: [PATCH proxmox-backup 1/4] ui: tape/ChangerStatus: only show loading on 'force refresh' Dietmar Maurer
  3 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2021-02-22 13:25 UTC (permalink / raw)
  To: pbs-devel

to not deselect items when the store is updated

this makes the ui a bit better to use

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/tape/ChangerStatus.js | 43 +++++++++++++++++++++++++++++++++++----
 1 file changed, 39 insertions(+), 4 deletions(-)

diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index aae13e43..11b159ce 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -1,3 +1,16 @@
+Ext.define('pbs-slot-model', {
+    extend: 'Ext.data.Model',
+    fields: ['entry-id', 'label-text', 'is-labeled', ' model', 'name', 'vendor', 'serial', 'state',
+	{
+	    name: 'is-blocked',
+	    calculate: function(data) {
+		return data.state !== undefined;
+	    },
+	},
+    ],
+    idProperty: 'entry-id',
+});
+
 Ext.define('PBS.TapeManagement.ChangerStatus', {
     extend: 'Ext.panel.Panel',
     alias: 'widget.pbsChangerStatus',
@@ -500,10 +513,18 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 		    data[type].push(entry);
 		}
 
+		// the stores are diffstores and are only refreshed
+		// on a 'load' event, which does not trigger on 'setData'
+		// so we have to fire them ourselves
 
-		me.lookup('slots').getStore().setData(data.slot);
-		me.lookup('import_export').getStore().setData(data['import-export']);
-		me.lookup('drives').getStore().setData(data.drive);
+		me.lookup('slots').getStore().rstore.setData(data.slot);
+		me.lookup('slots').getStore().rstore.fireEvent('load', me, [], true);
+
+		me.lookup('import_export').getStore().rstore.setData(data['import-export']);
+		me.lookup('import_export').getStore().rstore.fireEvent('load', me, [], true);
+
+		me.lookup('drives').getStore().rstore.setData(data.drive);
+		me.lookup('drives').getStore().rstore.fireEvent('load', me, [], true);
 
 		if (!use_cache) {
 		    Proxmox.Utils.setErrorMask(view);
@@ -638,6 +659,11 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 		    padding: 5,
 		    flex: 1,
 		    store: {
+			type: 'diff',
+			rstore: {
+			    type: 'store',
+			    model: 'pbs-slot-model',
+			},
 			data: [],
 		    },
 		    columns: [
@@ -697,7 +723,11 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 			    reference: 'drives',
 			    title: gettext('Drives'),
 			    store: {
-				fields: ['entry-id', 'label-text', 'model', 'name', 'vendor', 'serial'],
+				type: 'diff',
+				rstore: {
+				    type: 'store',
+				    model: 'pbs-slot-model',
+				},
 				data: [],
 			    },
 			    columns: [
@@ -803,6 +833,11 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 			    xtype: 'grid',
 			    reference: 'import_export',
 			    store: {
+				type: 'diff',
+				rstore: {
+				    type: 'store',
+				    model: 'pbs-slot-model',
+				},
 				data: [],
 			    },
 			    title: gettext('Import-Export Slots'),
-- 
2.20.1





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

* [pbs-devel] [PATCH proxmox-backup 4/4] ui: tape/ChangerStatus: disable drive buttons when it's blocked
  2021-02-22 13:25 [pbs-devel] [PATCH proxmox-backup 1/4] ui: tape/ChangerStatus: only show loading on 'force refresh' Dominik Csapak
  2021-02-22 13:25 ` [pbs-devel] [PATCH proxmox-backup 2/4] ui: tape/ChangerStatus: reload changer status (cached) every 5000ms Dominik Csapak
  2021-02-22 13:25 ` [pbs-devel] [PATCH proxmox-backup 3/4] ui: tape/ChangerStatus: convert grid stores to DiffStores Dominik Csapak
@ 2021-02-22 13:25 ` Dominik Csapak
  2021-02-23  8:07 ` [pbs-devel] applied: [PATCH proxmox-backup 1/4] ui: tape/ChangerStatus: only show loading on 'force refresh' Dietmar Maurer
  3 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2021-02-22 13:25 UTC (permalink / raw)
  To: pbs-devel

if the drive state is not empty, some action blocks it, so we cannot
do any task anyway. Since we now refresh the state every 5 seconds,
we can disable/enable them 'live'.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/tape/ChangerStatus.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index 11b159ce..b1a294c4 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -795,35 +795,37 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 					    iconCls: 'fa fa-rotate-270 fa-upload',
 					    handler: 'unload',
 					    tooltip: gettext('Unload'),
-					    isDisabled: (v, r, c, i, rec) => !rec.data['label-text'],
+					    isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'],
 					},
 					{
 					    iconCls: 'fa fa-hdd-o',
 					    handler: 'cartridgeMemory',
 					    tooltip: gettext('Cartridge Memory'),
-					    isDisabled: (v, r, c, i, rec) => !rec.data['label-text'],
+					    isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'],
 					},
 					{
 					    iconCls: 'fa fa-line-chart',
 					    handler: 'volumeStatistics',
 					    tooltip: gettext('Volume Statistics'),
-					    isDisabled: (v, r, c, i, rec) => !rec.data['label-text'],
+					    isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'],
 					},
 					{
 					    iconCls: 'fa fa-tag',
 					    handler: 'readLabel',
 					    tooltip: gettext('Read Label'),
-					    isDisabled: (v, r, c, i, rec) => !rec.data['label-text'],
+					    isDisabled: (v, r, c, i, rec) => !rec.data['label-text'] || rec.data['is-blocked'],
 					},
 					{
 					    iconCls: 'fa fa-info-circle',
 					    tooltip: gettext('Status'),
 					    handler: 'status',
+					    isDisabled: (v, r, c, i, rec) => rec.data['is-blocked'],
 					},
 					{
 					    iconCls: 'fa fa-shower',
 					    tooltip: gettext('Clean Drive'),
 					    handler: 'cleanDrive',
+					    isDisabled: (v, r, c, i, rec) => rec.data['is-blocked'],
 					},
 				    ],
 				},
-- 
2.20.1





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

* [pbs-devel] applied: [PATCH proxmox-backup 1/4] ui: tape/ChangerStatus: only show loading on 'force refresh'
  2021-02-22 13:25 [pbs-devel] [PATCH proxmox-backup 1/4] ui: tape/ChangerStatus: only show loading on 'force refresh' Dominik Csapak
                   ` (2 preceding siblings ...)
  2021-02-22 13:25 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui: tape/ChangerStatus: disable drive buttons when it's blocked Dominik Csapak
@ 2021-02-23  8:07 ` Dietmar Maurer
  3 siblings, 0 replies; 5+ messages in thread
From: Dietmar Maurer @ 2021-02-23  8:07 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

applied all 4 patches




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

end of thread, other threads:[~2021-02-23  8:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22 13:25 [pbs-devel] [PATCH proxmox-backup 1/4] ui: tape/ChangerStatus: only show loading on 'force refresh' Dominik Csapak
2021-02-22 13:25 ` [pbs-devel] [PATCH proxmox-backup 2/4] ui: tape/ChangerStatus: reload changer status (cached) every 5000ms Dominik Csapak
2021-02-22 13:25 ` [pbs-devel] [PATCH proxmox-backup 3/4] ui: tape/ChangerStatus: convert grid stores to DiffStores Dominik Csapak
2021-02-22 13:25 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui: tape/ChangerStatus: disable drive buttons when it's blocked Dominik Csapak
2021-02-23  8:07 ` [pbs-devel] applied: [PATCH proxmox-backup 1/4] ui: tape/ChangerStatus: only show loading on 'force refresh' Dietmar Maurer

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