From 4806c62976ca0ba59adf9059a0a9704c0a66630a Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 13 Nov 2026 19:53:30 +0100 Subject: [PATCH] feat(mail-ingest): the admin status as tiles with a health dot The last read sits in the head line with a green dot, amber while the last run failed; the day's numbers are tiles with their icon in a soft tone (mails, added on their own, waiting, failed turning red above zero); the last error is its own amber note. Desktop and phone. --- .../Admin/mailIngest/MailIngestAdminCard.tsx | 95 +++++++++++++++---- .../screens/admin/MMailIngestAdminCard.tsx | 86 +++++++++++++---- 2 files changed, 145 insertions(+), 36 deletions(-) diff --git a/client/src/components/Admin/mailIngest/MailIngestAdminCard.tsx b/client/src/components/Admin/mailIngest/MailIngestAdminCard.tsx index 7fdfe74de..7df33878e 100644 --- a/client/src/components/Admin/mailIngest/MailIngestAdminCard.tsx +++ b/client/src/components/Admin/mailIngest/MailIngestAdminCard.tsx @@ -1,4 +1,17 @@ -import { CheckCircle, Copy, Inbox, Loader2, Mail, PlugZap, Save, Upload, Webhook, XCircle } from 'lucide-react'; +import { + AlertTriangle, + CheckCircle, + Clock, + Copy, + Inbox, + Loader2, + Mail, + PlugZap, + Save, + Upload, + Webhook, + XCircle, +} from 'lucide-react'; import type { ReactNode } from 'react'; import { useTranslation } from '../../../i18n'; import type { TranslationFn } from '../../../types'; @@ -156,7 +169,46 @@ function WebhookFields({ admin, form, t, error }: FieldsProps) { ); } -/** How the import runs, in counts only: no subject, sender or content of a mail is ever shown here. */ +type StatTone = 'neutral' | 'success' | 'warning' | 'danger'; + +const STAT_TONE: Record = { + neutral: { icon: 'bg-surface-tertiary text-content-muted', value: 'text-content' }, + success: { icon: 'bg-success-soft text-success', value: 'text-content' }, + warning: { icon: 'bg-warning-soft text-warning', value: 'text-content' }, + danger: { icon: 'bg-danger-soft text-danger', value: 'text-danger' }, +}; + +/** One number of the status: its icon in the tone's soft colour, the count large, the label under it. */ +function StatTile({ + icon: Icon, + label, + value, + tone, +}: { + icon: typeof Mail; + label: string; + value: number; + tone: StatTone; +}) { + const look = STAT_TONE[tone]; + return ( +
+ + + +
+
{value}
+
{label}
+
+
+ ); +} + +/** + * How the import runs, in counts only: no subject, sender or content of a mail + * is ever shown here. A head line with the last successful read (green, or + * amber while the last run failed), then the day's numbers as tiles. + */ function StatusBlock({ admin, t, locale }: { admin: MailIngestAdmin; t: T; locale: string }) { const status = admin.status; if (!status) return null; @@ -164,30 +216,35 @@ function StatusBlock({ admin, t, locale }: { admin: MailIngestAdmin; t: T; local const lastRead = status.last_ok_at ? relativeTime(Date.parse(status.last_ok_at), locale) : t('mailAdmin.status.never'); + const healthy = !status.last_error && !!status.last_ok_at; return ( -
-
+
+
{t('mailAdmin.status.title')} - + + {t('mailAdmin.status.lastRead', { time: lastRead })} - +
-
- {[ - { label: t('mailAdmin.status.mails'), value: facts.mails }, - { label: t('mailAdmin.status.added'), value: facts.added }, - { label: t('mailAdmin.status.waiting'), value: facts.waiting }, - { label: t('mailAdmin.status.failed'), value: facts.failed }, - ].map((f) => ( -
-
{f.label}
-
{f.value}
-
- ))} +
+ + + + 0 ? 'danger' : 'neutral'} + />
- {status.last_error && {status.last_error}} + {status.last_error && ( +

+ + {status.last_error} +

+ )}
); } diff --git a/client/src/mobile/screens/admin/MMailIngestAdminCard.tsx b/client/src/mobile/screens/admin/MMailIngestAdminCard.tsx index 5a2446b30..e0d0097bb 100644 --- a/client/src/mobile/screens/admin/MMailIngestAdminCard.tsx +++ b/client/src/mobile/screens/admin/MMailIngestAdminCard.tsx @@ -1,4 +1,4 @@ -import { Inbox, Upload, Webhook } from 'lucide-react'; +import { CheckCircle, Clock, Inbox, Mail, Upload, Webhook, XCircle } from 'lucide-react'; import { TRANSPORTS, problemText, @@ -111,7 +111,50 @@ function WebhookFields({ admin, form, t }: PartProps) { ); } -/** How the import runs, in counts only. */ +type StatTone = 'neutral' | 'success' | 'warning' | 'danger'; + +const STAT_COLOR: Record = { + neutral: 'var(--m-muted)', + success: 'var(--m-st-confirmed)', + warning: 'var(--m-st-pending)', + danger: 'var(--m-st-danger)', +}; + +/** One number of the status, the desktop tile in the phone's tokens. */ +function StatTile({ + icon: Icon, + label, + value, + tone, +}: { + icon: typeof Mail; + label: string; + value: number; + tone: StatTone; +}) { + const color = STAT_COLOR[tone]; + return ( +
+ + + +
+
+ {value} +
+
{label}
+
+
+ ); +} + +/** How the import runs, in counts only: the last read with its health dot, then the day's numbers. */ function Status({ admin, t, locale }: { admin: MailIngestAdmin; t: TranslationFn; locale: string }) { const status = admin.status; if (!status) return null; @@ -119,23 +162,32 @@ function Status({ admin, t, locale }: { admin: MailIngestAdmin; t: TranslationFn const lastRead = status.last_ok_at ? relativeTime(Date.parse(status.last_ok_at), locale) : t('mailAdmin.status.never'); + const healthy = !status.last_error && !!status.last_ok_at; return ( -
-

{t('mailAdmin.status.lastRead', { time: lastRead })}

-
- {[ - { label: t('mailAdmin.status.mails'), value: facts.mails }, - { label: t('mailAdmin.status.added'), value: facts.added }, - { label: t('mailAdmin.status.waiting'), value: facts.waiting }, - { label: t('mailAdmin.status.failed'), value: facts.failed }, - ].map((f) => ( -
- {f.label} - {f.value} -
- ))} +
+

+ + {t('mailAdmin.status.lastRead', { time: lastRead })} +

+
+ + + + 0 ? 'danger' : 'neutral'} + />
- {status.last_error &&

{status.last_error}

} + {status.last_error && ( +

+ {status.last_error} +

+ )}
); }