Web: respond to worker updates that indicate a worker was removed

The code isn't the prettiest, but it works ;-)
This commit is contained in:
Sybren A. Stüvel 2022-08-11 17:45:12 -07:00
parent 6122f14cbc
commit b4194e32e9
2 changed files with 20 additions and 9 deletions

View File

@ -137,7 +137,12 @@ export default {
const existingRow = this.tabulator.rowManager.findRow(workerUpdate.id); const existingRow = this.tabulator.rowManager.findRow(workerUpdate.id);
let promise; let promise;
// TODO: clean up the code below:
if (existingRow) { if (existingRow) {
if (workerUpdate.deleted_at) {
// This is a deletion, not a regular update.
promise = existingRow.delete();
} else {
// Tabbulator doesn't update ommitted fields, but if `status_change` // Tabbulator doesn't update ommitted fields, but if `status_change`
// is ommitted it means "no status change requested"; this should still // is ommitted it means "no status change requested"; this should still
// force an update of the `status_change` field. // force an update of the `status_change` field.
@ -148,6 +153,7 @@ export default {
// Tabulator doesn't know we're using 'status_change' in the 'status' // Tabulator doesn't know we're using 'status_change' in the 'status'
// column, so it also won't know to redraw when that field changes. // column, so it also won't know to redraw when that field changes.
promise.then(() => existingRow.reinitialize(true)); promise.then(() => existingRow.reinitialize(true));
}
} else { } else {
promise = this.tabulator.addData([workerUpdate]); promise = this.tabulator.addData([workerUpdate]);
} }

View File

@ -78,6 +78,11 @@ export default {
if (this.workerID != workerUpdate.id) if (this.workerID != workerUpdate.id)
return; return;
if (workerUpdate.deleted_at) {
this._routeToWorker("");
return;
}
this._fetchWorker(this.workerID); this._fetchWorker(this.workerID);
}, },