From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id A74F768F53 for ; Mon, 1 Mar 2021 12:23:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9DFE31E994 for ; Mon, 1 Mar 2021 12:22:46 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id BA6401E979 for ; Mon, 1 Mar 2021 12:22:44 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 78DEB4581E for ; Mon, 1 Mar 2021 12:22:44 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Mon, 1 Mar 2021 12:22:39 +0100 Message-Id: <20210301112243.15842-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.204 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 1/5] ui: tape: add DriveStatus panel X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Mar 2021 11:23:16 -0000 not used yet Signed-off-by: Dominik Csapak --- 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