Web: show task status changes in the notifications

This of course only shows notifications about tasks of the active job,
as otherwise things would get messy.
This commit is contained in:
Sybren A. Stüvel 2022-05-19 14:28:31 +02:00
parent 3c622264a4
commit 4602ef2523
2 changed files with 18 additions and 0 deletions

View File

@ -39,6 +39,21 @@ export const useNotifs = defineStore('notifications', {
this._restartHideTimer(); this._restartHideTimer();
}, },
/**
* @param {API.SioTaskUpdate} taskUpdate Task update received via SocketIO.
*/
addTaskUpdate(taskUpdate) {
console.log('Received task update:', taskUpdate);
let msg = `Task ${taskUpdate.name}`;
if (taskUpdate.previous_status && taskUpdate.previous_status != taskUpdate.status) {
msg += ` changed status ${taskUpdate.previous_status}${taskUpdate.status}`;
}
if (taskUpdate.activity) {
msg += `: ${taskUpdate.activity}`;
}
this.add(msg)
},
/* Ensure there is only 1000 items in the history. */ /* Ensure there is only 1000 items in the history. */
_prune() { _prune() {
if (this.history.length <= 1000) return; if (this.history.length <= 1000) return;

View File

@ -23,6 +23,7 @@ import * as urls from '@/urls'
import * as API from '@/manager-api'; import * as API from '@/manager-api';
import { useJobs } from '@/stores/jobs'; import { useJobs } from '@/stores/jobs';
import { useTasks } from '@/stores/tasks'; import { useTasks } from '@/stores/tasks';
import { useNotifs } from '@/stores/notifications'
import { apiClient } from '@/stores/api-query-count'; import { apiClient } from '@/stores/api-query-count';
import FooterPopup from '@/components/FooterPopup.vue' import FooterPopup from '@/components/FooterPopup.vue'
@ -51,6 +52,7 @@ export default {
jobs: useJobs(), jobs: useJobs(),
tasks: useTasks(), tasks: useTasks(),
notifs: useNotifs(),
showFooterPopup: false, showFooterPopup: false,
}), }),
mounted() { mounted() {
@ -127,6 +129,7 @@ export default {
this.$refs.tasksTable.processTaskUpdate(taskUpdate); this.$refs.tasksTable.processTaskUpdate(taskUpdate);
if (this.taskID == taskUpdate.id) if (this.taskID == taskUpdate.id)
this._fetchTask(this.taskID); this._fetchTask(this.taskID);
this.notifs.addTaskUpdate(taskUpdate);
}, },
/** /**