feat: Add application-level settings for CSS color management
Some checks failed
Run Tests / test (push) Failing after 1m51s
Some checks failed
Run Tests / test (push) Failing after 1m51s
- Introduced a new table `application_setting` to store configurable application options. - Implemented functions to manage CSS color settings, including loading, updating, and reading environment overrides. - Added a new settings view to render and manage theme colors. - Updated UI to include a settings page with theme color management and environment overrides display. - Enhanced CSS styles for the settings page and sidebar navigation. - Created unit and end-to-end tests for the new settings functionality and CSS management.
This commit is contained in:
@@ -27,6 +27,25 @@ SET name = EXCLUDED.name,
|
||||
symbol = EXCLUDED.symbol,
|
||||
is_active = EXCLUDED.is_active;
|
||||
|
||||
-- Application-level settings table
|
||||
CREATE TABLE IF NOT EXISTS application_setting (
|
||||
id SERIAL PRIMARY KEY,
|
||||
key VARCHAR(128) NOT NULL UNIQUE,
|
||||
value TEXT NOT NULL,
|
||||
value_type VARCHAR(32) NOT NULL DEFAULT 'string',
|
||||
category VARCHAR(32) NOT NULL DEFAULT 'general',
|
||||
description TEXT,
|
||||
is_editable BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS ux_application_setting_key
|
||||
ON application_setting (key);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ix_application_setting_category
|
||||
ON application_setting (category);
|
||||
|
||||
-- Measurement unit reference table
|
||||
CREATE TABLE IF NOT EXISTS measurement_unit (
|
||||
id SERIAL PRIMARY KEY,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
-- Migration: Create application_setting table for configurable application options
|
||||
-- Date: 2025-10-25
|
||||
-- Description: Introduces persistent storage for application-level settings such as theme colors.
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS application_setting (
|
||||
id SERIAL PRIMARY KEY,
|
||||
key VARCHAR(128) NOT NULL UNIQUE,
|
||||
value TEXT NOT NULL,
|
||||
value_type VARCHAR(32) NOT NULL DEFAULT 'string',
|
||||
category VARCHAR(32) NOT NULL DEFAULT 'general',
|
||||
description TEXT,
|
||||
is_editable BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS ux_application_setting_key
|
||||
ON application_setting (key);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ix_application_setting_category
|
||||
ON application_setting (category);
|
||||
|
||||
COMMIT;
|
||||
@@ -1141,6 +1141,14 @@ def main() -> None:
|
||||
app_validated = True
|
||||
return True
|
||||
|
||||
should_run_migrations = args.run_migrations
|
||||
auto_run_migrations_reason: Optional[str] = None
|
||||
if args.seed_data and not should_run_migrations:
|
||||
should_run_migrations = True
|
||||
auto_run_migrations_reason = (
|
||||
"Seed data requested without explicit --run-migrations; applying migrations first."
|
||||
)
|
||||
|
||||
try:
|
||||
if args.ensure_database:
|
||||
setup.ensure_database()
|
||||
@@ -1154,8 +1162,10 @@ def main() -> None:
|
||||
"SQLAlchemy schema initialization"
|
||||
):
|
||||
setup.initialize_schema()
|
||||
if args.run_migrations:
|
||||
if should_run_migrations:
|
||||
if ensure_application_connection_for("migration execution"):
|
||||
if auto_run_migrations_reason:
|
||||
logger.info(auto_run_migrations_reason)
|
||||
migrations_path = (
|
||||
Path(args.migrations_dir)
|
||||
if args.migrations_dir
|
||||
|
||||
Reference in New Issue
Block a user