Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
}
4 changes: 3 additions & 1 deletion messages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
}
13 changes: 12 additions & 1 deletion src/lib/dto/worker.ts
Original file line number Diff line number Diff line change
@@ -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<string, string>;
workerStatus: WorkerStatusItem[];
}
65 changes: 39 additions & 26 deletions src/routes/dashboard/admin/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
</script>

<div class="space-y-6">
Expand Down Expand Up @@ -40,7 +51,7 @@
class="group relative overflow-hidden shadow-lg transition-all duration-300 hover:-translate-y-2 hover:shadow-xl"
>
<div
class="absolute inset-0 bg-gradient-to-br from-[var(--primary)]/5 via-[var(--secondary)]/5 to-[var(--primary)]/10 opacity-30 transition-opacity duration-300 group-hover:opacity-50"
class="absolute inset-0 bg-linear-to-br from-(--primary)/5 via-(--secondary)/5 to-(--primary)/10 opacity-30 transition-opacity duration-300 group-hover:opacity-50"
></div>

<Card.Content class="relative p-6">
Expand All @@ -55,7 +66,7 @@
</p>
</div>
<div
class="flex h-12 w-12 items-center justify-center rounded-xl bg-gradient-to-br from-[var(--primary)] to-[var(--secondary)] shadow-md transition-transform duration-300 group-hover:scale-110"
class="flex h-12 w-12 items-center justify-center rounded-xl bg-linear-to-br from-primary to-secondary shadow-md transition-transform duration-300 group-hover:scale-110"
>
<Server class="h-6 w-6 text-primary-foreground" />
</div>
Expand All @@ -64,7 +75,7 @@
<!-- Progress bar -->
<div class="mt-4 h-1 w-full overflow-hidden rounded-full bg-muted">
<div
class="h-full origin-left scale-x-0 transform rounded-full bg-gradient-to-r from-[var(--primary)] to-[var(--secondary)] transition-transform duration-500 group-hover:scale-x-100"
class="h-full origin-left scale-x-0 transform rounded-full bg-linear-to-r from-primary to-secondary transition-transform duration-500 group-hover:scale-x-100"
></div>
</div>
</Card.Content>
Expand All @@ -75,7 +86,7 @@
class="group relative overflow-hidden shadow-lg transition-all duration-300 hover:-translate-y-2 hover:shadow-xl"
>
<div
class="absolute inset-0 bg-gradient-to-br from-[var(--primary)]/5 via-[var(--secondary)]/5 to-[var(--primary)]/10 opacity-30 transition-opacity duration-300 group-hover:opacity-50"
class="absolute inset-0 bg-linear-to-br from-(--primary)/5 via-(--secondary)/5 to-(--primary)/10 opacity-30 transition-opacity duration-300 group-hover:opacity-50"
></div>

<Card.Content class="relative p-6">
Expand All @@ -90,7 +101,7 @@
</p>
</div>
<div
class="flex h-12 w-12 items-center justify-center rounded-xl bg-gradient-to-br from-[var(--primary)] to-[var(--secondary)] shadow-md transition-transform duration-300 group-hover:scale-110"
class="flex h-12 w-12 items-center justify-center rounded-xl bg-linear-to-br from-primary to-secondary shadow-md transition-transform duration-300 group-hover:scale-110"
>
<Activity class="h-6 w-6 text-primary-foreground" />
</div>
Expand All @@ -99,7 +110,7 @@
<!-- Progress bar -->
<div class="mt-4 h-1 w-full overflow-hidden rounded-full bg-muted">
<div
class="h-full origin-left scale-x-0 transform rounded-full bg-gradient-to-r from-[var(--primary)] to-[var(--secondary)] transition-transform duration-500 group-hover:scale-x-100"
class="h-full origin-left scale-x-0 transform rounded-full bg-linear-to-r from-primary to-secondary transition-transform duration-500 group-hover:scale-x-100"
></div>
</div>
</Card.Content>
Expand All @@ -110,7 +121,7 @@
class="group relative overflow-hidden shadow-lg transition-all duration-300 hover:-translate-y-2 hover:shadow-xl"
>
<div
class="absolute inset-0 bg-gradient-to-br from-[var(--primary)]/5 via-[var(--secondary)]/5 to-[var(--primary)]/10 opacity-30 transition-opacity duration-300 group-hover:opacity-50"
class="absolute inset-0 bg-linear-to-br from-(--primary)/5 via-(--secondary)/5 to-(--primary)/10 opacity-30 transition-opacity duration-300 group-hover:opacity-50"
></div>

<Card.Content class="relative p-6">
Expand All @@ -125,7 +136,7 @@
</p>
</div>
<div
class="flex h-12 w-12 items-center justify-center rounded-xl bg-gradient-to-br from-[var(--primary)] to-[var(--secondary)] shadow-md transition-transform duration-300 group-hover:scale-110"
class="flex h-12 w-12 items-center justify-center rounded-xl bg-linear-to-br from-primary to-secondary shadow-md transition-transform duration-300 group-hover:scale-110"
>
<CheckCircle class="h-6 w-6 text-primary-foreground" />
</div>
Expand All @@ -134,21 +145,21 @@
<!-- Progress bar -->
<div class="mt-4 h-1 w-full overflow-hidden rounded-full bg-muted">
<div
class="h-full origin-left scale-x-0 transform rounded-full bg-gradient-to-r from-[var(--primary)] to-[var(--secondary)] transition-transform duration-500 group-hover:scale-x-100"
class="h-full origin-left scale-x-0 transform rounded-full bg-linear-to-r from-primary to-secondary transition-transform duration-500 group-hover:scale-x-100"
></div>
</div>
</Card.Content>
</Card.Root>
</div>

<!-- Worker Details Card -->
{#if Object.keys(status.workerStatus).length > 0}
{#if status.workerStatus.length > 0}
<Card.Root
class="group relative overflow-hidden border-border shadow-md transition-all duration-300 hover:shadow-lg"
>
<!-- Gradient Background Overlay -->
<div
class="absolute inset-0 bg-gradient-to-br from-[var(--primary)]/5 via-[var(--secondary)]/5 to-[var(--primary)]/10 opacity-30 transition-opacity duration-300 group-hover:opacity-50"
class="absolute inset-0 bg-linear-to-br from-(--primary)/5 via-(--secondary)/5 to-(--primary)/10 opacity-30 transition-opacity duration-300 group-hover:opacity-50"
></div>

<Card.Header class="relative">
Expand All @@ -165,30 +176,32 @@

<Card.Content class="relative">
<div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
{#each Object.entries(status.workerStatus) as [workerId, workerState] (workerId)}
{#each status.workerStatus as worker (worker.id)}
<div
class="group/item relative overflow-hidden rounded-lg border border-border bg-card p-4 transition-all duration-300 hover:-translate-y-1 hover:shadow-md"
>
<div
class="absolute inset-0 bg-gradient-to-br from-[var(--primary)] to-[var(--secondary)] opacity-5 transition-opacity duration-300 group-hover/item:opacity-10"
class="absolute inset-0 bg-linear-to-br from-primary to-secondary opacity-5 transition-opacity duration-300 group-hover/item:opacity-10"
></div>

<div class="relative flex items-center justify-between">
<div class="flex-1">
<p class="font-mono text-sm font-medium text-foreground">{workerId}</p>
</div>
{#if workerState === 'idle'}
<div class="relative space-y-2">
<div class="flex items-center justify-between">
<p class="font-mono text-sm font-medium text-foreground">
{m.admin_dashboard_worker_id({ id: worker.id })}
</p>
<span
class="inline-flex items-center rounded-full bg-primary/10 px-3 py-1 text-xs font-semibold text-primary shadow-sm"
class="inline-flex items-center rounded-full px-3 py-1 text-xs font-semibold shadow-sm {getStatusStyle(
worker.status
)}"
>
{workerState}
</span>
{:else}
<span
class="inline-flex items-center rounded-full bg-secondary/10 px-3 py-1 text-xs font-semibold text-secondary-foreground shadow-sm"
>
{workerState}
{worker.status}
</span>
</div>
{#if worker.processingMessageId}
<div class="text-xs text-muted-foreground">
<span class="font-medium">{m.admin_dashboard_worker_processing()}</span>
<span class="font-mono">{worker.processingMessageId}</span>
</div>
{/if}
</div>
</div>
Expand Down