varaverk: memory card — top 3 usages by size in top-right corner
This commit is contained in:
@@ -259,8 +259,25 @@ function vvRenderMemory(mem) {
|
|||||||
const usedKb = total - (mem.free_kb ?? 0);
|
const usedKb = total - (mem.free_kb ?? 0);
|
||||||
const usedPct = Math.round(usedKb / total * 100);
|
const usedPct = Math.round(usedKb / total * 100);
|
||||||
const totalColor = usedPct >= 85 ? '#f44336' : usedPct >= 65 ? '#ff9800' : '#ccc';
|
const totalColor = usedPct >= 85 ? '#f44336' : usedPct >= 65 ? '#ff9800' : '#ccc';
|
||||||
let html = `<div style="font-size:14px;font-weight:600;color:${totalColor};margin-bottom:10px;">
|
|
||||||
|
const buckets = [
|
||||||
|
{ label: 'System', kb: mem.system_kb ?? 0, color: VV_MEM_COLORS.system },
|
||||||
|
{ label: 'VM', kb: mem.vm_kb ?? 0, color: VV_MEM_COLORS.vm },
|
||||||
|
{ label: 'ZFS', kb: mem.zfs_kb ?? 0, color: VV_MEM_COLORS.zfs },
|
||||||
|
{ label: 'Docker', kb: mem.docker_kb ?? 0, color: VV_MEM_COLORS.docker },
|
||||||
|
];
|
||||||
|
const top3 = [...buckets].sort((a, b) => b.kb - a.kb).slice(0, 3);
|
||||||
|
const top3Html = top3.map(b =>
|
||||||
|
`<div><span style="color:${b.color};font-size:9px;margin-right:3px;">●</span>`+
|
||||||
|
`<span style="color:#888;font-size:9px;">${b.label} </span>`+
|
||||||
|
`<span style="color:#aaa;font-size:10px;font-weight:600;">${vvFmtGib(b.kb)}</span></div>`
|
||||||
|
).join('');
|
||||||
|
|
||||||
|
let html = `<div style="display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:10px;">
|
||||||
|
<div style="font-size:14px;font-weight:600;color:${totalColor};">
|
||||||
${vvFmtGib(usedKb)} <span style="font-size:11px;color:#555;font-weight:400;">/ ${vvFmtGib(total)}</span>
|
${vvFmtGib(usedKb)} <span style="font-size:11px;color:#555;font-weight:400;">/ ${vvFmtGib(total)}</span>
|
||||||
|
</div>
|
||||||
|
<div style="text-align:right;line-height:1.7;">${top3Html}</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
html += vvMemRow('System', mem.system_kb ?? 0, total, VV_MEM_COLORS.system)
|
html += vvMemRow('System', mem.system_kb ?? 0, total, VV_MEM_COLORS.system)
|
||||||
+ vvMemRow('VM', mem.vm_kb ?? 0, total, VV_MEM_COLORS.vm)
|
+ vvMemRow('VM', mem.vm_kb ?? 0, total, VV_MEM_COLORS.vm)
|
||||||
|
|||||||
Reference in New Issue
Block a user