fix: optimize column `CPU Usage` in `Monitor Nodes` (#34)

Co-authored-by: yaojiping <yaojiping@infini.ltd>
This commit is contained in:
yaojp123 2024-12-14 17:31:48 +08:00 committed by GitHub
parent aaa4dcee6b
commit 1a62e5a1c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 2 deletions

View File

@ -153,7 +153,16 @@ export default ({
{
title: "CPU Usage",
dataIndex: "cpu",
render: (text, record) => <span>{text ? `${text}%` : "N/A"}</span>,
render: (text, record) => {
const number = parseFloat(text);
if (Number.isNaN(number)) {
return "N/A"
}
if (number === 0) {
return "1%"
}
return `${text}%`
},
sorter: (a, b) => a?.cpu - b?.cpu,
className: "verticalAlign",
},
@ -171,7 +180,16 @@ export default ({
{
title: "JVM Heap",
dataIndex: "heap.percent",
render: (text, record) => <span>{text ? `${text}%` : "N/A"}</span>,
render: (text, record) => {
const number = parseFloat(text);
if (Number.isNaN(number)) {
return "N/A"
}
if (number === 0) {
return "1%"
}
return `${text}%`
},
sorter: (a, b) => a?.["heap.percent"] - b?.["heap.percent"],
className: "verticalAlign",
},