From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 4/5] ui: tape/DriveStatus: add state to Info panel
Date: Tue, 2 Mar 2021 12:19:39 +0100 [thread overview]
Message-ID: <20210302111940.17276-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210302111940.17276-1-d.csapak@proxmox.com>
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
next prev parent reply other threads:[~2021-03-02 11:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20210302111940.17276-4-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox