From 817e7d2e37d982250ed871ce256d9afd037756a2 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Tue, 8 Apr 2025 23:30:08 +0300 Subject: [PATCH 1/6] minor ui change --- ui/layouts/default.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/layouts/default.vue b/ui/layouts/default.vue index 2b0c5282..6d7675a1 100644 --- a/ui/layouts/default.vue +++ b/ui/layouts/default.vue @@ -205,6 +205,10 @@ onMounted(async () => { watch(selectedTheme, value => { try { + if ('auto' === value) { + applyPreferredColorScheme(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') + return + } applyPreferredColorScheme(value) } catch (e) { } }) From 88163cad42d240d06d2658704bb688b9debc7844 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Wed, 9 Apr 2025 17:35:11 +0300 Subject: [PATCH 2/6] make it possible to change notification data field key name --- app/library/Notifications.py | 18 ++++++++++++++++-- ui/components/NotificationForm.vue | 29 ++++++++++++++++++++++++++--- ui/pages/notifications.vue | 4 ++-- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/app/library/Notifications.py b/app/library/Notifications.py index a62e1bf3..91923e44 100644 --- a/app/library/Notifications.py +++ b/app/library/Notifications.py @@ -46,12 +46,14 @@ class TargetRequest: method: str url: str headers: list[TargetRequestHeader] = field(default_factory=list) + data_key: str = "data" def serialize(self) -> dict: return { "type": self.type, "method": self.method, "url": self.url, + "data_key": self.data_key, "headers": [h.serialize() for h in self.headers], } @@ -247,6 +249,7 @@ class Notification(metaclass=Singleton): type=target.get("request", {}).get("type", "json"), method=target.get("request", {}).get("method", "POST"), url=target.get("request", {}).get("url"), + data_key=target.get("request", {}).get("data_key", "data"), headers=[ TargetRequestHeader( key=str(h.get("key", "")).strip(), @@ -288,6 +291,10 @@ class Notification(metaclass=Singleton): msg = "Invalid notification target. No URL found." raise ValueError(msg) + if "data_key" not in target["request"]: + msg = "Invalid notification target. No data_key found." + raise ValueError(msg) + if "method" in target["request"] and target["request"]["method"].upper() not in ["POST", "PUT"]: msg = "Invalid notification target. Invalid method found." raise ValueError(msg) @@ -363,10 +370,17 @@ class Notification(metaclass=Singleton): for h in target.request.headers: reqBody["headers"][h.key] = h.value - reqBody["json" if "json" == target.request.type.lower() else "data"] = self._deep_unpack(ev.serialize()) + body_key = "json" if "json" == target.request.type.lower() else "data" + reqBody[body_key] = self._deep_unpack(ev.serialize()) + + if "data" != target.request.data_key: + reqBody[body_key][target.request.data_key] = reqBody[body_key]["data"] + reqBody[body_key].pop("data", None) if "form" == target.request.type.lower(): - reqBody["data"]["data"] = self._encoder.encode(reqBody["data"]["data"]) + reqBody[body_key][target.request.data_key] = self._encoder.encode( + reqBody[body_key][target.request.data_key] + ) response = await self._client.request(**reqBody) diff --git a/ui/components/NotificationForm.vue b/ui/components/NotificationForm.vue index 112e54d4..87130c3f 100644 --- a/ui/components/NotificationForm.vue +++ b/ui/components/NotificationForm.vue @@ -138,7 +138,7 @@ -
+
+
+
+ +
+ + +
+ + + + The field name to use when sending the notification. This is used to identify the data in the + request. The default is data. + + +
+
+