mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-18 18:49:50 +00:00
Feature: gitlab service widget (#4317)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
94bbcbe1fb
commit
2b8647b2ef
9 changed files with 82 additions and 0 deletions
|
@ -38,6 +38,7 @@ const components = {
|
|||
gatus: dynamic(() => import("./gatus/component")),
|
||||
ghostfolio: dynamic(() => import("./ghostfolio/component")),
|
||||
gitea: dynamic(() => import("./gitea/component")),
|
||||
gitlab: dynamic(() => import("./gitlab/component")),
|
||||
glances: dynamic(() => import("./glances/component")),
|
||||
gluetun: dynamic(() => import("./gluetun/component")),
|
||||
gotify: dynamic(() => import("./gotify/component")),
|
||||
|
|
36
src/widgets/gitlab/component.jsx
Normal file
36
src/widgets/gitlab/component.jsx
Normal file
|
@ -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: gitlabCounts, error: gitlabCountsError } = useWidgetAPI(widget, "counts");
|
||||
|
||||
if (gitlabCountsError) {
|
||||
return <Container service={service} error={gitlabCountsError} />;
|
||||
}
|
||||
|
||||
if (!gitlabCounts) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="gitlab.groups" />
|
||||
<Block label="gitlab.issues" />
|
||||
<Block label="gitlab.merges" />
|
||||
<Block label="gitlab.projects" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="gitlab.groups" value={t("common.number", { value: gitlabCounts.groups_count })} />
|
||||
<Block label="gitlab.issues" value={t("common.number", { value: gitlabCounts.issues_count })} />
|
||||
<Block label="gitlab.merges" value={t("common.number", { value: gitlabCounts.merge_requests_count })} />
|
||||
<Block label="gitlab.projects" value={t("common.number", { value: gitlabCounts.projects_count })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
13
src/widgets/gitlab/widget.js
Normal file
13
src/widgets/gitlab/widget.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/v4/{endpoint}",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
mappings: {
|
||||
counts: {
|
||||
endpoint: "users/{user_id}/associations_count",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
|
@ -32,6 +32,7 @@ import gamedig from "./gamedig/widget";
|
|||
import gatus from "./gatus/widget";
|
||||
import ghostfolio from "./ghostfolio/widget";
|
||||
import gitea from "./gitea/widget";
|
||||
import gitlab from "./gitlab/widget";
|
||||
import glances from "./glances/widget";
|
||||
import gluetun from "./gluetun/widget";
|
||||
import gotify from "./gotify/widget";
|
||||
|
@ -164,6 +165,7 @@ const widgets = {
|
|||
gatus,
|
||||
ghostfolio,
|
||||
gitea,
|
||||
gitlab,
|
||||
glances,
|
||||
gluetun,
|
||||
gotify,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue