[pve-devel] [PATCH manager 3/3] ui: GuestStatusView: add 'privileged' and 'ostype' fields

Christoph Heiss c.heiss at proxmox.com
Wed May 3 11:50:42 CEST 2023


The privileged status is displayed by adding a new row to the status
panel, while the distribution logo and name are displayed on the right
side of the title bar of the status panel. The latter fits neatly there,
is rather unintrusive and yet still visible at first sight.

This also solves the problem of having to create a bigger row, so that
the icon is still easily recognisable. At the default font-size of
13pt, this really wasn't the case.

I verified that each supported distro is present in the font and the
name matches up and tested through all supported distros (including
'unmanaged').

Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
 www/manager6/panel/GuestStatusView.js | 51 ++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/www/manager6/panel/GuestStatusView.js b/www/manager6/panel/GuestStatusView.js
index 8db1f492..c773f252 100644
--- a/www/manager6/panel/GuestStatusView.js
+++ b/www/manager6/panel/GuestStatusView.js
@@ -11,6 +11,30 @@ Ext.define('PVE.panel.GuestStatusView', {
 	};
     },

+    controller: {
+	xclass: 'Ext.app.ViewController',
+
+	init: 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));
+		    view.ostype = result.data.ostype;
+		},
+	    });
+	},
+    },
+
     layout: {
 	type: 'vbox',
 	align: 'stretch',
@@ -58,6 +82,15 @@ Ext.define('PVE.panel.GuestStatusView', {
 	    },
 	    printBar: false,
 	},
+	{
+	    itemId: 'unprivileged',
+	    iconCls: 'fa fa-lock fa-fw',
+	    title: gettext('Unprivileged'),
+	    printBar: false,
+	    cbind: {
+		hidden: '{isQemu}',
+	    },
+	},
 	{
 	    xtype: 'box',
 	    height: 15,
@@ -134,6 +167,22 @@ Ext.define('PVE.panel.GuestStatusView', {
 		+ ')';
 	}

-	me.setTitle(me.getRecordValue('name') + text);
+	let title = `<div class="left-aligned">${me.getRecordValue('name') + text}</div>`;
+
+	if (me.pveSelNode.data.type === 'lxc' && me.ostype && me.ostype !== 'unmanaged') {
+	    // Manual mappings for distros with special casing
+	    const namemap = {
+		'archlinux': 'Arch Linux',
+		'nixos': 'NixOS',
+		'opensuse': 'openSUSE',
+		'centos': 'CentOS',
+	    };
+
+	    const distro = namemap[me.ostype] ?? Ext.String.capitalize(me.ostype);
+	    title += `<div class="right-aligned">
+		<i class="fl-${me.ostype} fl-fw"></i> ${distro}</div>`;
+	}
+
+	me.setTitle(title);
     },
 });
--
2.39.2






More information about the pve-devel mailing list