ux
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
import os
|
||||
import platform
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
|
||||
from app.core_settings import get_settings
|
||||
@@ -7,10 +11,12 @@ from app.services.capabilities import build_capabilities
|
||||
from app.services.catalog import get_catalog
|
||||
from app.services.kiosk_settings import get_kiosk_settings_service
|
||||
from app.services.auth import get_auth_service
|
||||
from app.services.influx_http import InfluxHTTPService
|
||||
from app.utils.serialization import to_plain
|
||||
|
||||
|
||||
dashboard_blueprint = Blueprint("dashboard", __name__)
|
||||
_APP_STARTED_AT = datetime.now(timezone.utc)
|
||||
|
||||
|
||||
@dashboard_blueprint.get("/dashboard/config")
|
||||
@@ -78,3 +84,38 @@ def update_dashboard_kiosk_settings():
|
||||
return jsonify({"detail": str(exc)}), 403
|
||||
except ValueError as exc:
|
||||
return jsonify({"detail": str(exc)}), 400
|
||||
|
||||
|
||||
@dashboard_blueprint.get("/dashboard/diagnostics")
|
||||
def dashboard_diagnostics():
|
||||
settings = get_settings()
|
||||
influx_diagnostics = InfluxHTTPService(settings).diagnose()
|
||||
now = datetime.now(timezone.utc)
|
||||
payload = {
|
||||
"app": {
|
||||
"name": settings.app_name,
|
||||
"version": settings.version,
|
||||
"debug": settings.debug,
|
||||
"timezone": settings.timezone,
|
||||
"site_name": settings.site_name,
|
||||
"installed_power_kwp": settings.installed_power_kwp,
|
||||
"auth_enabled": settings.auth["enabled"],
|
||||
"started_at": _APP_STARTED_AT.isoformat(),
|
||||
"uptime_seconds": max(int((now - _APP_STARTED_AT).total_seconds()), 0),
|
||||
"python_version": platform.python_version(),
|
||||
"pid": os.getpid(),
|
||||
},
|
||||
"api": {
|
||||
"status": "ok",
|
||||
"prefix": settings.api_prefix,
|
||||
"cors_origins_count": len(settings.cors_origins),
|
||||
},
|
||||
"influx": influx_diagnostics,
|
||||
"storage": {
|
||||
"sqlite_path": settings.storage["sqlite_path"],
|
||||
"historical_import_enabled": settings.history["enabled"],
|
||||
"auto_sync_enabled": settings.history["auto_sync_enabled"],
|
||||
"default_chunk_days": settings.history["default_chunk_days"],
|
||||
},
|
||||
}
|
||||
return jsonify(to_plain(payload))
|
||||
|
||||
Reference in New Issue
Block a user