feat: add frontend, nginx reverse proxy and monitoring/reports extras

- apps/frontend: Next.js 15 (App Router) + Tailwind v4 + componentes estilo
  shadcn/ui sobre Radix UI + TanStack Query. Tema light/dark, logo
  processada. Menu completo (secao 52) com gating por permissao real.
  Todas as telas do checklist de aceite (secao 90) conectadas a endpoints
  reais (nao mockup): login, usuarios, perfis/permissoes, ramais/troncos,
  dialplan, filas/agentes, console do agente, campanhas (CPS/CSV/
  iniciar/pausar), monitoramento ao vivo (polling, nao WebSocket real),
  TME/TMA, busca/export de chamadas, administracao do Asterisk, auditoria
- infrastructure/nginx: reverse proxy colocando frontend+API na mesma
  origem (porta 80), antecipado da Fase 9 pois a API nao publica porta
  propria
- apps/api: GET /api/monitoring/agents (estado corrente real via
  agent_state_events em aberto) e filtro queueId em GET /api/reports/calls

Pendencia registrada: tela de Callbacks nao implementada (schema existe
desde a Fase 6, mas nunca houve controller/service — construir a tela sem
API real seria mockup). Verificacao visual em navegador nao foi possivel
neste ambiente headless; validado via tsc/eslint/next build limpos + curl
reproduzindo as chamadas do navegador (middleware de auth, 24 paginas
protegidas via Nginx, endpoints de dados com cookie de sessao).
This commit is contained in:
2026-08-27 17:35:34 -03:00
parent 0a8b830e2c
commit 6273b32214
100 changed files with 12280 additions and 17 deletions

View File

@@ -77,4 +77,38 @@ export class MonitoringController {
};
});
}
// Estado corrente real (agent_state_events sem ended_at), nunca inferido
// de cache — cada linha aqui é o snapshot atual de fato do agente.
@Get('agents')
@RequirePermissions('monitoring.view')
async agentsStatus() {
const agents = await this.prisma.agent.findMany({
where: { active: true },
orderBy: { code: 'asc' },
include: {
user: { select: { name: true } },
queues: { include: { queue: { select: { name: true } } } },
},
});
const openEvents = await this.prisma.agentStateEvent.findMany({
where: { endedAt: null },
orderBy: { startedAt: 'desc' },
});
const stateByAgent = new Map(openEvents.map((e) => [e.agentId, e]));
return agents.map((agent) => {
const event = stateByAgent.get(agent.id);
return {
id: agent.id,
code: agent.code,
name: agent.name,
userName: agent.user.name,
currentExtension: agent.currentExtension,
queues: agent.queues.map((q) => q.queue.name),
state: event?.state ?? 'LOGGED_OUT',
stateSince: event?.startedAt ?? null,
};
});
}
}

View File

@@ -22,6 +22,10 @@ export class QueryCallsReportDto {
@IsUUID('4')
campaignId?: string;
@IsOptional()
@IsUUID('4')
queueId?: string;
@IsOptional()
@IsUUID('4')
agentId?: string;

View File

@@ -13,6 +13,7 @@ function buildCallsWhere(
dispositionId: query.dispositionId,
state: query.state as CallState | undefined,
calledNumber: query.phone ? { contains: query.phone } : undefined,
campaign: query.queueId ? { queueId: query.queueId } : undefined,
startedAt: {
gte: query.from ? new Date(query.from) : undefined,
lte: query.to ? new Date(query.to) : undefined,