If no fields are configured, set the calcaulated defaults. Limit the field count to 4. Always provide the data as common in widgets.
This commit is contained in:
parent
05a7c0ff56
commit
7575723c99
@ -11,7 +11,9 @@ You can display general connectivity status from your Unifi (Network) Controller
|
|||||||
|
|
||||||
An optional 'site' parameter can be supplied, if it is not the widget will use the default site for the controller.
|
An optional 'site' parameter can be supplied, if it is not the widget will use the default site for the controller.
|
||||||
|
|
||||||
Allowed fields: `["uptime", "wan", "lan_users", "wlan_users"]`.
|
Allowed fields: `["uptime", "wan", "lan", "lan_users", "lan_devices", "wlan" "wlan_users", "wlan_devices" ]`.
|
||||||
|
|
||||||
|
If more than 4 fields are provided, only the first 4 are displayed.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
widget:
|
widget:
|
||||||
@ -22,4 +24,4 @@ widget:
|
|||||||
site: Site Name # optional
|
site: Site Name # optional
|
||||||
```
|
```
|
||||||
|
|
||||||
_Added in v0.4.18, updated in 0.6.7_
|
_Added in v0.4.18, updated in 0.8.7_
|
||||||
|
|||||||
@ -52,22 +52,40 @@ export default function Component({ service }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If fields are not configured, set the dynamically determined fields.
|
||||||
|
if (!widget.fields) {
|
||||||
|
widget.fields = [];
|
||||||
|
if (uptime) {
|
||||||
|
widget.fields.push("unifi.uptime");
|
||||||
|
}
|
||||||
|
if (wan.show) {
|
||||||
|
widget.fields.push("unifi.wan");
|
||||||
|
}
|
||||||
|
if (lan.show && !wlan.show) {
|
||||||
|
widget.fields.push("unifi.lan_users");
|
||||||
|
widget.fields.push("unifi.lan");
|
||||||
|
}
|
||||||
|
if (wlan.show) {
|
||||||
|
widget.fields.push("unifi.wlan_users");
|
||||||
|
}
|
||||||
|
if (wlan.show && !lan.show) {
|
||||||
|
widget.fields.push("unifi.wlan_devices");
|
||||||
|
widget.fields.push("unifi.wlan");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Limit to the first 4 available
|
||||||
|
widget.fields = widget.fields.slice(0, 4);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
{uptime && <Block label="unifi.uptime" value={uptime} />}
|
<Block label="unifi.uptime" value={uptime} />
|
||||||
{wan.show && <Block label="unifi.wan" value={wan.status === "ok" ? t("unifi.up") : t("unifi.down")} />}
|
<Block label="unifi.wan" value={wan.status === "ok" ? t("unifi.up") : t("unifi.down")} />
|
||||||
|
<Block label="unifi.lan_users" value={t("common.number", { value: lan.num_user })} />
|
||||||
{lan.show && <Block label="unifi.lan_users" value={t("common.number", { value: lan.num_user })} />}
|
<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")} />
|
||||||
<Block label="unifi.lan_devices" value={t("common.number", { value: lan.num_adopted })} />
|
<Block label="unifi.wlan_users" value={t("common.number", { value: wlan.num_user })} />
|
||||||
)}
|
<Block label="unifi.wlan_devices" value={t("common.number", { value: wlan.num_adopted })} />
|
||||||
{lan.show && !wlan.show && <Block label="unifi.lan" value={lan.up ? t("unifi.up") : t("unifi.down")} />}
|
<Block label="unifi.wlan" value={wlan.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>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user