From b59526b20d6f13d0f0f5f7a9d8d721c095f8d722 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 8 May 2026 11:09:34 +0200 Subject: [PATCH] feat(Localization, User Management): add missingUserId translations and enhance user ID handling - Added translations for the "missingUserId" key in multiple languages to improve user feedback when user ID is not available. - Updated the user ID handling in the store and WorkerSchedulesView component to ensure proper user identification when sending data to the daemon. - Enhanced error handling to notify users when the user ID is missing, improving overall user experience. --- frontend/src/i18n/locales/ceb/admin.json | 3 ++- frontend/src/i18n/locales/de/admin.json | 1 + frontend/src/i18n/locales/en/admin.json | 3 ++- frontend/src/i18n/locales/es/admin.json | 3 ++- frontend/src/i18n/locales/fr/admin.json | 3 ++- frontend/src/store/index.js | 9 +++++++-- .../admin/falukant/WorkerSchedulesView.vue | 18 +++++++++++++++++- 7 files changed, 33 insertions(+), 7 deletions(-) diff --git a/frontend/src/i18n/locales/ceb/admin.json b/frontend/src/i18n/locales/ceb/admin.json index b8346b6..701d83a 100644 --- a/frontend/src/i18n/locales/ceb/admin.json +++ b/frontend/src/i18n/locales/ceb/admin.json @@ -347,7 +347,8 @@ "cadence": "Interbal", "nextRun": "Pinakataas nga sunod nga dagan", "remaining": "Nahibilin", - "noTasks": "Walay tasks para ani nga worker." + "noTasks": "Walay tasks para ani nga worker.", + "missingUserId": "Walay user ID nga anaa (kulang ang setUserId)." } }, "chatrooms": { diff --git a/frontend/src/i18n/locales/de/admin.json b/frontend/src/i18n/locales/de/admin.json index 747a2ae..69b0cc8 100644 --- a/frontend/src/i18n/locales/de/admin.json +++ b/frontend/src/i18n/locales/de/admin.json @@ -333,6 +333,7 @@ "generatedAt": "Erzeugt am", "empty": "Keine Schedules vorhanden.", "notConnected": "Keine Daemon-Verbindung verfügbar.", + "missingUserId": "Keine Benutzer-ID verfügbar (setUserId fehlt).", "sendError": "Anfrage an den Daemon fehlgeschlagen.", "responseError": "Antwort konnte nicht verarbeitet werden.", "currentStep": "Aktueller Schritt", diff --git a/frontend/src/i18n/locales/en/admin.json b/frontend/src/i18n/locales/en/admin.json index 1a071f1..35e5b2b 100644 --- a/frontend/src/i18n/locales/en/admin.json +++ b/frontend/src/i18n/locales/en/admin.json @@ -395,7 +395,8 @@ "cadence": "Cadence", "nextRun": "Latest next run", "remaining": "Remaining", - "noTasks": "No tasks for this worker." + "noTasks": "No tasks for this worker.", + "missingUserId": "No user ID available (setUserId missing)." } }, "chatrooms": { diff --git a/frontend/src/i18n/locales/es/admin.json b/frontend/src/i18n/locales/es/admin.json index 098b9ae..9b74b1b 100644 --- a/frontend/src/i18n/locales/es/admin.json +++ b/frontend/src/i18n/locales/es/admin.json @@ -320,7 +320,8 @@ "cadence": "Intervalo", "nextRun": "Próxima ejecución máxima", "remaining": "Restante", - "noTasks": "No hay tareas para este worker." + "noTasks": "No hay tareas para este worker.", + "missingUserId": "No hay ID de usuario disponible (falta setUserId)." } }, "chatrooms": { diff --git a/frontend/src/i18n/locales/fr/admin.json b/frontend/src/i18n/locales/fr/admin.json index bf27d6a..f041db0 100644 --- a/frontend/src/i18n/locales/fr/admin.json +++ b/frontend/src/i18n/locales/fr/admin.json @@ -320,7 +320,8 @@ "cadence": "Intervalle", "nextRun": "Prochaine exécution au plus tard", "remaining": "Restant", - "noTasks": "Aucune tâche pour ce worker." + "noTasks": "Aucune tâche pour ce worker.", + "missingUserId": "Aucun ID utilisateur disponible (setUserId manquant)." } }, "chatrooms": { diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index dcd7727..b0bb860 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -418,12 +418,17 @@ const store = createStore({ setTimeout(() => { try { if (daemonSocket.readyState === WebSocket.OPEN && state.isLoggedIn && state.user) { + const daemonUserId = state.user?.hashedId || state.user?.id || state.user?.username; + if (!daemonUserId) { + console.warn('[Daemon] Keine User-ID fuer setUserId vorhanden'); + return; + } const payload = JSON.stringify({ event: 'setUserId', - data: { userId: state.user.id } + data: { userId: daemonUserId } }); daemonSocket.send(payload); - console.log('[Daemon] setUserId gesendet für User:', state.user.id); + console.log('[Daemon] setUserId gesendet fuer User:', daemonUserId); } else { console.warn('[Daemon] Socket nicht mehr offen oder Benutzer nicht eingeloggt beim Senden von setUserId'); } diff --git a/frontend/src/views/admin/falukant/WorkerSchedulesView.vue b/frontend/src/views/admin/falukant/WorkerSchedulesView.vue index cab959b..9c7ce77 100644 --- a/frontend/src/views/admin/falukant/WorkerSchedulesView.vue +++ b/frontend/src/views/admin/falukant/WorkerSchedulesView.vue @@ -94,7 +94,7 @@ export default { }; }, computed: { - ...mapState(['daemonSocket', 'daemonConnectionStatus', 'menu']), + ...mapState(['daemonSocket', 'daemonConnectionStatus', 'menu', 'user']), hasAccess() { const path = '/admin/falukant/worker-schedules'; const walk = (node) => { @@ -137,6 +137,18 @@ export default { if (this.timer) clearInterval(this.timer); }, methods: { + getDaemonUserId() { + return this.user?.hashedId || this.user?.id || this.user?.username || ''; + }, + sendSetUserId() { + const userId = this.getDaemonUserId(); + if (!userId) return false; + this.daemonSocket.send(JSON.stringify({ + event: 'setUserId', + data: { userId }, + })); + return true; + }, setupTimer() { if (this.timer) { clearInterval(this.timer); @@ -151,6 +163,10 @@ export default { this.error = this.$t('admin.falukant.workerSchedules.notConnected'); return; } + if (!this.sendSetUserId()) { + this.error = this.$t('admin.falukant.workerSchedules.missingUserId'); + return; + } this.loading = true; this.error = null; const event = this.detailed ? 'getWorkerSchedulesDetailed' : 'getWorkerSchedules';