improvements

pull/442/head
Fernando Neira 2 years ago
parent c9512a6d26
commit 5c5b677075

@ -287,10 +287,10 @@
},
"homebridge": {
"available_update": "System",
"updates": "Updates",
"update_available": "Update Available",
"up_to_date": "Up to Date",
"available_homebridge_update": "Plugins",
"plugins_updates_available": "{{quantity}} Available",
"plugins_up_to_date": "Up to Date"
"child_bridges": "Child Bridges",
"child_bridges_status": "{{ok}}/{{total}}"
}
}

@ -19,8 +19,8 @@ export default function Component({ service }) {
return (
<Container service={service}>
<Block label="widget.status" />
<Block label="homebridge.available_plugin_updates" />
<Block label="homebridge.available_homebridge_update" />
<Block label="homebridge.updates" />
<Block label="homebridge.child_bridges" />
</Container>
);
}
@ -32,13 +32,20 @@ export default function Component({ service }) {
value={homebridge.data.status}
/>
<Block
label="homebridge.available_update"
value={homebridge.data.updateAvailable ? t("homebridge.update_available") : t("homebridge.up_to_date")}
/>
<Block
label="homebridge.available_homebridge_update"
value={homebridge.data.plugins.updatesAvailable ? t("homebridge.plugins_updates_available", { quantity: homebridge.data.plugins.quantity }) : t("homebridge.plugins_up_to_date")}
label="homebridge.updates"
value={
(homebridge.data.updateAvailable || homebridge.data.plugins.updatesAvailable)
? t("homebridge.update_available")
: t("homebridge.up_to_date")}
/>
{homebridge?.data?.childBridges.quantity > 0 &&
<Block
label="homebridge.child_bridges"
value={t("homebridge.child_bridges_status", {
total: homebridge.data.childBridges.quantity,
ok: homebridge.data.childBridges.quantityWithOkStatus
})}
/>}
</Container>
);
}

@ -70,6 +70,14 @@ function formatPluginsResponse(plugins) {
}
}
function formatChildBridgesResponse(childBridges) {
const quantity = childBridges?.data?.length
return {
quantity,
quantityWithOkStatus: childBridges?.data?.filter(cb => cb.status === "ok").length,
}
}
export default async function homebridgeProxyHandler(req, res) {
const { group, service } = req.query;
@ -87,15 +95,17 @@ export default async function homebridgeProxyHandler(req, res) {
await login(widget);
const statusRS = await apiCall(widget, "status/homebridge");
const versionRS = await apiCall(widget, "status/homebridge-version");
const pluginsRS = await apiCall(widget, "plugins");
const statusRs = await apiCall(widget, "status/homebridge");
const versionRs = await apiCall(widget, "status/homebridge-version");
const childBrigdeRs = await apiCall(widget, "status/homebridge/child-bridges");
const pluginsRs = await apiCall(widget, "plugins");
return res.status(200).send({
data: {
status: statusRS?.data?.status,
updateAvailable: versionRS?.data?.updateAvailable,
plugins: formatPluginsResponse(pluginsRS)
status: statusRs?.data?.status,
updateAvailable: versionRs?.data?.updateAvailable,
plugins: formatPluginsResponse(pluginsRs),
childBridges: formatChildBridgesResponse(childBrigdeRs),
}
});
}

Loading…
Cancel
Save