mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-05 21:47:48 +01:00
Compare commits
21 Commits
817a9bbce5
...
feature/60
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3c7823f28 | ||
|
|
5b50e8ff81 | ||
|
|
c36c6a9012 | ||
|
|
cf990063b9 | ||
|
|
610f1bd974 | ||
|
|
4031178831 | ||
|
|
b65c8399d8 | ||
|
|
6b63cfd491 | ||
|
|
196c51bf73 | ||
|
|
17c9b2631e | ||
|
|
1a21189643 | ||
|
|
b6b428363c | ||
|
|
e707fa46cf | ||
|
|
3d040362cb | ||
|
|
57b193b037 | ||
|
|
8a75c9b6e3 | ||
|
|
0dafc792f7 | ||
|
|
afc0fe29ee | ||
|
|
3ef7031eb0 | ||
|
|
6faf32eae9 | ||
|
|
455e86571a |
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -38,3 +38,4 @@ What type of change does your PR introduce to Homepage?
|
|||||||
- [ ] If applicable, I have reviewed the [feature / enhancement](https://gethomepage.dev/more/development/#new-feature-guidelines) and / or [service widget guidelines](https://gethomepage.dev/more/development/#service-widget-guidelines).
|
- [ ] If applicable, I have reviewed the [feature / enhancement](https://gethomepage.dev/more/development/#new-feature-guidelines) and / or [service widget guidelines](https://gethomepage.dev/more/development/#service-widget-guidelines).
|
||||||
- [ ] I have checked that all code style checks pass using [pre-commit hooks](https://gethomepage.dev/more/development/#code-formatting-with-pre-commit-hooks) and [linting checks](https://gethomepage.dev/more/development/#code-linting).
|
- [ ] I have checked that all code style checks pass using [pre-commit hooks](https://gethomepage.dev/more/development/#code-formatting-with-pre-commit-hooks) and [linting checks](https://gethomepage.dev/more/development/#code-linting).
|
||||||
- [ ] If applicable, I have tested my code for new features & regressions on both mobile & desktop devices, using the latest version of major browsers.
|
- [ ] If applicable, I have tested my code for new features & regressions on both mobile & desktop devices, using the latest version of major browsers.
|
||||||
|
- [ ] In the description above I have disclosed the use of AI tools in the coding of this PR.
|
||||||
|
|||||||
2
.github/workflows/crowdin.yml
vendored
2
.github/workflows/crowdin.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: crowdin action
|
- name: crowdin action
|
||||||
uses: crowdin/github-action@v2
|
uses: crowdin/github-action@v2
|
||||||
with:
|
with:
|
||||||
|
|||||||
8
.github/workflows/docker-publish.yml
vendored
8
.github/workflows/docker-publish.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
|||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Install python
|
- name: Install python
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
@@ -35,6 +35,7 @@ jobs:
|
|||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
|
version: 10
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
@@ -61,7 +62,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Extract Docker metadata
|
- name: Extract Docker metadata
|
||||||
id: meta
|
id: meta
|
||||||
@@ -93,6 +94,7 @@ jobs:
|
|||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
|
version: 10
|
||||||
run_install: false
|
run_install: false
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
@@ -127,7 +129,7 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Setup QEMU
|
- name: Setup QEMU
|
||||||
uses: docker/setup-qemu-action@v3.6.0
|
uses: docker/setup-qemu-action@v3.7.0
|
||||||
|
|
||||||
- name: Setup Docker buildx
|
- name: Setup Docker buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|||||||
6
.github/workflows/docs-publish.yml
vendored
6
.github/workflows/docs-publish.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: Install python
|
- name: Install python
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
@@ -32,7 +32,7 @@ jobs:
|
|||||||
needs:
|
needs:
|
||||||
- pre-commit
|
- pre-commit
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-python@v6
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: 3.x
|
python-version: 3.x
|
||||||
@@ -54,7 +54,7 @@ jobs:
|
|||||||
needs:
|
needs:
|
||||||
- pre-commit
|
- pre-commit
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- name: Configure Git Credentials
|
- name: Configure Git Credentials
|
||||||
run: |
|
run: |
|
||||||
git config user.name github-actions[bot]
|
git config user.name github-actions[bot]
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ COPY --link --from=builder --chown=1000:1000 /app/.next/static/ ./.next/static
|
|||||||
|
|
||||||
RUN apk add --no-cache su-exec iputils-ping shadow
|
RUN apk add --no-cache su-exec iputils-ping shadow
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV HOSTNAME=0.0.0.0
|
ENV HOSTNAME=0.0.0.0
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ if [ -d /app/.next ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Drop privileges (when asked to) if root, otherwise run as current user
|
# Drop privileges (when asked to) if root, otherwise run as current user
|
||||||
if [ "$(id -u)" == "0" ] && [ "${PUID}" != "0" ]; then
|
if [ "$(id -u)" = "0" ] && [ "${PUID}" != "0" ]; then
|
||||||
su-exec ${PUID}:${PGID} "$@"
|
exec su-exec ${PUID}:${PGID} "$@"
|
||||||
else
|
else
|
||||||
exec "$@"
|
exec "$@"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -571,3 +571,18 @@ or per service widget (`services.yaml`) with:
|
|||||||
```
|
```
|
||||||
|
|
||||||
If either value is set to true, the error message will be hidden.
|
If either value is set to true, the error message will be hidden.
|
||||||
|
|
||||||
|
## Disable Search Engine Indexing
|
||||||
|
|
||||||
|
You can request that search engines not to index your Homepage instance by enabling the `disableIndexing` setting.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
disableIndexing: true
|
||||||
|
```
|
||||||
|
|
||||||
|
When enabled, this will:
|
||||||
|
|
||||||
|
- Disallow all crawlers in `robots.txt`
|
||||||
|
- Add `<meta name="robots" content="noindex, nofollow">` tags to prevent indexing
|
||||||
|
|
||||||
|
By default this feature is disabled.
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ Learn more about [Crowdsec](https://crowdsec.net).
|
|||||||
See the [crowdsec docs](https://docs.crowdsec.net/docs/local_api/intro/#machines) for information about registering a machine,
|
See the [crowdsec docs](https://docs.crowdsec.net/docs/local_api/intro/#machines) for information about registering a machine,
|
||||||
in most instances you can use the default credentials (`/etc/crowdsec/local_api_credentials.yaml`).
|
in most instances you can use the default credentials (`/etc/crowdsec/local_api_credentials.yaml`).
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
Without the `limit24h` option, the widget will fetch all alerts which is limited to 100 by the API to avoid performance issues.
|
||||||
|
|
||||||
Allowed fields: `["alerts", "bans"]`.
|
Allowed fields: `["alerts", "bans"]`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -16,4 +19,5 @@ widget:
|
|||||||
url: http://crowdsechostorip:port
|
url: http://crowdsechostorip:port
|
||||||
username: localhost # machine_id in crowdsec
|
username: localhost # machine_id in crowdsec
|
||||||
password: password
|
password: password
|
||||||
|
limit24h: true # optional, limits alerts to last 24h. Default: false
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -14,4 +14,6 @@ widget:
|
|||||||
type: frigate
|
type: frigate
|
||||||
url: http://frigate.host.or.ip:port
|
url: http://frigate.host.or.ip:port
|
||||||
enableRecentEvents: true # Optional, defaults to false
|
enableRecentEvents: true # Optional, defaults to false
|
||||||
|
username: username # optional
|
||||||
|
password: password # optional
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ See the [official docs](https://github.com/ghostfolio/ghostfolio#authorization-b
|
|||||||
|
|
||||||
_Note that the Bearer token is valid for 6 months, after which a new one must be generated._
|
_Note that the Bearer token is valid for 6 months, after which a new one must be generated._
|
||||||
|
|
||||||
Allowed fields: `["gross_percent_today", "gross_percent_1y", "gross_percent_max"]`
|
Allowed fields: `["gross_percent_today", "gross_percent_1y", "gross_percent_max", "net_worth"]`
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
widget:
|
widget:
|
||||||
|
|||||||
@@ -12,11 +12,17 @@ Learn more about [Gluetun](https://github.com/qdm12/gluetun).
|
|||||||
Allowed fields: `["public_ip", "region", "country", "port_forwarded"]`.
|
Allowed fields: `["public_ip", "region", "country", "port_forwarded"]`.
|
||||||
Default fields: `["public_ip", "region", "country"]`.
|
Default fields: `["public_ip", "region", "country"]`.
|
||||||
|
|
||||||
To setup authentication, follow [the official Gluetun documentation](https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/control-server.md#authentication). Note that to use the api key method, you must add the route `GET /v1/publicip/ip` to the `routes` array in your Gluetun config.toml. Similarly, if you want to include the `port_forwarded` field, you must add the route `GET /v1/openvpn/portforwarded` to your Gluetun config.toml.
|
To setup authentication, follow [the official Gluetun documentation](https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/control-server.md#authentication). Note that to use the api key method, you must add the route `GET /v1/publicip/ip` to the `routes` array in your Gluetun config.toml. Similarly, if you want to include the `port_forwarded` field, you must add the route `GET /v1/openvpn/portforwarded` (or `/v1/portforward`) to your Gluetun config.toml.
|
||||||
|
|
||||||
|
| Gluetun Version | Homepage Widget Version |
|
||||||
|
| --------------- | ----------------------- |
|
||||||
|
| < 3.40.1 | 1 (default) |
|
||||||
|
| >= 3.40.1 | 2 |
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
widget:
|
widget:
|
||||||
type: gluetun
|
type: gluetun
|
||||||
url: http://gluetun.host.or.ip:port
|
url: http://gluetun.host.or.ip:port
|
||||||
key: gluetunkey # Not required if /v1/publicip/ip endpoint is configured with `auth = none`
|
key: gluetunkey # Not required if /v1/publicip/ip endpoint is configured with `auth = none`
|
||||||
|
version: 2 # optional, default is 1
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title: Omada
|
|||||||
description: Omada Widget Configuration
|
description: Omada Widget Configuration
|
||||||
---
|
---
|
||||||
|
|
||||||
The widget supports controller versions 3, 4 and 5.
|
The widget supports controller versions 3, 4, 5 and 6.
|
||||||
|
|
||||||
Allowed fields: `["connectedAp", "activeUser", "alerts", "connectedGateways", "connectedSwitches"]`.
|
Allowed fields: `["connectedAp", "activeUser", "alerts", "connectedGateways", "connectedSwitches"]`.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "homepage",
|
"name": "homepage",
|
||||||
"version": "1.6.1",
|
"version": "1.7.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "npx only-allow pnpm",
|
"preinstall": "npx only-allow pnpm",
|
||||||
@@ -63,13 +63,6 @@
|
|||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"osx-temperature-sensor": "^1.0.8"
|
"osx-temperature-sensor": "^1.0.8"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.8.1",
|
|
||||||
"devEngines": {
|
|
||||||
"packageManager": {
|
|
||||||
"name": "pnpm",
|
|
||||||
"version": "10.8.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"onlyBuiltDependencies": [
|
"onlyBuiltDependencies": [
|
||||||
"osx-temperature-sensor",
|
"osx-temperature-sensor",
|
||||||
|
|||||||
@@ -759,7 +759,8 @@
|
|||||||
"ghostfolio": {
|
"ghostfolio": {
|
||||||
"gross_percent_today": "Today",
|
"gross_percent_today": "Today",
|
||||||
"gross_percent_1y": "One year",
|
"gross_percent_1y": "One year",
|
||||||
"gross_percent_max": "All time"
|
"gross_percent_max": "All time",
|
||||||
|
"net_worth": "Net Worth"
|
||||||
},
|
},
|
||||||
"audiobookshelf": {
|
"audiobookshelf": {
|
||||||
"podcasts": "Podcasts",
|
"podcasts": "Podcasts",
|
||||||
|
|||||||
@@ -200,10 +200,10 @@
|
|||||||
"rutorrent": {
|
"rutorrent": {
|
||||||
"active": "活动中",
|
"active": "活动中",
|
||||||
"upload": "Upload",
|
"upload": "Upload",
|
||||||
"download": "Download"
|
"download": "下载"
|
||||||
},
|
},
|
||||||
"transmission": {
|
"transmission": {
|
||||||
"download": "Download",
|
"download": "下载",
|
||||||
"upload": "",
|
"upload": "",
|
||||||
"leech": "Leech",
|
"leech": "Leech",
|
||||||
"seed": "Seed"
|
"seed": "Seed"
|
||||||
@@ -223,8 +223,8 @@
|
|||||||
"invalid": "Invalid"
|
"invalid": "Invalid"
|
||||||
},
|
},
|
||||||
"deluge": {
|
"deluge": {
|
||||||
"download": "Download",
|
"download": "下载",
|
||||||
"upload": "Upload",
|
"upload": "上传",
|
||||||
"leech": "Leech",
|
"leech": "Leech",
|
||||||
"seed": "Seed"
|
"seed": "Seed"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ export default function Error({ error }) {
|
|||||||
|
|
||||||
if (typeof error === "string") {
|
if (typeof error === "string") {
|
||||||
error = { message: error }; // eslint-disable-line no-param-reassign
|
error = { message: error }; // eslint-disable-line no-param-reassign
|
||||||
|
} else if (typeof error === "number") {
|
||||||
|
error = { message: `Error ${error}` }; // eslint-disable-line no-param-reassign
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error?.data?.error) {
|
if (error?.data?.error) {
|
||||||
|
|||||||
@@ -400,6 +400,7 @@ function Home({ initialSettings }) {
|
|||||||
"A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations."
|
"A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations."
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
{settings.disableIndexing && <meta name="robots" content="noindex, nofollow" />}
|
||||||
{settings.base && <base href={settings.base} />}
|
{settings.base && <base href={settings.base} />}
|
||||||
{settings.favicon ? (
|
{settings.favicon ? (
|
||||||
<>
|
<>
|
||||||
|
|||||||
19
src/pages/robots.txt.js
Normal file
19
src/pages/robots.txt.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { getSettings } from "utils/config/config";
|
||||||
|
|
||||||
|
export async function getServerSideProps({ res }) {
|
||||||
|
const settings = getSettings();
|
||||||
|
const content = ["User-agent: *", !!settings.disableIndexing ? "Disallow: /" : "Allow: /"].join("\n");
|
||||||
|
|
||||||
|
res.setHeader("Content-Type", "text/plain");
|
||||||
|
res.write(content);
|
||||||
|
res.end();
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function RobotsTxt() {
|
||||||
|
// placeholder component
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -279,6 +279,9 @@ export function cleanServiceGroups(groups) {
|
|||||||
slugs,
|
slugs,
|
||||||
symbols,
|
symbols,
|
||||||
|
|
||||||
|
// crowdsec
|
||||||
|
limit24h,
|
||||||
|
|
||||||
// customapi
|
// customapi
|
||||||
mappings,
|
mappings,
|
||||||
display,
|
display,
|
||||||
@@ -473,6 +476,10 @@ export function cleanServiceGroups(groups) {
|
|||||||
if (defaultinterval) widget.defaultinterval = defaultinterval;
|
if (defaultinterval) widget.defaultinterval = defaultinterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (limit24h !== undefined) {
|
||||||
|
widget.limit24h = !!limit24h;
|
||||||
|
}
|
||||||
|
|
||||||
if (type === "docker") {
|
if (type === "docker") {
|
||||||
if (server) widget.server = server;
|
if (server) widget.server = server;
|
||||||
if (container) widget.container = container;
|
if (container) widget.container = container;
|
||||||
@@ -556,6 +563,7 @@ export function cleanServiceGroups(groups) {
|
|||||||
"speedtest",
|
"speedtest",
|
||||||
"wgeasy",
|
"wgeasy",
|
||||||
"grafana",
|
"grafana",
|
||||||
|
"gluetun",
|
||||||
].includes(type)
|
].includes(type)
|
||||||
) {
|
) {
|
||||||
if (version) widget.version = parseInt(version, 10);
|
if (version) widget.version = parseInt(version, 10);
|
||||||
|
|||||||
@@ -106,13 +106,19 @@ export default function Integration({ config, params, setEvents, hideErrors, tim
|
|||||||
};
|
};
|
||||||
|
|
||||||
const eventsToAdd = [];
|
const eventsToAdd = [];
|
||||||
events.forEach((event, index) => {
|
events.forEach((event) => {
|
||||||
const occurrences = getOcurrencesFromRange(event);
|
const occurrences = getOcurrencesFromRange(event);
|
||||||
|
|
||||||
occurrences.forEach((icalDate) => {
|
occurrences.forEach((icalDate) => {
|
||||||
const date = icalDate.toJSDate();
|
const date = icalDate.toJSDate();
|
||||||
|
|
||||||
const hash = simpleHash(`${event.id}-${event.title}-${index}-${date.toString()}`);
|
const occurrenceTimestamp = date.getTime();
|
||||||
|
const eventIdentifier =
|
||||||
|
event.id ??
|
||||||
|
simpleHash(
|
||||||
|
`${event.title ?? ""}-${event.type ?? ""}-${event.status ?? ""}-${event.url ?? ""}-${event.location ?? ""}`,
|
||||||
|
);
|
||||||
|
const hash = simpleHash(`${eventIdentifier}-${occurrenceTimestamp}`);
|
||||||
|
|
||||||
let title = event.title;
|
let title = event.title;
|
||||||
if (showName) {
|
if (showName) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
|
||||||
const { data: alerts, error: alertsError } = useWidgetAPI(widget, "alerts");
|
const { data: alerts, error: alertsError } = useWidgetAPI(widget, !!widget.limit24h ? "alerts24h" : "alerts");
|
||||||
const { data: bans, error: bansError } = useWidgetAPI(widget, "bans");
|
const { data: bans, error: bansError } = useWidgetAPI(widget, "bans");
|
||||||
|
|
||||||
if (alertsError || bansError) {
|
if (alertsError || bansError) {
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ const widget = {
|
|||||||
alerts: {
|
alerts: {
|
||||||
endpoint: "alerts",
|
endpoint: "alerts",
|
||||||
},
|
},
|
||||||
|
alerts24h: {
|
||||||
|
endpoint: "alerts?limit=0&since=24h",
|
||||||
|
},
|
||||||
bans: {
|
bans: {
|
||||||
endpoint: "alerts?decision_type=ban&origin=crowdsec&has_active_decision=1",
|
endpoint: "alerts?decision_type=ban&origin=crowdsec&has_active_decision=1",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -166,7 +166,11 @@ export default function Component({ service }) {
|
|||||||
refreshInterval: Math.max(1000, refreshInterval),
|
refreshInterval: Math.max(1000, refreshInterval),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (customError) {
|
// if mappings includes an error field and the data contains an error field then show data even if there is an error
|
||||||
|
const mappingsIncludesError = Array.isArray(mappings) && mappings.find((mapping) => mapping.field === "error");
|
||||||
|
const errorIsData = customData && typeof customData === "object" && "error" in customData;
|
||||||
|
|
||||||
|
if (customError && !(mappingsIncludesError && errorIsData)) {
|
||||||
return <Container service={service} error={customError} />;
|
return <Container service={service} error={customError} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ export default function Component({ service }) {
|
|||||||
return <Container service={service} error={resultError} />;
|
return <Container service={service} error={resultError} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!widget.fields || widget.fields.length === 0) {
|
||||||
|
widget.fields = ["online", "offline", "offline_alt", "total"];
|
||||||
|
} else if (widget.fields.length > 4) {
|
||||||
|
widget.fields = widget.fields.slice(0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
if (!resultData) {
|
if (!resultData) {
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
|
|||||||
95
src/widgets/frigate/proxy.js
Normal file
95
src/widgets/frigate/proxy.js
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import getServiceWidget from "utils/config/service-helpers";
|
||||||
|
import createLogger from "utils/logger";
|
||||||
|
import { asJson, formatApiCall, sanitizeErrorURL } from "utils/proxy/api-helpers";
|
||||||
|
import { addCookieToJar } from "utils/proxy/cookie-jar";
|
||||||
|
import { httpProxy } from "utils/proxy/http";
|
||||||
|
import widgets from "widgets/widgets";
|
||||||
|
|
||||||
|
const proxyName = "frigateProxyHandler";
|
||||||
|
const logger = createLogger(proxyName);
|
||||||
|
|
||||||
|
export default async function frigateProxyHandler(req, res, map) {
|
||||||
|
const { group, service, endpoint, index } = req.query;
|
||||||
|
|
||||||
|
if (group && service) {
|
||||||
|
const widget = await getServiceWidget(group, service, index);
|
||||||
|
|
||||||
|
if (!widgets?.[widget.type]?.api) {
|
||||||
|
return res.status(403).json({ error: "Service does not support API calls" });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widget) {
|
||||||
|
const url = formatApiCall(widgets[widget.type].api, { endpoint, ...widget });
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let [status, , data] = await httpProxy(url, params);
|
||||||
|
|
||||||
|
if (status === 401 && widget.username && widget.password) {
|
||||||
|
const loginUrl = `${widget.url}/api/login`;
|
||||||
|
logger.debug("Attempting login to Frigate at %s", loginUrl);
|
||||||
|
const [loginStatus, , , loginResponseHeaders] = await httpProxy(loginUrl, {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ user: widget.username, password: widget.password }),
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (loginStatus !== 200) {
|
||||||
|
logger.error("HTTP Error %d calling %s", loginStatus, sanitizeErrorURL(loginUrl));
|
||||||
|
return res.status(status).json({
|
||||||
|
error: {
|
||||||
|
message: `HTTP Error ${status} while trying to login to Frigate`,
|
||||||
|
url: sanitizeErrorURL(url),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
addCookieToJar(url, loginResponseHeaders);
|
||||||
|
// Retry original request with cookie set
|
||||||
|
[status, , data] = await httpProxy(url, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status >= 400) {
|
||||||
|
logger.error("HTTP Error %d calling %s", status, sanitizeErrorURL(url));
|
||||||
|
return res.status(status).json({
|
||||||
|
error: {
|
||||||
|
message: `HTTP Error ${status} from Frigate`,
|
||||||
|
url: sanitizeErrorURL(url),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
data = asJson(data);
|
||||||
|
|
||||||
|
if (endpoint == "stats") {
|
||||||
|
res.status(status).send({
|
||||||
|
num_cameras: data?.cameras !== undefined ? Object.keys(data?.cameras).length : 0,
|
||||||
|
uptime: data?.service?.uptime,
|
||||||
|
version: data?.service.version,
|
||||||
|
});
|
||||||
|
} else if (endpoint == "events") {
|
||||||
|
return res.status(status).send(
|
||||||
|
data.slice(0, 5).map((event) => ({
|
||||||
|
id: event.id,
|
||||||
|
camera: event.camera,
|
||||||
|
label: event.label,
|
||||||
|
start_time: new Date(event.start_time * 1000),
|
||||||
|
thumbnail: event.thumbnail,
|
||||||
|
score: event.data.score,
|
||||||
|
type: event.data.type,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("Invalid or missing proxy service type '%s' in group '%s'", service, group);
|
||||||
|
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||||
|
}
|
||||||
@@ -1,37 +1,12 @@
|
|||||||
import { asJson } from "utils/proxy/api-helpers";
|
import frigateProxyHandler from "./proxy";
|
||||||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/{endpoint}",
|
api: "{url}/api/{endpoint}",
|
||||||
proxyHandler: genericProxyHandler,
|
proxyHandler: frigateProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
stats: {
|
stats: { endpoint: "stats" },
|
||||||
endpoint: "stats",
|
events: { endpoint: "events" },
|
||||||
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,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
events: {
|
|
||||||
endpoint: "events",
|
|
||||||
map: (data) =>
|
|
||||||
asJson(data)
|
|
||||||
.slice(0, 5)
|
|
||||||
.map((event) => ({
|
|
||||||
id: event.id,
|
|
||||||
camera: event.camera,
|
|
||||||
label: event.label,
|
|
||||||
start_time: new Date(event.start_time * 1000),
|
|
||||||
thumbnail: event.thumbnail,
|
|
||||||
score: event.data.score,
|
|
||||||
type: event.data.type,
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,15 @@ function getPerformancePercent(t, performanceRange) {
|
|||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
const includeNetWorth = widget.fields?.includes("net_worth");
|
||||||
|
|
||||||
const { data: performanceToday, error: ghostfolioErrorToday } = useWidgetAPI(widget, "today");
|
const { data: performanceToday, error: ghostfolioErrorToday } = useWidgetAPI(widget, "today");
|
||||||
const { data: performanceYear, error: ghostfolioErrorYear } = useWidgetAPI(widget, "year");
|
const { data: performanceYear, error: ghostfolioErrorYear } = useWidgetAPI(widget, "year");
|
||||||
const { data: performanceMax, error: ghostfolioErrorMax } = useWidgetAPI(widget, "max");
|
const { data: performanceMax, error: ghostfolioErrorMax } = useWidgetAPI(widget, "max");
|
||||||
|
const { data: userInfo, error: ghostfolioErrorUserInfo } = useWidgetAPI(widget, includeNetWorth ? "userInfo" : "");
|
||||||
|
|
||||||
if (ghostfolioErrorToday || ghostfolioErrorYear || ghostfolioErrorMax) {
|
if (ghostfolioErrorToday || ghostfolioErrorYear || ghostfolioErrorMax || ghostfolioErrorUserInfo) {
|
||||||
const finalError = ghostfolioErrorToday ?? ghostfolioErrorYear ?? ghostfolioErrorMax;
|
const finalError = ghostfolioErrorToday ?? ghostfolioErrorYear ?? ghostfolioErrorMax ?? ghostfolioErrorUserInfo;
|
||||||
return <Container service={service} error={finalError} />;
|
return <Container service={service} error={finalError} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,12 +36,13 @@ export default function Component({ service }) {
|
|||||||
return <Container service={service} error={performanceToday} />;
|
return <Container service={service} error={performanceToday} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!performanceToday || !performanceYear || !performanceMax) {
|
if (!performanceToday || !performanceYear || !performanceMax || (includeNetWorth && !userInfo)) {
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="ghostfolio.gross_percent_today" />
|
<Block label="ghostfolio.gross_percent_today" />
|
||||||
<Block label="ghostfolio.gross_percent_1y" />
|
<Block label="ghostfolio.gross_percent_1y" />
|
||||||
<Block label="ghostfolio.gross_percent_max" />
|
<Block label="ghostfolio.gross_percent_max" />
|
||||||
|
{includeNetWorth && <Block label="ghostfolio.net_worth" />}
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -49,6 +52,12 @@ export default function Component({ service }) {
|
|||||||
<Block label="ghostfolio.gross_percent_today" value={getPerformancePercent(t, performanceToday)} />
|
<Block label="ghostfolio.gross_percent_today" value={getPerformancePercent(t, performanceToday)} />
|
||||||
<Block label="ghostfolio.gross_percent_1y" value={getPerformancePercent(t, performanceYear)} />
|
<Block label="ghostfolio.gross_percent_1y" value={getPerformancePercent(t, performanceYear)} />
|
||||||
<Block label="ghostfolio.gross_percent_max" value={getPerformancePercent(t, performanceMax)} />
|
<Block label="ghostfolio.gross_percent_max" value={getPerformancePercent(t, performanceMax)} />
|
||||||
|
{includeNetWorth && (
|
||||||
|
<Block
|
||||||
|
label="ghostfolio.net_worth"
|
||||||
|
value={`${performanceToday.performance.currentNetWorth.toFixed(2)} ${userInfo?.settings?.currency ?? ""}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/api/v2/portfolio/performance?range={endpoint}",
|
api: "{url}/api/{endpoint}",
|
||||||
proxyHandler: credentialedProxyHandler,
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
today: {
|
today: {
|
||||||
endpoint: "1d",
|
endpoint: "v2/portfolio/performance?range=1d",
|
||||||
},
|
},
|
||||||
year: {
|
year: {
|
||||||
endpoint: "1y",
|
endpoint: "v2/portfolio/performance?range=1y",
|
||||||
},
|
},
|
||||||
max: {
|
max: {
|
||||||
endpoint: "max",
|
endpoint: "v2/portfolio/performance?range=max",
|
||||||
|
},
|
||||||
|
userInfo: {
|
||||||
|
endpoint: "v1/user",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,10 +12,8 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
const { data: gluetunData, error: gluetunError } = useWidgetAPI(widget, "ip");
|
const { data: gluetunData, error: gluetunError } = useWidgetAPI(widget, "ip");
|
||||||
const includePF = widget.fields.includes("port_forwarded");
|
const includePF = widget.fields.includes("port_forwarded");
|
||||||
const { data: portForwardedData, error: portForwardedError } = useWidgetAPI(
|
const pfEndpoint = widget.version > 1 ? "port_forwarded_v2" : "port_forwarded";
|
||||||
widget,
|
const { data: portForwardedData, error: portForwardedError } = useWidgetAPI(widget, includePF ? pfEndpoint : "");
|
||||||
includePF ? "port_forwarded" : "",
|
|
||||||
);
|
|
||||||
|
|
||||||
if (gluetunError || (includePF && portForwardedError)) {
|
if (gluetunError || (includePF && portForwardedError)) {
|
||||||
return <Container service={service} error={gluetunError || portForwardedError} />;
|
return <Container service={service} error={gluetunError || portForwardedError} />;
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ const widget = {
|
|||||||
endpoint: "openvpn/portforwarded",
|
endpoint: "openvpn/portforwarded",
|
||||||
validate: ["port"],
|
validate: ["port"],
|
||||||
},
|
},
|
||||||
|
port_forwarded_v2: {
|
||||||
|
endpoint: "portforward",
|
||||||
|
validate: ["port"],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
(!widget.showStacks && !containersData) ||
|
(!widget.showStacks && !containersData) ||
|
||||||
(widget.showSummary && (!stacksData || !serversData)) ||
|
(widget.showSummary && (!containersData || !stacksData || !serversData)) ||
|
||||||
(widget.showStacks && !stacksData)
|
(widget.showStacks && !stacksData)
|
||||||
) {
|
) {
|
||||||
return widget.showSummary ? (
|
return widget.showSummary ? (
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ export default function Component({ service }) {
|
|||||||
if (!data || (data && data.length === 0)) {
|
if (!data || (data && data.length === 0)) {
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="myspeed.ping" />
|
|
||||||
<Block label="myspeed.download" />
|
<Block label="myspeed.download" />
|
||||||
<Block label="myspeed.upload" />
|
<Block label="myspeed.upload" />
|
||||||
|
<Block label="myspeed.ping" />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,12 +38,13 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
if (Array.isArray(statusData.volume.volumeUseList.volumeUse)) {
|
if (Array.isArray(statusData.volume.volumeUseList.volumeUse)) {
|
||||||
if (widget.volume) {
|
if (widget.volume) {
|
||||||
const volumeSelected = statusData.volume.volumeList.volume.findIndex(
|
const volumeSelected = statusData.volume.volumeList.volume.find((vl) => vl.volumeLabel._cdata === widget.volume);
|
||||||
(vl) => vl.volumeLabel._cdata === widget.volume,
|
if (volumeSelected) {
|
||||||
);
|
const volumeUsed = statusData.volume.volumeUseList.volumeUse.find(
|
||||||
if (volumeSelected !== -1) {
|
(vu) => vu.volumeValue._cdata === volumeSelected.volumeValue._cdata,
|
||||||
volumeTotalSize = statusData.volume.volumeUseList.volumeUse[volumeSelected].total_size._cdata;
|
);
|
||||||
volumeFreeSize = statusData.volume.volumeUseList.volumeUse[volumeSelected].free_size._cdata;
|
volumeTotalSize = volumeUsed.total_size._cdata;
|
||||||
|
volumeFreeSize = volumeUsed.free_size._cdata;
|
||||||
} else {
|
} else {
|
||||||
validVolume = false;
|
validVolume = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user