[pbs-devel] [PATCH proxmox-backup 1/2] ui: tape/DriveStatus: add cartridge memory grid

Dominik Csapak d.csapak at proxmox.com
Mon Mar 8 10:06:06 CET 2021


that the user can load when a tape is inserted

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

diff --git a/www/tape/DriveStatus.js b/www/tape/DriveStatus.js
index deb8d952..ec1b9fb9 100644
--- a/www/tape/DriveStatus.js
+++ b/www/tape/DriveStatus.js
@@ -8,12 +8,17 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
     cbindData: function(config) {
 	let me = this;
 	me.setTitle(`${gettext('Drive')}: ${me.drive}`);
+	let baseurl = `/api2/json/tape/drive/${me.drive}/`;
 	return {
-	    driveStatusUrl: `/api2/json/tape/drive/${me.drive}/status`,
+	    driveStatusUrl: `${baseurl}/status`,
+	    cartridgeMemoryUrl: `${baseurl}/cartridge-memory`,
 	};
     },
 
-    scrollable: true,
+    layout: {
+	type: 'vbox',
+	align: 'stretch',
+    },
 
     bodyPadding: 5,
 
@@ -40,6 +45,9 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 	    let online = statusFlags.indexOf('ONLINE') !== -1;
 	    let vm = me.getViewModel();
 	    vm.set('online', online);
+	    if (!online) {
+		me.lookup('cartridgegrid').getStore().removeAll();
+	    }
 	},
 
 	onStateLoad: function(store) {
@@ -193,6 +201,18 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
 		},
 	    ],
 	},
+	{
+	    xtype: 'pbsDriveCartridgeMemoryGrid',
+	    flex: 1,
+	    padding: 5,
+	    reference: 'cartridgegrid',
+	    bind: {
+		disabled: '{!online}',
+	    },
+	    cbind: {
+		url: '{cartridgeMemoryUrl}',
+	    },
+	},
     ],
 });
 
@@ -257,6 +277,66 @@ Ext.define('PBS.TapeManagement.DriveStatusGrid', {
     },
 });
 
+Ext.define('PBS.TapeManagement.CartridgeMemoryGrid', {
+    extend: 'Ext.grid.Panel',
+    alias: 'widget.pbsDriveCartridgeMemoryGrid',
+
+    title: gettext('Cartridge Memory'),
+
+    emptyText: gettext('Not Loaded yet'),
+    viewConfig: {
+	deferEmptyText: false,
+    },
+
+    controller: {
+	xclass: 'Ext.app.ViewController',
+
+	loadCartridgeMemory: function() {
+	    console.log(this);
+	    this.getView().getStore().load();
+	},
+
+	init: function(view) {
+	    if (!view.url) {
+		throw "no url given";
+	    }
+
+	    view.getStore().getProxy().setUrl(view.url);
+	},
+    },
+
+    store: {
+	proxy: {
+	    type: 'proxmox',
+	},
+    },
+
+    tbar: [
+	{
+	    text: gettext('Reload'),
+	    handler: 'loadCartridgeMemory',
+	},
+    ],
+
+    columns: [
+	{
+	    text: gettext('ID'),
+	    dataIndex: 'id',
+	    width: 60,
+	},
+	{
+	    text: gettext('Name'),
+	    dataIndex: 'name',
+	    flex: 2,
+	},
+	{
+	    text: gettext('Value'),
+	    dataIndex: 'value',
+	    flex: 1,
+	},
+    ],
+});
+
 Ext.define('PBS.TapeManagement.DriveInfoPanel', {
     extend: 'Ext.panel.Panel',
     alias: 'widget.pbsDriveInfoPanel',
-- 
2.20.1






More information about the pbs-devel mailing list