36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = function (app) {
|
|
const router = require('express').Router();
|
|
const ctl = require('../controllers/dashboard');
|
|
|
|
/**
|
|
* Pilot analytics dashboard endpoints.
|
|
* All routes require a valid JWT (enforced by the global checkUser middleware).
|
|
* Data is always scoped to the authenticated user — pilotId is derived from req.uid.
|
|
*/
|
|
|
|
// KPI summary cards
|
|
router.get('/pilot/kpi', ctl.getKpi);
|
|
|
|
// Daily summary: today vs yesterday with percentage deltas
|
|
router.get('/pilot/summary', ctl.getSummary);
|
|
|
|
// Trend charts: daily hours flown + hectares sprayed over a date range
|
|
router.get('/pilot/trend', ctl.getTrend);
|
|
|
|
// Active jobs panel with per-job progress and applied volume
|
|
router.get('/pilot/activeJobs', ctl.getActiveJobs);
|
|
|
|
// Performance gauges: average XT error and spray altitude
|
|
router.get('/pilot/performance', ctl.getPerformance);
|
|
|
|
// Save custom XT / altitude thresholds for the authenticated user
|
|
router.put('/pilot/performance/thresholds', ctl.savePerformanceThresholds);
|
|
|
|
// Composite snapshot: fetch multiple dashboard modules in one request
|
|
router.get('/pilot/snapshot', ctl.getSnapshot);
|
|
|
|
app.use('/api/dashboard', router);
|
|
};
|