mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 07:18:47 +00:00
Better support non-OS Unifi Controllers
This commit is contained in:
parent
4ea279856f
commit
3d89d7ad1b
4 changed files with 66 additions and 46 deletions
|
@ -31,28 +31,25 @@ export default function Component({ service }) {
|
|||
const wan = defaultSite.health.find(h => h.subsystem === "wan");
|
||||
const lan = defaultSite.health.find(h => h.subsystem === "lan");
|
||||
const wlan = defaultSite.health.find(h => h.subsystem === "wlan");
|
||||
const data = {
|
||||
name: wan.gw_name,
|
||||
uptime: wan["gw_system-stats"].uptime,
|
||||
up: wan.status === 'ok',
|
||||
wlan: {
|
||||
users: wlan.num_user,
|
||||
status: wlan.status
|
||||
},
|
||||
lan: {
|
||||
users: lan.num_user,
|
||||
status: lan.status
|
||||
},
|
||||
};
|
||||
[wan, lan, wlan].forEach(s => {
|
||||
s.up = s.status === "ok" // eslint-disable-line no-param-reassign
|
||||
s.show = s.status !== "unknown" // eslint-disable-line no-param-reassign
|
||||
});
|
||||
|
||||
const uptime = `${t("common.number", { value: data.uptime / 86400, maximumFractionDigits: 1 })} ${t("unifi.days")}`;
|
||||
const uptime = wan["gw_system-stats"] ? `${t("common.number", { value: wan["gw_system-stats"].uptime / 86400, maximumFractionDigits: 1 })} ${t("unifi.days")}` : null;
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="unifi.uptime" value={ uptime } />
|
||||
<Block label="unifi.wan" value={ data.up ? t("unifi.up") : t("unifi.down") } />
|
||||
<Block label="unifi.lan_users" value={ t("common.number", { value: data.lan.users }) } />
|
||||
<Block label="unifi.wlan_users" value={ t("common.number", { value: data.wlan.users }) } />
|
||||
{uptime && <Block label="unifi.uptime" value={ uptime } />}
|
||||
{wan.show && <Block label="unifi.wan" value={ wan.up ? t("unifi.up") : t("unifi.down") } />}
|
||||
|
||||
{lan.show && <Block label="unifi.lan_users" value={ t("common.number", { value: lan.num_user }) } />}
|
||||
{lan.show && !wlan.show && <Block label="unifi.lan_devices" value={ t("common.number", { value: lan.num_adopted }) } />}
|
||||
{lan.show && !wlan.show && <Block label="unifi.lan" value={ lan.up ? t("unifi.up") : t("unifi.down") } />}
|
||||
|
||||
{wlan.show && <Block label="unifi.wlan_users" value={ t("common.number", { value: wlan.num_user }) } />}
|
||||
{wlan.show && !lan.show && <Block label="unifi.wlan_devices" value={ t("common.number", { value: wlan.num_adopted }) } />}
|
||||
{wlan.show && !lan.show && <Block label="unifi.wlan" value={ wlan.up ? t("unifi.up") : t("unifi.down") } />}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue