From 886d92c3a05db119541db05f2ef3fcc5a20ad2e3 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 2 Jun 2024 16:38:35 +0000 Subject: [PATCH 1/2] add config Option to filterClients per Domain --- config.example.json | 2 +- config.json | 6 ++++-- lib/config_default.ts | 1 + lib/legend.ts | 33 ++++++++++++++++++++++++++++++++- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/config.example.json b/config.example.json index 277319dc..eb7291e0 100644 --- a/config.example.json +++ b/config.example.json @@ -19,7 +19,7 @@ [49.9282, 9.3164] ], "domainNames": [ - { "domain": "ffffm_60431", "name": "60431 Frankfurt am Main" }, + { "domain": "ffffm_60431", "name": "60431 Frankfurt am Main", "filterClients": "false" }, { "domain": "ffffm_default", "name": "Default" } ], "nodeInfos": [ diff --git a/config.json b/config.json index 479e8f19..b0c26c79 100644 --- a/config.json +++ b/config.json @@ -359,11 +359,13 @@ }, { "domain": "ffmuc_unifi_respondd_fallback", - "name": "UniFi" + "name": "UniFi", + "filterClients": true }, { "domain": "omada_respondd_fallback", - "name": "Omada" + "name": "Omada", + "filterClients": true } ], "linkList": [ diff --git a/lib/config_default.ts b/lib/config_default.ts index f954b59e..2b835d9a 100644 --- a/lib/config_default.ts +++ b/lib/config_default.ts @@ -40,6 +40,7 @@ interface Icon { export interface Domain { name: string; domain: string; + filterClients: boolean; } export interface LinkInfo { diff --git a/lib/legend.ts b/lib/legend.ts index cd3169ba..d695e43c 100644 --- a/lib/legend.ts +++ b/lib/legend.ts @@ -14,8 +14,39 @@ export const Legend = function (language: ReturnType) { self.setData = function setData(data: ObjectsLinksAndNodes) { let totalNodes = Object.keys(data.nodeDict).length; let totalOnlineNodes = data.nodes.online.length; + + let config = window.config; + var filterNodes = []; + if (config.domainNames) { + let domains = config.domainNames.filter(function (domain) { + if(typeof domain.filterClients !== 'undefined'){ + return domain.filterClients; + }else{ + return false + } + }); + domains.forEach((domain) => { + filterNodes.push(domain.name) + filterNodes.push(domain.domain) + }) + } + + let totalNodesFiltert = data.nodes.online.filter(function (node) { + var isFiltert = true + // filter nodes based on the domain + if(filterNodes.includes(node.domain)){ + isFiltert = false + } + // also filter nodes based on the firmware base (Domainname) for custom respondd + if(filterNodes.includes(node.firmware.base))[ + isFiltert = false + ] + return isFiltert + }) + + let totalClients = helper.sum( - data.nodes.online.map(function (node) { + totalNodesFiltert.map(function (node) { return node.clients; }), ); From 0bd7f617af081e48cb38d6a99e4f2c243282cc48 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 2 Jun 2024 17:02:38 +0000 Subject: [PATCH 2/2] fix naming --- lib/legend.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/legend.ts b/lib/legend.ts index d695e43c..71433c0e 100644 --- a/lib/legend.ts +++ b/lib/legend.ts @@ -16,29 +16,29 @@ export const Legend = function (language: ReturnType) { let totalOnlineNodes = data.nodes.online.length; let config = window.config; - var filterNodes = []; + var filtertNodes = []; if (config.domainNames) { - let domains = config.domainNames.filter(function (domain) { + let filtertdomains = config.domainNames.filter(function (domain) { if(typeof domain.filterClients !== 'undefined'){ return domain.filterClients; }else{ return false } }); - domains.forEach((domain) => { - filterNodes.push(domain.name) - filterNodes.push(domain.domain) + filtertdomains.forEach((domain) => { + filtertNodes.push(domain.name) + filtertNodes.push(domain.domain) }) } let totalNodesFiltert = data.nodes.online.filter(function (node) { var isFiltert = true // filter nodes based on the domain - if(filterNodes.includes(node.domain)){ + if(filtertNodes.includes(node.domain)){ isFiltert = false } // also filter nodes based on the firmware base (Domainname) for custom respondd - if(filterNodes.includes(node.firmware.base))[ + if(filtertNodes.includes(node.firmware.base))[ isFiltert = false ] return isFiltert