fix(modals): portal modals to document.body and add interactive time filter to device & remote IP popups

This commit is contained in:
ypratama committed 2026-11-11 17:45:34 +07:00
1 parent 7abb56e328
commit 74cf627fb8
5 files changed
+221 -28

No files matched your search

+18 -3
View File
@@ -74,8 +74,9 @@ module.exports = async function deviceDetailsHandler(req, res, helpers) {
const flowFilter = { ...siteFilter, ...strictAgentFilter };
const rawTimeRange = String(req.query.timeRange ?? 'all');
let tf = null;
if (rawTimeRange !== 'all') {
const tf = getTimeFilter(req);
tf = getTimeFilter(req);
if (tf) flowFilter.timestamp = tf;
}
@@ -89,6 +90,10 @@ module.exports = async function deviceDetailsHandler(req, res, helpers) {
else if (mac) threatQuery.$or = [{ mac_address: mac }, { src_mac: mac }];
const appFilter = { ...siteFilter, ...strictAgentFilter, ip_address: ip };
if (tf) {
appFilter.timestamp = tf;
threatQuery.timestamp = tf;
}
const [deviceAppStats, flowsQuery, rawThreats] = await Promise.all([
ip ? DeviceAppStat.find(appFilter).sort({ timestamp: -1 }).lean() : [],
@@ -157,8 +162,18 @@ module.exports = async function deviceDetailsHandler(req, res, helpers) {
agentUuid = deviceAppStats[0]?.agent_uuid || flowsQuery[0]?.agent_uuid || agentUuid;
const appsDl = apps.reduce((s, a) => s + (a.download || 0), 0);
const appsUl = apps.reduce((s, a) => s + (a.upload || 0), 0);
const totalDownload = Math.max(device?.download || 0, appsDl);
const totalUpload = Math.max(device?.upload || 0, appsUl);
let totalDownload = appsDl;
let totalUpload = appsUl;
if (rawTimeRange === 'all') {
totalDownload = Math.max(device?.download || 0, appsDl);
totalUpload = Math.max(device?.upload || 0, appsUl);
} else {
const flowsDl = flowsQuery.filter(f => (ip ? f.src_ip === ip : f.src_mac === mac)).reduce((s, f) => s + (f.download || 0), 0);
const flowsUl = flowsQuery.filter(f => (ip ? f.src_ip === ip : f.src_mac === mac)).reduce((s, f) => s + (f.upload || 0), 0);
totalDownload = Math.max(appsDl, flowsDl);
totalUpload = Math.max(appsUl, flowsUl);
}
// ── Device metadata ───────────────────────────────────────────────────────
const flowMac = flowsQuery.find(f => f.src_ip === ip && f.src_mac && !f.src_mac.startsWith('00:16:3e:'))?.src_mac;