+ :class="$store.notificationStore?.getNotificationItemClass(notification) || 'notification-item'"
+ @click="$store.notificationStore?.markAsRead(notification.id)">
+ x-html="$store.notificationStore?.getNotificationIcon(notification.type) || ''">
@@ -45,7 +40,7 @@
x-text="notification.message">
+ x-text="$store.notificationStore?.formatTimestamp(notification.timestamp) || notification.timestamp">
@@ -74,11 +69,13 @@
-
-
đ
+
+
+ notifications
+
No notifications to display
+ x-show="$store.notificationStore && $store.notificationStore.notifications.length > 0">
All notifications have been read and are older than 5 minutes
diff --git a/webui/js/notificationStore.js b/webui/components/notifications/notification-store.js
similarity index 93%
rename from webui/js/notificationStore.js
rename to webui/components/notifications/notification-store.js
index 257b8b14f..869e54f41 100644
--- a/webui/js/notificationStore.js
+++ b/webui/components/notifications/notification-store.js
@@ -306,16 +306,17 @@ const model = {
return `notification-item ${typeClass} ${readClass}`;
},
- // Get icon for notification type
+ // Get icon for notification type (Google Material Icons)
getNotificationIcon(type) {
const icons = {
- info: "âšī¸",
- success: "â
",
- warning: "â ī¸",
- error: "â",
- progress: "âŗ"
+ info: "info",
+ success: "check_circle",
+ warning: "warning",
+ error: "error",
+ progress: "hourglass_empty"
};
- return icons[type] || "âšī¸";
+ const iconName = icons[type] || "info";
+ return `
${iconName}`;
},
// Create notification via backend (will appear via polling)
@@ -491,10 +492,10 @@ const model = {
const store = createStore("notificationStore", model);
// NEW: Global function for frontend error toasts (replaces toastFetchError)
-window.toastFrontendError = async function(message, title = "Connection Error") {
+window.toastFrontendError = async function(message, title = "Connection Error", display_time = 8, group = "") {
if (window.Alpine && window.Alpine.store && window.Alpine.store('notificationStore')) {
try {
- return await window.Alpine.store('notificationStore').frontendError(message, title);
+ return await window.Alpine.store('notificationStore').addFrontendToast('error', message, title, display_time, group);
} catch (error) {
console.error('Failed to create frontend error notification:', error);
// Fallback to console if something goes wrong
@@ -509,10 +510,10 @@ window.toastFrontendError = async function(message, title = "Connection Error")
};
// NEW: Additional global convenience functions
-window.toastFrontendWarning = async function(message, title = "Warning") {
+window.toastFrontendWarning = async function(message, title = "Warning", display_time = 5, group = "") {
if (window.Alpine && window.Alpine.store && window.Alpine.store('notificationStore')) {
try {
- return await window.Alpine.store('notificationStore').frontendWarning(message, title);
+ return await window.Alpine.store('notificationStore').addFrontendToast('warning', message, title, display_time, group);
} catch (error) {
console.error('Failed to create frontend warning notification:', error);
console.warn('Frontend Warning:', title, '-', message);
@@ -524,10 +525,10 @@ window.toastFrontendWarning = async function(message, title = "Warning") {
}
};
-window.toastFrontendInfo = async function(message, title = "Info") {
+window.toastFrontendInfo = async function(message, title = "Info", display_time = 3, group = "") {
if (window.Alpine && window.Alpine.store && window.Alpine.store('notificationStore')) {
try {
- return await window.Alpine.store('notificationStore').frontendInfo(message, title);
+ return await window.Alpine.store('notificationStore').addFrontendToast('info', message, title, display_time, group);
} catch (error) {
console.error('Failed to create frontend info notification:', error);
console.log('Frontend Info:', title, '-', message);
@@ -539,4 +540,19 @@ window.toastFrontendInfo = async function(message, title = "Info") {
}
};
+window.toastFrontendSuccess = async function(message, title = "Success", display_time = 3, group = "") {
+ if (window.Alpine && window.Alpine.store && window.Alpine.store('notificationStore')) {
+ try {
+ return await window.Alpine.store('notificationStore').addFrontendToast('success', message, title, display_time, group);
+ } catch (error) {
+ console.error('Failed to create frontend success notification:', error);
+ console.log('Frontend Success:', title, '-', message);
+ return null;
+ }
+ } else {
+ console.log('Frontend Success:', title, '-', message);
+ return null;
+ }
+};
+
export { store };
diff --git a/webui/components/notifications/notification-toast-stack.html b/webui/components/notifications/notification-toast-stack.html
index 8bbd77fc2..4f37c6d5a 100644
--- a/webui/components/notifications/notification-toast-stack.html
+++ b/webui/components/notifications/notification-toast-stack.html
@@ -2,14 +2,15 @@
Notification Toast Stack