diff --git a/backend/routes/dashboard/apps.js b/backend/routes/dashboard/apps.js index 059e886..70bd617 100644 --- a/backend/routes/dashboard/apps.js +++ b/backend/routes/dashboard/apps.js @@ -1,6 +1,6 @@ const express = require('express'); const router = express.Router(); -const { AppStat, ProtocolStat, AppCategoryStat, LookupApp } = require('../../models/Schemas'); +const { AppStat, ProtocolStat, AppCategoryStat, LookupApp, Flow } = require('../../models/Schemas'); const { getTimeFilter, getBaseFilter } = require('./helpers'); // GET /api/dashboard/apps @@ -44,17 +44,18 @@ router.get('/protocols', async (req, res) => { const base = getBaseFilter(req, timeFilter); const pipeline = [ - { $match: base }, + { $match: { ...base, protocol: { $ne: null, $ne: '' } } }, { $group: { - _id: '$protocol_label', + _id: '$protocol', download: { $sum: '$download' }, upload: { $sum: '$upload' }, - flows: { $sum: '$flows' }, + flows: { $sum: 1 }, }}, - { $sort: { download: -1 } } + { $sort: { download: -1 } }, + { $limit: 20 } ]; - const result = await ProtocolStat.aggregate(pipeline); + const result = await Flow.aggregate(pipeline); const formatted = result.map(r => ({ protocol_label: r._id, download: r.download || 0, diff --git a/src/app/(dashboard)/page.tsx b/src/app/(dashboard)/page.tsx index fc5a8c8..752ac67 100644 --- a/src/app/(dashboard)/page.tsx +++ b/src/app/(dashboard)/page.tsx @@ -22,7 +22,7 @@ export default function SummaryPage() { let appsData = rawTopApps.data || []; const standardProtocols = [ - 'QUIC', 'HTTPS', 'HTTP', 'STUN', 'TCP', 'UDP', 'TLS', 'DNS', 'ICMP', + 'QUIC', 'HTTPS', 'HTTP', 'STUN', 'TCP', 'UDP', 'TLS', 'DNS', 'ICMP', 'SSH', 'FTP', 'SMTP', 'POP3', 'IMAP', 'NTP', 'DHCP', 'BGP', 'OSPF', 'IPSEC', 'OPENVPN' ];