all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/5] ui: tape: add DriveStatus panel
Date: Mon,  1 Mar 2021 12:22:39 +0100	[thread overview]
Message-ID: <20210301112243.15842-1-d.csapak@proxmox.com> (raw)

not used yet

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/Makefile            |   1 +
 www/tape/DriveStatus.js | 212 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 213 insertions(+)
 create mode 100644 www/tape/DriveStatus.js

diff --git a/www/Makefile b/www/Makefile
index 11858f98..53981aa4 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -29,6 +29,7 @@ TAPE_UI_FILES=						\
 	tape/ChangerConfig.js				\
 	tape/ChangerStatus.js				\
 	tape/DriveConfig.js				\
+	tape/DriveStatus.js				\
 	tape/EncryptionKeys.js				\
 	tape/PoolConfig.js				\
 	tape/TapeInventory.js				\
diff --git a/www/tape/DriveStatus.js b/www/tape/DriveStatus.js
new file mode 100644
index 00000000..0035dc22
--- /dev/null
+++ b/www/tape/DriveStatus.js
@@ -0,0 +1,212 @@
+Ext.define('PBS.TapeManagement.DriveStatus', {
+    extend: 'Ext.panel.Panel',
+    alias: 'widget.pbsDriveStatus',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    cbindData: function(config) {
+	let me = this;
+	me.setTitle(`${gettext('Drive')}: ${me.drive}`);
+	return {
+	    driveStatusUrl: `/api2/json/tape/drive/${me.drive}/status`,
+	};
+    },
+
+    scrollable: true,
+
+    bodyPadding: 5,
+
+    controller: {
+	xclass: 'Ext.app.ViewController',
+
+	reload: function() {
+	    let me = this;
+	    me.lookup('statusgrid').rstore.load();
+	},
+    },
+
+    listeners: {
+	activate: 'reload',
+    },
+
+    tbar: [
+	{
+	    xtype: 'proxmoxButton',
+	    handler: 'reload',
+	    text: gettext('Reload'),
+	},
+    ],
+
+    items: [
+	{
+	    xtype: 'container',
+	    layout: {
+		type: 'hbox',
+		align: 'stretch',
+	    },
+	    defaults: {
+		padding: 5,
+		flex: 1,
+	    },
+	    items: [
+		{
+		    xtype: 'pbsDriveInfoPanel',
+		    cbind: {
+			drive: '{drive}',
+		    },
+		},
+		{
+		    xtype: 'pbsDriveStatusGrid',
+		    reference: 'statusgrid',
+		    cbind: {
+			url: '{driveStatusUrl}',
+		    },
+		},
+	    ],
+	},
+    ],
+});
+
+Ext.define('PBS.TapeManagement.DriveStatusGrid', {
+    extend: 'Proxmox.grid.ObjectGrid',
+    alias: 'widget.pbsDriveStatusGrid',
+
+    title: gettext('Status'),
+
+    rows: {
+	'blocksize': {
+	    required: true,
+	    header: gettext('Blocksize'),
+	    renderer: function(value) {
+		if (!value) {
+		    return gettext('Dynamic');
+		}
+		return `${gettext('Fixed')} - ${Proxmox.Utils.format_size(value)}`;
+	    },
+	},
+	'options': {
+	    required: true,
+	    header: gettext('Options'),
+	    defaultValue: '',
+	},
+	'status': {
+	    required: true,
+	    header: gettext('Status'),
+	},
+	'density': {
+	    header: gettext('Tape Density'),
+	},
+	'manufactured': {
+	    header: gettext('Tape Manufacture Date'),
+	    renderer: function(value) {
+		if (value) {
+		    return new Date(value*1000);
+		}
+		return "";
+	    },
+	},
+	'bytes-read': {
+	    header: gettext('Tape Read'),
+	    renderer: Proxmox.Utils.format_size,
+	},
+	'bytes-written': {
+	    header: gettext('Tape Written'),
+	    renderer: Proxmox.Utils.format_size,
+	},
+    },
+});
+
+Ext.define('PBS.TapeManagement.DriveInfoPanel', {
+    extend: 'Ext.panel.Panel',
+    alias: 'widget.pbsDriveInfoPanel',
+
+    title: gettext('Information'),
+
+    defaults: {
+	printBar: false,
+	padding: 5,
+    },
+    bodyPadding: 15,
+
+    viewModel: {
+	data: {},
+    },
+
+    items: [
+	{
+	    xtype: 'pmxInfoWidget',
+	    title: gettext('Name'),
+	    bind: {
+		data: {
+		    text: '{name}',
+		},
+	    },
+	},
+	{
+	    xtype: 'pmxInfoWidget',
+	    title: gettext('Vendor'),
+	    bind: {
+		data: {
+		    text: '{vendor}',
+		},
+	    },
+	},
+	{
+	    xtype: 'pmxInfoWidget',
+	    title: gettext('Model'),
+	    bind: {
+		data: {
+		    text: '{model}',
+		},
+	    },
+	},
+	{
+	    xtype: 'pmxInfoWidget',
+	    title: gettext('Serial'),
+	    bind: {
+		data: {
+		    text: '{serial}',
+		},
+	    },
+	},
+	{
+	    xtype: 'pmxInfoWidget',
+	    title: gettext('Path'),
+	    bind: {
+		data: {
+		    text: '{path}',
+		},
+	    },
+	},
+    ],
+
+    updateData: function(record) {
+	let me = this;
+	if (!record) {
+	    return;
+	}
+
+	let vm = me.getViewModel();
+	for (const [key, value] of Object.entries(record.data)) {
+	    vm.set(key, value);
+	}
+    },
+
+    initComponent: function() {
+	let me = this;
+	if (!me.drive) {
+	    throw "no drive given";
+	}
+
+	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.callParent();
+    },
+});
-- 
2.20.1





             reply	other threads:[~2021-03-01 11:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 11:22 Dominik Csapak [this message]
2021-03-01 11:22 ` [pbs-devel] [PATCH proxmox-backup 2/5] ui: MainView: adapt router to add changer/drive entries Dominik Csapak
2021-03-01 11:22 ` [pbs-devel] [PATCH proxmox-backup 3/5] ui: NavigationTree: add entries for changers/drives Dominik Csapak
2021-03-01 11:22 ` [pbs-devel] [PATCH proxmox-backup 4/5] ui: tape: ChangerStatus: remove changerselector combobox Dominik Csapak
2021-03-01 11:22 ` [pbs-devel] [PATCH proxmox-backup 5/5] ui: tape/ChangerStatus: handle vanishing view during reload Dominik Csapak
2021-03-01 11:39 ` [pbs-devel] applied: [PATCH proxmox-backup 1/5] ui: tape: add DriveStatus panel Dietmar Maurer

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=20210301112243.15842-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-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