mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Initial commit of Frigate widget.
This commit is contained in:
14
docs/widgets/services/frigate.md
Normal file
14
docs/widgets/services/frigate.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
title: Frigate
|
||||
description: Frigate Widget Configuration
|
||||
---
|
||||
|
||||
Learn more about [Frigate](https://frigate.video/).
|
||||
|
||||
Allowed fields: `["cameras", "uptime", "version"]`.
|
||||
|
||||
```yaml
|
||||
widget:
|
||||
type: frigate
|
||||
url: http://frigate.host.or.ip:port
|
||||
```
|
||||
@@ -55,6 +55,7 @@ nav:
|
||||
- widgets/services/fileflows.md
|
||||
- widgets/services/flood.md
|
||||
- widgets/services/freshrss.md
|
||||
- widgets/services/frigate.md
|
||||
- widgets/services/fritzbox.md
|
||||
- widgets/services/gamedig.md
|
||||
- widgets/services/gatus.md
|
||||
|
||||
@@ -900,5 +900,11 @@
|
||||
"open": "Open - US Market",
|
||||
"closed": "Closed - US Market",
|
||||
"invalidConfiguration": "Invalid Configuration"
|
||||
},
|
||||
"frigate": {
|
||||
"camera": "Camera",
|
||||
"cameras": "Cameras",
|
||||
"uptime": "Uptime",
|
||||
"version": "Version"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ const components = {
|
||||
fileflows: dynamic(() => import("./fileflows/component")),
|
||||
flood: dynamic(() => import("./flood/component")),
|
||||
freshrss: dynamic(() => import("./freshrss/component")),
|
||||
frigate: dynamic(() => import("./frigate/component")),
|
||||
fritzbox: dynamic(() => import("./fritzbox/component")),
|
||||
gamedig: dynamic(() => import("./gamedig/component")),
|
||||
gatus: dynamic(() => import("./gatus/component")),
|
||||
|
||||
47
src/widgets/frigate/component.jsx
Normal file
47
src/widgets/frigate/component.jsx
Normal file
@@ -0,0 +1,47 @@
|
||||
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, error } = useWidgetAPI(widget, "stats");
|
||||
|
||||
if (error) {
|
||||
return <Container service={service} error={error} />;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="frigate.cameras" />
|
||||
<Block label="frigate.uptime" />
|
||||
<Block label="frigate.version" />
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block
|
||||
label={data.num_cameras === 1 ? "frigate.camera" : "frigate.cameras"}
|
||||
value={t("common.number", {
|
||||
value: data.num_cameras,
|
||||
})}
|
||||
/>
|
||||
<Block
|
||||
label="frigate.uptime"
|
||||
value={t("common.uptime", {
|
||||
value: data.uptime,
|
||||
})}
|
||||
/>
|
||||
<Block
|
||||
label="frigate.version"
|
||||
value={data.version}
|
||||
/>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
24
src/widgets/frigate/widget.js
Normal file
24
src/widgets/frigate/widget.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { asJson } from "utils/proxy/api-helpers";
|
||||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
|
||||
// export default widget;
|
||||
const widget = {
|
||||
api: "{url}/api/{endpoint}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
"stats": {
|
||||
endpoint: "stats",
|
||||
map: (data) => {
|
||||
const jsonData = asJson(data);
|
||||
return {
|
||||
num_cameras: jsonData?.cameras !== undefined ? Object.keys(jsonData?.cameras).length : 0,
|
||||
uptime: jsonData?.service?.uptime,
|
||||
version: jsonData?.service.version,
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
||||
@@ -23,6 +23,7 @@ import evcc from "./evcc/widget";
|
||||
import fileflows from "./fileflows/widget";
|
||||
import flood from "./flood/widget";
|
||||
import freshrss from "./freshrss/widget";
|
||||
import frigate from "./frigate/widget";
|
||||
import fritzbox from "./fritzbox/widget";
|
||||
import gamedig from "./gamedig/widget";
|
||||
import gatus from "./gatus/widget";
|
||||
@@ -141,6 +142,7 @@ const widgets = {
|
||||
fileflows,
|
||||
flood,
|
||||
freshrss,
|
||||
frigate,
|
||||
fritzbox,
|
||||
gamedig,
|
||||
gatus,
|
||||
|
||||
Reference in New Issue
Block a user