feat(definitions): add widget-integration map and default configs
Add static mapping of widget kinds to integration kinds for server-side use without importing @homarr/widgets. Includes default widget configs (size, options, skip), featured integrations list for grid sorting, and default bookmark apps for onboarding dashboard population.
This commit is contained in:
2 files changed
+97
No files matched your search
@@ -12,5 +12,6 @@ export * from "./docs";
|
|||||||
export * from "./cookie";
|
export * from "./cookie";
|
||||||
export * from "./search-engine";
|
export * from "./search-engine";
|
||||||
export * from "./onboarding";
|
export * from "./onboarding";
|
||||||
|
export * from "./widget-integration-map";
|
||||||
export * from "./emptysuperjson";
|
export * from "./emptysuperjson";
|
||||||
export * from "./hotkeys";
|
export * from "./hotkeys";
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
import { createDocumentationLink } from "./docs";
|
||||||
|
import type { IntegrationKind } from "./integration";
|
||||||
|
import { getIntegrationKindsByCategory } from "./integration";
|
||||||
|
import type { WidgetKind } from "./widget";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Static mapping of widget kinds to the integration kinds they support.
|
||||||
|
* Mirrors the supportedIntegrations declared in each widget definition
|
||||||
|
* but lives in @homarr/definitions so server-side code (API layer)
|
||||||
|
* can use it without importing @homarr/widgets.
|
||||||
|
*/
|
||||||
|
export const widgetIntegrationSupport: Partial<Record<WidgetKind, readonly IntegrationKind[]>> = {
|
||||||
|
dnsHoleSummary: getIntegrationKindsByCategory("dnsHole"),
|
||||||
|
dnsHoleControls: getIntegrationKindsByCategory("dnsHole"),
|
||||||
|
"smartHome-entityState": getIntegrationKindsByCategory("smartHomeServer"),
|
||||||
|
"smartHome-executeAutomation": getIntegrationKindsByCategory("smartHomeServer"),
|
||||||
|
mediaServer: getIntegrationKindsByCategory("mediaService"),
|
||||||
|
calendar: getIntegrationKindsByCategory("calendar"),
|
||||||
|
downloads: getIntegrationKindsByCategory("downloadClient"),
|
||||||
|
"mediaRequests-requestList": getIntegrationKindsByCategory("mediaRequest"),
|
||||||
|
"mediaRequests-requestStats": getIntegrationKindsByCategory("mediaRequest"),
|
||||||
|
mediaTranscoding: getIntegrationKindsByCategory("mediaTranscoding"),
|
||||||
|
networkControllerSummary: getIntegrationKindsByCategory("networkController"),
|
||||||
|
networkControllerStatus: getIntegrationKindsByCategory("networkController"),
|
||||||
|
indexerManager: getIntegrationKindsByCategory("indexerManager"),
|
||||||
|
healthMonitoring: getIntegrationKindsByCategory("healthMonitoring"),
|
||||||
|
firewall: getIntegrationKindsByCategory("firewall"),
|
||||||
|
notifications: getIntegrationKindsByCategory("notifications"),
|
||||||
|
mediaReleases: ["emby", "jellyfin", "plex"],
|
||||||
|
systemResources: ["dashDot", "openmediavault", "truenas", "unraid", "glances"],
|
||||||
|
systemDisks: ["dashDot", "openmediavault", "truenas", "unraid"],
|
||||||
|
coolify: ["coolify"],
|
||||||
|
timetable: ["searchCh"],
|
||||||
|
"immich-serverStats": ["immich"],
|
||||||
|
"immich-albumCarousel": ["immich"],
|
||||||
|
tracearr: ["tracearr"],
|
||||||
|
speedtestTracker: ["speedtestTracker"],
|
||||||
|
anchorNote: ["anchor"],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getWidgetKindsForIntegration = (integrationKind: IntegrationKind): WidgetKind[] => {
|
||||||
|
const result: WidgetKind[] = [];
|
||||||
|
for (const [widgetKind, supportedIntegrations] of Object.entries(widgetIntegrationSupport)) {
|
||||||
|
if (supportedIntegrations.includes(integrationKind)) {
|
||||||
|
result.push(widgetKind as WidgetKind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface DefaultWidgetConfig {
|
||||||
|
kind: WidgetKind;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
options?: Record<string, unknown>;
|
||||||
|
skip?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const defaultWidgetConfigs: DefaultWidgetConfig[] = [
|
||||||
|
{ kind: "clock", width: 2, height: 1 },
|
||||||
|
{ kind: "weather", width: 2, height: 1, options: { showCity: true, hasForecast: true, forecastDayCount: 3 } },
|
||||||
|
{ kind: "bookmarks", width: 2, height: 1, options: { title: "Useful Links", layout: "grid", openNewTab: true } },
|
||||||
|
{ kind: "timetable", width: 2, height: 2, skip: true },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const generalWidgets: WidgetKind[] = defaultWidgetConfigs
|
||||||
|
.filter((config) => !config.skip)
|
||||||
|
.map((config) => config.kind);
|
||||||
|
|
||||||
|
export const featuredIntegrations: readonly IntegrationKind[] = [
|
||||||
|
"sonarr",
|
||||||
|
"radarr",
|
||||||
|
"prowlarr",
|
||||||
|
"sabNzbd",
|
||||||
|
"qBittorrent",
|
||||||
|
"jellyseerr",
|
||||||
|
"jellyfin",
|
||||||
|
];
|
||||||
|
|
||||||
|
export const defaultBookmarkApps = [
|
||||||
|
{
|
||||||
|
name: "Homarr Docs",
|
||||||
|
href: createDocumentationLink("/docs/getting-started"),
|
||||||
|
iconUrl: "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/homarr.svg",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Homarr GitHub",
|
||||||
|
href: "https://github.com/homarr-labs/homarr",
|
||||||
|
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/svg/github.svg",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Help Translate",
|
||||||
|
href: createDocumentationLink("/docs/community/translations"),
|
||||||
|
iconUrl: "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/homarr.svg",
|
||||||
|
},
|
||||||
|
];
|
||||||
Reference in new issue
Block a user