From dcc3d7f2d5fa9f69e4a80d46ea4b6d031c78b71c Mon Sep 17 00:00:00 2001 From: ayurishchev Date: Sun, 4 Oct 2026 21:05:41 +0300 Subject: [PATCH] UI: shared toast notifications in the bottom-right corner - useToast composable and ToastContainer (mounted once in App.vue): stacked toasts with icon, close button and progress bar, hover pause, slide-in animation, aria roles, full width on phones. - Light and dark theme colour tokens; old .toast-message styles removed. - PKIConfig, VPNConfig, ServerManagement and Certificates use the shared toast through thin showMessage/showToast wrappers. - Docs: plan and summary in DOCS/Changes, README, Index. Co-Authored-By: Claude Sonnet 5.5 --- APP_UI/src/App.vue | 4 + APP_UI/src/assets/main.css | 179 +++++++++++++++--- APP_UI/src/components/ToastContainer.vue | 33 ++++ APP_UI/src/composables/useToast.js | 64 +++++++ APP_UI/src/views/Certificates.vue | 16 +- APP_UI/src/views/PKIConfig.vue | 23 +-- APP_UI/src/views/ServerManagement.vue | 22 +-- APP_UI/src/views/VPNConfig.vue | 18 +- .../Changes/2026-10-04_Toast_Notifications.md | 28 +++ .../2026-10-04_Toast_Notifications_PLAN.md | 20 ++ DOCS/General/Index.md | 1 + README.md | 1 + 12 files changed, 316 insertions(+), 93 deletions(-) create mode 100644 APP_UI/src/components/ToastContainer.vue create mode 100644 APP_UI/src/composables/useToast.js create mode 100644 DOCS/Changes/2026-10-04_Toast_Notifications.md create mode 100644 DOCS/Changes/2026-10-04_Toast_Notifications_PLAN.md diff --git a/APP_UI/src/App.vue b/APP_UI/src/App.vue index 18ab9f2..b68be8b 100644 --- a/APP_UI/src/App.vue +++ b/APP_UI/src/App.vue @@ -118,6 +118,9 @@ + + + diff --git a/APP_UI/src/composables/useToast.js b/APP_UI/src/composables/useToast.js new file mode 100644 index 0000000..fdcce74 --- /dev/null +++ b/APP_UI/src/composables/useToast.js @@ -0,0 +1,64 @@ +import { reactive } from 'vue'; + +const MAX_VISIBLE = 4; +const DEFAULT_TIMEOUT = 5000; +const ERROR_TIMEOUT = 8000; + +// Module-level state: every caller (views, ToastContainer) shares the same list +const toasts = reactive([]); +const timers = new Map(); // id -> { handle, startedAt, remaining } +let nextId = 1; + +const clearTimer = (id) => { + const t = timers.get(id); + if (t) clearTimeout(t.handle); + timers.delete(id); +}; + +const dismiss = (id) => { + clearTimer(id); + const idx = toasts.findIndex((t) => t.id === id); + if (idx !== -1) toasts.splice(idx, 1); +}; + +const startTimer = (id, ms) => { + clearTimer(id); + timers.set(id, { handle: setTimeout(() => dismiss(id), ms), startedAt: Date.now(), remaining: ms }); +}; + +// Stop the countdown (mouse over the toast); the progress bar is paused by CSS +const pause = (id) => { + const t = timers.get(id); + if (!t) return; + clearTimeout(t.handle); + t.remaining = Math.max(0, t.remaining - (Date.now() - t.startedAt)); + t.handle = null; +}; + +const resume = (id) => { + const t = timers.get(id); + if (!t || t.handle !== null) return; + startTimer(id, t.remaining); +}; + +const show = (text, type = 'success', timeout) => { + const kind = ['success', 'warning', 'error', 'info'].includes(type) ? type : 'info'; + const duration = timeout ?? (kind === 'error' ? ERROR_TIMEOUT : DEFAULT_TIMEOUT); + const id = nextId++; + + toasts.push({ id, text: String(text ?? ''), type: kind, timeout: duration }); + while (toasts.length > MAX_VISIBLE) dismiss(toasts[0].id); + if (duration > 0) startTimer(id, duration); + return id; +}; + +// Drop everything and release all timers (container unmount) +const clear = () => { + timers.forEach((t) => clearTimeout(t.handle)); + timers.clear(); + toasts.splice(0, toasts.length); +}; + +export function useToast() { + return { toasts, show, dismiss, pause, resume, clear }; +} diff --git a/APP_UI/src/views/Certificates.vue b/APP_UI/src/views/Certificates.vue index 7f082e8..d4c684e 100644 --- a/APP_UI/src/views/Certificates.vue +++ b/APP_UI/src/views/Certificates.vue @@ -147,11 +147,6 @@ - -
- - {{ toastMessage }} -