fix(dashboard): pinpoint zoom-scaled Agent red markers, city-center blue markers, and standardize netify./siab. to backone. everywhere

This commit is contained in:
ypratama committed 2026-11-09 19:04:07 +07:00
1 parent 2482e0c670
commit 87dc19f63f
10 files changed
+130 -146

No files matched your search

+10 -3
View File
@@ -34,7 +34,14 @@ module.exports = async function appDetailsHandler(req, res, helpers) {
if (agentUuid) baseFilter.agent_uuid = agentUuid;
// ── Step 1: Query DeviceAppStat (Primary source for per-device bandwidth per-app) ──
const queryFilter = { ...baseFilter, app_label: label };
const baseName = label.replace(/^(?:backone|netify|siab|nexus)\./i, '');
const labelVariants = Array.from(new Set([
label,
`netify.${baseName}`,
`backone.${baseName}`,
`siab.${baseName}`,
]));
const queryFilter = { ...baseFilter, app_label: { $in: labelVariants } };
const deviceApps = await DeviceAppStat.find(queryFilter).sort({ timestamp: -1 }).lean();
if (deviceApps.length > 0) {
@@ -75,7 +82,7 @@ module.exports = async function appDetailsHandler(req, res, helpers) {
// Enrich domain & protocol info from Flow if available
const flows = await Flow.find({
...baseFilter,
app_label: label
app_label: { $in: labelVariants }
}).sort({ timestamp: -1 }).limit(100).lean();
flows.forEach(f => {
@@ -90,7 +97,7 @@ module.exports = async function appDetailsHandler(req, res, helpers) {
.sort((a, b) => (b.download + b.upload) - (a.download + a.upload));
// Ambil total download/upload dari sum AppStat over the time range
const appStats = await AppStat.find({ ...baseFilter, app_label: label }).lean();
const appStats = await AppStat.find({ ...baseFilter, app_label: { $in: labelVariants } }).lean();
const totalDl = appStats.reduce((s, x) => s + (x.download || 0), 0);
const totalUl = appStats.reduce((s, x) => s + (x.upload || 0), 0);
+19 -56
View File
@@ -10,66 +10,25 @@ const axios = require('axios');
const PROXY_URL = process.env.PROXY_URL || 'http://localhost:4010';
// ─── Rebranding Helper (Memory Safe & Fast) ──────────────────────────────────
const BRAND_NAMES = {
'1959bb55_045b_47c7_bbdd_f33b7db197b9': 'Office',
'6681452d_9cae_4ff4_8ae8_0d504774265e': 'SIAB',
'default': 'BackOne'
};
function getBrandNameForRequest(req) {
const requestedSiteUuid = req.headers['x-backone-site-uuid'];
const userSiteUuid = req.user?.site_uuid;
const siteUuid = (req.user?.role === 'SUPER_ADMIN' || !userSiteUuid || userSiteUuid === 'default')
? (requestedSiteUuid || 'default')
: userSiteUuid;
return BRAND_NAMES[siteUuid] || 'BackOne';
}
function rebrandString(str, brandName) {
function rebrandString(str) {
if (typeof str !== 'string') return str;
if (brandName === 'Nexus') {
return str
.replace(/netify\.unclassified/gi, 'nexus.unclassified')
.replace(/netify\.(?!ai)/gi, 'nexus.')
.replace(/Netify's/g, "Nexus'")
.replace(/netify's/g, "nexus'")
.replace(/Netify(?!(\.ai))/g, 'Nexus')
.replace(/netify(?!(\.ai))/g, 'nexus')
.replace(/BackOne's/g, "Nexus'")
.replace(/backone's/g, "nexus'")
.replace(/BackOne/g, 'Nexus')
.replace(/backone/g, 'nexus')
.replace(/PT\.?\s*Data\s*Bisnis\s*Solusi/g, 'PT. Nexus Solusi');
} else if (brandName === 'SIAB') {
return str
.replace(/netify\.unclassified/gi, 'siab.unclassified')
.replace(/netify\.(?!ai)/gi, 'siab.')
.replace(/Netify's/g, "SIAB's")
.replace(/netify's/g, "siab's")
.replace(/Netify(?!(\.ai))/g, 'SIAB')
.replace(/netify(?!(\.ai))/g, 'siab');
}
// Default (BackOne)
// Standardize all netify./siab./nexus. prefixes across protocols, apps, and domains to backone.
return str
.replace(/netify\.unclassified/gi, 'backone.unclassified')
.replace(/netify\.(?!ai)/gi, 'backone.')
.replace(/Netify's/g, "BackOne's")
.replace(/netify's/g, "backone's")
.replace(/\b(?:netify|siab|nexus)\.unclassified/gi, 'backone.unclassified')
.replace(/\b(?:netify|siab|nexus)\.(?!ai)/gi, 'backone.')
.replace(/(?:Netify|SIAB)'s/g, "BackOne's")
.replace(/(?:netify|siab)'s/g, "backone's")
.replace(/Netify(?!(\.ai))/g, 'BackOne')
.replace(/netify(?!(\.ai))/g, 'backone');
}
function rebrandObj(obj, brandName) {
function rebrandObj(obj) {
if (obj === null || obj === undefined) return obj;
if (Array.isArray(obj)) {
for (let i = 0; i < obj.length; i++) {
obj[i] = rebrandObj(obj[i], brandName);
obj[i] = rebrandObj(obj[i]);
}
return obj;
}
@@ -78,9 +37,9 @@ function rebrandObj(obj, brandName) {
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
if (typeof obj[key] === 'string') {
obj[key] = rebrandString(obj[key], brandName);
obj[key] = rebrandString(obj[key]);
} else if (typeof obj[key] === 'object') {
obj[key] = rebrandObj(obj[key], brandName);
obj[key] = rebrandObj(obj[key]);
}
}
}
@@ -88,20 +47,21 @@ function rebrandObj(obj, brandName) {
}
if (typeof obj === 'string') {
return rebrandString(obj, brandName);
return rebrandString(obj);
}
return obj;
}
// ─── Rebranding Middleware ────────────────────────────────────────────────────
router.use((req, res, next) => {
const brandName = getBrandNameForRequest(req);
function rebrandMiddleware(req, res, next) {
if (res._rebrandAttached) return next();
res._rebrandAttached = true;
const originalJson = res.json.bind(res);
res.json = function (body) {
if (body) {
try {
body = rebrandObj(body, brandName);
body = rebrandObj(body);
} catch (err) {
console.error('[Dashboard] Rebrand error:', err.message);
}
@@ -109,7 +69,9 @@ router.use((req, res, next) => {
return originalJson(body);
};
next();
});
}
router.use(rebrandMiddleware);
// POST /api/dashboard/refresh
router.post('/refresh', async (req, res) => {
@@ -140,4 +102,5 @@ router.use(require('./dashboard/tenantConfig'));
router.use(require('./dashboard/agentLocations'));
router.use(require('./dashboard/blacklist'));
router.rebrandMiddleware = rebrandMiddleware;
module.exports = router;
+9 -46
View File
@@ -6,14 +6,8 @@ const { getTimeFilter } = require('./helpers');
// ─── 1. GET /api/dashboard/agent-locations ──────────────────────────────────────
router.get('/agent-locations', async (req, res) => {
try {
const isGlobalUser = req.user?.role === 'SUPER_ADMIN' ||
((!req.user?.site_uuid || req.user?.site_uuid === 'default') && ['SOC_ANALYST', 'ENGINEER'].includes(req.user?.role));
let query = {};
if (!isGlobalUser && req.user?.site_uuid) {
query.site_uuid = req.user.site_uuid;
}
if (req.user?.role === 'AGENT_VIEWER' && req.user?.agent_uuid) {
if (req.user?.role === 'AGENT_VIEWER' && req.user?.agent_uuid && !req.user?._viewAsMode) {
query.agent_uuid = req.user.agent_uuid;
}
@@ -28,7 +22,8 @@ router.get('/agent-locations', async (req, res) => {
// ─── 2. POST /api/dashboard/agent-locations ─────────────────────────────────────
router.post('/agent-locations', async (req, res) => {
try {
if (req.user?.role !== 'SUPER_ADMIN' && req.user?.role !== 'TENANT_ADMIN') {
const effectiveRole = req.user?._originalRole || req.user?.role;
if (effectiveRole !== 'SUPER_ADMIN' && effectiveRole !== 'TENANT_ADMIN') {
return res.status(403).json({ ok: false, error: 'Only administrators can configure agent geolocations.' });
}
const { agent_uuid, latitude, longitude, label } = req.body;
@@ -36,35 +31,11 @@ router.post('/agent-locations', async (req, res) => {
return res.status(400).json({ ok: false, error: 'agent_uuid, latitude, and longitude are required' });
}
// Determine site_uuid
let siteUuid = null;
const isGlobalUser = req.user?.role === 'SUPER_ADMIN' ||
((!req.user?.site_uuid || req.user?.site_uuid === 'default') && ['SOC_ANALYST', 'ENGINEER'].includes(req.user?.role));
if (!isGlobalUser && req.user?.site_uuid) {
const agentBelongs = await Summary.findOne({ agent_uuid, site_uuid: req.user.site_uuid });
if (!agentBelongs) {
return res.status(403).json({ ok: false, error: 'Unauthorized: This agent does not belong to your tenant.' });
}
siteUuid = req.user.site_uuid;
} else {
// Find the site_uuid from Summary collection for this agent
const summaryDoc = await Summary.findOne({ agent_uuid });
if (summaryDoc) {
siteUuid = summaryDoc.site_uuid;
} else {
// Fallback or use standard env site_uuid
siteUuid = process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID || '6681452d_9cae_4ff4_8ae8_0d504774265e';
}
}
const findQuery = { agent_uuid };
if (!isGlobalUser && req.user?.site_uuid) {
findQuery.site_uuid = req.user.site_uuid;
}
const summaryDoc = await Summary.findOne({ agent_uuid }).lean();
const siteUuid = summaryDoc?.site_uuid || process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID || '6681452d_9cae_4ff4_8ae8_0d504774265e';
const upserted = await CustomAgentLocation.findOneAndUpdate(
findQuery,
{ agent_uuid },
{
agent_uuid,
site_uuid: siteUuid,
@@ -85,20 +56,12 @@ router.post('/agent-locations', async (req, res) => {
// ─── 3. DELETE /api/dashboard/agent-locations/:agent_uuid ────────────────────────
router.delete('/agent-locations/:agent_uuid', async (req, res) => {
try {
if (req.user?.role !== 'SUPER_ADMIN' && req.user?.role !== 'TENANT_ADMIN') {
const effectiveRole = req.user?._originalRole || req.user?.role;
if (effectiveRole !== 'SUPER_ADMIN' && effectiveRole !== 'TENANT_ADMIN') {
return res.status(403).json({ ok: false, error: 'Only administrators can delete agent geolocations.' });
}
const { agent_uuid } = req.params;
let query = { agent_uuid };
const isGlobalUser = req.user?.role === 'SUPER_ADMIN' ||
((!req.user?.site_uuid || req.user?.site_uuid === 'default') && ['SOC_ANALYST', 'ENGINEER'].includes(req.user?.role));
if (!isGlobalUser && req.user?.site_uuid) {
query.site_uuid = req.user.site_uuid;
}
const resDelete = await CustomAgentLocation.deleteOne(query);
const resDelete = await CustomAgentLocation.deleteOne({ agent_uuid });
res.json({ ok: true, deleted: resDelete.deletedCount > 0 });
} catch (err) {
console.error('[DELETE /agent-locations]', err.message);
+1
View File
@@ -77,6 +77,7 @@ const {
// ─── Protected Dashboard Routes ───────────────────────────────────────────────
const dashboardRoutes = require('./routes/dashboard');
app.use('/api/dashboard', dashboardRoutes.rebrandMiddleware);
// Override /api/dashboard/app-details to show real-time device mapping per application
app.get('/api/dashboard/app-details', requireAuth, (req, res) => {
+1
View File
@@ -29,6 +29,7 @@ export function TopWidgets({ topApps, topProtocols }: TopWidgetsProps) {
const protocolsData = (topProtocols.data || []).map(p => ({
...p,
protocol_label: formatAppLabel(p.protocol_label),
total: (p.download || 0) + (p.upload || 0)
}));
+4 -4
View File
@@ -2,7 +2,7 @@
import { useState } from "react";
import { Globe } from "lucide-react";
import { fmtBytes } from "@/lib/utils";
import { fmtBytes, formatAppLabel } from "@/lib/utils";
import { Pagination } from "./Pagination";
import { UniversalFilters, useUniversalFilterState, FilterConfig } from "./UniversalFilters";
@@ -28,7 +28,7 @@ export default function DeviceDomainsTab({ domains, totalDownload, totalUpload }
};
const filterConfigs: FilterConfig[] = [
{ id: "app_label", label: "Domain", type: "select", value: filters.app_label, options: opts("app_label") },
{ id: "app_label", label: "Domain", type: "select", value: filters.app_label, options: opts("app_label"), formatter: formatAppLabel },
{ id: "sort_download", label: "Sort Download", type: "select", value: filters.sort_download, options: ["Descending", "Ascending"] },
{ id: "sort_upload", label: "Sort Upload", type: "select", value: filters.sort_upload, options: ["Descending", "Ascending"] },
];
@@ -93,8 +93,8 @@ export default function DeviceDomainsTab({ domains, totalDownload, totalUpload }
return (
<div key={i} className="bg-slate-50/50 dark:bg-white/[0.03] border border-border p-4 rounded-2xl hover:bg-slate-100/50 dark:hover:bg-white/[0.05] transition-colors group relative overflow-hidden text-xs">
<div className="absolute top-0 left-0 h-1 bg-purple-500/30 transition-all duration-500" style={{ width: `${pct}%` }} />
<h5 className="font-semibold text-card-foreground mb-3 text-sm flex justify-between items-center truncate gap-2" title={dom.app_label}>
<span className="truncate">{dom.app_label}</span>
<h5 className="font-semibold text-card-foreground mb-3 text-sm flex justify-between items-center truncate gap-2" title={formatAppLabel(dom.app_label)}>
<span className="truncate">{formatAppLabel(dom.app_label)}</span>
<span className="text-[10px] font-mono text-purple-600 dark:text-purple-400 bg-purple-500/10 px-2 py-0.5 rounded-full ring-1 ring-purple-500/20 shrink-0">{pct}%</span>
</h5>
<div className="space-y-2">
+1 -1
View File
@@ -130,7 +130,7 @@ export default function DeviceIdentityCard({
<div className="space-y-2.5">
{domains.slice(0, 5).map((d: any, i: number) => (
<div key={i} className="flex items-center justify-between gap-2 text-xs border-b border-border/40 pb-2 last:border-0 last:pb-0">
<span className="font-medium text-card-foreground truncate" title={d.app_label}>{d.app_label}</span>
<span className="font-medium text-card-foreground truncate" title={formatAppLabel(d.app_label)}>{formatAppLabel(d.app_label)}</span>
<span className="font-mono text-purple-400 shrink-0">{fmtBytes((d.download || 0) + (d.upload || 0))}</span>
</div>
))}
+26 -17
View File
@@ -23,6 +23,15 @@ export const GlobeMap = ({ data }: GlobeMapProps) => {
const destPoints = pointsData.filter((pt) => !pt.isOrigin);
const originPoints = pointsData.filter((pt) => pt.isOrigin);
const zoom = Math.max(position.zoom || 1, 1);
const invZoom = 1 / zoom;
const handleSelectPoint = (pt: GlobePointData) => {
setSelectedPoint(pt);
const targetZoom = pt.isOrigin ? Math.max(zoom, 8) : Math.max(zoom, 3.5);
setPosition({ coordinates: [pt.lng, pt.lat], zoom: targetZoom });
};
const mapBorderColor = isLight ? "#ffffff" : "#0ea5e9";
const mapFillColor = isLight ? "#4ade80" : "#0f172a";
const mapHoverFill = isLight ? "#22c55e" : "#1e293b";
@@ -54,7 +63,7 @@ export const GlobeMap = ({ data }: GlobeMapProps) => {
center={position.coordinates as [number, number]}
onMoveEnd={setPosition}
minZoom={1}
maxZoom={8}
maxZoom={35}
>
<Geographies geography={geoUrl}>
{({ geographies }) =>
@@ -64,7 +73,7 @@ export const GlobeMap = ({ data }: GlobeMapProps) => {
geography={geo}
fill={mapFillColor}
stroke={mapBorderColor}
strokeWidth={0.5}
strokeWidth={0.5 * invZoom}
onClick={() => setSelectedPoint(null)}
style={{
default: { outline: "none" },
@@ -84,7 +93,7 @@ export const GlobeMap = ({ data }: GlobeMapProps) => {
if (isLocal) {
return (
<Marker key={`arc-${i}`} coordinates={[arc.startLng, arc.startLat]}>
<circle r={9} fill="none" stroke={color} strokeWidth={1.5} opacity={0.7} strokeDasharray="2,2" />
<circle r={9 * invZoom} fill="none" stroke={color} strokeWidth={1.5 * invZoom} opacity={0.7} strokeDasharray="2,2" />
</Marker>
);
}
@@ -106,7 +115,7 @@ export const GlobeMap = ({ data }: GlobeMapProps) => {
key={`arc-${i}`}
coordinates={coordinates}
stroke={color}
strokeWidth={1.6}
strokeWidth={1.6 * invZoom}
strokeLinecap="round"
strokeOpacity={0.92}
strokeDasharray="2 4 4 4 8 78"
@@ -120,12 +129,12 @@ export const GlobeMap = ({ data }: GlobeMapProps) => {
<Marker
key={`dest-marker-${i}`}
coordinates={[pt.lng, pt.lat]}
onClick={(e) => { e.stopPropagation(); setSelectedPoint(pt); }}
onClick={(e) => { e.stopPropagation(); handleSelectPoint(pt); }}
style={{ default: { cursor: "pointer" }, hover: { cursor: "pointer" }, pressed: { cursor: "pointer" } }}
>
<circle r={9} fill="transparent" />
<circle r={6} fill={pt.color} opacity={0.25} />
<circle r={3.5} fill={pt.color} stroke="#ffffff" strokeWidth={1} opacity={0.98} />
<circle r={9 * invZoom} fill="transparent" />
<circle r={6 * invZoom} fill={pt.color} opacity={0.25} />
<circle r={3.5 * invZoom} fill={pt.color} stroke="#ffffff" strokeWidth={1 * invZoom} opacity={0.98} />
</Marker>
))}
@@ -133,13 +142,13 @@ export const GlobeMap = ({ data }: GlobeMapProps) => {
<Marker
key={`origin-marker-${i}`}
coordinates={[pt.lng, pt.lat]}
onClick={(e) => { e.stopPropagation(); setSelectedPoint(pt); }}
onClick={(e) => { e.stopPropagation(); handleSelectPoint(pt); }}
style={{ default: { cursor: "pointer" }, hover: { cursor: "pointer" }, pressed: { cursor: "pointer" } }}
>
<circle r={12} fill="transparent" />
<circle r={11} fill="#f43f5e" opacity={0.35} className="globe-origin-pulse" />
<circle r={8} fill="#f43f5e" opacity={0.25} />
<circle r={5.2} fill="#f43f5e" stroke="#ffffff" strokeWidth={1.5} />
<circle r={12 * invZoom} fill="transparent" />
<circle r={11 * invZoom} fill="#f43f5e" opacity={0.35} className="globe-origin-pulse" />
<circle r={8 * invZoom} fill="#f43f5e" opacity={0.25} />
<circle r={5.2 * invZoom} fill="#f43f5e" stroke="#ffffff" strokeWidth={1.5 * invZoom} />
</Marker>
))}
@@ -147,13 +156,13 @@ export const GlobeMap = ({ data }: GlobeMapProps) => {
<Marker
key={`label-${i}`}
coordinates={[lbl.lng, lbl.lat]}
onClick={(e) => { e.stopPropagation(); if (lbl.point) setSelectedPoint(lbl.point); }}
onClick={(e) => { e.stopPropagation(); if (lbl.point) handleSelectPoint(lbl.point); }}
style={{ default: { cursor: "pointer" }, hover: { cursor: "pointer" }, pressed: { cursor: "pointer" } }}
>
<text
textAnchor="middle"
y={-12}
style={{ fontFamily: "system-ui", fill: lbl.color, fontSize: `${lbl.size * 6}px`, fontWeight: "bold" }}
y={-12 * invZoom}
style={{ fontFamily: "system-ui", fill: lbl.color, fontSize: `${lbl.size * 6 * invZoom}px`, fontWeight: "bold" }}
>
{lbl.name}
</text>
@@ -178,7 +187,7 @@ export const GlobeMap = ({ data }: GlobeMapProps) => {
</span>
<h4 className="mt-1 text-xs font-bold text-white break-words">{selectedPoint.name}</h4>
<p className="text-[9px] font-mono text-slate-400">
Lat: {selectedPoint.lat.toFixed(4)}, Lng: {selectedPoint.lng.toFixed(4)}
Lat: {selectedPoint.lat.toFixed(6)}, Lng: {selectedPoint.lng.toFixed(6)}
</p>
</div>
<button
+4 -1
View File
@@ -1,6 +1,9 @@
export function formatAppLabel(appLabel: string | null | undefined): string {
if (!appLabel) return "-";
const trimLabel = appLabel.trim();
const trimLabel = appLabel
.trim()
.replace(/\b(?:netify|siab|nexus)\.unclassified/gi, "backone.unclassified")
.replace(/\b(?:netify|siab|nexus)\.(?!ai)/gi, "backone.");
const portMatch = trimLabel.match(/^(?:Port\s+)?(\d+)$/i);
if (portMatch) {
+55 -18
View File
@@ -9,31 +9,66 @@ export interface GeoLocation {
// ─── 1. GLOBAL DESTINATION COORDINATES (By Country Code) ────────────────
export const COUNTRY_COORDS: Record<string, [number, number]> = WORLD_COUNTRY_COORDS;
// Capital / Major City Center Coordinates [lng, lat] so Blue Dots sit at the city center
export const CAPITAL_CITY_COORDS: Record<string, [number, number]> = {
"ID": [106.8272, -6.1754], // Jakarta (Monas / Pusat Kota)
"US": [-77.0369, 38.9072], // Washington D.C.
"HK": [114.1694, 22.3193], // Hong Kong
"SG": [103.8198, 1.3521], // Singapore
"JP": [139.6917, 35.6895], // Tokyo
"SC": [55.4513, -4.6191], // Victoria
"GB": [-0.1276, 51.5072], // London
"IT": [12.4964, 41.9028], // Rome
"CN": [116.4074, 39.9042], // Beijing
"KR": [126.9780, 37.5665], // Seoul
"CA": [-75.6972, 45.4215], // Ottawa
"LU": [6.1319, 49.6116], // Luxembourg
"NL": [4.9041, 52.3676], // Amsterdam
"IE": [-6.2603, 53.3498], // Dublin
"TR": [32.8597, 39.9334], // Ankara
"UA": [30.5234, 50.4501], // Kyiv
"RU": [37.6173, 55.7558], // Moscow
"HU": [19.0402, 47.4979], // Budapest
"BD": [90.4125, 23.8103], // Dhaka
"AU": [149.1300, -35.2809], // Canberra
"IN": [77.2090, 28.6139], // New Delhi
"DE": [13.4050, 52.5200], // Berlin
"FR": [2.3522, 48.8566], // Paris
"ES": [-3.7038, 40.4168], // Madrid
"BR": [-47.8825, -15.7942], // Brasilia
"MX": [-99.1332, 19.4326], // Mexico City
"MY": [101.6869, 3.1390], // Kuala Lumpur
"TH": [100.5018, 13.7563], // Bangkok
"VN": [105.8342, 21.0278], // Hanoi
"PH": [120.9842, 14.5995], // Manila
"TW": [121.5654, 25.0330], // Taipei
"GR": [23.7275, 37.9838], // Athens
};
// ─── 2. MANUAL CONFIGURATION (For Local IPs, Agent UUIDs, or City Names) ───
// Users can edit this section to map their internal locations accurately.
export const MANUAL_OVERRIDES: Record<string, GeoLocation> = {
// Map by IP
"192.168.201.30": { lat: -7.2504, lng: 112.7688, label: "Surabaya, Indonesia" },
// Map by Network Agent UUID
"14-6Q-G6-7G": { lat: -5.3864, lng: 105.3821, label: "Feedmill Lampung, Indonesia" },
"F6-2V-DT-8A": { lat: -6.2263, lng: 106.4247, label: "CPI Balaraja, Indonesia" },
"2F-TF-1D-GK": { lat: -6.3763, lng: 106.8983, label: "JRP Cibubur, Indonesia" },
"2N-ID-VQ-AL": { lat: -6.1751, lng: 106.8650, label: "Fazza Jakarta, Indonesia" },
"23-TE-6L-I2": { lat: -6.2260, lng: 106.8580, label: "Kantor Tebet, Indonesia" },
"8A-V3-PB-85": { lat: -6.2253, lng: 106.8061, label: "IFG Lt 18 Jakarta, Indonesia" },
"1T-5Q-RC-AS": { lat: -6.2088, lng: 106.8456, label: "BackOne Lab Jakarta, Indonesia" },
"YW-6I-61-LL": { lat: -6.2088, lng: 106.8456, label: "Gateway 07 Jakarta, Indonesia" },
"Balaraja-Agent": { lat: -6.1915, lng: 106.4526, label: "Balaraja, Indonesia" },
// Map by Network Agent UUID (Exact coordinates matching CustomAgentLocation)
"14-6Q-G6-7G": { lat: -5.3863909, lng: 105.3820549, label: "Feedmill Lampung, Indonesia" },
"F6-2V-DT-8A": { lat: -6.2263304, lng: 106.4247322, label: "CPI Balaraja, Indonesia" },
"2F-TF-1D-GK": { lat: -6.3763318, lng: 106.8983017, label: "JRP Cibubur, Indonesia" },
"8A-V3-PB-85": { lat: -6.2253265, lng: 106.8061484, label: "IFG Lt 18 Jakarta, Indonesia" },
"2N-ID-VQ-AL": { lat: -6.1751100, lng: 106.8650395, label: "Fazza Jakarta, Indonesia" },
"23-TE-6L-I2": { lat: -6.2260120, lng: 106.8580450, label: "Kantor Tebet, Indonesia" },
"1T-5Q-RC-AS": { lat: -6.2087634, lng: 106.8455990, label: "BackOne Lab Jakarta, Indonesia" },
"YW-6I-61-LL": { lat: -6.2087634, lng: 106.8455990, label: "Gateway 07 Jakarta, Indonesia" },
"Balaraja-Agent": { lat: -6.2263304, lng: 106.4247322, label: "Balaraja, Indonesia" },
// Map by City Names
"Jakarta": { lat: -6.2088, lng: 106.8456, label: "Jakarta, Indonesia" },
"Lampung": { lat: -5.3864, lng: 105.3821, label: "Lampung, Indonesia" },
"Cibubur": { lat: -6.3763, lng: 106.8983, label: "Cibubur, Indonesia" },
"Tebet": { lat: -6.2260, lng: 106.8580, label: "Tebet, Indonesia" },
"Lampung": { lat: -5.3863909, lng: 105.3820549, label: "Lampung, Indonesia" },
"Cibubur": { lat: -6.3763318, lng: 106.8983017, label: "Cibubur, Indonesia" },
"Tebet": { lat: -6.2260120, lng: 106.8580450, label: "Tebet, Indonesia" },
"Surabaya": { lat: -7.2504, lng: 112.7688, label: "Surabaya, Indonesia" },
"Bandung": { lat: -6.9147, lng: 107.6098, label: "Bandung, Indonesia" },
"Balaraja": { lat: -6.1915, lng: 106.4526, label: "Balaraja, Indonesia" },
"Balaraja": { lat: -6.2263304, lng: 106.4247322, label: "Balaraja, Indonesia" },
};
// Default fallback origin if nothing matches
@@ -57,6 +92,7 @@ export const COUNTRY_CAPITALS: Record<string, string> = {
"CA": "Ottawa",
"LU": "Luxembourg",
"NL": "Amsterdam",
"IE": "Dublin",
"TR": "Ankara",
"UA": "Kyiv",
"RU": "Moscow",
@@ -68,6 +104,7 @@ export const COUNTRY_CAPITALS: Record<string, string> = {
"FR": "Paris",
"ES": "Madrid",
"BR": "Brasilia",
"MX": "Mexico City",
"MY": "Kuala Lumpur",
"TH": "Bangkok",
"VN": "Hanoi",
@@ -96,16 +133,16 @@ export function getOriginLocation(identifier?: string, customLabel?: string): Ge
}
/**
* Gets the exact destination coordinates based on Country Code.
* Gets the destination city-center coordinates based on Country Code.
*/
export function getDestinationLocation(countryCode: string, countryName?: string): GeoLocation | null {
const coords = COUNTRY_COORDS[countryCode];
const coords = CAPITAL_CITY_COORDS[countryCode] || COUNTRY_COORDS[countryCode];
if (!coords) return null;
const cityName = COUNTRY_CAPITALS[countryCode];
const cName = countryName || countryCode;
// Note: COUNTRY_COORDS uses [lng, lat] format
// Note: coordinates use [lng, lat] format
return {
lat: coords[1],
lng: coords[0],