improve: add version data to mock nodes and clean up storage display

- Add PVE and kernel version data to mock node generation
- Remove redundant total storage stats from node header rows in storage tab
- Simplify storage table layout by spanning node name across full row
This commit is contained in:
Pulse Monitor
2025-08-29 22:43:25 +00:00
parent 5430ec571d
commit 421de870db
2 changed files with 19 additions and 28 deletions
@@ -123,20 +123,6 @@ const Storage: Component = () => {
// setSortDirection('asc');
};
const getTotalByNode = (storages: StorageType[]) => {
const totals = { used: 0, total: 0, free: 0 };
storages.forEach(s => {
totals.used += s.used || 0;
totals.total += s.total || 0;
totals.free += s.free || 0;
});
return totals;
};
const calculateOverallUsage = (storages: StorageType[]) => {
const totals = getTotalByNode(storages);
return totals.total > 0 ? (totals.used / totals.total * 100) : 0;
};
// Handle keyboard shortcuts
let searchInputRef: HTMLInputElement | undefined;
@@ -281,7 +267,7 @@ const Storage: Component = () => {
{/* Group Header */}
<Show when={viewMode() === 'node'}>
<tr class="bg-gray-50/50 dark:bg-gray-700/30">
<td class="p-0.5 px-1.5 text-xs font-medium text-gray-600 dark:text-gray-400">
<td class="p-0.5 px-1.5 text-xs font-medium text-gray-600 dark:text-gray-400" colspan="9">
<a
href={nodeHostMap()[groupName] || (groupName.includes(':') ? `https://${groupName}` : `https://${groupName}:8006`)}
target="_blank"
@@ -292,13 +278,6 @@ const Storage: Component = () => {
{groupName}
</a>
</td>
<td class="p-0.5 px-1.5 text-[10px] text-gray-500 dark:text-gray-400" colspan="8">
{getTotalByNode(storages).total > 0 && (
<span>
{formatBytes(getTotalByNode(storages).used)} / {formatBytes(getTotalByNode(storages).total)} ({calculateOverallUsage(storages).toFixed(1)}%)
</span>
)}
</td>
</tr>
</Show>
+18 -6
View File
@@ -228,13 +228,25 @@ func generateNode(name string, highLoad bool, config MockConfig) models.Node {
coreCounts := []int{4, 8, 12, 16, 24, 32, 48, 64}
cores := coreCounts[rand.Intn(len(coreCounts))]
// Generate realistic version information
pveVersions := []string{"8.2.4", "8.2.2", "8.1.10", "8.0.12", "7.4-18"}
kernelVersions := []string{
"6.8.12-1-pve",
"6.8.8-2-pve",
"6.5.13-5-pve",
"6.2.16-20-pve",
"5.15.143-1-pve",
}
return models.Node{
Name: name,
Instance: "", // Set by generateNodes based on cluster/standalone
Type: "pve",
Status: "online",
Uptime: int64(86400 * (1 + rand.Intn(30))), // 1-30 days
CPU: cpu,
Name: name,
Instance: "", // Set by generateNodes based on cluster/standalone
Type: "pve",
Status: "online",
Uptime: int64(86400 * (1 + rand.Intn(30))), // 1-30 days
CPU: cpu,
PVEVersion: pveVersions[rand.Intn(len(pveVersions))],
KernelVersion: kernelVersions[rand.Intn(len(kernelVersions))],
Memory: models.Memory{
Total: totalMem * 1024 * 1024 * 1024, // Convert to bytes
Used: usedMem * 1024 * 1024 * 1024,