mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-07 07:43:39 +01:00

* 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>
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
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>
|
|
);
|
|
}
|