made sync notification global accross modules by integrating it in the shared sync method wrapper and more notification formatting

This commit is contained in:
2026-09-09 21:42:24 +02:00
parent 730b861644
commit 89b6af9229
4 changed files with 13 additions and 8 deletions
+8 -1
View File
@@ -2,7 +2,7 @@ from flask import jsonify, render_template, Blueprint, app, Response
from abc import abstractmethod, ABC
from dataclasses import dataclass
from .notificationmanager import Notification
from .notificationmanager import Notification, NOTIFICATION_MANAGER
@dataclass
class SyncResult:
@@ -21,6 +21,13 @@ class BaseModule(ABC):
def sync_wrapper(self):
result = self.sync()
NOTIFICATION_MANAGER.notify(Notification(
module=self.name,
status=Notification.Status.INFO if result.success else Notification.Status.ERROR,
msg=result.msg
));
return jsonify({"success":result.success, "msg":result.msg}), 200
@abstractmethod
+4
View File
@@ -71,6 +71,10 @@ main {
/* notification modal */
#notification-container{
margin-top:.6rem;
}
.notification-title{
display:flex;
align-items:center;
+1 -1
View File
@@ -121,7 +121,7 @@ function renderNotifications() {
break;
}
html += `"></i>`
html += `<span id="notification-text-${nid}"><span class="notification-metadata">${formatTime(n.time)} ${n.module}:</span><br>${n.msg}</span>`;
html += `<span id="notification-text-${nid}"><span class="notification-metadata">${formatTime(n.time)} <b>${n.module}</b>:</span><br>${n.msg}</span>`;
html += `<button id="notification-button-${nid}" class="notification-read-button" onclick="deleteNotification('${nid}')"><i class="fa-solid fa-fw fa-xmark"></i></button></p>`;
});
-6
View File
@@ -41,12 +41,6 @@ class SocialWatchModule(BaseModule):
result = self.addrbook.update()
NOTIFICATION_MANAGER.notify(Notification(
module=self.name,
status=Notification.Status.INFO if result["success"] else Notification.Status.ERROR,
msg=result["msg"]
));
return SyncResult(success=result["success"], msg=result["msg"])
# ROUTES ===