make GuestStatusView declarative

use the cbind function to generate isLxc/Qemu to hide the
relevant fields, and cbind the nodename

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2018-02-26 13:12:21 +01:00 committed by Thomas Lamprecht
parent 8d58a8bcdd
commit 5ba37d7c0b

View File

@ -5,6 +5,14 @@ Ext.define('PVE.panel.GuestStatusView', {
height: 300, height: 300,
cbindData: function (initialConfig) {
var me = this;
return {
isQemu: me.pveSelNode.data.type === 'qemu',
isLxc: me.pveSelNode.data.type === 'lxc'
};
},
layout: { layout: {
type: 'vbox', type: 'vbox',
align: 'stretch' align: 'stretch'
@ -35,9 +43,13 @@ Ext.define('PVE.panel.GuestStatusView', {
renderer: PVE.Utils.format_ha renderer: PVE.Utils.format_ha
}, },
{ {
xtype: 'pveInfoWidget',
itemId: 'node', itemId: 'node',
iconCls: 'fa fa-building fa-fw', iconCls: 'fa fa-building fa-fw',
title: gettext('Node'), title: gettext('Node'),
cbind: {
text: '{pveSelNode.data.node}'
},
printBar: false printBar: false
}, },
{ {
@ -64,10 +76,15 @@ Ext.define('PVE.panel.GuestStatusView', {
}, },
{ {
itemId: 'swap', itemId: 'swap',
xtype: 'pveInfoWidget',
iconCls: 'fa fa-refresh fa-fw', iconCls: 'fa fa-refresh fa-fw',
title: gettext('SWAP usage'), title: gettext('SWAP usage'),
valueField: 'swap', valueField: 'swap',
maxField: 'maxswap' maxField: 'maxswap',
cbind: {
hidden: '{isQemu}',
disabled: '{isQemu}'
}
}, },
{ {
itemId: 'rootfs', itemId: 'rootfs',
@ -95,7 +112,9 @@ Ext.define('PVE.panel.GuestStatusView', {
xtype: 'pveAgentIPView', xtype: 'pveAgentIPView',
cbind: { cbind: {
rstore: '{rstore}', rstore: '{rstore}',
pveSelNode: '{pveSelNode}' pveSelNode: '{pveSelNode}',
hidden: '{isLxc}',
disabled: '{isLxc}'
} }
} }
], ],
@ -111,17 +130,5 @@ Ext.define('PVE.panel.GuestStatusView', {
} }
me.setTitle(me.getRecordValue('name') + text); me.setTitle(me.getRecordValue('name') + text);
},
initComponent: function() {
var me = this;
me.callParent();
if (me.pveSelNode.data.type !== 'lxc') {
me.remove(me.getComponent('swap'));
} else {
me.remove(me.getComponent('ips'));
}
me.getComponent('node').updateValue(me.pveSelNode.data.node);
} }
}); });