ui: tape/DriveStatus: add state to Info panel

and optimize the updateData function a bit

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-03-02 12:19:39 +01:00 committed by Dietmar Maurer
parent e0f6892625
commit d810014eeb
1 changed files with 34 additions and 17 deletions

View File

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