new: [app] Added verbose mode
This commit is contained in:
parent
837227b9e0
commit
1efb38ef79
4 changed files with 37 additions and 1 deletions
|
@ -8,6 +8,14 @@ import config
|
|||
from urllib.parse import parse_qs
|
||||
|
||||
|
||||
VERBOSE_MODE = False
|
||||
|
||||
|
||||
def set_verbose_mode(enabled: bool):
|
||||
global VERBOSE_MODE
|
||||
VERBOSE_MODE = enabled
|
||||
|
||||
|
||||
def get_notifications() -> list[dict]:
|
||||
return list(db.NOTIFICATION_MESSAGES)
|
||||
|
||||
|
@ -125,8 +133,12 @@ def get_scope_action_from_url(url) -> Union[str, None]:
|
|||
|
||||
|
||||
def is_accepted_notification(notification) -> bool:
|
||||
global VERBOSE_MODE
|
||||
|
||||
if notification['user_agent'] == 'misp-exercise-dashboard': # Ignore message generated from this app
|
||||
return False
|
||||
if VERBOSE_MODE:
|
||||
return True
|
||||
if '@' not in notification['user']: # Ignore message from system
|
||||
return False
|
||||
|
||||
|
|
|
@ -73,6 +73,10 @@ def reset_all_exercise_progress(sid):
|
|||
def get_diagnostic(sid):
|
||||
return getDiagnostic()
|
||||
|
||||
@sio.event
|
||||
def toggle_verbose_mode(sid, payload):
|
||||
return notification_model.set_verbose_mode(payload['verbose'])
|
||||
|
||||
@sio.on('*')
|
||||
def any_event(event, sid, data={}):
|
||||
print('>> Unhandled event', event)
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
<script setup>
|
||||
import { notifications, userCount, notificationCounter, notificationAPICounter } from "@/socket";
|
||||
import { ref, watch } from "vue"
|
||||
import { notifications, userCount, notificationCounter, notificationAPICounter, toggleVerboseMode } from "@/socket";
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
||||
import { faSignal, faCloud, faCog, faUser, faCircle } from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
|
||||
const verbose = ref(false)
|
||||
|
||||
watch(verbose, (newValue) => {
|
||||
toggleVerboseMode(newValue == true)
|
||||
})
|
||||
|
||||
function getClassFromResponseCode(response_code) {
|
||||
if (String(response_code).startsWith('2')) {
|
||||
return 'text-green-500'
|
||||
|
@ -44,6 +51,12 @@
|
|||
</span>
|
||||
<span class="font-bold">{{ notificationAPICounter }}</span>
|
||||
</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"/>
|
||||
Verbose
|
||||
</label>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<table class="bg-white dark:bg-slate-800 rounded-lg shadow-xl w-full">
|
||||
|
|
|
@ -91,6 +91,13 @@ export function changeExerciseSelection(exec_uuid, state_enabled) {
|
|||
})
|
||||
}
|
||||
|
||||
export function toggleVerboseMode(enabled) {
|
||||
const payload = {
|
||||
verbose: enabled
|
||||
}
|
||||
socket.emit("toggle_verbose_mode", payload, () => {})
|
||||
}
|
||||
|
||||
|
||||
const socket = io(URL, {
|
||||
autoConnect: true
|
||||
|
|
Loading…
Reference in a new issue