System Management: - System Settings page with 8 configurable parameters (admin only) - Audit Log page with filterable table (user, action, resource, date range) - Audit logging wired into auth, devices, users, alarms, reports API handlers - SystemSetting model + migration (002) Device Detail: - Dedicated /devices/:id page with 4 tabs (realtime, historical trends, alarm history, device info) - ECharts historical charts with granularity/time range selectors - Device name clickable in Devices and Monitoring tables → navigates to detail Email & Scheduling: - Email service with SMTP support (STARTTLS/SSL/plain) - Alarm email notification with professional HTML template - Report scheduler using APScheduler for cron-based auto-generation - Scheduled report task seeded (daily at 8am) UI Enhancements: - Dark mode toggle (persisted to localStorage, Ant Design darkAlgorithm) - Data comparison view in Analysis page (dual date range, side-by-side metrics) - i18n framework (i18next) with zh/en translations for menu and common UI - Language switcher in header (中文/English) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
"""Add system_settings table
|
|
|
|
Revision ID: 002_system_settings
|
|
Revises: 001_initial
|
|
Create Date: 2026-04-02
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = "002_system_settings"
|
|
down_revision = "001_initial"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"system_settings",
|
|
sa.Column("id", sa.Integer, primary_key=True, autoincrement=True),
|
|
sa.Column("key", sa.String(100), unique=True, nullable=False, index=True),
|
|
sa.Column("value", sa.Text, nullable=False, server_default=""),
|
|
sa.Column("description", sa.String(255)),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
|
|
)
|
|
|
|
# Seed default settings
|
|
op.execute("""
|
|
INSERT INTO system_settings (key, value, description) VALUES
|
|
('platform_name', '天普零碳园区智慧能源管理平台', '平台名称'),
|
|
('data_retention_days', '365', '数据保留天数'),
|
|
('alarm_auto_resolve_minutes', '30', '告警自动解除时间(分钟)'),
|
|
('simulator_interval_seconds', '15', '模拟器采集间隔(秒)'),
|
|
('notification_email_enabled', 'false', '是否启用邮件通知'),
|
|
('notification_email_smtp', '', 'SMTP服务器地址'),
|
|
('report_auto_schedule_enabled', 'false', '是否启用自动报表'),
|
|
('timezone', 'Asia/Shanghai', '系统时区')
|
|
""")
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table("system_settings")
|