56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
/**
|
|
* Dashboard Controller
|
|
*
|
|
* Provides dashboard analytics and KPI endpoints
|
|
*/
|
|
|
|
import { Controller, Get, UseGuards, Request } from '@nestjs/common';
|
|
import { AnalyticsService } from '../services/analytics.service';
|
|
import { JwtAuthGuard } from '../guards/jwt-auth.guard';
|
|
|
|
@Controller('api/v1/dashboard')
|
|
@UseGuards(JwtAuthGuard)
|
|
export class DashboardController {
|
|
constructor(private readonly analyticsService: AnalyticsService) {}
|
|
|
|
/**
|
|
* Get dashboard KPIs
|
|
* GET /api/v1/dashboard/kpis
|
|
*/
|
|
@Get('kpis')
|
|
async getKPIs(@Request() req: any) {
|
|
const organizationId = req.user.organizationId;
|
|
return this.analyticsService.calculateKPIs(organizationId);
|
|
}
|
|
|
|
/**
|
|
* Get bookings chart data (6 months)
|
|
* GET /api/v1/dashboard/bookings-chart
|
|
*/
|
|
@Get('bookings-chart')
|
|
async getBookingsChart(@Request() req: any) {
|
|
const organizationId = req.user.organizationId;
|
|
return this.analyticsService.getBookingsChartData(organizationId);
|
|
}
|
|
|
|
/**
|
|
* Get top 5 trade lanes
|
|
* GET /api/v1/dashboard/top-trade-lanes
|
|
*/
|
|
@Get('top-trade-lanes')
|
|
async getTopTradeLanes(@Request() req: any) {
|
|
const organizationId = req.user.organizationId;
|
|
return this.analyticsService.getTopTradeLanes(organizationId);
|
|
}
|
|
|
|
/**
|
|
* Get dashboard alerts
|
|
* GET /api/v1/dashboard/alerts
|
|
*/
|
|
@Get('alerts')
|
|
async getAlerts(@Request() req: any) {
|
|
const organizationId = req.user.organizationId;
|
|
return this.analyticsService.getAlerts(organizationId);
|
|
}
|
|
}
|