pve-manager/www/manager6/panel/GuestStatusView.js
Christoph Heiss b1785dbc65 ui: container guest status: show privileged status as new row
As that info is not available through the store (which stores the
status), it must be fetched separately.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
 [ TL: rework subject and avoid arror-fn for controller to keep `this`
   working, as reviewed by Dominik ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-10-23 17:27:14 +02:00

172 lines
3.6 KiB
JavaScript

Ext.define('PVE.panel.GuestStatusView', {
extend: 'Proxmox.panel.StatusView',
alias: 'widget.pveGuestStatusView',
mixins: ['Proxmox.Mixin.CBind'],
cbindData: function(initialConfig) {
var me = this;
return {
isQemu: me.pveSelNode.data.type === 'qemu',
isLxc: me.pveSelNode.data.type === 'lxc',
};
},
controller: {
xclass: 'Ext.app.ViewController',
init: function(view) {
if (view.pveSelNode.data.type !== 'lxc') {
return;
}
const nodename = view.pveSelNode.data.node;
const vmid = view.pveSelNode.data.vmid;
Proxmox.Utils.API2Request({
url: `/api2/extjs/nodes/${nodename}/lxc/${vmid}/config`,
waitMsgTargetView: view,
method: 'GET',
success: ({ result }) => {
view.down('#unprivileged').updateValue(
Proxmox.Utils.format_boolean(result.data.unprivileged));
},
});
},
},
layout: {
type: 'vbox',
align: 'stretch',
},
defaults: {
xtype: 'pmxInfoWidget',
padding: '2 25',
},
items: [
{
xtype: 'box',
height: 20,
},
{
itemId: 'status',
title: gettext('Status'),
iconCls: 'fa fa-info fa-fw',
printBar: false,
multiField: true,
renderer: function(record) {
var me = this;
var text = record.data.status;
var qmpstatus = record.data.qmpstatus;
if (qmpstatus && qmpstatus !== record.data.status) {
text += ' (' + qmpstatus + ')';
}
return text;
},
},
{
itemId: 'hamanaged',
iconCls: 'fa fa-heartbeat fa-fw',
title: gettext('HA State'),
printBar: false,
textField: 'ha',
renderer: PVE.Utils.format_ha,
},
{
itemId: 'node',
iconCls: 'fa fa-building fa-fw',
title: gettext('Node'),
cbind: {
text: '{pveSelNode.data.node}',
},
printBar: false,
},
{
itemId: 'unprivileged',
iconCls: 'fa fa-lock fa-fw',
title: gettext('Unprivileged'),
printBar: false,
cbind: {
hidden: '{isQemu}',
},
},
{
xtype: 'box',
height: 15,
},
{
itemId: 'cpu',
iconCls: 'fa fa-fw pmx-itype-icon-processor pmx-icon',
title: gettext('CPU usage'),
valueField: 'cpu',
maxField: 'cpus',
renderer: Proxmox.Utils.render_cpu_usage,
// in this specific api call
// we already have the correct value for the usage
calculate: Ext.identityFn,
},
{
itemId: 'memory',
iconCls: 'fa fa-fw pmx-itype-icon-memory pmx-icon',
title: gettext('Memory usage'),
valueField: 'mem',
maxField: 'maxmem',
},
{
itemId: 'swap',
iconCls: 'fa fa-refresh fa-fw',
title: gettext('SWAP usage'),
valueField: 'swap',
maxField: 'maxswap',
cbind: {
hidden: '{isQemu}',
disabled: '{isQemu}',
},
},
{
itemId: 'rootfs',
iconCls: 'fa fa-hdd-o fa-fw',
title: gettext('Bootdisk size'),
valueField: 'disk',
maxField: 'maxdisk',
printBar: false,
renderer: function(used, max) {
var me = this;
me.setPrintBar(used > 0);
if (used === 0) {
return Proxmox.Utils.render_size(max);
} else {
return Proxmox.Utils.render_size_usage(used, max);
}
},
},
{
xtype: 'box',
height: 15,
},
{
itemId: 'ips',
xtype: 'pveAgentIPView',
cbind: {
rstore: '{rstore}',
pveSelNode: '{pveSelNode}',
hidden: '{isLxc}',
disabled: '{isLxc}',
},
},
],
updateTitle: function() {
var me = this;
var uptime = me.getRecordValue('uptime');
var text = "";
if (Number(uptime) > 0) {
text = " (" + gettext('Uptime') + ': ' + Proxmox.Utils.format_duration_long(uptime)
+ ')';
}
me.setTitle(me.getRecordValue('name') + text);
},
});