b673e87c9b
Add hoover model.js as a central reactive store per subsystem, replacing per-component data fetching with a single source of truth. - Add hoover/model.js with modelRegister, modelFetch, and WS invalidation - Refactor websocket.js to route messages to model refresh (drop per-component subscribe/unsubscribe) - Simplify component.js by removing WS subscription management - Add refresh option to apiSubmit, deprecate refactorLoad and checkAbort - Rewrite all pages to use getModel() instead of inline data fetching - Bootstrap model registrations in app.js - Add GET /api/firewall/state endpoint - Fix restart-services.sh restart order and add service health verification - Update hoover.md docs with model layer architecture
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
/**
|
|
* Hoover — components/toast.js
|
|
*
|
|
* ToastContainer component that renders queued toast notifications.
|
|
* Uses the toast/dismissToast state from api.js.
|
|
*/
|
|
|
|
import { h } from '../vdom.js?v=7';
|
|
import { _toasts, dismissToast } from '../api.js?v=7';
|
|
|
|
/**
|
|
* Render all pending toast notifications.
|
|
*
|
|
* @returns {VNode}
|
|
*/
|
|
export function ToastContainer() {
|
|
if (!_toasts.length) return h('#text', '');
|
|
|
|
const clsMap = {
|
|
info: 'toast-info',
|
|
success: 'toast-success',
|
|
error: 'toast-error',
|
|
warning: 'toast-warning',
|
|
};
|
|
|
|
return h('div', { class: 'toast-container' },
|
|
..._toasts.map(t =>
|
|
h('div', {
|
|
class: `toast ${clsMap[t.type] || clsMap.info}`,
|
|
'on:click': () => dismissToast(t.id),
|
|
},
|
|
h('span', null, t.message),
|
|
h('button', {
|
|
class: 'toast-close',
|
|
'on:click': (e) => { e.stopPropagation(); dismissToast(t.id); },
|
|
}, '\u00d7'),
|
|
),
|
|
),
|
|
);
|
|
}
|