new: [app:live_logs] Added filters for API queries only
This commit is contained in:
parent
fb32b59abe
commit
34869497a1
4 changed files with 37 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
<script setup>
|
||||
import { ref, watch } from "vue"
|
||||
import { notifications, userCount, notificationCounter, notificationAPICounter, toggleVerboseMode } from "@/socket";
|
||||
import { notifications, userCount, notificationCounter, notificationAPICounter, toggleVerboseMode, toggleApiQueryMode } from "@/socket";
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
||||
import { faSignal, faCloud, faCog, faUser, faCircle } from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
|
||||
const verbose = ref(false)
|
||||
const api_query = ref(false)
|
||||
|
||||
watch(verbose, (newValue) => {
|
||||
toggleVerboseMode(newValue == true)
|
||||
})
|
||||
|
||||
watch(api_query, (newValue) => {
|
||||
toggleApiQueryMode(newValue == true)
|
||||
})
|
||||
|
||||
function getClassFromResponseCode(response_code) {
|
||||
if (String(response_code).startsWith('2')) {
|
||||
return 'text-green-500'
|
||||
|
@ -53,10 +58,17 @@
|
|||
</span>
|
||||
<span class="flex items-center">
|
||||
<label class="mr-1 flex items-center cursor-pointer">
|
||||
<input type="checkbox" class="toggle toggle-success [--fallback-su:#22c55e] mr-1" :checked="verbose" @change="verbose = !verbose"/>
|
||||
<input type="checkbox" class="toggle toggle-warning [--fallback-su:#22c55e] mr-1" :checked="verbose" @change="verbose = !verbose"/>
|
||||
Verbose
|
||||
</label>
|
||||
</span>
|
||||
<span class="flex items-center">
|
||||
<label class="mr-1 flex items-center cursor-pointer">
|
||||
<input type="checkbox" class="toggle toggle-success [--fallback-su:#22c55e] mr-1" :checked="api_query" @change="api_query = !api_query"/>
|
||||
<FontAwesomeIcon :icon="faCog" size="sm" :mask="faCloud" transform="shrink-7 left-1" class="mr-1"></FontAwesomeIcon>
|
||||
API Queries
|
||||
</label>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<table class="bg-white dark:bg-slate-800 rounded-lg shadow-xl w-full">
|
||||
|
|
|
@ -81,6 +81,10 @@ export function toggleVerboseMode(enabled) {
|
|||
sendToggleVerboseMode(enabled)
|
||||
}
|
||||
|
||||
export function toggleApiQueryMode(enabled) {
|
||||
sendToggleApiQueryMode(enabled)
|
||||
}
|
||||
|
||||
export const debouncedGetProgress = debounce(getProgress, 200, {leading: true})
|
||||
export const debouncedGetDiangostic = debounce(getDiangostic, 1000, {leading: true})
|
||||
|
||||
|
@ -151,6 +155,13 @@ function sendToggleVerboseMode(enabled) {
|
|||
socket.emit("toggle_verbose_mode", payload, () => {})
|
||||
}
|
||||
|
||||
function sendToggleApiQueryMode(enabled) {
|
||||
const payload = {
|
||||
apiquery: enabled
|
||||
}
|
||||
socket.emit("toggle_apiquery_mode", payload, () => {})
|
||||
}
|
||||
|
||||
/* Event listener */
|
||||
|
||||
socket.on("connect", () => {
|
||||
|
|
Loading…
Reference in a new issue