Enhancement: Add album count to Jellyfin widget (#6974)

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
Alex Clarke
2026-08-13 01:07:58 +01:00
committed by GitHub
parent 1a047d1dfc
commit 8621eb79c1
3 changed files with 29 additions and 2 deletions
+2 -1
View File
@@ -132,7 +132,8 @@
"movies": "Movies",
"series": "Series",
"episodes": "Episodes",
"songs": "Songs"
"songs": "Songs",
"albums": "Albums"
},
"esphome": {
"offline": "Offline",
+9
View File
@@ -176,6 +176,13 @@ function SessionEntry({ playCommand, session, enableUser, showEpisodeNumber, ena
function CountBlocks({ service, countData }) {
const { t } = useTranslation();
const { widget } = service;
if (!widget.fields || widget.fields.length === 0) {
widget.fields = ["movies", "series", "episodes", "songs"];
} else if (widget.fields?.length > 4) {
widget.fields = widget.fields.slice(0, 4);
}
if (!countData) {
return (
@@ -184,6 +191,7 @@ function CountBlocks({ service, countData }) {
<Block label="jellyfin.series" />
<Block label="jellyfin.episodes" />
<Block label="jellyfin.songs" />
<Block label="jellyfin.albums" />
</Container>
);
}
@@ -194,6 +202,7 @@ function CountBlocks({ service, countData }) {
<Block label="jellyfin.series" value={t("common.number", { value: countData.SeriesCount })} />
<Block label="jellyfin.episodes" value={t("common.number", { value: countData.EpisodeCount })} />
<Block label="jellyfin.songs" value={t("common.number", { value: countData.SongCount })} />
<Block label="jellyfin.albums" value={t("common.number", { value: countData.AlbumCount })} />
</Container>
);
}
+18 -1
View File
@@ -40,7 +40,7 @@ describe("widgets/jellyfin/component", () => {
useWidgetAPI
.mockReturnValueOnce({ data: [], error: undefined, mutate: vi.fn() }) // sessions
.mockReturnValueOnce({
data: { MovieCount: 1, SeriesCount: 2, EpisodeCount: 3, SongCount: 4 },
data: { MovieCount: 1, SeriesCount: 2, EpisodeCount: 3, SongCount: 4, AlbumCount: 5 },
error: undefined,
}); // count
@@ -89,4 +89,21 @@ describe("widgets/jellyfin/component", () => {
expect(screen.getByText(/00:00/)).toBeInTheDocument();
expect(screen.getByText(/01:00/)).toBeInTheDocument();
});
it("renders optional albums field when included", () => {
useWidgetAPI
.mockReturnValueOnce({ data: [], error: undefined, mutate: vi.fn() }) // sessions
.mockImplementation(() => ({
data: { MovieCount: 1, SeriesCount: 2, EpisodeCount: 3, SongCount: 4, AlbumCount: 5 },
error: undefined,
}));
renderWithProviders(
<Component
service={{
widget: { type: "jellyfin", url: "http://x", fields: ["movies", "series", "episodes", "albums"] },
}}
/>,
);
});
});