From a6dac34b2432ec433fe928c6d0329b48985d995f Mon Sep 17 00:00:00 2001
From: AtsumeruDev <119543708+AtsumeruDev@users.noreply.github.com>
Date: Mon, 21 Aug 2023 19:30:22 +0300
Subject: [PATCH] Add widget for Atsumeru self-hosted media server (#1839)
* Add widget for Atsumeru self-hosted media server
* Revert localization
* Update widget.js
---------
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
---
public/locales/en/common.json | 6 +++++
src/widgets/atsumeru/component.jsx | 36 ++++++++++++++++++++++++++++++
src/widgets/atsumeru/widget.js | 14 ++++++++++++
src/widgets/components.js | 1 +
src/widgets/widgets.js | 2 ++
5 files changed, 59 insertions(+)
create mode 100644 src/widgets/atsumeru/component.jsx
create mode 100644 src/widgets/atsumeru/widget.js
diff --git a/public/locales/en/common.json b/public/locales/en/common.json
index 2d86809f..373a9bea 100644
--- a/public/locales/en/common.json
+++ b/public/locales/en/common.json
@@ -579,6 +579,12 @@
"incident": "Incident",
"m": "m"
},
+ "atsumeru": {
+ "series": "Series",
+ "archives": "Archives",
+ "chapters": "Chapters",
+ "categories": "Categories"
+ },
"komga": {
"libraries": "Libraries",
"series": "Series",
diff --git a/src/widgets/atsumeru/component.jsx b/src/widgets/atsumeru/component.jsx
new file mode 100644
index 00000000..85e78182
--- /dev/null
+++ b/src/widgets/atsumeru/component.jsx
@@ -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: infoData, error: infoError } = useWidgetAPI(widget, "info");
+
+ if (infoError) {
+ return ;
+ }
+
+ if (!infoData) {
+ return (
+
+
+
+
+
+
+ );
+ }
+
+ return (
+
+
+
+
+
+
+ );
+}
diff --git a/src/widgets/atsumeru/widget.js b/src/widgets/atsumeru/widget.js
new file mode 100644
index 00000000..3934f6f4
--- /dev/null
+++ b/src/widgets/atsumeru/widget.js
@@ -0,0 +1,14 @@
+import genericProxyHandler from "utils/proxy/handlers/generic";
+
+const widget = {
+ api: "{url}/api/server/{endpoint}",
+ proxyHandler: genericProxyHandler,
+
+ mappings: {
+ info: {
+ endpoint: "info"
+ }
+ },
+};
+
+export default widget;
\ No newline at end of file
diff --git a/src/widgets/components.js b/src/widgets/components.js
index 5c9155c3..4662a8c3 100644
--- a/src/widgets/components.js
+++ b/src/widgets/components.js
@@ -2,6 +2,7 @@ import dynamic from "next/dynamic";
const components = {
adguard: dynamic(() => import("./adguard/component")),
+ atsumeru: dynamic(() => import("./atsumeru/component")),
audiobookshelf: dynamic(() => import("./audiobookshelf/component")),
authentik: dynamic(() => import("./authentik/component")),
autobrr: dynamic(() => import("./autobrr/component")),
diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js
index 3af06123..f17a4767 100644
--- a/src/widgets/widgets.js
+++ b/src/widgets/widgets.js
@@ -1,4 +1,5 @@
import adguard from "./adguard/widget";
+import atsumeru from "./atsumeru/widget";
import audiobookshelf from "./audiobookshelf/widget";
import authentik from "./authentik/widget";
import autobrr from "./autobrr/widget";
@@ -96,6 +97,7 @@ import urbackup from "./urbackup/widget";
const widgets = {
adguard,
+ atsumeru,
audiobookshelf,
authentik,
autobrr,