mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Add Unmanic service widget
This commit is contained in:
33
src/widgets/unmanic/component.jsx
Normal file
33
src/widgets/unmanic/component.jsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { widget } = service;
|
||||
|
||||
const { data: workersData, error: workersError } = useWidgetAPI(widget, "workers");
|
||||
const { data: pendingData, error: pendingError } = useWidgetAPI(widget, "pending");
|
||||
|
||||
if (workersError || pendingError) {
|
||||
const finalError = workersError ?? pendingError;
|
||||
return <Container error={finalError} />;
|
||||
}
|
||||
|
||||
if (!workersData || !pendingData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="unmanic.active_workers" />
|
||||
<Block label="unmanic.total_workers" />
|
||||
<Block label="unmanic.records_total" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="unmanic.active_workers" value={workersData.active_workers} />
|
||||
<Block label="unmanic.total_workers" value={workersData.total_workers} />
|
||||
<Block label="unmanic.records_total" value={pendingData.recordsTotal} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user