From 34869497a1b6e6540f7f5e1aef9af0da30f04d10 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Wed, 3 Jul 2024 12:43:20 +0200 Subject: [PATCH] new: [app:live_logs] Added filters for API queries only --- notification.py | 8 ++++++++ server.py | 4 ++++ src/components/TheLiveLogs.vue | 16 ++++++++++++++-- src/socket.js | 11 +++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/notification.py b/notification.py index ad22e76..4ca19c0 100644 --- a/notification.py +++ b/notification.py @@ -9,6 +9,7 @@ from urllib.parse import parse_qs VERBOSE_MODE = False +APIQUERY_MODE = False NOTIFICATION_COUNT = 1 @@ -17,6 +18,11 @@ def set_verbose_mode(enabled: bool): VERBOSE_MODE = enabled +def set_apiquery_mode(enabled: bool): + global APIQUERY_MODE + APIQUERY_MODE = enabled + + def get_notifications() -> list[dict]: return list(db.NOTIFICATION_MESSAGES) @@ -148,6 +154,8 @@ def is_accepted_notification(notification) -> bool: return False if VERBOSE_MODE: return True + if APIQUERY_MODE and not notification['is_api_request']: + return False if '@' not in notification['user']: # Ignore message from system return False diff --git a/server.py b/server.py index 2454eef..0897359 100755 --- a/server.py +++ b/server.py @@ -112,6 +112,10 @@ async def get_diagnostic(sid): async def toggle_verbose_mode(sid, payload): return notification_model.set_verbose_mode(payload['verbose']) +@sio.event +async def toggle_apiquery_mode(sid, payload): + return notification_model.set_apiquery_mode(payload['apiquery']) + @sio.on('*') async def any_event(event, sid, data={}): logger.info('>> Unhandled event %s', event) diff --git a/src/components/TheLiveLogs.vue b/src/components/TheLiveLogs.vue index e59201a..92f237c 100644 --- a/src/components/TheLiveLogs.vue +++ b/src/components/TheLiveLogs.vue @@ -1,16 +1,21 @@