made sync notification global accross modules by integrating it in the shared sync method wrapper and more notification formatting
This commit is contained in:
+8
-1
@@ -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
|
||||
|
||||
@@ -71,6 +71,10 @@ main {
|
||||
|
||||
/* notification modal */
|
||||
|
||||
#notification-container{
|
||||
margin-top:.6rem;
|
||||
}
|
||||
|
||||
.notification-title{
|
||||
display:flex;
|
||||
align-items:center;
|
||||
|
||||
@@ -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>`;
|
||||
});
|
||||
|
||||
|
||||
@@ -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 ===
|
||||
|
||||
Reference in New Issue
Block a user