Files
Heimdall/src/Heimdall.Api/Controllers/StatsController.cs
T

31 lines
967 B
C#
Raw Normal View History

using Heimdall.Application.Services;
2026-07-17 17:22:33 +00:00
using Heimdall.Infrastructure.Security;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Heimdall.Api.Controllers;
[ApiController]
[Route("api/stats")]
public class StatsController : ControllerBase
{
private readonly IStatsService _statsService;
2026-07-17 17:22:33 +00:00
public StatsController(IStatsService statsService) => _statsService = statsService;
2026-07-17 17:22:33 +00:00
[Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.SiteRead)]
[HttpGet]
public async Task<IActionResult> GetStats(CancellationToken ct)
{
var stats = await _statsService.GetStatsAsync(ct);
2026-07-17 17:22:33 +00:00
return Ok(new
{
totalSites = stats.TotalSites,
totalCameras = stats.TotalCameras,
totalAgents = stats.TotalAgents,
onlineAgents = stats.OnlineAgents,
activeSites = stats.ActiveSites,
2026-07-17 17:22:33 +00:00
timestamp = DateTime.UtcNow
});
}
}