Seed plant app + capabilities
Registers the new plant-room monitoring app (LXC 123): view, manage_assets, acknowledge_alerts, settings capabilities. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
e612ce7c64
commit
8db43ebe97
1 changed files with 34 additions and 0 deletions
34
src/db.js
34
src/db.js
|
|
@ -455,6 +455,40 @@ export async function initDb() {
|
||||||
sort_order = EXCLUDED.sort_order
|
sort_order = EXCLUDED.sort_order
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// Seed plant app + capabilities (no default Staff grants — admin assigns via portal,
|
||||||
|
// same convention as hvac/wages/utilities). LXC 123 — read-only plant-room monitoring
|
||||||
|
// (boilers, water softener, calorifiers, pumps) via MQTT, no actuation/control.
|
||||||
|
await pool.query(`
|
||||||
|
INSERT INTO apps (slug, name, description, base_path, icon, theme_color, category, internal_host, internal_port)
|
||||||
|
VALUES ('plant', 'Plant Room', 'Plant-room equipment monitoring and alerting — boilers, water softener, calorifiers and pumps via MQTT telemetry', '/plant', 'Gauge', '#0e7490', 'Operations', '10.10.10.123', 3080)
|
||||||
|
ON CONFLICT (slug) DO UPDATE SET
|
||||||
|
name = EXCLUDED.name,
|
||||||
|
description = EXCLUDED.description,
|
||||||
|
base_path = EXCLUDED.base_path,
|
||||||
|
icon = EXCLUDED.icon,
|
||||||
|
theme_color = EXCLUDED.theme_color,
|
||||||
|
category = EXCLUDED.category,
|
||||||
|
internal_host = EXCLUDED.internal_host,
|
||||||
|
internal_port = EXCLUDED.internal_port
|
||||||
|
`)
|
||||||
|
|
||||||
|
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', 'View the plant-room dashboard and alert list', 1),
|
||||||
|
('manage_assets', 'Manage Assets', 'Create/edit assets, alert rules and asset photos', 2),
|
||||||
|
('acknowledge_alerts', 'Acknowledge Alerts', 'Acknowledge and resolve triggered alerts', 3),
|
||||||
|
('settings', 'Settings', 'Configure plant app settings', 4)
|
||||||
|
) AS c(slug, name, description, sort_order)
|
||||||
|
WHERE a.slug = 'plant'
|
||||||
|
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
|
// Seed first admin user if table is empty
|
||||||
const { rows } = await pool.query('SELECT COUNT(*) FROM users')
|
const { rows } = await pool.query('SELECT COUNT(*) FROM users')
|
||||||
if (parseInt(rows[0].count) === 0) {
|
if (parseInt(rows[0].count) === 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue