From 0410da8cd3bcd25e48f64a72f0e51074dbc4986c Mon Sep 17 00:00:00 2001 From: Pierre GIRAUD Date: Wed, 13 Nov 2024 11:19:57 +0100 Subject: [PATCH] Fix broken management of alert messages In aded59171451ac, the function to add alert message has been modified for no good reason resulting in message to be empty in the interface. We also fix alert message management when loading data. This has been missed when switching to VueJS. We shouldn't use "this" keyword anymore in vue components or views. --- powa/static/js/App.vue | 4 ++-- powa/static/js/composables/MessageService.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/powa/static/js/App.vue b/powa/static/js/App.vue index 5d9d178c..25bdea62 100644 --- a/powa/static/js/App.vue +++ b/powa/static/js/App.vue @@ -165,7 +165,7 @@ import LoginView from "@/components/LoginView.vue"; import { encodeQueryData } from "@/utils/query"; import { useMessageService } from "@/composables/MessageService.js"; -const { alertMessages, addAlertMessage, removeAlertMessage } = +const { alertMessages, addAlertMessage, addAlertMessages, removeAlertMessage } = useMessageService(); const theme = useTheme(); @@ -355,7 +355,7 @@ function loadData() { try { const data = JSON.parse(response); if (data) { - this.addAlertMessages(data.messages); + addAlertMessages(data.messages); } } catch (error) { // pass diff --git a/powa/static/js/composables/MessageService.js b/powa/static/js/composables/MessageService.js index f83a20ce..7065929c 100644 --- a/powa/static/js/composables/MessageService.js +++ b/powa/static/js/composables/MessageService.js @@ -27,8 +27,10 @@ function addAlertMessage(level, message) { } function addAlertMessages(messages) { - for (let message in messages) { - addAlertMessage(message.level, message.message); + for (let level in messages) { + for (let message of messages[level]) { + addAlertMessage(level, message); + } } } function removeAlertMessage(id) {