- Complete Flask-based control panel for multi-tenant POS instances - Dashboard with global stats, system health, and recent demos - Demo provisioning in 1 click with auto-expiration tracking - Tenant management: activate/deactivate, reset data, delete - Health monitoring: PostgreSQL, Redis, disk, memory, systemd services - Migration orchestration UI for running schema updates across all tenants - JWT authentication with manager_users table - Dark theme SPA frontend with real-time search and actions - systemd service file included
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
"""Admin dashboard blueprint."""
|
|
from flask import Blueprint, jsonify
|
|
from blueprints.auth_bp import require_manager_auth
|
|
from services import tenant_service, migration_service
|
|
|
|
admin_bp = Blueprint("admin", __name__, url_prefix="/api/admin")
|
|
|
|
|
|
@admin_bp.route("/stats", methods=["GET"])
|
|
@require_manager_auth
|
|
def dashboard_stats():
|
|
return jsonify(tenant_service.get_dashboard_stats())
|
|
|
|
|
|
@admin_bp.route("/migrations", methods=["GET"])
|
|
@require_manager_auth
|
|
def list_migrations():
|
|
return jsonify({
|
|
"migrations": migration_service.list_available_migrations(),
|
|
"tenants": migration_service.get_tenant_versions()
|
|
})
|
|
|
|
|
|
@admin_bp.route("/migrations/run-all", methods=["POST"])
|
|
@require_manager_auth
|
|
def run_all_migrations():
|
|
result = migration_service.run_all_pending_migrations()
|
|
return jsonify(result)
|
|
|
|
|
|
@admin_bp.route("/migrations/run/<version>", methods=["POST"])
|
|
@require_manager_auth
|
|
def run_specific_migration(version):
|
|
result = migration_service.run_migration_on_all_tenants(version)
|
|
return jsonify({"results": result})
|