mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
improvements
This commit is contained in:
parent
c9512a6d26
commit
5c5b677075
@ -287,10 +287,10 @@
|
|||||||
},
|
},
|
||||||
"homebridge": {
|
"homebridge": {
|
||||||
"available_update": "System",
|
"available_update": "System",
|
||||||
|
"updates": "Updates",
|
||||||
"update_available": "Update Available",
|
"update_available": "Update Available",
|
||||||
"up_to_date": "Up to Date",
|
"up_to_date": "Up to Date",
|
||||||
"available_homebridge_update": "Plugins",
|
"child_bridges": "Child Bridges",
|
||||||
"plugins_updates_available": "{{quantity}} Available",
|
"child_bridges_status": "{{ok}}/{{total}}"
|
||||||
"plugins_up_to_date": "Up to Date"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ export default function Component({ service }) {
|
|||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="widget.status" />
|
<Block label="widget.status" />
|
||||||
<Block label="homebridge.available_plugin_updates" />
|
<Block label="homebridge.updates" />
|
||||||
<Block label="homebridge.available_homebridge_update" />
|
<Block label="homebridge.child_bridges" />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -32,13 +32,20 @@ export default function Component({ service }) {
|
|||||||
value={homebridge.data.status}
|
value={homebridge.data.status}
|
||||||
/>
|
/>
|
||||||
<Block
|
<Block
|
||||||
label="homebridge.available_update"
|
label="homebridge.updates"
|
||||||
value={homebridge.data.updateAvailable ? t("homebridge.update_available") : t("homebridge.up_to_date")}
|
value={
|
||||||
|
(homebridge.data.updateAvailable || homebridge.data.plugins.updatesAvailable)
|
||||||
|
? t("homebridge.update_available")
|
||||||
|
: t("homebridge.up_to_date")}
|
||||||
/>
|
/>
|
||||||
|
{homebridge?.data?.childBridges.quantity > 0 &&
|
||||||
<Block
|
<Block
|
||||||
label="homebridge.available_homebridge_update"
|
label="homebridge.child_bridges"
|
||||||
value={homebridge.data.plugins.updatesAvailable ? t("homebridge.plugins_updates_available", { quantity: homebridge.data.plugins.quantity }) : t("homebridge.plugins_up_to_date")}
|
value={t("homebridge.child_bridges_status", {
|
||||||
/>
|
total: homebridge.data.childBridges.quantity,
|
||||||
|
ok: homebridge.data.childBridges.quantityWithOkStatus
|
||||||
|
})}
|
||||||
|
/>}
|
||||||
</Container>
|
</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) {
|
export default async function homebridgeProxyHandler(req, res) {
|
||||||
const { group, service } = req.query;
|
const { group, service } = req.query;
|
||||||
|
|
||||||
@ -87,15 +95,17 @@ export default async function homebridgeProxyHandler(req, res) {
|
|||||||
|
|
||||||
await login(widget);
|
await login(widget);
|
||||||
|
|
||||||
const statusRS = await apiCall(widget, "status/homebridge");
|
const statusRs = await apiCall(widget, "status/homebridge");
|
||||||
const versionRS = await apiCall(widget, "status/homebridge-version");
|
const versionRs = await apiCall(widget, "status/homebridge-version");
|
||||||
const pluginsRS = await apiCall(widget, "plugins");
|
const childBrigdeRs = await apiCall(widget, "status/homebridge/child-bridges");
|
||||||
|
const pluginsRs = await apiCall(widget, "plugins");
|
||||||
|
|
||||||
return res.status(200).send({
|
return res.status(200).send({
|
||||||
data: {
|
data: {
|
||||||
status: statusRS?.data?.status,
|
status: statusRs?.data?.status,
|
||||||
updateAvailable: versionRS?.data?.updateAvailable,
|
updateAvailable: versionRs?.data?.updateAvailable,
|
||||||
plugins: formatPluginsResponse(pluginsRS)
|
plugins: formatPluginsResponse(pluginsRs),
|
||||||
|
childBridges: formatChildBridgesResponse(childBrigdeRs),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user