Calibre web widget (#1855)
* Add widget for calibre-web with reverse-proxy auth * Add custom proxy * Get it working * Fix lint issues * Calibreweb widget: Handle empty series / authors / books * Switch to new opds stats endpoint * Remove calibre-web custom proxy handler --------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>pull/1868/head
parent
1faaa1466a
commit
4b4c63d562
@ -0,0 +1,36 @@
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
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 { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
const { data, error } = useWidgetAPI(widget, "stats");
|
||||
|
||||
if (error) {
|
||||
return <Container service={service} error={error} />;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="calibreweb.books" />
|
||||
<Block label="calibreweb.authors" />
|
||||
<Block label="calibreweb.categories" />
|
||||
<Block label="calibreweb.series" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="calibreweb.books" value={t("common.number", { value: data.books })} />
|
||||
<Block label="calibreweb.authors" value={t("common.number", { value: data.authors })} />
|
||||
<Block label="calibreweb.categories" value={t("common.number", { value: data.categories })} />
|
||||
<Block label="calibreweb.series" value={t("common.number", { value: data.series })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import genericProxyHandler from "../../utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/{endpoint}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
stats: {
|
||||
endpoint: "opds/stats",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
Loading…
Reference in new issue