Properly pass threshold
This commit is contained in:
parent
30d0492c55
commit
2283b4391c
@ -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;
|
||||
|
||||
@ -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 }) {
|
||||
<Block label="wgeasy.connected" value={connected} />
|
||||
<Block label="wgeasy.enabled" value={enabled} />
|
||||
<Block label="wgeasy.diabled" value={disabled} />
|
||||
<Block label="wgeasy.total" value={total} />
|
||||
<Block label="wgeasy.total" value={infoData.length} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user