51 lines
2.1 KiB
TypeScript
51 lines
2.1 KiB
TypeScript
import { IconHeadphones, IconServerOff } from "@tabler/icons-react";
|
|
|
|
import { createWidgetDefinition } from "../definition";
|
|
import { optionsBuilder } from "../options";
|
|
|
|
const hideUnlessNavidrome = {
|
|
shouldHide: (_: unknown, integrationKinds: string[]) => !integrationKinds.includes("navidrome"),
|
|
};
|
|
|
|
const hideUnlessAudiobookshelf = {
|
|
shouldHide: (_: unknown, integrationKinds: string[]) => !integrationKinds.includes("audiobookshelf"),
|
|
};
|
|
|
|
export const { definition, componentLoader } = createWidgetDefinition("audioStats", {
|
|
icon: IconHeadphones,
|
|
supportedIntegrations: ["navidrome", "audiobookshelf"],
|
|
integrationsRequired: true,
|
|
maxIntegrations: 1,
|
|
createOptions() {
|
|
return optionsBuilder.from(
|
|
(factory) => ({
|
|
showArtists: factory.switch({ defaultValue: true, withDescription: true }),
|
|
showAlbums: factory.switch({ defaultValue: true, withDescription: true }),
|
|
showSongs: factory.switch({ defaultValue: true, withDescription: true }),
|
|
showLibraryCount: factory.switch({ defaultValue: true, withDescription: true }),
|
|
showAudiobooks: factory.switch({ defaultValue: true, withDescription: true }),
|
|
showPodcasts: factory.switch({ defaultValue: true, withDescription: true }),
|
|
showListeningTime: factory.switch({ defaultValue: true, withDescription: true }),
|
|
showActiveSessions: factory.switch({ defaultValue: true, withDescription: true }),
|
|
compactMode: factory.switch({ defaultValue: false, withDescription: true }),
|
|
}),
|
|
{
|
|
showArtists: hideUnlessNavidrome,
|
|
showAlbums: hideUnlessNavidrome,
|
|
showSongs: hideUnlessNavidrome,
|
|
showLibraryCount: hideUnlessAudiobookshelf,
|
|
showAudiobooks: hideUnlessAudiobookshelf,
|
|
showPodcasts: hideUnlessAudiobookshelf,
|
|
showListeningTime: hideUnlessAudiobookshelf,
|
|
showActiveSessions: hideUnlessAudiobookshelf,
|
|
},
|
|
);
|
|
},
|
|
errors: {
|
|
INTERNAL_SERVER_ERROR: {
|
|
icon: IconServerOff,
|
|
message: (t) => t("widget.audioStats.error.internalServerError"),
|
|
},
|
|
},
|
|
}).withDynamicImport(() => import("./component"));
|