public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 3/3] ui: GuestStatusView: add 'privileged' and 'ostype' fields
Date: Wed,  3 May 2023 11:50:42 +0200	[thread overview]
Message-ID: <20230503095042.137966-4-c.heiss@proxmox.com> (raw)
In-Reply-To: <20230503095042.137966-1-c.heiss@proxmox.com>

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@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>&nbsp;${distro}</div>`;
+	}
+
+	me.setTitle(title);
     },
 });
--
2.39.2





  parent reply	other threads:[~2023-05-03  9:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-03  9:50 [pve-devel] [PATCH manager 0/3] fix #2435: lxc: show distro and privileged status in summary Christoph Heiss
2023-05-03  9:50 ` [pve-devel] [PATCH manager 1/3] ui: clean up remnants of in-tree font-awesome files Christoph Heiss
2023-06-07 10:15   ` [pve-devel] applied: " Thomas Lamprecht
2023-05-03  9:50 ` [pve-devel] [PATCH manager 2/3] ui: add 'font-logos' stylesheet and font files Christoph Heiss
2023-06-07 10:59   ` Thomas Lamprecht
2023-06-09  9:28     ` Christoph Heiss
2023-05-03  9:50 ` Christoph Heiss [this message]
2023-06-07 11:49   ` [pve-devel] [PATCH manager 3/3] ui: GuestStatusView: add 'privileged' and 'ostype' fields Thomas Lamprecht

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=20230503095042.137966-4-c.heiss@proxmox.com \
    --to=c.heiss@proxmox.com \
    --cc=pve-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal