diff --git a/front/css/app.css b/front/css/app.css index 5f2cc40c..c8601286 100755 --- a/front/css/app.css +++ b/front/css/app.css @@ -144,6 +144,16 @@ { background-color: rgba(0, 0, 0, 0); } + +.unread-notifications-bell +{ + opacity: 70%; + color: red; + position: absolute; + top: 3px; + /* display: none; */ +} + .header-status-locked-db { width: 25px; diff --git a/front/js/modal.js b/front/js/modal.js index 701c5ef2..5892a7fa 100755 --- a/front/js/modal.js +++ b/front/js/modal.js @@ -261,6 +261,7 @@ function checkNotification() { // Find the oldest unread notification with level "interrupt" const oldestInterruptNotification = response.find(notification => notification.read === 0 && notification.level === "interrupt"); + const allUnreadNotification = response.filter(notification => notification.read === 0); if (oldestInterruptNotification) { // Show modal dialog with the oldest unread notification @@ -290,6 +291,9 @@ function checkNotification() { }); }); } + + $('#unread-notifications-bell-count').html(allUnreadNotification.length); + } }, error: function() { diff --git a/front/php/server/utilNotification.php b/front/php/server/utilNotification.php index 32dd9399..02c674ec 100755 --- a/front/php/server/utilNotification.php +++ b/front/php/server/utilNotification.php @@ -31,6 +31,10 @@ if (isset($_GET['action'])) { // Call the notifications_clear function notifications_clear(); break; + case 'notifications_mark_all_read': + // Call the notifications_mark_all_read function + notifications_mark_all_read(); + break; case 'get_unread_notifications': // Call the get_unread_notifications function get_unread_notifications(); @@ -120,6 +124,9 @@ function mark_notification_as_read($guid) { // Mark the notification as read $notification['read'] = 1; break; + } elseif ($guid == null) // no guid given, mark all read + { + $notification['read'] = 1; } } @@ -141,6 +148,10 @@ function mark_notification_as_read($guid) { echo "Failed to read notification file after $max_attempts attempts."; } +function notifications_mark_all_read() { + mark_notification_as_read(null); +} + function get_unread_notifications() { $NOTIFICATION_API_FILE = '/app/front/api/user_notifications.json'; diff --git a/front/php/templates/header.php b/front/php/templates/header.php index 58bccd6d..f5a90c84 100755 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -148,19 +148,24 @@ if ($ENABLED_DARKMODE === True) {