Skip to content

Commit 37f03a1

Browse files
committed
working on homepage upgrade
1 parent a5b9dc6 commit 37f03a1

File tree

6 files changed

+84
-61
lines changed

6 files changed

+84
-61
lines changed

config/homepage/services.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@
3636
- pihole-kuma:
3737
- pihole:
3838
weight: 1
39-
href: http://pi.hole/admin/
39+
href: http://pi.hole:8080/admin/
4040
icon: pi-hole.svg
4141
widget:
4242
type: pihole
43-
url: http://pi.hole
43+
url: http://pi.hole:8080
44+
version: 6 # required if running v6 or higher, defaults to 5
45+
key: "{{HOMEPAGE_VAR_PIHOLE_API_KEY}}" # optional, in v6 can be your password or app password
46+
4447
- uptime kuma:
4548
icon: uptime-kuma.svg
4649
href: https://kuma.petalas.dev/dashboard

docker-compose.yml

+3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ services:
136136
dockerfile: ./homepage
137137
container_name: homepage
138138
restart: unless-stopped
139+
environment:
140+
HOMEPAGE_ALLOWED_HOSTS: dashboard.petalas.dev
141+
HOMEPAGE_VAR_PIHOLE_API_KEY: ${HOMEPAGE_VAR_PIHOLE_API_KEY}
139142
healthcheck:
140143
<<: *healthcheck
141144
test: [ "CMD-SHELL", "exit 0" ] # TODO: figure out what kind of healthcheck we can do

dockerfiles/color.jsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { useContext, Fragment } from "react";
2-
import { IoColorPalette } from "react-icons/io5";
3-
import { Popover, Transition } from "@headlessui/react";
1+
import {Popover, Transition} from "@headlessui/react";
42
import classNames from "classnames";
5-
6-
import { ColorContext } from "utils/contexts/color";
3+
import {Fragment, useContext} from "react";
4+
import {IoColorPalette} from "react-icons/io5";
5+
import {ColorContext} from "utils/contexts/color";
76

87
const colors = [
98
"slate",
@@ -32,7 +31,7 @@ const colors = [
3231
];
3332

3433
export default function ColorToggle() {
35-
const { color: active, setColor } = useContext(ColorContext);
34+
const {color: active, setColor} = useContext(ColorContext);
3635

3736
if (!active) {
3837
return null;

dockerfiles/homepage

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# FROM ghcr.io/gethomepage/homepage:latest
2-
FROM docker.io/node:18-alpine
2+
FROM docker.io/node:22-alpine
33

44
# install general dependencies
55
RUN apk add --no-cache git libc6-compat su-exec
@@ -23,9 +23,9 @@ COPY theme.css /app/src/styles/theme.css
2323

2424
# build
2525
SHELL ["/bin/ash", "-xeo", "pipefail", "-c"]
26-
RUN npm run telemetry \
26+
RUN pnpm run telemetry \
2727
&& mkdir config \
28-
&& npm run build
28+
&& pnpm run build
2929

3030
# server.js is generated during the build in /app/.next/standalone
3131
RUN cp -r /app/.next/standalone/server.js ./

dockerfiles/qbittorrent.jsx

+58-41
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,72 @@
1-
import {useTranslation} from "next-i18next";
2-
1+
import { useTranslation } from "next-i18next";
32
import Container from "components/services/widget/container";
43
import Block from "components/services/widget/block";
4+
5+
import QueueEntry from "../../components/widgets/queue/queueEntry";
6+
57
import useWidgetAPI from "utils/proxy/use-widget-api";
68

7-
export default function Component({service}) {
8-
const {t} = useTranslation();
9+
export default function Component({ service }) {
10+
const { t } = useTranslation();
11+
const { widget } = service;
12+
const {refreshInterval = 1000} = widget;
913

10-
const {widget} = service;
11-
const {refreshInterval = 1000} = widget;
14+
const { data: torrentData, error: torrentError } = useWidgetAPI(widget, "torrents",
15+
{refreshInterval: Math.max(1000, refreshInterval)}
16+
);
1217

13-
const {data: torrentData, error: torrentError} = useWidgetAPI(widget, "torrents/info",
14-
{refreshInterval: Math.max(1000, refreshInterval)}
18+
if (torrentError) {
19+
return <Container service={service} error={torrentError} />;
20+
}
21+
22+
if (!torrentData) {
23+
return (
24+
<Container service={service}>
25+
<Block label="qbittorrent.leech" />
26+
<Block label="qbittorrent.download" />
27+
<Block label="qbittorrent.seed" />
28+
<Block label="qbittorrent.upload" />
29+
</Container>
1530
);
31+
}
1632

17-
if (torrentError) {
18-
return <Container service={service} error={torrentError} />;
19-
}
33+
let rateDl = 0;
34+
let rateUl = 0;
35+
let completed = 0;
36+
const leechTorrents = [];
2037

21-
if (!torrentData) {
22-
return (
23-
<Container service={service}>
24-
<Block label="qbittorrent.leech" />
25-
<Block label="qbittorrent.download" />
26-
<Block label="qbittorrent.seed" />
27-
<Block label="qbittorrent.upload" />
28-
</Container>
29-
);
38+
for (let i = 0; i < torrentData.length; i += 1) {
39+
const torrent = torrentData[i];
40+
rateDl += torrent.dlspeed;
41+
rateUl += torrent.upspeed;
42+
if (torrent.progress === 1) {
43+
completed += 1;
3044
}
31-
32-
let rateDl = 0;
33-
let rateUl = 0;
34-
let completed = 0;
35-
36-
for (let i = 0; i < torrentData.length; i += 1) {
37-
const torrent = torrentData[i];
38-
rateDl += torrent.dlspeed;
39-
rateUl += torrent.upspeed;
40-
if (torrent.progress === 1) {
41-
completed += 1;
42-
}
45+
if (torrent.state.includes("DL") || torrent.state === "downloading") {
46+
leechTorrents.push(torrent);
4347
}
48+
}
4449

45-
const leech = torrentData.length - completed;
50+
const leech = torrentData.length - completed;
4651

47-
return (
48-
<Container service={service}>
49-
<Block label="qbittorrent.leech" value={t("common.number", {value: leech})} />
50-
<Block label="qbittorrent.download" value={t("common.bibyterate", {value: rateDl, decimals: 1})} />
51-
<Block label="qbittorrent.seed" value={t("common.number", {value: completed})} />
52-
<Block label="qbittorrent.upload" value={t("common.bibyterate", {value: rateUl, decimals: 1})} />
53-
</Container>
54-
);
52+
return (
53+
<>
54+
<Container service={service}>
55+
<Block label="qbittorrent.leech" value={t("common.number", { value: leech })} />
56+
<Block label="qbittorrent.download" value={t("common.bibyterate", { value: rateDl, decimals: 1 })} />
57+
<Block label="qbittorrent.seed" value={t("common.number", { value: completed })} />
58+
<Block label="qbittorrent.upload" value={t("common.bibyterate", { value: rateUl, decimals: 1 })} />
59+
</Container>
60+
{widget?.enableLeechProgress &&
61+
leechTorrents.map((queueEntry) => (
62+
<QueueEntry
63+
progress={queueEntry.progress * 100}
64+
timeLeft={t("common.duration", { value: queueEntry.eta })}
65+
title={queueEntry.name}
66+
activity={queueEntry.state}
67+
key={`${queueEntry.name}-${queueEntry.amount_left}`}
68+
/>
69+
))}
70+
</>
71+
);
5572
}

dockerfiles/sabnzbd.jsx

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {useTranslation} from "next-i18next";
2-
1+
import { useTranslation } from "next-i18next";
32
import Container from "components/services/widget/container";
43
import Block from "components/services/widget/block";
4+
55
import useWidgetAPI from "utils/proxy/use-widget-api";
66

77
function fromUnits(value) {
@@ -14,14 +14,15 @@ function fromUnits(value) {
1414
return parseFloat(number) * 1024 ** index;
1515
}
1616

17-
export default function Component({service}) {
18-
const {t} = useTranslation();
17+
export default function Component({ service }) {
18+
const { t } = useTranslation();
1919

20-
const {widget} = service;
20+
const { widget } = service;
2121
const {refreshInterval = 1000} = widget;
2222

23-
const {data: queueData, error: queueError} = useWidgetAPI(widget, "queue",
24-
{refreshInterval: Math.max(1000, refreshInterval)});
23+
const { data: queueData, error: queueError } = useWidgetAPI(widget, "queue",
24+
{refreshInterval: Math.max(1000, refreshInterval)}
25+
);
2526

2627
if (queueError) {
2728
return <Container service={service} error={queueError} />;
@@ -39,8 +40,8 @@ export default function Component({service}) {
3940

4041
return (
4142
<Container service={service}>
42-
<Block label="sabnzbd.rate" value={t("common.bitrate", {value: fromUnits(queueData.queue.speed) * 8})} />
43-
<Block label="sabnzbd.queue" value={t("common.number", {value: queueData.queue.noofslots})} />
43+
<Block label="sabnzbd.rate" value={t("common.byterate", { value: fromUnits(queueData.queue.speed) })} />
44+
<Block label="sabnzbd.queue" value={t("common.number", { value: queueData.queue.noofslots })} />
4445
<Block label="sabnzbd.timeleft" value={queueData.queue.timeleft} />
4546
</Container>
4647
);

0 commit comments

Comments
 (0)