Merge remote-tracking branch 'origin/dev' into HEAD

# Conflicts:
#	packages/integrations/src/navidrome/test/navidrome-integration.spec.ts
This commit is contained in:
ajnart committed 2026-07-31 20:19:26 +02:00
commit fe5d8e9468
10 files changed
+47 -219

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
## [1.73.0](https://github.com/homarr-labs/homarr/compare/v1.72.0...v1.73.0) (2026-07-31)
## [1.72.0](https://github.com/homarr-labs/homarr/compare/v1.71.0...v1.72.0) (2026-07-24) ## [1.72.0](https://github.com/homarr-labs/homarr/compare/v1.71.0...v1.72.0) (2026-07-24)
## [1.71.0](https://github.com/homarr-labs/homarr/compare/v1.70.0...v1.71.0) (2026-07-17) ## [1.71.0](https://github.com/homarr-labs/homarr/compare/v1.70.0...v1.71.0) (2026-07-17)
+24 -22
View File
@@ -1,43 +1,45 @@
--- ---
title: 'Audio Stats' title: "Audio Stats"
description: 'Displays library statistics from Navidrome or Audiobookshelf, adapting its display based on the linked integration.' description: "Displays media and listening statistics from Navidrome or Audiobookshelf, adapting its display based on the linked integration."
hide_title: true hide_title: true
--- ---
import { WidgetHeader } from '@site/src/components/widgets/header'; import { WidgetHeader } from "@site/src/components/widgets/header";
import { AddingWidget } from '@site/src/components/widgets/adding'; import { AddingWidget } from "@site/src/components/widgets/adding";
import { WidgetConfig } from '@site/src/components/widgets/configuration'; import { WidgetConfig } from "@site/src/components/widgets/configuration";
import { WidgetIntegrations } from '@site/src/components/widgets/integrations'; import { WidgetIntegrations } from "@site/src/components/widgets/integrations";
import { audioStatsWidget } from '.'; import { audioStatsWidget } from ".";
import { navidromeIntegration } from '@site/docs/integrations/navidrome'; import { navidromeIntegration } from "@site/docs/integrations/navidrome";
import { audiobookshelfIntegration } from '@site/docs/integrations/audiobookshelf'; import { audiobookshelfIntegration } from "@site/docs/integrations/audiobookshelf";
<WidgetHeader widget={audioStatsWidget} categories={["Media"]} />
<WidgetHeader
widget={audioStatsWidget}
categories={['Media']}
/>
This widget adapts its display based on the linked integration: This widget adapts its display based on the linked integration:
- **Navidrome**: Shows artist, album, and song counts, plus a now playing section with active streams - **Navidrome**: Shows artist, album, and song counts
- **Audiobookshelf**: Shows library count, audiobook/podcast totals, listening time, and active sessions - **Audiobookshelf**: Shows library count, audiobook/podcast totals, listening time, and active sessions
Only options relevant to your linked integration are shown in the configuration panel. Only options relevant to your linked integration are shown in the configuration panel.
### Supported Integrations ### Supported Integrations
<WidgetIntegrations items={[{ <WidgetIntegrations
integration: navidromeIntegration, items={[
note: "Displays music library stats and now playing" {
}, { integration: navidromeIntegration,
integration: audiobookshelfIntegration, note: "Displays music library statistics",
note: "Displays audiobook/podcast library stats and listening time" },
}]} /> {
integration: audiobookshelfIntegration,
note: "Displays audiobook/podcast library stats and listening time",
},
]}
/>
### Adding the widget ### Adding the widget
<AddingWidget /> <AddingWidget />
### Configuration ### Configuration
<WidgetConfig configuration={audioStatsWidget.configuration} /> <WidgetConfig configuration={audioStatsWidget.configuration} />
@@ -27,24 +27,6 @@ export const audioStatsWidget: WidgetDefinition = {
values: { type: "boolean" }, values: { type: "boolean" },
defaultValue: "yes", defaultValue: "yes",
}, },
{
name: "Show now playing",
description: "Displays currently playing tracks (Navidrome only)",
values: { type: "boolean" },
defaultValue: "yes",
},
{
name: "Show now playing list",
description: "Displays a detailed list of now playing tracks (Navidrome only)",
values: { type: "boolean" },
defaultValue: "yes",
},
{
name: "Max now playing items",
description: "Maximum number of now playing tracks to display (Navidrome only)",
values: "Number (1-5)",
defaultValue: "3",
},
{ {
name: "Show library count", name: "Show library count",
description: "Displays the number of libraries (Audiobookshelf only)", description: "Displays the number of libraries (Audiobookshelf only)",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "homarr", "name": "homarr",
"version": "1.72.0", "version": "1.73.0",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "cross-env CI=true turbo build", "build": "cross-env CI=true turbo build",
@@ -55,17 +55,15 @@ export class NavidromeIntegration extends Integration implements IMediaServerInt
} }
public async getDashboardDataAsync(): Promise<NavidromeDashboardData> { public async getDashboardDataAsync(): Promise<NavidromeDashboardData> {
const [artistCount, libraryCounts, nowPlaying] = await Promise.all([ const [artistCount, libraryCounts] = await Promise.all([
this.getArtistCountAsync(), this.getArtistCountAsync(),
this.getAlbumAndSongCountsAsync(), this.getAlbumAndSongCountsAsync(),
this.getNowPlayingAsync(),
]); ]);
return { return {
artistCount, artistCount,
albumCount: libraryCounts.albumCount, albumCount: libraryCounts.albumCount,
songCount: libraryCounts.songCount, songCount: libraryCounts.songCount,
nowPlaying,
}; };
} }
@@ -67,5 +67,4 @@ export interface NavidromeDashboardData {
artistCount: number; artistCount: number;
albumCount: number; albumCount: number;
songCount: number; songCount: number;
nowPlaying: NavidromeNowPlayingEntry[];
} }
@@ -1,6 +1,12 @@
// @vitest-environment node
import { Response } from "undici"; import { Response } from "undici";
import { beforeEach, describe, expect, test, vi } from "vitest"; import { beforeEach, describe, expect, test, vi } from "vitest";
vi.hoisted(() => {
process.env.SKIP_ENV_VALIDATION = "true";
process.env.SECRET_ENCRYPTION_KEY = "0".repeat(64);
});
import { fetchWithTrustedCertificatesAsync } from "@homarr/core/infrastructure/http"; import { fetchWithTrustedCertificatesAsync } from "@homarr/core/infrastructure/http";
import type { IntegrationSecret } from "../../base/types"; import type { IntegrationSecret } from "../../base/types";
@@ -39,19 +45,19 @@ const subsonicFailed = (message: string, code = 70) =>
"subsonic-response": { status: "failed", error: { code, message } }, "subsonic-response": { status: "failed", error: { code, message } },
}); });
const makeAlbums = (count: number, songCount: number) =>
Array.from({ length: count }, (_, index) => ({
id: `album-${index}`,
name: `Album ${index}`,
songCount,
}));
beforeEach(() => { beforeEach(() => {
mockFetch.mockReset(); mockFetch.mockReset();
}); });
describe("NavidromeIntegration.getDashboardDataAsync", () => { describe("NavidromeIntegration.getDashboardDataAsync", () => {
test("paginates album list and counts songs", async () => { test("paginates album list and counts songs", async () => {
const makeAlbums = (count: number, songCount: number) =>
Array.from({ length: count }, (_, i) => ({
id: `album-${i}`,
name: `Album ${i}`,
songCount,
}));
mockFetch.mockImplementation((url) => { mockFetch.mockImplementation((url) => {
const urlStr = toUrlString(url); const urlStr = toUrlString(url);
@@ -84,13 +90,7 @@ describe("NavidromeIntegration.getDashboardDataAsync", () => {
>; >;
} }
if (urlStr.includes("getNowPlaying")) { return Promise.reject(new Error(`Unexpected dashboard request: ${urlStr}`)) as unknown as ReturnType<
return Promise.resolve(new Response(subsonicOk({ nowPlaying: {} }), { status: 200 })) as unknown as ReturnType<
typeof fetchWithTrustedCertificatesAsync
>;
}
return Promise.resolve(new Response(subsonicOk({}), { status: 200 })) as unknown as ReturnType<
typeof fetchWithTrustedCertificatesAsync typeof fetchWithTrustedCertificatesAsync
>; >;
}); });
@@ -101,7 +101,6 @@ describe("NavidromeIntegration.getDashboardDataAsync", () => {
expect(result.albumCount).toBe(700); expect(result.albumCount).toBe(700);
expect(result.songCount).toBe(500 * 10 + 200 * 5); expect(result.songCount).toBe(500 * 10 + 200 * 5);
expect(result.artistCount).toBe(1); expect(result.artistCount).toBe(1);
expect(result.nowPlaying).toEqual([]);
}); });
test("handles empty library gracefully", async () => { test("handles empty library gracefully", async () => {
@@ -120,13 +119,7 @@ describe("NavidromeIntegration.getDashboardDataAsync", () => {
) as unknown as ReturnType<typeof fetchWithTrustedCertificatesAsync>; ) as unknown as ReturnType<typeof fetchWithTrustedCertificatesAsync>;
} }
if (urlStr.includes("getNowPlaying")) { return Promise.reject(new Error(`Unexpected dashboard request: ${urlStr}`)) as unknown as ReturnType<
return Promise.resolve(
new Response(subsonicFailed("Library not found or empty"), { status: 200 }),
) as unknown as ReturnType<typeof fetchWithTrustedCertificatesAsync>;
}
return Promise.resolve(new Response(subsonicOk({}), { status: 200 })) as unknown as ReturnType<
typeof fetchWithTrustedCertificatesAsync typeof fetchWithTrustedCertificatesAsync
>; >;
}); });
@@ -137,7 +130,6 @@ describe("NavidromeIntegration.getDashboardDataAsync", () => {
expect(result.artistCount).toBe(0); expect(result.artistCount).toBe(0);
expect(result.albumCount).toBe(0); expect(result.albumCount).toBe(0);
expect(result.songCount).toBe(0); expect(result.songCount).toBe(0);
expect(result.nowPlaying).toEqual([]);
}); });
test("throws on non-empty-library subsonic error", async () => { test("throws on non-empty-library subsonic error", async () => {
@@ -151,53 +143,6 @@ describe("NavidromeIntegration.getDashboardDataAsync", () => {
const integration = createIntegration(); const integration = createIntegration();
await expect(integration.getDashboardDataAsync()).rejects.toThrow(); await expect(integration.getDashboardDataAsync()).rejects.toThrow();
}); });
test("now playing maps entries correctly", async () => {
mockFetch.mockImplementation((url) => {
const urlStr = toUrlString(url);
if (urlStr.includes("getNowPlaying")) {
return Promise.resolve(
new Response(
subsonicOk({
nowPlaying: {
entry: { title: "Song", artist: "Band", album: "LP", username: "user1", playerName: "Chrome" },
},
}),
{ status: 200 },
),
) as unknown as ReturnType<typeof fetchWithTrustedCertificatesAsync>;
}
if (urlStr.includes("getArtists")) {
return Promise.resolve(new Response(subsonicOk({ artists: {} }), { status: 200 })) as unknown as ReturnType<
typeof fetchWithTrustedCertificatesAsync
>;
}
if (urlStr.includes("getAlbumList2")) {
return Promise.resolve(new Response(subsonicOk({ albumList2: {} }), { status: 200 })) as unknown as ReturnType<
typeof fetchWithTrustedCertificatesAsync
>;
}
return Promise.resolve(new Response(subsonicOk({}), { status: 200 })) as unknown as ReturnType<
typeof fetchWithTrustedCertificatesAsync
>;
});
const integration = createIntegration();
const result = await integration.getDashboardDataAsync();
expect(result.nowPlaying).toHaveLength(1);
expect(result.nowPlaying[0]).toEqual({
title: "Song",
artist: "Band",
album: "LP",
username: "user1",
playerName: "Chrome",
});
});
}); });
describe("NavidromeIntegration.getCurrentSessionsAsync", () => { describe("NavidromeIntegration.getCurrentSessionsAsync", () => {
@@ -331,8 +276,9 @@ describe("NavidromeIntegration.getCurrentSessionsAsync", () => {
const integration = createIntegration(); const integration = createIntegration();
await expect(integration.getCurrentSessionsAsync({ showOnlyPlaying: true })).rejects.toThrow( await expect(integration.getCurrentSessionsAsync({ showOnlyPlaying: true })).rejects.toMatchObject({
"An unknown error occured while executing Integration method", message: "An unknown error occured while executing Integration method",
); cause: { message: "Wrong username or password" },
});
}); });
}); });
-14
View File
@@ -3779,18 +3779,6 @@
"label": "Show songs", "label": "Show songs",
"description": "Show the total number of songs in your music library (Navidrome)" "description": "Show the total number of songs in your music library (Navidrome)"
}, },
"showNowPlaying": {
"label": "Show now playing",
"description": "Show tracks currently being played (Navidrome)"
},
"showNowPlayingList": {
"label": "Show now playing list",
"description": "Show individual tracks instead of only the active stream count (Navidrome)"
},
"maxNowPlayingItems": {
"label": "Max now playing items",
"description": "Maximum number of tracks to show in the now playing list (Navidrome)"
},
"showLibraryCount": { "showLibraryCount": {
"label": "Show library count", "label": "Show library count",
"description": "Show the number of libraries on your instance (Audiobookshelf)" "description": "Show the number of libraries on your instance (Audiobookshelf)"
@@ -3824,8 +3812,6 @@
"podcasts": "Podcasts", "podcasts": "Podcasts",
"listeningTime": "Listening Time", "listeningTime": "Listening Time",
"activeSessions": "Active Sessions", "activeSessions": "Active Sessions",
"nowPlaying": "Now Playing",
"nowPlayingCount": "{count, plural, one {# stream} other {# streams}}",
"error": { "error": {
"internalServerError": "Failed to fetch audio stats data" "internalServerError": "Failed to fetch audio stats data"
} }
@@ -42,7 +42,6 @@ describe("getVisibleStats", () => {
artistCount: 100, artistCount: 100,
albumCount: 200, albumCount: 200,
songCount: 3000, songCount: 3000,
nowPlaying: [],
}; };
const audiobookshelfStats: AudiobookshelfDashboardData = { const audiobookshelfStats: AudiobookshelfDashboardData = {
@@ -87,92 +87,6 @@
font-size: clamp(11px, 4cqi, 16px); font-size: clamp(11px, 4cqi, 16px);
} }
.nowPlaying {
display: flex;
flex-direction: column;
gap: clamp(3px, 1.2cqi, 5px);
flex: 1;
min-height: 0;
overflow: hidden;
}
.nowPlayingHeader {
display: flex;
align-items: center;
gap: clamp(4px, 1.5cqi, 6px);
font-size: clamp(10px, 2.8cqi, 12px);
font-weight: 600;
flex-shrink: 0;
min-width: 0;
}
.nowPlayingTitle {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.nowPlayingCount {
flex-shrink: 0;
margin-inline-start: auto;
}
.nowPlayingList {
display: flex;
flex-direction: column;
gap: clamp(2px, 0.8cqi, 4px);
flex: 1;
min-height: 0;
overflow: hidden;
}
.nowPlayingItem {
display: flex;
align-items: center;
justify-content: space-between;
gap: clamp(4px, 1.5cqi, 6px);
padding: clamp(3px, 1.2cqi, 6px) clamp(4px, 1.5cqi, 8px);
border-radius: var(--mantine-radius-sm);
background-color: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-6));
min-width: 0;
flex-shrink: 0;
}
.trackInfo {
display: flex;
flex-direction: column;
gap: 1px;
min-width: 0;
flex: 1;
}
.trackTitle {
font-size: clamp(9px, 2.6cqi, 12px);
font-weight: 500;
line-height: 1.2;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.trackArtist {
font-size: clamp(8px, 2.2cqi, 10px);
color: var(--mantine-color-dimmed);
line-height: 1.2;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.trackUser {
flex-shrink: 0;
max-width: clamp(40px, 22cqi, 88px);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.emptyState { .emptyState {
display: flex; display: flex;
flex: 1; flex: 1;