socialwatch sync notification now also shows errors, added startap notification from server and made info bar (module and time) in notification italian style
This commit is contained in:
@@ -13,6 +13,13 @@ app = Flask(__name__, static_folder=os.path.join(".", "base", "static"))
|
||||
mod_manager = ModuleManager()
|
||||
mod_manager.load(app, "modules")
|
||||
|
||||
# a warm welcome
|
||||
ntfy.NOTIFICATION_MANAGER.notify(ntfy.Notification(
|
||||
module = "server",
|
||||
status = ntfy.Notification.Status.INFO,
|
||||
msg = "Server started!",
|
||||
))
|
||||
|
||||
@app.route("/notifications", methods=["GET"])
|
||||
def api_notifications():
|
||||
return jsonify(ntfy.NOTIFICATION_MANAGER.serialized())
|
||||
|
||||
@@ -11,13 +11,13 @@ class Notification:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
module: str = "defaultmod",
|
||||
module: str = "server",
|
||||
status: Status = Status.INFO,
|
||||
msg: str = "Default Notification",
|
||||
):
|
||||
self.status = status
|
||||
self.msg = msg
|
||||
self.module = module
|
||||
self.module = module.lower()
|
||||
self.time = datetime.now()
|
||||
|
||||
def as_dict(self):
|
||||
|
||||
@@ -91,6 +91,10 @@ main {
|
||||
font-size:.8rem;
|
||||
}
|
||||
|
||||
.notification-metadata{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.notification-info{background:var(--primary-bg);color:var(--primary)}
|
||||
.notification-warning{background:var(--warn-bg);color:var(--warn)}
|
||||
.notification-error{background:var(--critical-bg);color:var(--critical)}
|
||||
|
||||
@@ -106,7 +106,7 @@ function renderNotifications() {
|
||||
break;
|
||||
}
|
||||
html += `"></i>`
|
||||
html += `<span id="notification-text-${nid}">${formatTime(n.time)} – ${n.msg}</span>`;
|
||||
html += `<span id="notification-text-${nid}"><span class="notification-metadata">${formatTime(n.time)} – ${n.module}:</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>`;
|
||||
});
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ class SocialWatchModule(BaseModule):
|
||||
|
||||
NOTIFICATION_MANAGER.notify(Notification(
|
||||
module=self.name,
|
||||
status=Notification.Status.INFO,
|
||||
msg=f"Synced module {self.name}. Contacts: {len(self.addrbook.people)}, Events: {len(self.addrbook.events)}."
|
||||
status=Notification.Status.INFO if status["success"] else Notification.Status.ERROR,
|
||||
msg=status["msg"]
|
||||
));
|
||||
|
||||
return jsonify(status), 200
|
||||
|
||||
@@ -60,7 +60,7 @@ class Addressbook:
|
||||
self.update_cross_refs()
|
||||
|
||||
logger.info("Sync completed.")
|
||||
return {"msg": str("Sync completed."), "success": True }
|
||||
return {"msg": f"Socialwatch sync completed. People: {len(self.people)}, Events: {len(self.events)}.", "success": True }
|
||||
|
||||
def clear_cross_refs(self):
|
||||
for person in self.people:
|
||||
|
||||
Reference in New Issue
Block a user