1
0
mirror of https://github.com/lensapp/lens.git synced 2024-09-19 05:17:22 +03:00

Display CPU usage percentage with 2 decimal points (#2000)

Signed-off-by: Alex Culliere <alozhkin@mirantis.com>
This commit is contained in:
Alex 2021-01-22 16:51:42 +02:00 committed by GitHub
parent f8c111ddd8
commit 9da349ce42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,6 +51,10 @@ export class Nodes extends React.Component<Props> {
if (!metrics || !metrics[1]) return <LineProgress value={0}/>;
const usage = metrics[0];
const cores = metrics[1];
const cpuUsagePercent = Math.ceil(usage * 100) / cores;
const cpuUsagePercentLabel: String = cpuUsagePercent % 1 === 0
? cpuUsagePercent.toString()
: cpuUsagePercent.toFixed(2);
return (
<LineProgress
@ -58,7 +62,7 @@ export class Nodes extends React.Component<Props> {
value={usage}
tooltip={{
preferredPositions: TooltipPosition.BOTTOM,
children: `CPU: ${Math.ceil(usage * 100) / cores}\%, cores: ${cores}`
children: `CPU: ${cpuUsagePercentLabel}\%, cores: ${cores}`
}}
/>
);