Документация

Dashboard Module

This section describes the unified dashboard subsystem responsible for summarising crisis ticket data and monitoring system health.

Role

The dashboard blueprint aggregates ticket information and presents it at the /dashboard route. Logged in users can inspect trends, track KPIs or download a PDF briefing for offline use.

Key components

  • app/tickets_dashboard.py defines dashboard_bp with several routes:
  • /dashboard renders the main dashboard page;
  • /briefing returns the briefing page or a PDF when ?format=pdf is supplied;
  • /kanban shows tickets grouped by status;
  • /admin/status and /admin/status/data expose system checks.
  • Vue components under static/js/components/dashboard/ build charts and handle live updates.
  • templates/dashboard.html and templates/briefing.html contain the dashboard markup.
  • utils/analytics.py provides helpers like find_time_clusters.
  • Each user's layout preferences are stored in the dashboard_config JSON field of the User model. The layout can be edited directly on the dashboard page. Clicking Edit layout switches to a grid-based mode where widgets become movable and resizable tiles. You can drag tiles to new positions, resize them using their handles and remove or add widgets via the dropdown. After arranging the grid click Save to store the layout through the /api/v1/user/dashboard-config endpoint.

Example layout data:

json [ {"name": "kpis", "x": 0, "y": 0, "w": 2, "h": 1}, {"name": "trend", "x": 0, "y": 1, "w": 2, "h": 2}, {"name": "recent", "x": 2, "y": 0, "w": 1, "h": 3} ]

Integration with the rest of the system

dashboard_bp is registered in the application factory and requires authentication. Some routes are restricted to admins. Views query SQLAlchemy models such as CrisisTicket, Status and IncidentType.

Admin dashboard

The /admin/ route provides a concise overview for administrators. The page shows three KPI cards with the total number of tickets, currently open tickets and the count of registered users. Below the KPIs is a grid of quick actions linking to the user list, backup manager, utility scripts and reference dictionaries.

Example output:

Total tickets: 150
Open tickets: 7
Users: 5

[Users] [Backups] [Utilities & scripts] [References]

Advanced metrics

The dashboard exposes additional analytics via calculate_advanced_analytics. Average response and resolution times are calculated for each emergency type. A heatmap summarises incident counts by region and day of week. These datasets power the extra charts on the dashboard and are also available through /api/v1/analytics/advanced.

Hot spot widget

find_time_clusters detects bursts of activity. The dashboard displays these clusters in a "Hot spots" widget which fetches data from /api/v1/tickets/clusters and lists the time range and number of incidents for each period.

Report builder

The route /reports/builder provides an interactive UI for assembling custom reports. Pick the fields to include, add filter rules and optionally group rows.

Saved reports store a configuration object. Filters can be nested using group and rules keys:

{
  "fields": ["id", "title", "status", "risk_level"],
  "filters": {
    "group": "AND",
    "rules": [
      {"field": "status", "op": "eq", "value": "resolved"},
      {
        "group": "OR",
        "rules": [
          {"field": "risk_level", "op": "eq", "value": "High"},
          {"field": "priority", "op": "gt", "value": 2}
        ]
      }
    ]
  },
  "group_by": "status"
}

Upload this JSON via /reports/api/v1/reports/save to reuse the report later.