mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-29 15:31:16 -07:00
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com> Signed-off-by: dependabot[bot] <support@github.com>
36 lines
1010 B
React
36 lines
1010 B
React
import Block from "components/services/widget/block";
|
|
import Container from "components/services/widget/container";
|
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
|
|
|
export default function Component({ service }) {
|
|
const { widget } = service;
|
|
|
|
const { data: infoData, error: infoError } = useWidgetAPI(widget, "hosts");
|
|
|
|
if (infoError) {
|
|
return <Container service={service} error={infoError} />;
|
|
}
|
|
|
|
if (!infoData) {
|
|
return (
|
|
<Container service={service}>
|
|
<Block label="npm.enabled" />
|
|
<Block label="npm.disabled" />
|
|
<Block label="npm.total" />
|
|
</Container>
|
|
);
|
|
}
|
|
|
|
const enabled = infoData.filter((c) => !!c.enabled).length;
|
|
const disabled = infoData.filter((c) => !c.enabled).length;
|
|
const total = infoData.length;
|
|
|
|
return (
|
|
<Container service={service}>
|
|
<Block label="npm.enabled" value={enabled} />
|
|
<Block label="npm.disabled" value={disabled} />
|
|
<Block label="npm.total" value={total} />
|
|
</Container>
|
|
);
|
|
}
|