diff --git a/routes/log.js b/routes/log.js index 3102f1d..eb1c42c 100644 --- a/routes/log.js +++ b/routes/log.js @@ -49,7 +49,11 @@ module.exports = function(pool) { await client.query(`DELETE FROM pf.log WHERE id = $1`, [logid]); await client.query('COMMIT'); - res.json({ message: 'Operation undone', rows_deleted: del.rowCount }); + res.json({ + message: 'Operation undone', + rows_deleted: del.rowCount, + pf_ids: del.rows.map(r => r.pf_id) + }); } catch (err) { await client.query('ROLLBACK'); console.error(err); diff --git a/routes/operations.js b/routes/operations.js index 2d32df4..e3d74df 100644 --- a/routes/operations.js +++ b/routes/operations.js @@ -164,7 +164,11 @@ module.exports = function(pool) { [versionId] ); await client.query('COMMIT'); - res.json({ rows_deleted: delRows.rowCount, log_entries_deleted: delLog.rowCount }); + res.json({ + rows_deleted: delRows.rowCount, + log_entries_deleted: delLog.rowCount, + pf_ids: delRows.rows.map(r => r.pf_id) + }); } catch (err) { await client.query('ROLLBACK'); throw err; @@ -377,7 +381,10 @@ module.exports = function(pool) { ); await client.query('DELETE FROM pf.log WHERE id = $1', [logId]); await client.query('COMMIT'); - res.json({ rows_deleted: deleted.rowCount }); + res.json({ + rows_deleted: deleted.rowCount, + pf_ids: deleted.rows.map(r => r.pf_id) + }); } catch (err) { await client.query('ROLLBACK'); throw err; diff --git a/ui/src/views/Forecast.jsx b/ui/src/views/Forecast.jsx index bf3719e..e9f649f 100644 --- a/ui/src/views/Forecast.jsx +++ b/ui/src/views/Forecast.jsx @@ -192,8 +192,8 @@ export default function Forecast() { const worker = await perspective.worker() workerRef.current = worker tableRef.current = rowCount > 0 - ? await worker.table(buffer, { name: tableName }) - : await worker.table([], { name: tableName }) + ? await worker.table(buffer, { name: tableName, index: 'pf_id' }) + : await worker.table([], { name: tableName, index: 'pf_id' }) await viewer.load(worker) @@ -386,8 +386,10 @@ export default function Forecast() { const data = await res.json() if (!res.ok) { flash(data.error, 'error'); return } setLogEntries(prev => prev.filter(e => e.id !== logId)) + if (data.pf_ids?.length && tableRef.current) { + await tableRef.current.remove(data.pf_ids) + } flash(`Undone — ${data.rows_deleted} rows removed`) - initViewer(versionId, sourceId) } catch (err) { flash(err.message, 'error') } finally {