diff --git a/routes/auth.js b/routes/auth.js index 1c64b51..34ac0cf 100644 --- a/routes/auth.js +++ b/routes/auth.js @@ -46,7 +46,8 @@ module.exports = function(pool) { try { const result = await pool.query( - `SELECT id, username, display_name, pass_hash, is_active + `SELECT id, username, display_name, pass_hash, is_active, + is_admin, territory FROM pf.app_user WHERE lower(username) = lower($1)`, [username] ); diff --git a/ui/src/views/Forecast.jsx b/ui/src/views/Forecast.jsx index 0510d42..affd063 100644 --- a/ui/src/views/Forecast.jsx +++ b/ui/src/views/Forecast.jsx @@ -806,8 +806,15 @@ export default function Forecast({ sources = [], sourceId, versions = [], versio // restore last-used layout or build default // Strip cfg.table — table is already loaded by reference above; a stale name // in a saved config would cause Perspective to fail the name lookup. - const saved = localStorage.getItem(LAYOUT_KEY(vid)) - if (saved) { + // + // An empty table has no schema at all, so any config naming any column + // aborts the worker -- "Could not get dtype for column `sseas_e`". There + // is nothing to lay out, so nothing is restored; the saved layout stays in + // localStorage and comes back when there are rows again. + const saved = rowCount > 0 ? localStorage.getItem(LAYOUT_KEY(vid)) : null + if (rowCount === 0) { + await viewer.restore({ settings: false, plugin_config: { edit_mode: 'SELECT_REGION' } }) + } else if (saved) { const { table: _t, ...rest } = cleanLayout(JSON.parse(saved), validCols) const cfg = { ...rest, plugin_config: { ...(rest.plugin_config || {}), edit_mode: 'SELECT_REGION' } } await viewer.restore(cfg)