Add dashboard defaults (visitor-IP -> business-unit) for kiosk displays
Classic feature gap: a shopfloor/lobby kiosk auto-selects which business unit to show based on the display PC's IP (classic dashboarddefaults table + apivisitorlocation.asp). For the main admin dashboard this does nothing - it is kiosk/visitor-display infra. - Model: DashboardDefault (dashboarddefaults: ipaddress unique, businessunitid FK, description). Migration 7d01_dashboarddefaults (head). - API (core, /api/dashboarddefaults): CRUD + GET /visitor-location that resolves the calling display's business unit from its IP (X-Forwarded-For/remote_addr, or explicit ?ipaddress=); unmapped IP returns a null businessunitid, not an error. Unauthenticated resolve (kiosks); writes are admin. - Frontend: ShopfloorDashboard auto-selects its business unit via visitor-location on load when none is chosen; Settings > Dashboard Defaults CRUD page + dashboardDefaultsApi client. Tests: create + resolve by IP -> BU; unmapped IP -> null; duplicate IP 409. 191 tests pass, naming green, app boots, endpoint + admin page verified live. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
37
migrations/versions/7d01_dashboarddefaults.py
Normal file
37
migrations/versions/7d01_dashboarddefaults.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""Add dashboarddefaults (visitor-IP -> business-unit mapping)
|
||||
|
||||
A shopfloor / lobby kiosk resolves which business unit to display from the
|
||||
display PC's IP. Powers the visitor-location lookup.
|
||||
|
||||
Revision ID: 7d01_dashboarddefaults
|
||||
Revises: 7c04_fold_plugin_schema
|
||||
Create Date: 2026-06-27
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '7d01_dashboarddefaults'
|
||||
down_revision = '7c04_fold_plugin_schema'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
'dashboarddefaults',
|
||||
sa.Column('dashboarddefaultid', sa.Integer(), primary_key=True),
|
||||
sa.Column('ipaddress', sa.String(length=50), nullable=False, unique=True),
|
||||
sa.Column('businessunitid', sa.Integer(), nullable=False),
|
||||
sa.Column('description', sa.String(length=255), nullable=True),
|
||||
sa.Column('createddate', sa.DateTime(), nullable=True),
|
||||
sa.Column('modifieddate', sa.DateTime(), nullable=True),
|
||||
sa.Column('isactive', sa.Boolean(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['businessunitid'], ['businessunits.businessunitid'],
|
||||
name='fk_dashboarddefaults_businessunit'),
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('dashboarddefaults')
|
||||
Reference in New Issue
Block a user