mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-23 20:45:49 -07:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 40082f798d | |||
| db480ca991 |
@@ -6,6 +6,7 @@ description: Arcane Widget Configuration
|
||||
Learn more about [Arcane](https://github.com/getarcaneapp/arcane).
|
||||
|
||||
**Allowed fields** (max 4): `running`, `stopped`, `total`, `images`, `images_used`, `images_unused`, `image_updates`.
|
||||
|
||||
**Default fields**: `running`, `stopped`, `total`, `image_updates`.
|
||||
|
||||
```yaml
|
||||
@@ -17,4 +18,4 @@ widget:
|
||||
fields: ["running", "stopped", "total", "image_updates"] # optional
|
||||
```
|
||||
|
||||
Using an api key for the widget requires permissions for: `containers:list` `images:list and `image-updates:read`
|
||||
Using an API key for the widget requires permissions for: `containers:list`, `images:list`, and `image-updates:read`.
|
||||
|
||||
@@ -115,7 +115,6 @@ You can also find a list of all available service widgets in the sidebar navigat
|
||||
- [Prowlarr](prowlarr.md)
|
||||
- [Proxmox](proxmox.md)
|
||||
- [Proxmox Backup Server](proxmoxbackupserver.md)
|
||||
- [PrusaLink](prusalink.md)
|
||||
- [Pterodactyl](pterodactyl.md)
|
||||
- [PyLoad](pyload.md)
|
||||
- [qBittorrent](qbittorrent.md)
|
||||
|
||||
@@ -11,10 +11,13 @@ const widget = {
|
||||
},
|
||||
issues: {
|
||||
endpoint: "repos/issues/search",
|
||||
map: (data) => ({
|
||||
pulls: asJson(data).filter((issue) => issue.pull_request),
|
||||
issues: asJson(data).filter((issue) => !issue.pull_request),
|
||||
}),
|
||||
map: (data) => {
|
||||
const items = asJson(data);
|
||||
return {
|
||||
pulls: items.filter((issue) => issue.pull_request),
|
||||
issues: items.filter((issue) => !issue.pull_request),
|
||||
};
|
||||
},
|
||||
},
|
||||
repositories: {
|
||||
endpoint: "repos/search",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, it } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
@@ -8,4 +8,13 @@ describe("gitea widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
});
|
||||
|
||||
it("splits issues and pull requests", () => {
|
||||
const result = widget.mappings.issues.map(
|
||||
Buffer.from(JSON.stringify([{ id: 1, pull_request: {} }, { id: 2 }, { id: 3 }])),
|
||||
);
|
||||
|
||||
expect(result.pulls.map((i) => i.id)).toEqual([1]);
|
||||
expect(result.issues.map((i) => i.id)).toEqual([2, 3]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,10 +8,13 @@ const widget = {
|
||||
mappings: {
|
||||
counters: {
|
||||
endpoint: "feeds/counters",
|
||||
map: (data) => ({
|
||||
read: Object.values(asJson(data).reads).reduce((acc, i) => acc + i, 0),
|
||||
unread: Object.values(asJson(data).unreads).reduce((acc, i) => acc + i, 0),
|
||||
}),
|
||||
map: (data) => {
|
||||
const { reads, unreads } = asJson(data);
|
||||
return {
|
||||
read: Object.values(reads).reduce((acc, i) => acc + i, 0),
|
||||
unread: Object.values(unreads).reduce((acc, i) => acc + i, 0),
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, it } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
@@ -8,4 +8,12 @@ describe("miniflux widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
});
|
||||
|
||||
it("sums read and unread counters", () => {
|
||||
const result = widget.mappings.counters.map(
|
||||
Buffer.from(JSON.stringify({ reads: { 1: 2, 2: 3 }, unreads: { 1: 4, 2: 1 } })),
|
||||
);
|
||||
|
||||
expect(result).toEqual({ read: 5, unread: 5 });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { asJson, jsonArrayFilter } from "utils/proxy/api-helpers";
|
||||
import { asJson } from "utils/proxy/api-helpers";
|
||||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
@@ -8,15 +8,18 @@ const widget = {
|
||||
mappings: {
|
||||
movie: {
|
||||
endpoint: "movie",
|
||||
map: (data) => ({
|
||||
wanted: jsonArrayFilter(data, (item) => item.monitored && !item.hasFile && item.isAvailable).length,
|
||||
have: jsonArrayFilter(data, (item) => item.hasFile).length,
|
||||
missing: jsonArrayFilter(data, (item) => item.monitored && !item.hasFile).length,
|
||||
all: asJson(data).map((entry) => ({
|
||||
title: entry.title,
|
||||
id: entry.id,
|
||||
})),
|
||||
}),
|
||||
map: (data) => {
|
||||
const movieData = asJson(data) ?? [];
|
||||
return {
|
||||
wanted: movieData.filter((item) => item.monitored && !item.hasFile && item.isAvailable).length,
|
||||
have: movieData.filter((item) => item.hasFile).length,
|
||||
missing: movieData.filter((item) => item.monitored && !item.hasFile).length,
|
||||
all: movieData.map((entry) => ({
|
||||
title: entry.title,
|
||||
id: entry.id,
|
||||
})),
|
||||
};
|
||||
},
|
||||
},
|
||||
"queue/status": {
|
||||
endpoint: "queue/status",
|
||||
|
||||
@@ -33,4 +33,27 @@ describe("radarr widget config", () => {
|
||||
|
||||
expect(queue.map((entry) => entry.movieId)).toEqual([2, 1]);
|
||||
});
|
||||
|
||||
it("maps movie counts and titles", () => {
|
||||
const movies = widget.mappings.movie.map(
|
||||
Buffer.from(
|
||||
JSON.stringify([
|
||||
{ id: 1, title: "A", monitored: true, hasFile: false, isAvailable: true },
|
||||
{ id: 2, title: "B", monitored: true, hasFile: true },
|
||||
{ id: 3, title: "C", monitored: true, hasFile: false, isAvailable: false },
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
expect(movies).toEqual({
|
||||
wanted: 1,
|
||||
have: 1,
|
||||
missing: 2,
|
||||
all: [
|
||||
{ title: "A", id: 1 },
|
||||
{ title: "B", id: 2 },
|
||||
{ title: "C", id: 3 },
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,10 +8,13 @@ const widget = {
|
||||
mappings: {
|
||||
workers: {
|
||||
endpoint: "workers/status",
|
||||
map: (data) => ({
|
||||
total_workers: asJson(data).workers_status.length,
|
||||
active_workers: asJson(data).workers_status.filter((worker) => !worker.idle).length,
|
||||
}),
|
||||
map: (data) => {
|
||||
const workers = asJson(data).workers_status;
|
||||
return {
|
||||
total_workers: workers.length,
|
||||
active_workers: workers.filter((worker) => !worker.idle).length,
|
||||
};
|
||||
},
|
||||
},
|
||||
pending: {
|
||||
method: "POST",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, it } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { expectWidgetConfigShape } from "test-utils/widget-config";
|
||||
|
||||
@@ -8,4 +8,12 @@ describe("unmanic widget config", () => {
|
||||
it("exports a valid widget config", () => {
|
||||
expectWidgetConfigShape(widget);
|
||||
});
|
||||
|
||||
it("counts total and active workers", () => {
|
||||
const result = widget.mappings.workers.map(
|
||||
Buffer.from(JSON.stringify({ workers_status: [{ idle: true }, { idle: false }, { idle: false }] })),
|
||||
);
|
||||
|
||||
expect(result).toEqual({ total_workers: 3, active_workers: 2 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user