diff --git a/messages/en.json b/messages/en.json index be46a6a..7beb075 100644 --- a/messages/en.json +++ b/messages/en.json @@ -574,5 +574,7 @@ "contest_collaborators_remove_cancel": "Cancel", "contest_collaborators_remove_success": "Collaborator removed successfully!", "contest_collaborators_remove_error": "Failed to remove collaborator", - "admin_contests_card_view_collaborators": "View Collaborators" + "admin_contests_card_view_collaborators": "View Collaborators", + "admin_dashboard_worker_id": "Worker {id}", + "admin_dashboard_worker_processing": "Processing:" } diff --git a/messages/pl.json b/messages/pl.json index 1483dc8..33864af 100644 --- a/messages/pl.json +++ b/messages/pl.json @@ -574,5 +574,7 @@ "contest_collaborators_remove_cancel": "Anuluj", "contest_collaborators_remove_success": "Współpracownik został usunięty pomyślnie!", "contest_collaborators_remove_error": "Nie udało się usunąć współpracownika", - "admin_contests_card_view_collaborators": "Zobacz Współpracowników" + "admin_contests_card_view_collaborators": "Zobacz Współpracowników", + "admin_dashboard_worker_id": "Worker {id}", + "admin_dashboard_worker_processing": "Przetwarzanie:" } diff --git a/src/lib/dto/worker.ts b/src/lib/dto/worker.ts index 9476fb2..0984c1c 100644 --- a/src/lib/dto/worker.ts +++ b/src/lib/dto/worker.ts @@ -1,6 +1,17 @@ +export enum WorkerStatusType { + Idle = 'idle', + Busy = 'busy' +} + +export interface WorkerStatusItem { + id: number; + status: WorkerStatusType; + processingMessageId?: string; +} + export interface WorkerStatus { busyWorkers: number; statusTime: string; totalWorkers: number; - workerStatus: Record; + workerStatus: WorkerStatusItem[]; } diff --git a/src/routes/dashboard/admin/+page.svelte b/src/routes/dashboard/admin/+page.svelte index 91b10f3..5fe4ab0 100644 --- a/src/routes/dashboard/admin/+page.svelte +++ b/src/routes/dashboard/admin/+page.svelte @@ -8,8 +8,19 @@ import Activity from '@lucide/svelte/icons/activity'; import CheckCircle from '@lucide/svelte/icons/check-circle'; import Clock from '@lucide/svelte/icons/clock'; + import { WorkerStatusType } from '$lib/dto/worker'; const workerStatusQuery = getWorkerStatus(); + + // Status styling configuration + const statusStyles = { + [WorkerStatusType.Idle]: 'bg-primary/10 text-primary', + [WorkerStatusType.Busy]: 'bg-secondary/10 text-secondary-foreground' + } as const; + + function getStatusStyle(status: WorkerStatusType): string { + return statusStyles[status] || 'bg-muted/10 text-muted-foreground'; + }
@@ -40,7 +51,7 @@ class="group relative overflow-hidden shadow-lg transition-all duration-300 hover:-translate-y-2 hover:shadow-xl" >
@@ -55,7 +66,7 @@

@@ -64,7 +75,7 @@
@@ -75,7 +86,7 @@ class="group relative overflow-hidden shadow-lg transition-all duration-300 hover:-translate-y-2 hover:shadow-xl" >
@@ -90,7 +101,7 @@

@@ -99,7 +110,7 @@
@@ -110,7 +121,7 @@ class="group relative overflow-hidden shadow-lg transition-all duration-300 hover:-translate-y-2 hover:shadow-xl" >
@@ -125,7 +136,7 @@

@@ -134,7 +145,7 @@
@@ -142,13 +153,13 @@ - {#if Object.keys(status.workerStatus).length > 0} + {#if status.workerStatus.length > 0}
@@ -165,30 +176,32 @@
- {#each Object.entries(status.workerStatus) as [workerId, workerState] (workerId)} + {#each status.workerStatus as worker (worker.id)}
-
-
-

{workerId}

-
- {#if workerState === 'idle'} +
+
+

+ {m.admin_dashboard_worker_id({ id: worker.id })} +

- {workerState} - - {:else} - - {workerState} + {worker.status} +
+ {#if worker.processingMessageId} +
+ {m.admin_dashboard_worker_processing()} + {worker.processingMessageId} +
{/if}