add github widget
This commit is contained in:
parent
ef1dfc7323
commit
33073b08a6
@ -55,6 +55,8 @@ export default async function credentialedProxyHandler(req, res, map) {
|
||||
} else {
|
||||
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
||||
}
|
||||
} else if (widget.type === "github") {
|
||||
headers["User-Agent"] = `homepage`;
|
||||
} else {
|
||||
headers["X-API-Key"] = `${widget.key}`;
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ const components = {
|
||||
flood: dynamic(() => import("./flood/component")),
|
||||
freshrss: dynamic(() => import("./freshrss/component")),
|
||||
ghostfolio: dynamic(() => import("./ghostfolio/component")),
|
||||
github: dynamic(() => import("./github/component")),
|
||||
gluetun: dynamic(() => import("./gluetun/component")),
|
||||
gotify: dynamic(() => import("./gotify/component")),
|
||||
grafana: dynamic(() => import("./grafana/component")),
|
||||
|
||||
30
src/widgets/github/component.jsx
Normal file
30
src/widgets/github/component.jsx
Normal file
@ -0,0 +1,30 @@
|
||||
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: githubData, error: githubError } = useWidgetAPI(widget);
|
||||
|
||||
if (githubError) {
|
||||
return <Container service={service} error={githubError} />;
|
||||
}
|
||||
|
||||
if (!githubData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="open issues" />
|
||||
<Block label="stars" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="open issues" value={githubData.open_issues_count} />
|
||||
<Block label="stars" value={githubData.stargazers_count} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
8
src/widgets/github/widget.js
Normal file
8
src/widgets/github/widget.js
Normal file
@ -0,0 +1,8 @@
|
||||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||
|
||||
const widget = {
|
||||
api: "https://api.github.com/repos/{owner}/{repo}",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
};
|
||||
|
||||
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 github from "./github/widget";
|
||||
import gluetun from "./gluetun/widget";
|
||||
import gotify from "./gotify/widget";
|
||||
import grafana from "./grafana/widget";
|
||||
@ -99,6 +100,7 @@ const widgets = {
|
||||
flood,
|
||||
freshrss,
|
||||
ghostfolio,
|
||||
github,
|
||||
gluetun,
|
||||
gotify,
|
||||
grafana,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user