From 8d6fd718008b0971580e401c80ddd41afe2f955d Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Mon, 6 Jul 2026 12:58:35 +0000 Subject: [PATCH] Add reports app registration and capabilities Registers reports app (LXC 122, /reports, BarChart2, #1d4ed8, Management category) with two capabilities: view (run reports) and export (CSV download). Co-Authored-By: Claude Sonnet 4.6 --- src/db.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/db.js b/src/db.js index edf174c..5086b82 100644 --- a/src/db.js +++ b/src/db.js @@ -126,7 +126,8 @@ export async function initDb() { ('twin-optimiser', 'Twin Optimiser', 'Identify twin room opportunities from booking grid', '/twin-optimiser', 'LayoutGrid', '#c9841a', 'Housekeeping', '10.10.10.119', 3080), ('forecasting', 'Forecasting', 'Revenue forecasting and reporting', '/forecasting', 'TrendingUp', '#0077b6', 'Finance', '10.10.10.113', 3080), ('rates', 'Rate Monitor', 'Competitor rate monitoring and direct booking engine rates', '/rates', 'Tag', '#7b4f00', 'Finance', '10.10.10.115', 3080), - ('maintenance', 'Maintenance', 'Maintenance log book — faults, recurring tasks, assets and contractors', '/maintenance', 'Wrench', '#b45309', 'Operations', '10.10.10.121', 3080) + ('maintenance', 'Maintenance', 'Maintenance log book — faults, recurring tasks, assets and contractors', '/maintenance', 'Wrench', '#b45309', 'Operations', '10.10.10.121', 3080), + ('reports', 'Reports', 'Custom reports for NewBook, ResOS, SambaPOS and internal data', '/reports', 'BarChart2', '#1d4ed8', 'Management', '10.10.10.122', 3080) ON CONFLICT (slug) DO UPDATE SET name = EXCLUDED.name, icon = EXCLUDED.icon, @@ -269,6 +270,22 @@ export async function initDb() { sort_order = EXCLUDED.sort_order `) + // Seed reports capabilities + await pool.query(` + INSERT INTO app_capabilities (app_id, slug, name, description, sort_order) + SELECT a.id, c.slug, c.name, c.description, c.sort_order + FROM apps a + CROSS JOIN (VALUES + ('view', 'View & Run Reports', 'Browse and run all custom reports', 1), + ('export', 'Export to CSV', 'Download report results as a CSV file', 2) + ) AS c(slug, name, description, sort_order) + WHERE a.slug = 'reports' + ON CONFLICT (app_id, slug) DO UPDATE SET + name = EXCLUDED.name, + description = EXCLUDED.description, + sort_order = EXCLUDED.sort_order + `) + // Seed first admin user if table is empty const { rows } = await pool.query('SELECT COUNT(*) FROM users') if (parseInt(rows[0].count) === 0) {