From 2283b4391c91510f91d605a72900528dba320877 Mon Sep 17 00:00:00 2001
From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Thu, 16 May 2024 22:22:45 -0700
Subject: [PATCH] Properly pass threshold
---
src/utils/config/service-helpers.js | 6 ++++++
src/widgets/wgeasy/component.jsx | 7 +++----
src/widgets/wgeasy/proxy.js | 6 +-----
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js
index aaee636c..8e2f12d5 100644
--- a/src/utils/config/service-helpers.js
+++ b/src/utils/config/service-helpers.js
@@ -462,6 +462,9 @@ export function cleanServiceGroups(groups) {
// unifi
site,
+
+ // wgeasy
+ threshold,
} = cleanedService.widget;
let fieldsList = fields;
@@ -596,6 +599,9 @@ export function cleanServiceGroups(groups) {
cleanedService.widget.bitratePrecision = parseInt(bitratePrecision, 10);
}
}
+ if (type === "wgeasy") {
+ if (threshold !== undefined) cleanedService.widget.threshold = parseInt(threshold, 10);
+ }
}
return cleanedService;
diff --git a/src/widgets/wgeasy/component.jsx b/src/widgets/wgeasy/component.jsx
index ecbee6d1..0289d48c 100644
--- a/src/widgets/wgeasy/component.jsx
+++ b/src/widgets/wgeasy/component.jsx
@@ -26,10 +26,9 @@ export default function Component({ service }) {
);
}
- const total = infoData.length - 1;
const enabled = infoData.filter((item) => item.enabled).length;
- const disabled = total - enabled;
- const connectionThreshold = infoData[infoData.length - 1].threshold * 60 * 1000;
+ const disabled = infoData.length - enabled;
+ const connectionThreshold = widget.threshold ?? 2 * 60 * 1000;
const currentTime = new Date();
const connected = infoData.filter(
(item) => currentTime - new Date(item.latestHandshakeAt) < connectionThreshold,
@@ -40,7 +39,7 @@ export default function Component({ service }) {
-
+
);
}
diff --git a/src/widgets/wgeasy/proxy.js b/src/widgets/wgeasy/proxy.js
index 9ebaff8b..ec733475 100644
--- a/src/widgets/wgeasy/proxy.js
+++ b/src/widgets/wgeasy/proxy.js
@@ -21,7 +21,6 @@ async function login(widget, service) {
});
try {
- console.log(responseHeaders);
const connectSidCookie = responseHeaders["set-cookie"]
.find((cookie) => cookie.startsWith("connect.sid="))
.split(";")[0]
@@ -63,10 +62,7 @@ export default async function wgeasyProxyHandler(req, res) {
},
);
- const dataParsed = JSON.parse(data);
- dataParsed.push({ threshold: widget.threshold ?? 2 });
-
- return res.send(dataParsed);
+ return res.json(JSON.parse(data));
}
}