Skip to content

The only tool you need to know what is happening and how to fix it.

more fixes

dduxa3bf998aba2f
diff --git a/frontend/src/lib/components/dashboard/metric-card.svelte b/frontend/src/lib/components/dashboard/metric-card.svelte
index 5bda635e..4a57ec2a 100644
--- a/frontend/src/lib/components/dashboard/metric-card.svelte
+++ b/frontend/src/lib/components/dashboard/metric-card.svelte
@@ -1,7 +1,6 @@
<script lang="ts">
import * as Card from '$lib/components/ui/card';
import * as Chart from "$lib/components/ui/chart/index.js";
- import { TrendingUp, TrendingDown, Minus } from 'lucide-svelte';
import { LineChart, Points } from 'layerchart';
import { scaleUtc } from 'd3-scale';
import type { DashboardMetric, MetricTrendPoint, ServerMetricTrend } from '$lib/types/dashboard';
@@ -20,11 +19,6 @@
metric.servers && metric.servers.length > 1
);
- const statusColors: Record<string, string> = {
- healthy: 'bg-green-500',
- warning: 'bg-yellow-500',
- critical: 'bg-red-500'
- };
// Smart number formatting based on unit type
function formatMetricValue(value: number, unit: string): string {
@@ -62,24 +56,6 @@
return value.toFixed(1);
}
- const formattedValue = $derived(
- metric.formatValue
- ? metric.formatValue(metric.value)
- : formatMetricValue(metric.value, metric.unit)
- );
-
- const TrendChangeIcon = $derived(
- metric.change24h > 0 ? TrendingUp : metric.change24h < 0 ? TrendingDown : Minus
- );
-
- const trendChangeColor = $derived(
- metric.change24h > 0
- ? 'text-green-600 dark:text-green-400'
- : metric.change24h < 0
- ? 'text-red-600 dark:text-red-400'
- : 'text-muted-foreground'
- );
-
// Generate chart config based on servers or single value
const chartConfig = $derived(() => {
if (hasMultiServerData && metric.servers) {
@@ -216,8 +192,8 @@
// Convert to sorted array
return Array.from(timeMap.values())
.map(entry => ({
- timestamp: new Date(entry.timestamp as unknown as number),
- ...entry
+ ...entry,
+ timestamp: new Date(entry.timestamp as unknown as number)
}))
.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());
});
@@ -233,16 +209,10 @@
</script>
<Card.Root class="gap-3">
- <Card.Header class="flex flex-row items-center justify-between space-y-0 pb-0">
+ <Card.Header class="pb-2">
<Card.Title class="text-sm font-medium">
{metric.name}
</Card.Title>
- <div class="text-2xl font-bold">
- {formattedValue}{#if metric.unit && metric.unit !== 'MB'}<span class="ml-1 text-lg text-muted-foreground"
- >{metric.unit}</span
- >{/if}
- </div>
- <!-- <div class={`h-2 w-2 rounded-full ${statusColors[metric.status]}`} title={metric.status}></div> -->
</Card.Header>
<Card.Content class="pt-0">
@@ -346,12 +316,5 @@
{/if}
</Chart.Container>
</MetricChartOverlay>
-
- <!-- 24h Change -->
- <div class="flex items-center text-xs {trendChangeColor}">
- <TrendChangeIcon class="mr-1 h-3 w-3" />
- <span class="font-medium">{Math.abs(metric.change24h).toFixed(1)}%</span>
- <span class="ml-1 text-muted-foreground">vs 24h ago</span>
- </div>
</Card.Content>
</Card.Root>
diff --git a/frontend/src/lib/components/dashboard/server-filter.svelte b/frontend/src/lib/components/dashboard/server-filter.svelte
index f3a6b31f..36ec8480 100644
--- a/frontend/src/lib/components/dashboard/server-filter.svelte
+++ b/frontend/src/lib/components/dashboard/server-filter.svelte
@@ -3,18 +3,19 @@
import * as Popover from '$lib/components/ui/popover';
import { Checkbox } from '$lib/components/ui/checkbox';
import { Server, ChevronDown } from 'lucide-svelte';
- import { getServerColor } from '$lib/utils/server-colors';
interface Props {
availableServers: string[];
selectedServers: string[];
onSelectionChange?: (servers: string[]) => void;
+ serverColorMap: Record<string, string>;
}
let {
availableServers,
selectedServers = $bindable([]),
- onSelectionChange
+ onSelectionChange,
+ serverColorMap
}: Props = $props();
let isOpen = $state(false);
@@ -60,13 +61,26 @@
tempSelectedServers = new Set();
}
- function handleOpenChange(open: boolean) {
- if (!open) {
- // Apply selection when closing
- const newSelection = Array.from(tempSelectedServers);
+ function arraysEqual(a: string[], b: string[]): boolean {
+ if (a.length !== b.length) return false;
+ const sortedA = [...a].sort();
+ const sortedB = [...b].sort();
+ return sortedA.every((v, i) => v === sortedB[i]);
+ }
+
+ function applySelection() {
+ const newSelection = Array.from(tempSelectedServers);
+ if (!arraysEqual(newSelection, selectedServers)) {
selectedServers = newSelection;
onSelectionChange?.(newSelection);
}
+ }
+
+ function handleOpenChange(open: boolean) {
+ if (!open) {
+ // Apply selection when closing (only if changed)
+ applySelection();
+ }
isOpen = open;
}
@@ -109,8 +123,8 @@
</div>
</div>
<div class="max-h-[280px] overflow-y-auto py-2">
- {#each availableServers.sort() as serverName}
- {@const color = getServerColor(serverName, availableServers)}
+ {#each [...availableServers].sort() as serverName}
+ {@const color = serverColorMap[serverName] || '#888888'}
<button
class="w-full px-3 py-1.5 text-left text-sm hover:bg-muted/50 flex items-center gap-3 transition-colors"
onclick={() => toggleServer(serverName)}
@@ -128,7 +142,10 @@
{/each}
</div>
<div class="p-3 border-t">
- <Button size="sm" class="w-full" onclick={() => isOpen = false}>
+ <Button size="sm" class="w-full" onclick={() => {
+ applySelection();
+ isOpen = false;
+ }}>
Apply
</Button>
</div>
diff --git a/frontend/src/lib/utils/server-colors.ts b/frontend/src/lib/utils/server-colors.ts
index 91c69d11..9334c46d 100644
--- a/frontend/src/lib/utils/server-colors.ts
+++ b/frontend/src/lib/utils/server-colors.ts
@@ -1,12 +1,12 @@
export const SERVER_COLORS = [
- 'var(--chart-1)',
- 'var(--chart-2)',
- 'var(--chart-3)',
- 'var(--chart-4)',
- 'var(--chart-5)',
- 'oklch(0.7 0.15 300)', // Purple
- 'oklch(0.7 0.15 120)', // Green
- 'oklch(0.65 0.2 0)' // Red
+ '#e97a35', // Orange
+ '#2a9d8f', // Teal
+ '#4361ee', // Blue
+ '#d664ba', // Pink
+ '#e9c46a', // Yellow
+ '#9b5de5', // Purple
+ '#57cc99', // Green
+ '#ef476f' // Red
] as const;
export function getServerColor(serverName: string, allServers: string[]): string {
diff --git a/frontend/src/routes/metrics/+page.svelte b/frontend/src/routes/metrics/+page.svelte
index 5a4759cf..4af5792b 100644
--- a/frontend/src/routes/metrics/+page.svelte
+++ b/frontend/src/routes/metrics/+page.svelte
@@ -319,6 +319,7 @@
{availableServers}
bind:selectedServers
onSelectionChange={handleServerSelectionChange}
+ {serverColorMap}
/>
{/if}
<TimeRangePicker