mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-12 23:25:48 -07:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c764d05a0c | |||
| fcd9a715d9 | |||
| eacc205249 | |||
| 4249a3fb95 | |||
| 0b98428ab5 | |||
| bbe52519bb |
@@ -23,7 +23,7 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
- name: crowdin action
|
- name: crowdin action
|
||||||
uses: crowdin/github-action@e4a6c1338b4063c77d46a81875265f9e8bd76f95 # v3.0.0
|
uses: crowdin/github-action@71fdb8814261dd703be4ca7c6450d21b1868da4b # v3.0.1
|
||||||
with:
|
with:
|
||||||
upload_translations: false
|
upload_translations: false
|
||||||
download_translations: true
|
download_translations: true
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Setup QEMU
|
- name: Setup QEMU
|
||||||
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
|
uses: docker/setup-qemu-action@1f40c72289eff860ee54a304f1438e3cff362e0a # v4.3.0
|
||||||
|
|
||||||
- name: Setup Docker buildx
|
- name: Setup Docker buildx
|
||||||
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
|
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
|
||||||
|
|||||||
@@ -52,5 +52,5 @@ jobs:
|
|||||||
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
|
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
|
||||||
with:
|
with:
|
||||||
path: site
|
path: site
|
||||||
- uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
|
- uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
|
||||||
id: deployment
|
id: deployment
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ widget:
|
|||||||
url: http://whatsupdocker:port
|
url: http://whatsupdocker:port
|
||||||
username: username # optional
|
username: username # optional
|
||||||
password: password # optional
|
password: password # optional
|
||||||
|
key: bearer-token # optional, takes precedence over username/password
|
||||||
```
|
```
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@
|
|||||||
"gamedig": "^5.3.3",
|
"gamedig": "^5.3.3",
|
||||||
"i18next": "^26.3.6",
|
"i18next": "^26.3.6",
|
||||||
"ical.js": "^2.2.1",
|
"ical.js": "^2.2.1",
|
||||||
"js-yaml": "^5.4.0",
|
"js-yaml": "^5.4.1",
|
||||||
"json-rpc-2.0": "^1.7.1",
|
"json-rpc-2.0": "^1.7.1",
|
||||||
"luxon": "^3.7.2",
|
"luxon": "^3.7.2",
|
||||||
"memory-cache": "^0.2.0",
|
"memory-cache": "^0.2.0",
|
||||||
|
|||||||
Generated
+6
-6
@@ -36,8 +36,8 @@ importers:
|
|||||||
specifier: ^2.2.1
|
specifier: ^2.2.1
|
||||||
version: 2.2.1
|
version: 2.2.1
|
||||||
js-yaml:
|
js-yaml:
|
||||||
specifier: ^5.4.0
|
specifier: ^5.4.1
|
||||||
version: 5.4.0
|
version: 5.4.1
|
||||||
json-rpc-2.0:
|
json-rpc-2.0:
|
||||||
specifier: ^1.7.1
|
specifier: ^1.7.1
|
||||||
version: 1.7.1
|
version: 1.7.1
|
||||||
@@ -2481,8 +2481,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==}
|
resolution: {integrity: sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
js-yaml@5.4.0:
|
js-yaml@5.4.1:
|
||||||
resolution: {integrity: sha512-jE7vUJIebKzYQI5xu4co5CRBDlDEYnHrdzsxs4O2giCz4v2SbVMYKpmt1D9L38OKQAeCWmrOTRiCV93u0UkaJA==}
|
resolution: {integrity: sha512-28R/k+NAjeuf7+CKlTxWZVExJGwVVLwY06DgEnOMz2gEpfNkDcD7QvyiVPT0xy0XXhU8vHsd4Ot42OOPdJG7dQ==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
jsdom@30.0.1:
|
jsdom@30.0.1:
|
||||||
@@ -4359,7 +4359,7 @@ snapshots:
|
|||||||
form-data: 4.0.6
|
form-data: 4.0.6
|
||||||
hpagent: 1.2.0
|
hpagent: 1.2.0
|
||||||
isomorphic-ws: 5.0.0(ws@8.21.2)
|
isomorphic-ws: 5.0.0(ws@8.21.2)
|
||||||
js-yaml: 5.4.0
|
js-yaml: 5.4.1
|
||||||
jsonpath-plus: 10.4.0
|
jsonpath-plus: 10.4.0
|
||||||
openid-client: 6.8.5
|
openid-client: 6.8.5
|
||||||
rfc4648: 1.5.4
|
rfc4648: 1.5.4
|
||||||
@@ -6263,7 +6263,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
argparse: 2.0.1
|
argparse: 2.0.1
|
||||||
|
|
||||||
js-yaml@5.4.0:
|
js-yaml@5.4.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
argparse: 2.0.1
|
argparse: 2.0.1
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
} else {
|
} else {
|
||||||
headers.Authorization = basicAuthHeader(widget);
|
headers.Authorization = basicAuthHeader(widget);
|
||||||
}
|
}
|
||||||
} else if (widget.type === "ntfy") {
|
} else if (["ntfy", "whatsupdocker"].includes(widget.type)) {
|
||||||
if (widget.key) {
|
if (widget.key) {
|
||||||
headers.Authorization = `Bearer ${widget.key}`;
|
headers.Authorization = `Bearer ${widget.key}`;
|
||||||
} else if (widget.username && widget.password) {
|
} else if (widget.username && widget.password) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ vi.mock("widgets/widgets", () => ({
|
|||||||
proxmox: { api: "{url}/api2/json/{endpoint}" },
|
proxmox: { api: "{url}/api2/json/{endpoint}" },
|
||||||
truenas: { api: "{url}/api/v2.0/{endpoint}" },
|
truenas: { api: "{url}/api/v2.0/{endpoint}" },
|
||||||
ntfy: { api: "{url}/{endpoint}" },
|
ntfy: { api: "{url}/{endpoint}" },
|
||||||
|
whatsupdocker: { api: "{url}/{endpoint}" },
|
||||||
proxmoxbackupserver: { api: "{url}/api2/json/{endpoint}" },
|
proxmoxbackupserver: { api: "{url}/api2/json/{endpoint}" },
|
||||||
checkmk: { api: "{url}/{endpoint}" },
|
checkmk: { api: "{url}/{endpoint}" },
|
||||||
stocks: { api: "{url}/{endpoint}" },
|
stocks: { api: "{url}/{endpoint}" },
|
||||||
@@ -186,6 +187,24 @@ describe("utils/proxy/handlers/credentialed", () => {
|
|||||||
expect(params.headers.Authorization).toBe("Bearer k");
|
expect(params.headers.Authorization).toBe("Bearer k");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
["Bearer", { key: "token" }, "Bearer token"],
|
||||||
|
["Basic", { username: "u", password: "p" }, `Basic ${Buffer.from("u:p").toString("base64")}`],
|
||||||
|
["no", {}, undefined],
|
||||||
|
["Bearer over Basic", { key: "token", username: "u", password: "p" }, "Bearer token"],
|
||||||
|
])("uses %s auth for whatsupdocker", async (_mode, credentials, authorization) => {
|
||||||
|
getServiceWidget.mockResolvedValue({ type: "whatsupdocker", url: "http://whatsupdocker", ...credentials });
|
||||||
|
httpProxy.mockResolvedValue([200, "application/json", []]);
|
||||||
|
|
||||||
|
const req = { method: "GET", query: { group: "g", service: "s", endpoint: "api/containers", index: 0 } };
|
||||||
|
const res = createMockRes();
|
||||||
|
|
||||||
|
await credentialedProxyHandler(req, res);
|
||||||
|
|
||||||
|
const [, params] = httpProxy.mock.calls.at(-1);
|
||||||
|
expect(params.headers.Authorization).toBe(authorization);
|
||||||
|
});
|
||||||
|
|
||||||
it("uses Bearer auth for ntfy when key is provided", async () => {
|
it("uses Bearer auth for ntfy when key is provided", async () => {
|
||||||
getServiceWidget.mockResolvedValue({ type: "ntfy", url: "http://ntfy", topic: "alerts", key: "tk_test" });
|
getServiceWidget.mockResolvedValue({ type: "ntfy", url: "http://ntfy", topic: "alerts", key: "tk_test" });
|
||||||
httpProxy.mockResolvedValue([200, "application/json", { ok: true }]);
|
httpProxy.mockResolvedValue([200, "application/json", { ok: true }]);
|
||||||
|
|||||||
@@ -41,17 +41,15 @@ export default function Component({ service }) {
|
|||||||
status = t("peanut.low_battery");
|
status = t("peanut.low_battery");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
status = upsStatus;
|
status = typeof upsStatus === "string" && upsStatus ? upsStatus : "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const percent = (value) => (value === undefined || value === null ? "-" : t("common.percent", { value }));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block
|
<Block label="peanut.battery_charge" value={percent(batteryCharge)} highlightValue={batteryCharge} />
|
||||||
label="peanut.battery_charge"
|
<Block label="peanut.ups_load" value={percent(upsLoad)} highlightValue={upsLoad} />
|
||||||
value={t("common.percent", { value: batteryCharge })}
|
|
||||||
highlightValue={batteryCharge}
|
|
||||||
/>
|
|
||||||
<Block label="peanut.ups_load" value={t("common.percent", { value: upsLoad })} highlightValue={upsLoad} />
|
|
||||||
<Block label="peanut.ups_status" value={status} />
|
<Block label="peanut.ups_status" value={status} />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -51,4 +51,15 @@ describe("widgets/peanut/component", () => {
|
|||||||
expect(screen.getByText("peanut.online")).toBeInTheDocument();
|
expect(screen.getByText("peanut.online")).toBeInTheDocument();
|
||||||
expect(data).toEqual({ "battery.charge": 55, "ups.load": 12, "ups.status": "OL" });
|
expect(data).toEqual({ "battery.charge": 55, "ups.load": 12, "ups.status": "OL" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("renders dashes when readings are missing", () => {
|
||||||
|
useWidgetAPI.mockReturnValue({
|
||||||
|
data: { "device.model": "OR500LCDRM1Ua", "ups.status": 0 },
|
||||||
|
error: undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
renderWithProviders(<Component service={{ widget: { type: "peanut" } }} />, { settings: { hideErrors: false } });
|
||||||
|
|
||||||
|
expect(screen.getAllByText("-")).toHaveLength(3);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
const widget = {
|
const widget = {
|
||||||
api: "{url}/{endpoint}",
|
api: "{url}/{endpoint}",
|
||||||
proxyHandler: genericProxyHandler,
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
mappings: {
|
mappings: {
|
||||||
containers: {
|
containers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user