mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-01 13:09:31 +01:00
Feature: add gitea widget (#2968)
This commit is contained in:
parent
291bf422f9
commit
fce694e2b9
17
docs/widgets/services/gitea.md
Normal file
17
docs/widgets/services/gitea.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: Gitea
|
||||||
|
description: Gitea Widget Configuration
|
||||||
|
---
|
||||||
|
|
||||||
|
Learn more about [Gitea](https://gitea.com).
|
||||||
|
|
||||||
|
API token requires `notifications` and `repository` permissions. See the [gitea documentation](https://docs.gitea.com/development/api-usage#generating-and-listing-api-tokens) for details on generating tokens.
|
||||||
|
|
||||||
|
Allowed fields: ["notifications", "issues", "pulls"]
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
widget:
|
||||||
|
type: gitea
|
||||||
|
url: http://gitea.host.or.ip:port
|
||||||
|
key: giteaapitoken
|
||||||
|
```
|
@ -57,6 +57,7 @@ nav:
|
|||||||
- widgets/services/gamedig.md
|
- widgets/services/gamedig.md
|
||||||
- widgets/services/gatus.md
|
- widgets/services/gatus.md
|
||||||
- widgets/services/ghostfolio.md
|
- widgets/services/ghostfolio.md
|
||||||
|
- widgets/services/gitea.md
|
||||||
- widgets/services/glances.md
|
- widgets/services/glances.md
|
||||||
- widgets/services/gluetun.md
|
- widgets/services/gluetun.md
|
||||||
- widgets/services/gotify.md
|
- widgets/services/gotify.md
|
||||||
|
@ -831,5 +831,10 @@
|
|||||||
"plants": "Plants",
|
"plants": "Plants",
|
||||||
"photos": "Photos",
|
"photos": "Photos",
|
||||||
"species": "Species"
|
"species": "Species"
|
||||||
|
},
|
||||||
|
"gitea": {
|
||||||
|
"notifications": "Notifications",
|
||||||
|
"issues": "Issues",
|
||||||
|
"pulls": "Pull Requests"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ export function jsonArrayFilter(data, filter) {
|
|||||||
export function sanitizeErrorURL(errorURL) {
|
export function sanitizeErrorURL(errorURL) {
|
||||||
// Dont display sensitive params on frontend
|
// Dont display sensitive params on frontend
|
||||||
const url = new URL(errorURL);
|
const url = new URL(errorURL);
|
||||||
["apikey", "api_key", "token", "t"].forEach((key) => {
|
["apikey", "api_key", "token", "t", "access_token"].forEach((key) => {
|
||||||
if (url.searchParams.has(key)) url.searchParams.set(key, "***");
|
if (url.searchParams.has(key)) url.searchParams.set(key, "***");
|
||||||
});
|
});
|
||||||
return url.toString();
|
return url.toString();
|
||||||
|
@ -31,6 +31,7 @@ const components = {
|
|||||||
gamedig: dynamic(() => import("./gamedig/component")),
|
gamedig: dynamic(() => import("./gamedig/component")),
|
||||||
gatus: dynamic(() => import("./gatus/component")),
|
gatus: dynamic(() => import("./gatus/component")),
|
||||||
ghostfolio: dynamic(() => import("./ghostfolio/component")),
|
ghostfolio: dynamic(() => import("./ghostfolio/component")),
|
||||||
|
gitea: dynamic(() => import("./gitea/component")),
|
||||||
glances: dynamic(() => import("./glances/component")),
|
glances: dynamic(() => import("./glances/component")),
|
||||||
gluetun: dynamic(() => import("./gluetun/component")),
|
gluetun: dynamic(() => import("./gluetun/component")),
|
||||||
gotify: dynamic(() => import("./gotify/component")),
|
gotify: dynamic(() => import("./gotify/component")),
|
||||||
|
32
src/widgets/gitea/component.jsx
Normal file
32
src/widgets/gitea/component.jsx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
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 { widget } = service;
|
||||||
|
|
||||||
|
const { data: giteaNotifications, error: giteaNotificationsError } = useWidgetAPI(widget, "notifications");
|
||||||
|
const { data: giteaIssues, error: giteaIssuesError } = useWidgetAPI(widget, "issues");
|
||||||
|
|
||||||
|
if (giteaNotificationsError || giteaIssuesError) {
|
||||||
|
return <Container service={service} error={giteaNotificationsError ?? giteaIssuesError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!giteaNotifications || !giteaIssues) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="gitea.notifications" />
|
||||||
|
<Block label="gitea.issues" />
|
||||||
|
<Block label="gitea.pulls" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="gitea.notifications" value={giteaNotifications.length} />
|
||||||
|
<Block label="gitea.issues" value={giteaIssues.issues.length} />
|
||||||
|
<Block label="gitea.pulls" value={giteaIssues.pulls.length} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
22
src/widgets/gitea/widget.js
Normal file
22
src/widgets/gitea/widget.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { asJson } from "utils/proxy/api-helpers";
|
||||||
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/api/v1/{endpoint}?access_token={key}",
|
||||||
|
proxyHandler: genericProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
notifications: {
|
||||||
|
endpoint: "notifications",
|
||||||
|
},
|
||||||
|
issues: {
|
||||||
|
endpoint: "repos/issues/search",
|
||||||
|
map: (data) => ({
|
||||||
|
pulls: asJson(data).filter((issue) => issue.pull_request),
|
||||||
|
issues: asJson(data).filter((issue) => !issue.pull_request),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
@ -25,6 +25,7 @@ import fritzbox from "./fritzbox/widget";
|
|||||||
import gamedig from "./gamedig/widget";
|
import gamedig from "./gamedig/widget";
|
||||||
import gatus from "./gatus/widget";
|
import gatus from "./gatus/widget";
|
||||||
import ghostfolio from "./ghostfolio/widget";
|
import ghostfolio from "./ghostfolio/widget";
|
||||||
|
import gitea from "./gitea/widget";
|
||||||
import glances from "./glances/widget";
|
import glances from "./glances/widget";
|
||||||
import gluetun from "./gluetun/widget";
|
import gluetun from "./gluetun/widget";
|
||||||
import gotify from "./gotify/widget";
|
import gotify from "./gotify/widget";
|
||||||
@ -133,6 +134,7 @@ const widgets = {
|
|||||||
gamedig,
|
gamedig,
|
||||||
gatus,
|
gatus,
|
||||||
ghostfolio,
|
ghostfolio,
|
||||||
|
gitea,
|
||||||
glances,
|
glances,
|
||||||
gluetun,
|
gluetun,
|
||||||
gotify,
|
gotify,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user