From 0a7b7d9cf63802638e5c57c93663a2ab27ffdc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 30 Sep 2022 16:26:26 +0200 Subject: [PATCH] Webapp: remove assumption from SocketIO job updates Remove the assumption that a SocketIO job update without "previous state" set is always an indication that it's about a new job. Soon job priority will be changeable, and then this assumption will no longer hold. --- web/app/src/components/jobs/JobsTable.vue | 21 +++++++++------------ web/app/src/views/JobsView.vue | 5 +---- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/web/app/src/components/jobs/JobsTable.vue b/web/app/src/components/jobs/JobsTable.vue index 2c2299e9..166b2b56 100644 --- a/web/app/src/components/jobs/JobsTable.vue +++ b/web/app/src/components/jobs/JobsTable.vue @@ -150,19 +150,16 @@ export default { // updateData() will only overwrite properties that are actually set on // jobUpdate, and leave the rest as-is. if (this.tabulator.initialized) { - this.tabulator.updateData([jobUpdate]) - .then(this.sortData) - .then(() => { this.tabulator.redraw(); }) // Resize columns based on new data. - } - this._refreshAvailableStatuses(); - }, - processNewJob(jobUpdate) { - if (this.tabulator.initialized) { - this.tabulator.addData([jobUpdate]) - .then(this.sortData) - .then(() => { this.tabulator.redraw(); }) // Resize columns based on new data. - } + const row = this.tabulator.rowManager.findRow(jobUpdate.id); + let promise = null; + if (row) promise = this.tabulator.updateData([jobUpdate]); + else promise = this.tabulator.addData([jobUpdate]); + + promise + .then(this.sortData) + .then(() => { this.tabulator.redraw(); }) // Resize columns based on new data. + } this._refreshAvailableStatuses(); }, diff --git a/web/app/src/views/JobsView.vue b/web/app/src/views/JobsView.vue index a5b21675..f5eaf45b 100644 --- a/web/app/src/views/JobsView.vue +++ b/web/app/src/views/JobsView.vue @@ -146,10 +146,7 @@ export default { this.jobs.setIsJobless(false); if (this.$refs.jobsTable) { - if (jobUpdate.previous_status) - this.$refs.jobsTable.processJobUpdate(jobUpdate); - else - this.$refs.jobsTable.processNewJob(jobUpdate); + this.$refs.jobsTable.processJobUpdate(jobUpdate); } if (this.jobID != jobUpdate.id) return;