Web: show job updates in the notifications popover

This commit is contained in:
Sybren A. Stüvel 2022-05-19 15:18:19 +02:00
parent cc62cab1d6
commit 0242f2d217
3 changed files with 20 additions and 10 deletions

@ -33,17 +33,14 @@ export default {
},
_handleJobActionPromise(promise, description) {
// const numJobs = this.jobs.numSelected;
const numJobs = 1;
return promise
.then(() => {
let message;
if (numJobs == 1) {
message = `Job ${description}`;
} else {
message = `${numJobs} jobs ${description}`;
}
this.notifs.add(message);
// There used to be a call to `this.notifs.add(message)` here, but now
// that job status changes are logged in the notifications anyway,
// it's no longer necessary.
// This function is still kept, in case we want to bring back the
// notifications when multiple jobs can be selected. Then a summary
// ("N jobs requeued") could be logged here.
})
.catch((error) => {
const errorMsg = JSON.stringify(error); // TODO: handle API errors better.

@ -40,7 +40,19 @@ export const useNotifs = defineStore('notifications', {
},
/**
* @param {API.SioTaskUpdate} taskUpdate Task update received via SocketIO.
* @param {API.SocketIOJobUpdate} jobUpdate Job update received via SocketIO.
*/
addJobUpdate(jobUpdate) {
console.log('Received job update:', jobUpdate);
let msg = `Job ${jobUpdate.name}`;
if (jobUpdate.previous_status && jobUpdate.previous_status != jobUpdate.status) {
msg += ` changed status ${jobUpdate.previous_status}${jobUpdate.status}`;
}
this.add(msg)
},
/**
* @param {API.SocketIOTaskUpdate} taskUpdate Task update received via SocketIO.
*/
addTaskUpdate(taskUpdate) {
console.log('Received task update:', taskUpdate);

@ -104,6 +104,7 @@ export default {
// SocketIO data event handlers:
onSioJobUpdate(jobUpdate) {
this.notifs.addJobUpdate(jobUpdate);
if (this.$refs.jobsTable) {
if (jobUpdate.previous_status)