all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager] www: utils: fix inconsistency in host cpu usage display in search view
@ 2024-07-16  9:31 Christoph Heiss
  2024-07-16 16:07 ` Thomas Lamprecht
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Heiss @ 2024-07-16  9:31 UTC (permalink / raw)
  To: pve-devel

Between the number of CPUs and the actual label, a space was missing -
resulting in an inconsistency vs. the "CPU usage" column.

Also, fix a rather nonsensical check for `maxcpu` above - noticed that
while comparing the implementation to that of Proxmox.Utils.render_cpu().

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
 www/manager6/Utils.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index f5608944d..6a0ecc98f 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1073,13 +1073,14 @@ Ext.define('PVE.Utils', {
 	}
 	var maxcpu = node.data.maxcpu || 1;
 
-	if (!Ext.isNumeric(maxcpu) && (maxcpu >= 1)) {
+	if (!Ext.isNumeric(maxcpu) || maxcpu < 1) {
 	    return '';
 	}
 
 	var per = (record.data.cpu/maxcpu) * record.data.maxcpu * 100;
+	const cpu_label = maxcpu > 1 ? 'CPUs' : 'CPU';
 
-	return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU');
+	return `${per.toFixed(1)}% of ${maxcpu} ${cpu_label}`;
     },
 
     render_bandwidth: function(value) {
-- 
2.45.1



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH manager] www: utils: fix inconsistency in host cpu usage display in search view
  2024-07-16  9:31 [pve-devel] [PATCH manager] www: utils: fix inconsistency in host cpu usage display in search view Christoph Heiss
@ 2024-07-16 16:07 ` Thomas Lamprecht
  2024-07-17 12:27   ` Christoph Heiss
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Lamprecht @ 2024-07-16 16:07 UTC (permalink / raw)
  To: Proxmox VE development discussion, Christoph Heiss

Am 16/07/2024 um 11:31 schrieb Christoph Heiss:
> Between the number of CPUs and the actual label, a space was missing -
> resulting in an inconsistency vs. the "CPU usage" column.
> 
> Also, fix a rather nonsensical check for `maxcpu` above - noticed that
> while comparing the implementation to that of Proxmox.Utils.render_cpu().

can we split this in a different patch? it's rather unrelated.

Also I think the error here was the lacking parenthesis, i.e., the
following minimal change would make the check also correct

if (!(Ext.isNumeric(maxcpu) && maxcpu >= 1)) {

But I still like yours more, just wanted to point out that this was
probably a simple typo or incompletely moving from one variant to
the other, not straight out bogus in intend.

> 
> Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
> ---
>  www/manager6/Utils.js | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
> index f5608944d..6a0ecc98f 100644
> --- a/www/manager6/Utils.js
> +++ b/www/manager6/Utils.js
> @@ -1073,13 +1073,14 @@ Ext.define('PVE.Utils', {
>  	}
>  	var maxcpu = node.data.maxcpu || 1;
>  
> -	if (!Ext.isNumeric(maxcpu) && (maxcpu >= 1)) {
> +	if (!Ext.isNumeric(maxcpu) || maxcpu < 1) {
>  	    return '';
>  	}
>  
>  	var per = (record.data.cpu/maxcpu) * record.data.maxcpu * 100;
> +	const cpu_label = maxcpu > 1 ? 'CPUs' : 'CPU';
>  
> -	return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU');
> +	return `${per.toFixed(1)}% of ${maxcpu} ${cpu_label}`;
>      },
>  
>      render_bandwidth: function(value) {



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH manager] www: utils: fix inconsistency in host cpu usage display in search view
  2024-07-16 16:07 ` Thomas Lamprecht
@ 2024-07-17 12:27   ` Christoph Heiss
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Heiss @ 2024-07-17 12:27 UTC (permalink / raw)
  To: Thomas Lamprecht; +Cc: Proxmox VE development discussion

On Tue, Jul 16, 2024 at 06:07:10PM GMT, Thomas Lamprecht wrote:
> Am 16/07/2024 um 11:31 schrieb Christoph Heiss:
> > Between the number of CPUs and the actual label, a space was missing -
> > resulting in an inconsistency vs. the "CPU usage" column.
> >
> > Also, fix a rather nonsensical check for `maxcpu` above - noticed that
> > while comparing the implementation to that of Proxmox.Utils.render_cpu().
>
> can we split this in a different patch? it's rather unrelated.

Sure, I'll re-send them as separate patches.

>
> Also I think the error here was the lacking parenthesis, i.e., the
> following minimal change would make the check also correct
>
> if (!(Ext.isNumeric(maxcpu) && maxcpu >= 1)) {
>
> But I still like yours more,

I've just looked at how Proxmox.Utils.render_cpu does it and took that
check verbatim from there.

> just wanted to point out that this was
> probably a simple typo or incompletely moving from one variant to
> the other, not straight out bogus in intend.

Of course, that was my thinking too - that is was just a honest typo.
Should probably have formulated that a bit different.

>
> >
> > Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
> > ---
> >  www/manager6/Utils.js | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
> > index f5608944d..6a0ecc98f 100644
> > --- a/www/manager6/Utils.js
> > +++ b/www/manager6/Utils.js
> > @@ -1073,13 +1073,14 @@ Ext.define('PVE.Utils', {
> >  	}
> >  	var maxcpu = node.data.maxcpu || 1;
> >
> > -	if (!Ext.isNumeric(maxcpu) && (maxcpu >= 1)) {
> > +	if (!Ext.isNumeric(maxcpu) || maxcpu < 1) {
> >  	    return '';
> >  	}
> >
> >  	var per = (record.data.cpu/maxcpu) * record.data.maxcpu * 100;
> > +	const cpu_label = maxcpu > 1 ? 'CPUs' : 'CPU';
> >
> > -	return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU');
> > +	return `${per.toFixed(1)}% of ${maxcpu} ${cpu_label}`;
> >      },
> >
> >      render_bandwidth: function(value) {
>


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-17 12:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-16  9:31 [pve-devel] [PATCH manager] www: utils: fix inconsistency in host cpu usage display in search view Christoph Heiss
2024-07-16 16:07 ` Thomas Lamprecht
2024-07-17 12:27   ` Christoph Heiss

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal