mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-01 13:09:31 +01:00
Use statistics endpoint for paperless-ngx
This commit is contained in:
parent
a677a507b8
commit
a488cc0115
@ -118,7 +118,6 @@ export function cleanServiceGroups(groups) {
|
|||||||
container,
|
container,
|
||||||
currency, // coinmarketcap widget
|
currency, // coinmarketcap widget
|
||||||
symbols,
|
symbols,
|
||||||
inboxTag, // paperlessngx widget
|
|
||||||
} = cleanedService.widget;
|
} = cleanedService.widget;
|
||||||
|
|
||||||
cleanedService.widget = {
|
cleanedService.widget = {
|
||||||
@ -131,8 +130,6 @@ export function cleanServiceGroups(groups) {
|
|||||||
if (currency) cleanedService.widget.currency = currency;
|
if (currency) cleanedService.widget.currency = currency;
|
||||||
if (symbols) cleanedService.widget.symbols = symbols;
|
if (symbols) cleanedService.widget.symbols = symbols;
|
||||||
|
|
||||||
if (inboxTag) cleanedService.widget.inboxTag = inboxTag;
|
|
||||||
|
|
||||||
if (type === "docker") {
|
if (type === "docker") {
|
||||||
if (server) cleanedService.widget.server = server;
|
if (server) cleanedService.widget.server = server;
|
||||||
if (container) cleanedService.widget.container = container;
|
if (container) cleanedService.widget.container = container;
|
||||||
|
@ -5,26 +5,13 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
|
|||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
|
||||||
const { data: inboxData, error: inboxError } = useWidgetAPI(widget, "inbox",
|
const { data: statisticsData, error: statisticsError } = useWidgetAPI(widget, "statistics");
|
||||||
{
|
|
||||||
query: `tag:${widget.inboxTag}`,
|
|
||||||
format: "json",
|
|
||||||
fields: "count"
|
|
||||||
});
|
|
||||||
|
|
||||||
|
if (statisticsError) {
|
||||||
const { data: documentData, error: documentError } = useWidgetAPI(widget, "documents",
|
return <Container error={statisticsError} />;
|
||||||
{
|
|
||||||
fields: "count",
|
|
||||||
format: "json",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (inboxError || documentError) {
|
|
||||||
const finalError = inboxError ?? documentError;
|
|
||||||
return <Container error={finalError} />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inboxData || !documentData) {
|
if (!statisticsData) {
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="paperlessngx.inbox" />
|
<Block label="paperlessngx.inbox" />
|
||||||
@ -35,8 +22,8 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="paperlessngx.inbox" value={inboxData.count} />
|
{statisticsData.documents_inbox !== undefined && <Block label="paperlessngx.inbox" value={statisticsData.documents_inbox} />}
|
||||||
<Block label="paperlessngx.total" value={documentData.count} />
|
<Block label="paperlessngx.total" value={statisticsData.documents_total} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,10 @@ const widget = {
|
|||||||
proxyHandler: genericProxyHandler,
|
proxyHandler: genericProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
"inbox": {
|
"statistics": {
|
||||||
endpoint: "documents/",
|
endpoint: "statistics/?format=json",
|
||||||
params: ["format", "query", "fields"],
|
|
||||||
validate: [
|
validate: [
|
||||||
"count"
|
"documents_total"
|
||||||
]
|
|
||||||
},
|
|
||||||
"documents": {
|
|
||||||
endpoint: "documents/",
|
|
||||||
params: ["format", "fields"],
|
|
||||||
validate: [
|
|
||||||
"count"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user