Add gitlab widget
This commit is contained in:
parent
e730a0ceb0
commit
26e2e15201
20
docs/widgets/services/gitlab.md
Normal file
20
docs/widgets/services/gitlab.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
title: Gitlab
|
||||||
|
description: Gitlab Widget Configuration
|
||||||
|
---
|
||||||
|
|
||||||
|
Learn more about [Gitlab](https://gitlab.com).
|
||||||
|
|
||||||
|
API requires a personal access token with either `read_api` or `api` permission. See the [gitlab documentation](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token) for details on generating one.
|
||||||
|
|
||||||
|
Allowed fields: `["events", "issues", "openIssues", "closedIssues", "mergeRequests", "openMergeRequests",
|
||||||
|
"closedMergeRequests"]`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
widget:
|
||||||
|
type: gitlab
|
||||||
|
url: http://gitlab.host.or.ip:port
|
||||||
|
key: personal-access-token
|
||||||
|
issueState: all # supports "opened", "closed" and defaults to "all"
|
||||||
|
mergeRequestState: all # supports "opened", "closed", "locked" and defaults to "all"
|
||||||
|
```
|
||||||
@ -40,6 +40,7 @@ You can also find a list of all available service widgets in the sidebar navigat
|
|||||||
- [Gatus](gatus.md)
|
- [Gatus](gatus.md)
|
||||||
- [Ghostfolio](ghostfolio.md)
|
- [Ghostfolio](ghostfolio.md)
|
||||||
- [Gitea](gitea.md)
|
- [Gitea](gitea.md)
|
||||||
|
- [Gitlab](gitlab.md)
|
||||||
- [Glances](glances.md)
|
- [Glances](glances.md)
|
||||||
- [Gluetun](gluetun.md)
|
- [Gluetun](gluetun.md)
|
||||||
- [Gotify](gotify.md)
|
- [Gotify](gotify.md)
|
||||||
|
|||||||
@ -63,6 +63,7 @@ nav:
|
|||||||
- widgets/services/gatus.md
|
- widgets/services/gatus.md
|
||||||
- widgets/services/ghostfolio.md
|
- widgets/services/ghostfolio.md
|
||||||
- widgets/services/gitea.md
|
- widgets/services/gitea.md
|
||||||
|
- widgets/services/gitlab.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
|
||||||
|
|||||||
@ -988,5 +988,14 @@
|
|||||||
"memory": "MEM",
|
"memory": "MEM",
|
||||||
"disk": "Disk",
|
"disk": "Disk",
|
||||||
"network": "NET"
|
"network": "NET"
|
||||||
|
},
|
||||||
|
"gitlab": {
|
||||||
|
"events": "Events",
|
||||||
|
"issues": "Issues",
|
||||||
|
"issuesOpen": "Open Issues",
|
||||||
|
"issuesClosed": "Closed Issues",
|
||||||
|
"merges": "Merge Requests",
|
||||||
|
"mergesOpen": "Open Merge Requests",
|
||||||
|
"mergesClosed": "Closed Merge Requests"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,6 +93,8 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
}
|
}
|
||||||
} else if (widget.type === "wgeasy") {
|
} else if (widget.type === "wgeasy") {
|
||||||
headers.Authorization = widget.password;
|
headers.Authorization = widget.password;
|
||||||
|
} else if (widget.type === "gitlab") {
|
||||||
|
headers["PRIVATE-TOKEN"] = widget.key
|
||||||
} else {
|
} else {
|
||||||
headers["X-API-Key"] = `${widget.key}`;
|
headers["X-API-Key"] = `${widget.key}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,7 @@ const components = {
|
|||||||
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")),
|
gitea: dynamic(() => import("./gitea/component")),
|
||||||
|
gitlab: dynamic(() => import("./gitlab/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")),
|
||||||
|
|||||||
51
src/widgets/gitlab/component.jsx
Normal file
51
src/widgets/gitlab/component.jsx
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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: gitlabEvents, error: gitlabEventsError } = useWidgetAPI(widget, "events");
|
||||||
|
|
||||||
|
if (gitlabEventsError) {
|
||||||
|
return <Container service={service} error={gitlabEvents} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gitlabEvents) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="gitlab.events" />
|
||||||
|
<Block label="gitlab.issues" />
|
||||||
|
<Block label="gitlab.issuesOpen" />
|
||||||
|
<Block label="gitlab.issuesClosed" />
|
||||||
|
<Block label="gitlab.merges" />
|
||||||
|
<Block label="gitlab.mergesOpen" />
|
||||||
|
<Block label="gitlab.mergesClosed" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const issues = {
|
||||||
|
open: gitlabEvents.issues.filter(event => event.action_name.toLowerCase() === "opened").length,
|
||||||
|
closed: gitlabEvents.issues.filter(event => event.action_name.toLowerCase() === "closed").length,
|
||||||
|
count: gitlabEvents.issues.length
|
||||||
|
};
|
||||||
|
|
||||||
|
const merges = {
|
||||||
|
open: gitlabEvents.merges.filter(event => event.action_name.toLowerCase() === "opened").length,
|
||||||
|
closed: gitlabEvents.merges.filter(event => event.action_name.toLowerCase() === "closed").length,
|
||||||
|
count: gitlabEvents.merges.length
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="gitlab.events" value={gitlabEvents.events} />
|
||||||
|
<Block label="gitlab.issues" value={issues.count} />
|
||||||
|
<Block label="gitlab.issuesOpen" value={issues.open} />
|
||||||
|
<Block label="gitlab.issuesClosed" value={issues.closed} />
|
||||||
|
<Block label="gitlab.merges" value={merges.count} />
|
||||||
|
<Block label="gitlab.mergesOpen" value={merges.open} />
|
||||||
|
<Block label="gitlab.mergesClosed" value={merges.closed} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
39
src/widgets/gitlab/widget.js
Normal file
39
src/widgets/gitlab/widget.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import { asJson } from "utils/proxy/api-helpers";
|
||||||
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/api/v1/{endpoint}",
|
||||||
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
mappings: {
|
||||||
|
events: {
|
||||||
|
endpoint: "events",
|
||||||
|
map: (data) => ({
|
||||||
|
merges: asJson(data).filter((event) => event.target_type?.toLowerCase() === "merge_request"),
|
||||||
|
issues: asJson(data).filter((event) => event.target_type?.toLowerCase() === "issue"),
|
||||||
|
events: asJson(data).length
|
||||||
|
})
|
||||||
|
},
|
||||||
|
issues: {
|
||||||
|
endpoint: "issues",
|
||||||
|
params: ["state"]
|
||||||
|
},
|
||||||
|
openIssues: {
|
||||||
|
endpoint: "issues?state=opened"
|
||||||
|
},
|
||||||
|
closedIssues: {
|
||||||
|
endpoint: "issues?state=closed"
|
||||||
|
},
|
||||||
|
mergeRequests: {
|
||||||
|
endpoint: "merge_requests",
|
||||||
|
params: ["state"]
|
||||||
|
},
|
||||||
|
openMergeRequests: {
|
||||||
|
endpoint: "merge_requests?state=opened"
|
||||||
|
},
|
||||||
|
closedMergeRequests: {
|
||||||
|
endpoint: "merge_requests?state=closed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
||||||
@ -31,6 +31,7 @@ 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 gitea from "./gitea/widget";
|
||||||
|
import gitlab from "./gitlab/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";
|
||||||
@ -161,6 +162,7 @@ const widgets = {
|
|||||||
gatus,
|
gatus,
|
||||||
ghostfolio,
|
ghostfolio,
|
||||||
gitea,
|
gitea,
|
||||||
|
gitlab,
|
||||||
glances,
|
glances,
|
||||||
gluetun,
|
gluetun,
|
||||||
gotify,
|
gotify,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user