commit
f3c1063013
@ -0,0 +1,29 @@
|
||||
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: statisticsData, error: statisticsError } = useWidgetAPI(widget, "statistics");
|
||||
|
||||
if (statisticsError) {
|
||||
return <Container error={statisticsError} />;
|
||||
}
|
||||
|
||||
if (!statisticsData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="paperlessngx.inbox" />
|
||||
<Block label="paperlessngx.total" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
{statisticsData.documents_inbox !== undefined && <Block label="paperlessngx.inbox" value={statisticsData.documents_inbox} />}
|
||||
<Block label="paperlessngx.total" value={statisticsData.documents_total} />
|
||||
</Container>
|
||||
);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/{endpoint}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
"statistics": {
|
||||
endpoint: "statistics/?format=json",
|
||||
validate: [
|
||||
"documents_total"
|
||||
]
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
Loading…
Reference in new issue