public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/5] api2/tape/drive: add state to DriveListEntry
@ 2021-03-02 11:19 Dominik Csapak
  2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 2/5] ui: tape: refactor renderDriveState to Utils Dominik Csapak
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dominik Csapak @ 2021-03-02 11:19 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/api2/tape/drive.rs       | 4 +++-
 src/api2/types/tape/drive.rs | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs
index 6ef6a78b..f3cb1470 100644
--- a/src/api2/tape/drive.rs
+++ b/src/api2/tape/drive.rs
@@ -64,6 +64,7 @@ use crate::{
             open_drive,
             lock_tape_device,
             set_tape_device_state,
+            get_tape_device_state,
         },
         changer::update_changer_online_status,
     },
@@ -1223,7 +1224,8 @@ pub fn list_drives(
         }
 
         let info = lookup_device_identification(&linux_drives, &drive.path);
-        let entry = DriveListEntry { config: drive, info };
+        let state = get_tape_device_state(&config, &drive.name)?;
+        let entry = DriveListEntry { config: drive, info, state };
         list.push(entry);
     }
 
diff --git a/src/api2/types/tape/drive.rs b/src/api2/types/tape/drive.rs
index 067fdeba..2fd480ac 100644
--- a/src/api2/types/tape/drive.rs
+++ b/src/api2/types/tape/drive.rs
@@ -99,6 +99,9 @@ pub struct DriveListEntry {
     pub config: LinuxTapeDrive,
     #[serde(flatten)]
     pub info: OptionalDeviceIdentification,
+    /// the state of the drive if locked
+    #[serde(skip_serializing_if="Option::is_none")]
+    pub state: Option<String>,
 }
 
 #[api()]
-- 
2.20.1





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

* [pbs-devel] [PATCH proxmox-backup 2/5] ui: tape: refactor renderDriveState to Utils
  2021-03-02 11:19 [pbs-devel] [PATCH proxmox-backup 1/5] api2/tape/drive: add state to DriveListEntry Dominik Csapak
@ 2021-03-02 11:19 ` Dominik Csapak
  2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 3/5] ui: tape/DriveStatus: add more status lines Dominik Csapak
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2021-03-02 11:19 UTC (permalink / raw)
  To: pbs-devel

we will use this later again

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/Utils.js              | 16 ++++++++++++++++
 www/tape/ChangerStatus.js | 18 +-----------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/www/Utils.js b/www/Utils.js
index c531edbb..778dad24 100644
--- a/www/Utils.js
+++ b/www/Utils.js
@@ -603,6 +603,22 @@ Ext.define('PBS.Utils', {
 	}).show();
     },
 
+    renderDriveState: function(value, md) {
+	if (!value) {
+	    return gettext('Idle');
+	}
+
+	let icon = '<i class="fa fa-spinner fa-pulse fa-fw"></i>';
+
+	if (value.startsWith("UPID")) {
+	    let upid = Proxmox.Utils.parse_task_upid(value);
+	    md.tdCls = "pointer";
+	    return `${icon} ${upid.desc}`;
+	}
+
+	return `${icon} ${value}`;
+    },
+
 });
 
 Ext.define('PBS.Async', {
diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index 2f9c41f8..42306007 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -463,22 +463,6 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    return status;
 	},
 
-	renderState: function(value, md, record) {
-	    if (!value) {
-		return gettext('Idle');
-	    }
-
-	    let icon = '<i class="fa fa-spinner fa-pulse fa-fw"></i>';
-
-	    if (value.startsWith("UPID")) {
-		let upid = Proxmox.Utils.parse_task_upid(value);
-		md.tdCls = "pointer";
-		return `${icon} ${upid.desc}`;
-	    }
-
-	    return `${icon} ${value}`;
-	},
-
 	control: {
 	    'grid[reference=drives]': {
 		cellclick: function(table, td, ci, rec, tr, ri, e) {
@@ -683,7 +667,7 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 				    text: gettext('State'),
 				    dataIndex: 'state',
 				    flex: 3,
-				    renderer: 'renderState',
+				    renderer: PBS.Utils.renderDriveState,
 				},
 				{
 				    text: gettext("Vendor"),
-- 
2.20.1





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

* [pbs-devel] [PATCH proxmox-backup 3/5] ui: tape/DriveStatus: add more status lines
  2021-03-02 11:19 [pbs-devel] [PATCH proxmox-backup 1/5] api2/tape/drive: add state to DriveListEntry Dominik Csapak
  2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 2/5] ui: tape: refactor renderDriveState to Utils Dominik Csapak
@ 2021-03-02 11:19 ` Dominik Csapak
  2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 4/5] ui: tape/DriveStatus: add state to Info panel Dominik Csapak
  2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 5/5] ui: tape/DriveStatus: use the drive state to determine a status-load Dominik Csapak
  3 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2021-03-02 11:19 UTC (permalink / raw)
  To: pbs-devel

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

diff --git a/www/tape/DriveStatus.js b/www/tape/DriveStatus.js
index 768a74f4..2663ded9 100644
--- a/www/tape/DriveStatus.js
+++ b/www/tape/DriveStatus.js
@@ -206,6 +206,12 @@ Ext.define('PBS.TapeManagement.DriveStatusGrid', {
 	    header: gettext('Tape Written'),
 	    renderer: Proxmox.Utils.format_size,
 	},
+	'medium-passes': {
+	    header: gettext('Tape Passes'),
+	},
+	'medium-wearout': {
+	    header: gettext('Tape Wearout'),
+	},
     },
 });
 
-- 
2.20.1





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

* [pbs-devel] [PATCH proxmox-backup 4/5] ui: tape/DriveStatus: add state to Info panel
  2021-03-02 11:19 [pbs-devel] [PATCH proxmox-backup 1/5] api2/tape/drive: add state to DriveListEntry Dominik Csapak
  2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 2/5] ui: tape: refactor renderDriveState to Utils Dominik Csapak
  2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 3/5] ui: tape/DriveStatus: add more status lines Dominik Csapak
@ 2021-03-02 11:19 ` Dominik Csapak
  2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 5/5] ui: tape/DriveStatus: use the drive state to determine a status-load Dominik Csapak
  3 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2021-03-02 11:19 UTC (permalink / raw)
  To: pbs-devel

and optimize the updateData function a bit

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/tape/DriveStatus.js | 51 +++++++++++++++++++++++++++--------------
 1 file changed, 34 insertions(+), 17 deletions(-)

diff --git a/www/tape/DriveStatus.js b/www/tape/DriveStatus.js
index 2663ded9..c9e9ea02 100644
--- a/www/tape/DriveStatus.js
+++ b/www/tape/DriveStatus.js
@@ -228,7 +228,16 @@ Ext.define('PBS.TapeManagement.DriveInfoPanel', {
     bodyPadding: 15,
 
     viewModel: {
-	data: {},
+	data: {
+	    drive: {},
+	},
+
+	formulas: {
+	    driveState: function(get) {
+		let drive = get('drive');
+		return PBS.Utils.renderDriveState(drive.state, {});
+	    },
+	},
     },
 
     items: [
@@ -237,7 +246,7 @@ Ext.define('PBS.TapeManagement.DriveInfoPanel', {
 	    title: gettext('Name'),
 	    bind: {
 		data: {
-		    text: '{name}',
+		    text: '{drive.name}',
 		},
 	    },
 	},
@@ -246,7 +255,7 @@ Ext.define('PBS.TapeManagement.DriveInfoPanel', {
 	    title: gettext('Vendor'),
 	    bind: {
 		data: {
-		    text: '{vendor}',
+		    text: '{drive.vendor}',
 		},
 	    },
 	},
@@ -255,7 +264,7 @@ Ext.define('PBS.TapeManagement.DriveInfoPanel', {
 	    title: gettext('Model'),
 	    bind: {
 		data: {
-		    text: '{model}',
+		    text: '{drive.model}',
 		},
 	    },
 	},
@@ -264,7 +273,7 @@ Ext.define('PBS.TapeManagement.DriveInfoPanel', {
 	    title: gettext('Serial'),
 	    bind: {
 		data: {
-		    text: '{serial}',
+		    text: '{drive.serial}',
 		},
 	    },
 	},
@@ -273,22 +282,34 @@ Ext.define('PBS.TapeManagement.DriveInfoPanel', {
 	    title: gettext('Path'),
 	    bind: {
 		data: {
-		    text: '{path}',
+		    text: '{drive.path}',
+		},
+	    },
+	},
+	{
+	    xtype: 'pmxInfoWidget',
+	    title: gettext('State'),
+	    bind: {
+		data: {
+		    text: '{driveState}',
 		},
 	    },
 	},
     ],
 
-    updateData: function(record) {
+    updateData: function(store) {
 	let me = this;
+	if (!store) {
+	    return;
+	}
+	let record = store.findRecord('name', me.drive, 0, false, true, true);
 	if (!record) {
 	    return;
 	}
 
 	let vm = me.getViewModel();
-	for (const [key, value] of Object.entries(record.data)) {
-	    vm.set(key, value);
-	}
+	vm.set('drive', record.data);
+	vm.notify();
     },
 
     initComponent: function() {
@@ -298,13 +319,9 @@ Ext.define('PBS.TapeManagement.DriveInfoPanel', {
 	}
 
 	let tapeStore = Ext.ComponentQuery.query('navigationtree')[0].tapestore;
-	me.mon(tapeStore, 'load', function() {
-	    let driveRecord = tapeStore.findRecord('name', me.drive, 0, false, true, true);
-	    me.updateData(driveRecord);
-	});
-	if (!tapeStore.isLoading) {
-	    let driveRecord = tapeStore.findRecord('name', me.drive, 0, false, true, true);
-	    me.updateData(driveRecord);
+	me.mon(tapeStore, 'load', me.updateData, me);
+	if (tapeStore.isLoaded()) {
+	    me.updateData(tapeStore);
 	}
 
 	me.callParent();
-- 
2.20.1





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

* [pbs-devel] [PATCH proxmox-backup 5/5] ui: tape/DriveStatus: use the drive state to determine a status-load
  2021-03-02 11:19 [pbs-devel] [PATCH proxmox-backup 1/5] api2/tape/drive: add state to DriveListEntry Dominik Csapak
                   ` (2 preceding siblings ...)
  2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 4/5] ui: tape/DriveStatus: add state to Info panel Dominik Csapak
@ 2021-03-02 11:19 ` Dominik Csapak
  3 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2021-03-02 11:19 UTC (permalink / raw)
  To: pbs-devel

since the status api call blocks the drive, it only makes sense to do
when the drive is idle.

so do not reload on activate, but when the drive changes the first
time from busy to idle

also disable the reload button when the drive is busy

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

diff --git a/www/tape/DriveStatus.js b/www/tape/DriveStatus.js
index c9e9ea02..481f8b0d 100644
--- a/www/tape/DriveStatus.js
+++ b/www/tape/DriveStatus.js
@@ -18,6 +18,8 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
     viewModel: {
 	data: {
 	    online: false,
+	    busy: true,
+	    loaded: false,
 	},
     },
 
@@ -38,6 +40,33 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 	    vm.set('online', online);
 	},
 
+	onStateLoad: function(store) {
+	    let me = this;
+	    let view = me.getView();
+	    let vm = me.getViewModel();
+	    let driveRecord = store.findRecord('name', view.drive, 0, false, true, true);
+	    let busy = !!driveRecord.data.state;
+	    vm.set('busy', busy);
+	    let statusgrid = me.lookup('statusgrid');
+	    if (!vm.get('loaded')) {
+		if (busy) {
+		    // have to use a timeout so that the component can be rendered first
+		    // otherwise the 'mask' call errors out
+		    setTimeout(function() {
+			statusgrid.mask(gettext('Drive is busy'));
+		    }, 10);
+		} else {
+		    // have to use a timeout so that the component can be rendered first
+		    // otherwise the 'mask' call errors out
+		    setTimeout(function() {
+			statusgrid.unmask();
+		    }, 10);
+		    me.reload();
+		    vm.set('loaded', true);
+		}
+	    }
+	},
+
 	labelMedia: function() {
 	    let me = this;
 	    Ext.create('PBS.TapeManagement.LabelMediaWindow', {
@@ -84,18 +113,23 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 	init: function(view) {
 	    let me = this;
 	    me.mon(me.lookup('statusgrid').getStore().rstore, 'load', 'onLoad');
+	    let tapeStore = Ext.ComponentQuery.query('navigationtree')[0].tapestore;
+	    me.mon(tapeStore, 'load', 'onStateLoad');
+	    if (tapeStore.isLoaded()) {
+		me.onStateLoad(tapeStore);
+	    }
 	},
     },
 
-    listeners: {
-	activate: 'reload',
-    },
-
     tbar: [
 	{
 	    xtype: 'proxmoxButton',
 	    handler: 'reload',
 	    text: gettext('Reload'),
+	    disabled: true,
+	    bind: {
+		disabled: '{busy}',
+	    },
 	},
 	'-',
 	{
-- 
2.20.1





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

end of thread, other threads:[~2021-03-02 11:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 11:19 [pbs-devel] [PATCH proxmox-backup 1/5] api2/tape/drive: add state to DriveListEntry Dominik Csapak
2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 2/5] ui: tape: refactor renderDriveState to Utils Dominik Csapak
2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 3/5] ui: tape/DriveStatus: add more status lines Dominik Csapak
2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 4/5] ui: tape/DriveStatus: add state to Info panel Dominik Csapak
2021-03-02 11:19 ` [pbs-devel] [PATCH proxmox-backup 5/5] ui: tape/DriveStatus: use the drive state to determine a status-load Dominik Csapak

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