Adding gitea widget.
This commit is contained in:
parent
892fc0842d
commit
e48b7c48b0
@ -594,6 +594,13 @@
|
||||
"gross_percent_1y": "One year",
|
||||
"gross_percent_max": "All time"
|
||||
},
|
||||
"gitea": {
|
||||
"notifications": "Notifications",
|
||||
"Issue": "Issues",
|
||||
"Pull": "Pull Requests",
|
||||
"Commit": "Commits",
|
||||
"Repository": "Repositories"
|
||||
},
|
||||
"audiobookshelf": {
|
||||
"podcasts": "Podcasts",
|
||||
"books": "Books",
|
||||
|
||||
@ -19,6 +19,7 @@ const components = {
|
||||
fileflows: dynamic(() => import("./fileflows/component")),
|
||||
flood: dynamic(() => import("./flood/component")),
|
||||
freshrss: dynamic(() => import("./freshrss/component")),
|
||||
gitea: dynamic(() => import("./gitea/component")),
|
||||
ghostfolio: dynamic(() => import("./ghostfolio/component")),
|
||||
gluetun: dynamic(() => import("./gluetun/component")),
|
||||
gotify: dynamic(() => import("./gotify/component")),
|
||||
|
||||
46
src/widgets/gitea/component.jsx
Normal file
46
src/widgets/gitea/component.jsx
Normal file
@ -0,0 +1,46 @@
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Block from "components/services/widget/block";
|
||||
import Container from "components/services/widget/container";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
|
||||
|
||||
|
||||
export default function Component ({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
|
||||
const { data: notifications, error: giteaError } = useWidgetAPI(widget, "allNotifications");
|
||||
const notificationTypes = (notifications ?? []).reduce((acc, notification) => {
|
||||
acc[notification.subject.type].push(notification);
|
||||
return acc;
|
||||
}
|
||||
, {
|
||||
"Issue": [],
|
||||
"Pull": [],
|
||||
"Commit": [],
|
||||
"Repository": []
|
||||
}
|
||||
);
|
||||
|
||||
if (giteaError) {
|
||||
return <Container service={service} error={giteaError} />;
|
||||
}
|
||||
|
||||
if (!notifications) return (
|
||||
<Container service={service}>
|
||||
<Block label="gitea.notifications" />
|
||||
</Container>
|
||||
);
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
{Object.keys(notificationTypes).map((type) =>
|
||||
<Block key={type} label={`gitea.${type}`}
|
||||
value={t("common.number", { value: notificationTypes[type].length })} />
|
||||
)}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
17
src/widgets/gitea/widget.js
Normal file
17
src/widgets/gitea/widget.js
Normal file
@ -0,0 +1,17 @@
|
||||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/v1/{endpoint}?access_token={key}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
"allNotifications": {
|
||||
endpoint: "notifications",
|
||||
},
|
||||
"newNotifications": {
|
||||
endpoint: "notifications/new",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
||||
@ -15,6 +15,7 @@ import fileflows from "./fileflows/widget";
|
||||
import flood from "./flood/widget";
|
||||
import freshrss from "./freshrss/widget";
|
||||
import ghostfolio from "./ghostfolio/widget";
|
||||
import gitea from "./gitea/widget";
|
||||
import gluetun from "./gluetun/widget";
|
||||
import gotify from "./gotify/widget";
|
||||
import grafana from "./grafana/widget";
|
||||
@ -97,6 +98,7 @@ const widgets = {
|
||||
flood,
|
||||
freshrss,
|
||||
ghostfolio,
|
||||
gitea,
|
||||
gluetun,
|
||||
gotify,
|
||||
grafana,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user