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 {
|
} else {
|
||||||
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
headers.Authorization = `Basic ${Buffer.from(`${widget.username}:${widget.password}`).toString("base64")}`;
|
||||||
}
|
}
|
||||||
|
} else if (widget.type === "github") {
|
||||||
|
headers["User-Agent"] = `homepage`;
|
||||||
} else {
|
} else {
|
||||||
headers["X-API-Key"] = `${widget.key}`;
|
headers["X-API-Key"] = `${widget.key}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ const components = {
|
|||||||
flood: dynamic(() => import("./flood/component")),
|
flood: dynamic(() => import("./flood/component")),
|
||||||
freshrss: dynamic(() => import("./freshrss/component")),
|
freshrss: dynamic(() => import("./freshrss/component")),
|
||||||
ghostfolio: dynamic(() => import("./ghostfolio/component")),
|
ghostfolio: dynamic(() => import("./ghostfolio/component")),
|
||||||
|
github: dynamic(() => import("./github/component")),
|
||||||
gluetun: dynamic(() => import("./gluetun/component")),
|
gluetun: dynamic(() => import("./gluetun/component")),
|
||||||
gotify: dynamic(() => import("./gotify/component")),
|
gotify: dynamic(() => import("./gotify/component")),
|
||||||
grafana: dynamic(() => import("./grafana/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 flood from "./flood/widget";
|
||||||
import freshrss from "./freshrss/widget";
|
import freshrss from "./freshrss/widget";
|
||||||
import ghostfolio from "./ghostfolio/widget";
|
import ghostfolio from "./ghostfolio/widget";
|
||||||
|
import github from "./github/widget";
|
||||||
import gluetun from "./gluetun/widget";
|
import gluetun from "./gluetun/widget";
|
||||||
import gotify from "./gotify/widget";
|
import gotify from "./gotify/widget";
|
||||||
import grafana from "./grafana/widget";
|
import grafana from "./grafana/widget";
|
||||||
@ -99,6 +100,7 @@ const widgets = {
|
|||||||
flood,
|
flood,
|
||||||
freshrss,
|
freshrss,
|
||||||
ghostfolio,
|
ghostfolio,
|
||||||
|
github,
|
||||||
gluetun,
|
gluetun,
|
||||||
gotify,
|
gotify,
|
||||||
grafana,
|
grafana,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user