refactor: simplify widget and integration architecture
No files matched your search
@@ -6,6 +6,8 @@ import { optionsBuilder } from "../options";
|
||||
export const { definition, componentLoader } = createWidgetDefinition("airQuality", {
|
||||
icon: IconWind,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "airQuality", "atLocation"]],
|
||||
refetchInterval: 900,
|
||||
queryMatcher: ({ input }, scope) => {
|
||||
const location = scope.options.location;
|
||||
if (location === null || typeof location !== "object" || !("latitude" in location) || !("longitude" in location)) {
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { IconNotes } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("anchorNote", {
|
||||
icon: IconNotes,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "anchorNotes"]],
|
||||
...getWidgetIntegrationConfig("anchorNote"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
noteId: factory.anchorNote(),
|
||||
|
||||
@@ -16,6 +16,7 @@ import { optionsBuilder } from "../options";
|
||||
export const { definition, componentLoader } = createWidgetDefinition("app", {
|
||||
icon: IconApps,
|
||||
supportsAdvancedFocus: false,
|
||||
queryKeys: [[["app", "byId"]], [["widget", "app", "ping"]]],
|
||||
createOptions(settings) {
|
||||
return optionsBuilder.from(
|
||||
(factory) => ({
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { IconArchive } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("archiveTeamWarrior", {
|
||||
icon: IconArchive,
|
||||
supportsAdvancedFocus: true,
|
||||
...getWidgetIntegrationConfig("archiveTeamWarrior"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
showBroadcastMessage: factory.switch({
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { IconHeadphones, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition, matchesWidgetRuntimeQuery } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
@@ -14,7 +16,9 @@ const hideUnlessAudiobookshelf = {
|
||||
export const { definition, componentLoader } = createWidgetDefinition("audioStats", {
|
||||
icon: IconHeadphones,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKeys: [[["widget", "audioStats", "getStats"]], [["widget", "mediaServer", "getCurrentStreams"]]],
|
||||
queryMatcher: matchesWidgetRuntimeQuery,
|
||||
...getWidgetIntegrationConfig("audioStats"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from(
|
||||
(factory) => ({
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { IconBadgeCc, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("bazarr", {
|
||||
supportsAdvancedFocus: true,
|
||||
icon: IconBadgeCc,
|
||||
...getWidgetIntegrationConfig("bazarr"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
showMissingEpisodes: factory.switch({
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { IconBell, IconServerOff } from "@tabler/icons-react";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition, matchesWidgetRuntimeQuery, widgetQueryInputMatches } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("beszelAlerts", {
|
||||
icon: IconBell,
|
||||
queryKey: [["widget", "beszel", "getAlerts"]],
|
||||
queryMatcher(query, scope) {
|
||||
const hasRuntimeAlertsQuery = scope.runtimeQueries.some(({ path }) => path.at(-1) === "getAlerts");
|
||||
if (hasRuntimeAlertsQuery) return matchesWidgetRuntimeQuery(query, scope);
|
||||
@@ -16,6 +19,7 @@ export const { definition, componentLoader } = createWidgetDefinition("beszelAle
|
||||
maxHistoryItems: scope.options.maxHistoryItems,
|
||||
});
|
||||
},
|
||||
...getWidgetIntegrationConfig("beszelAlerts"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
showHistory: factory.switch({ defaultValue: true }),
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { IconLayoutGrid, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { statusOptions } from "../beszel/_shared/options";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("beszelSystemGrid", {
|
||||
icon: IconLayoutGrid,
|
||||
queryKey: [["widget", "beszel", "getSystems"]],
|
||||
...getWidgetIntegrationConfig("beszelSystemGrid"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
statusFilter: factory.select({
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { IconChartAreaLine, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition, matchesWidgetRuntimeQuery, widgetQueryInputMatches } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
@@ -17,6 +18,7 @@ const timePeriodOptions = [
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("beszelSystemStats", {
|
||||
icon: IconChartAreaLine,
|
||||
queryKeys: [[["widget", "beszel", "getSystems"]], [["widget", "beszel", "getSystemStats"]]],
|
||||
queryMatcher(query, scope) {
|
||||
if (query.path.at(-1) === "getSystems") {
|
||||
return widgetQueryInputMatches(query.input, { integrationIds: scope.integrationIds });
|
||||
@@ -39,6 +41,7 @@ export const { definition, componentLoader } = createWidgetDefinition("beszelSys
|
||||
(dockerEnabled && widgetQueryInputMatches(query.input, { ...expected, includeDocker: true }))
|
||||
);
|
||||
},
|
||||
...getWidgetIntegrationConfig("beszelSystemStats"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
systemId: factory.integrationSelect({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IconServerOff, IconTable } from "@tabler/icons-react";
|
||||
|
||||
import { invariantTechnicalLabels } from "@homarr/definitions";
|
||||
import { getWidgetIntegrationConfig, invariantTechnicalLabels } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition, matchesWidgetRuntimeQuery, widgetQueryInputMatches } from "../definition";
|
||||
import type { SelectOption } from "../_inputs/widget-select-input";
|
||||
@@ -28,10 +28,12 @@ const sortDirectionOptions = [
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("beszelSystemTable", {
|
||||
icon: IconTable,
|
||||
queryKeys: [[["widget", "beszel", "getSystems"]], [["widget", "beszel", "getSystemStats"]]],
|
||||
queryMatcher: (query, scope) =>
|
||||
query.path.at(-1) === "getSystems"
|
||||
? widgetQueryInputMatches(query.input, { integrationIds: scope.integrationIds })
|
||||
: matchesWidgetRuntimeQuery(query, scope),
|
||||
...getWidgetIntegrationConfig("beszelSystemTable"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from(
|
||||
(factory) => ({
|
||||
|
||||
@@ -12,6 +12,7 @@ import { createDirectBookmark, getBookmarkFaviconUrl, getDirectBookmarkUrl } fro
|
||||
export const { definition, componentLoader } = createWidgetDefinition("bookmarks", {
|
||||
icon: IconBookmark,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["app", "byIds"]],
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
title: factory.text(),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { IconCalendar } from "@tabler/icons-react";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
import { radarrReleaseTypes } from "@homarr/integrations/types";
|
||||
|
||||
import { createWidgetDefinition, matchesWidgetRuntimeQuery } from "../definition";
|
||||
@@ -9,6 +10,7 @@ import { optionsBuilder } from "../options";
|
||||
export const { definition, componentLoader } = createWidgetDefinition("calendar", {
|
||||
icon: IconCalendar,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "calendar", "findAllEvents"]],
|
||||
queryMatcher: matchesWidgetRuntimeQuery,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
@@ -32,4 +34,5 @@ export const { definition, componentLoader } = createWidgetDefinition("calendar"
|
||||
}),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("calendar"),
|
||||
}).withDynamicImport(() => import("./component"));
|
||||
@@ -15,6 +15,7 @@ const timeZoneOptions = getTimeZoneOptions();
|
||||
export const { definition, componentLoader } = createWidgetDefinition("clock", {
|
||||
icon: IconClock,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "weather", "atLocation"]],
|
||||
queryMatcher: ({ input }, scope) => {
|
||||
const location = scope.options.weatherLocation;
|
||||
if (
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { IconCloud, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
@@ -19,6 +21,7 @@ export const { definition, componentLoader } = createWidgetDefinition("coolify",
|
||||
}),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("coolify"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconServerOff,
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import type React from "react";
|
||||
import type { LoaderComponent } from "next/dynamic";
|
||||
import type { QueryClient, QueryKey } from "@tanstack/react-query";
|
||||
import { hashKey } from "@tanstack/react-query";
|
||||
import type { DefaultErrorData } from "@trpc/server/unstable-core-do-not-import";
|
||||
|
||||
import type { IntegrationKind, NativeFeatureCapabilityDescriptor, WidgetKind } from "@homarr/definitions";
|
||||
import { widgetFeatureCatalog } from "@homarr/definitions";
|
||||
import type { IntegrationKind, WidgetKind } from "@homarr/definitions";
|
||||
import type { ServerSettings } from "@homarr/server-settings";
|
||||
import type { SettingsContextProps } from "@homarr/settings/creator";
|
||||
import type { stringOrTranslation } from "@homarr/translation";
|
||||
@@ -74,86 +72,13 @@ export interface WidgetContextActionProps {
|
||||
widgetRuntimeRef: WidgetRuntimeRef;
|
||||
}
|
||||
|
||||
type WidgetFeatureCapability<TKind extends WidgetKind> = (typeof widgetFeatureCatalog)[TKind] extends {
|
||||
capability: infer TCapability extends NativeFeatureCapabilityDescriptor;
|
||||
}
|
||||
? TCapability
|
||||
: never;
|
||||
|
||||
type WidgetFeatureIntegrationDefinition<TKind extends WidgetKind> = [WidgetFeatureCapability<TKind>] extends [never]
|
||||
? object
|
||||
: {
|
||||
supportedIntegrations: WidgetFeatureCapability<TKind>["integrations"][number][];
|
||||
integrationsRequired: WidgetFeatureCapability<TKind> extends { connectionOptional: true } ? false : true;
|
||||
} & (WidgetFeatureCapability<TKind> extends { serverMaxIntegrations: infer TMax extends number }
|
||||
? { maxIntegrations: TMax }
|
||||
: object);
|
||||
|
||||
type CatalogOwnedWidgetDefinitionKey =
|
||||
| "kind"
|
||||
| "supportedIntegrations"
|
||||
| "integrationsRequired"
|
||||
| "maxIntegrations"
|
||||
| "queryKey"
|
||||
| "queryKeys"
|
||||
| "refetchInterval";
|
||||
|
||||
type WidgetDefinitionInput = Omit<WidgetDefinition, CatalogOwnedWidgetDefinitionKey>;
|
||||
|
||||
type WidgetDefinitionInputWithoutCatalogMetadata<TDefinition extends WidgetDefinitionInput> = TDefinition & {
|
||||
[TKey in CatalogOwnedWidgetDefinitionKey]?: never;
|
||||
};
|
||||
|
||||
type ResolvedWidgetDefinition<TKind extends WidgetKind, TDefinition extends WidgetDefinitionInput> = TDefinition &
|
||||
WidgetFeatureIntegrationDefinition<TKind> & {
|
||||
kind: TKind;
|
||||
queryKey?: QueryKey;
|
||||
queryKeys?: readonly QueryKey[];
|
||||
refetchInterval?: number | null;
|
||||
};
|
||||
|
||||
const resolveWidgetDefinition = <TKind extends WidgetKind, TDefinition extends WidgetDefinitionInput>(
|
||||
kind: TKind,
|
||||
definition: WidgetDefinitionInputWithoutCatalogMetadata<TDefinition>,
|
||||
): ResolvedWidgetDefinition<TKind, TDefinition> => {
|
||||
const descriptor = widgetFeatureCatalog[kind];
|
||||
const resolvedDefinition: WidgetDefinition = {
|
||||
...definition,
|
||||
kind,
|
||||
};
|
||||
|
||||
if ("capability" in descriptor) {
|
||||
const capability = descriptor.capability;
|
||||
const connectionOptional = "connectionOptional" in capability && capability.connectionOptional === true;
|
||||
resolvedDefinition.supportedIntegrations = [...capability.integrations];
|
||||
resolvedDefinition.integrationsRequired = !connectionOptional;
|
||||
if ("serverMaxIntegrations" in capability && capability.serverMaxIntegrations !== undefined) {
|
||||
resolvedDefinition.maxIntegrations = capability.serverMaxIntegrations;
|
||||
}
|
||||
}
|
||||
|
||||
if ("query" in descriptor) {
|
||||
const queryKeys: QueryKey[] = descriptor.query.paths.map((path) => [path]);
|
||||
if (queryKeys.length === 1) {
|
||||
resolvedDefinition.queryKey = queryKeys[0];
|
||||
} else {
|
||||
resolvedDefinition.queryKeys = queryKeys;
|
||||
}
|
||||
if ("refetchIntervalSeconds" in descriptor.query) {
|
||||
resolvedDefinition.refetchInterval = descriptor.query.refetchIntervalSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
return resolvedDefinition as ResolvedWidgetDefinition<TKind, TDefinition>;
|
||||
};
|
||||
|
||||
const createWithDynamicImport =
|
||||
<TKind extends WidgetKind, TDefinition extends WidgetDefinitionInput>(
|
||||
kind: TKind,
|
||||
definition: ResolvedWidgetDefinition<TKind, TDefinition>,
|
||||
) =>
|
||||
(componentLoader: () => LoaderComponent<WidgetComponentProps<TKind>>) => ({
|
||||
definition,
|
||||
<TKind extends WidgetKind, TDefinition extends WidgetDefinition>(kind: TKind, definition: TDefinition) =>
|
||||
(componentLoader: () => Promise<{ default: React.ComponentType<WidgetComponentProps<TKind>> }>) => ({
|
||||
definition: {
|
||||
...definition,
|
||||
kind,
|
||||
},
|
||||
kind,
|
||||
componentLoader,
|
||||
});
|
||||
@@ -167,18 +92,14 @@ export type Prefetch<TKind extends WidgetKind> = (
|
||||
}[],
|
||||
) => Promise<void>;
|
||||
|
||||
export const createWidgetDefinition = <TKind extends WidgetKind, TDefinition extends WidgetDefinitionInput>(
|
||||
export const createWidgetDefinition = <TKind extends WidgetKind, TDefinition extends WidgetDefinition>(
|
||||
kind: TKind,
|
||||
definition: WidgetDefinitionInputWithoutCatalogMetadata<TDefinition>,
|
||||
) => {
|
||||
const resolvedDefinition = resolveWidgetDefinition(kind, definition);
|
||||
return {
|
||||
withDynamicImport: createWithDynamicImport(kind, resolvedDefinition),
|
||||
};
|
||||
};
|
||||
definition: TDefinition,
|
||||
) => ({
|
||||
withDynamicImport: createWithDynamicImport(kind, definition),
|
||||
});
|
||||
|
||||
export interface WidgetDefinition {
|
||||
kind?: WidgetKind;
|
||||
icon: TablerIcon;
|
||||
supportsAdvancedFocus?: boolean;
|
||||
queryKey?: QueryKey;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconDeviceGamepad, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../../definition";
|
||||
import { optionsBuilder } from "../../options";
|
||||
@@ -9,6 +10,8 @@ export const widgetKind = "dnsHoleControls";
|
||||
export const { definition, componentLoader } = createWidgetDefinition(widgetKind, {
|
||||
supportsAdvancedFocus: false,
|
||||
icon: IconDeviceGamepad,
|
||||
queryKey: [["widget", "dnsHole"]],
|
||||
refetchInterval: 10,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
showToggleAllButtons: factory.switch({
|
||||
@@ -16,6 +19,7 @@ export const { definition, componentLoader } = createWidgetDefinition(widgetKind
|
||||
}),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("dnsHoleControls"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconServerOff,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconAd, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../../definition";
|
||||
import { optionsBuilder } from "../../options";
|
||||
@@ -9,6 +10,8 @@ export const widgetKind = "dnsHoleSummary";
|
||||
export const { definition, componentLoader } = createWidgetDefinition(widgetKind, {
|
||||
supportsAdvancedFocus: false,
|
||||
icon: IconAd,
|
||||
queryKey: [["widget", "dnsHole"]],
|
||||
refetchInterval: 10,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
usePiHoleColors: factory.switch({
|
||||
@@ -27,6 +30,7 @@ export const { definition, componentLoader } = createWidgetDefinition(widgetKind
|
||||
}),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("dnsHoleSummary"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconServerOff,
|
||||
|
||||
@@ -27,6 +27,8 @@ const columnTranslationKeyMap = {
|
||||
export const { definition, componentLoader } = createWidgetDefinition("dockerContainers", {
|
||||
icon: IconBrandDocker,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["docker", "getContainers"]],
|
||||
refetchInterval: 30,
|
||||
createOptions() {
|
||||
return optionsBuilder.from(
|
||||
(factory) => ({
|
||||
|
||||
|
Before Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 210 KiB |
|
Before Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 122 KiB |
@@ -1,152 +0,0 @@
|
||||
---
|
||||
title: "Download Client"
|
||||
description: "Allows you to view and manage your Downloads from both Torrent and Usenet clients."
|
||||
hide_title: true
|
||||
---
|
||||
|
||||
import { WidgetInteractionGuide } from "@site/src/components/widgets/interactions";
|
||||
|
||||
import { aria2Integration } from "@site/docs/integrations/aria2";
|
||||
import { delugeIntegration } from "@site/docs/integrations/deluge";
|
||||
import { nzbgetIntegration } from "@site/docs/integrations/nzbget";
|
||||
import { qBittorentIntegration } from "@site/docs/integrations/q-bittorent";
|
||||
import { sabnzbdIntegration } from "@site/docs/integrations/sabnzbd";
|
||||
import { transmissionIntegration } from "@site/docs/integrations/transmission";
|
||||
import { slskdIntegration } from "@site/docs/integrations/slskd";
|
||||
import { AddingWidget } from "@site/src/components/widgets/adding";
|
||||
import { WidgetConfig } from "@site/src/components/widgets/configuration";
|
||||
import { WidgetHeader } from "@site/src/components/widgets/header";
|
||||
import { WidgetIntegrations } from "@site/src/components/widgets/integrations";
|
||||
import { downloadsWidget } from ".";
|
||||
|
||||
<WidgetHeader widget={downloadsWidget} categories={["Torrent client", "Usenet client", "Downloads"]} />
|
||||
|
||||
This widget displays torrent, Usenet, and miscellaneous download jobs, along with their progress and other relevant information. It supports 7 download client integrations and provides a rich, responsive table interface.
|
||||
|
||||
### Screenshots
|
||||
|
||||
import downloadsCard from "./img/screenshot.png";
|
||||
import contextMenuImg from "./img/context-menu.png";
|
||||
import advancedViewImg from "./img/advanced-view.png";
|
||||
import filterPanelImg from "./img/filter-panel.png";
|
||||
|
||||
<div>
|
||||
<img src={downloadsCard} alt="Downloads widget showing torrent and usenet items" width={128 * 4} />
|
||||
</div>
|
||||
|
||||
#### Download-row context menu
|
||||
|
||||
<div>
|
||||
<img src={contextMenuImg} alt="Downloads row context menu with pause, delete, and copy actions" width={128 * 4} />
|
||||
</div>
|
||||
|
||||
#### Advanced view
|
||||
|
||||
<div>
|
||||
<img
|
||||
src={advancedViewImg}
|
||||
alt="Downloads widget in advanced view with stats, sortable columns, and expanded details"
|
||||
width={128 * 6}
|
||||
/>
|
||||
</div>
|
||||
|
||||
#### Advanced filter panel
|
||||
|
||||
<div>
|
||||
<img src={filterPanelImg} alt="Downloads advanced view with the status filter panel open" width={128 * 6} />
|
||||
</div>
|
||||
|
||||
### Features
|
||||
|
||||
- **Responsive compact table** — in compact mode, selected columns adapt to both widget width and height; narrow or short tiles hide speed/state columns, and the shortest tiles also hide the ETA column
|
||||
- **Sortable columns** — click any sortable column header to sort the current view; the configured default controls the initial column and direction
|
||||
- **Column customization** — choose which columns to display, then hover a header to reveal its grab handle for reordering or drag its edge to resize it; layouts save automatically per widget
|
||||
- **Download-row context menu** — copy a download name or ID from any row; pause, resume, and delete actions appear when you have Interact access to that integration
|
||||
- **Row expansion** — click any row to see full details inline without opening a separate modal
|
||||
- **Hover tooltips** — hover a download name to see size, speeds, ETA, ratio, and category; open tooltips close when switching between compact and advanced mode
|
||||
- **Global stats bar** — show queue progress, downloaded/total size, transfer speeds, global torrent ratio, and per-state counts in compact mode; advanced view always includes it
|
||||
- **Client filtering** — filter downloads by integration or status using the footer filter panel
|
||||
- **Global controls** — pause/resume actionable queues from the footer bar, limited to selected integrations where you have Interact access
|
||||
- **Status indicators** — color-coded badges show download state at a glance
|
||||
- **Speed overview** — total download and upload speeds for the selected clients are displayed in the footer
|
||||
|
||||
:::note
|
||||
|
||||
Compact layouts use both dimensions: below 500px wide, speed columns are hidden; below 300px wide, the ETA and state
|
||||
columns are hidden too. A tile shorter than 180px hides speed and state columns, and a tile shorter than 120px also
|
||||
hides ETA. The footer is hidden below 96px in compact mode. Advanced view bypasses these compact size reductions,
|
||||
keeps the selected column set, and always includes the stats bar and footer controls, with the filter panel available
|
||||
from the footer.
|
||||
|
||||
The filter panel changes the visible rows. Its client/status filters also change the stats bar's progress, size, and
|
||||
state counts, while transfer-speed totals summarize the selected clients and the global torrent ratio summarizes the
|
||||
selected torrent clients. The configured category/label filter can optionally be applied to the global torrent ratio
|
||||
through **Use category filter for global torrent ratio**; footer client/status filters do not change that ratio.
|
||||
|
||||
The per-item **Ratio** is sent bytes divided by the item's total size. **Global Ratio** is total uploaded bytes divided
|
||||
by total downloaded bytes.
|
||||
|
||||
Mutation controls depend on the integration's Interact permission. Users without that permission can still view rows and
|
||||
use the row menu's copy actions. `slskd` is list-only: its pause, resume, and delete operations are no-ops, so those
|
||||
controls have no effect for that client even when Interact permission exposes them.
|
||||
|
||||
The screenshot above is a Downloads row menu, separate from the shared widget context menu. When board right-click menus
|
||||
are enabled, the shared menu provides widget-level actions such as advanced view, widget options, refresh, and settings.
|
||||
|
||||
:::
|
||||
|
||||
### Supported Integrations
|
||||
|
||||
<WidgetIntegrations
|
||||
items={[
|
||||
{
|
||||
integration: sabnzbdIntegration,
|
||||
note: "Usenet client",
|
||||
},
|
||||
{
|
||||
integration: nzbgetIntegration,
|
||||
note: "Usenet client",
|
||||
},
|
||||
{
|
||||
integration: delugeIntegration,
|
||||
note: "Torrent client",
|
||||
},
|
||||
{
|
||||
integration: transmissionIntegration,
|
||||
note: "Torrent client",
|
||||
},
|
||||
{
|
||||
integration: qBittorentIntegration,
|
||||
note: "Torrent client",
|
||||
},
|
||||
{
|
||||
integration: aria2Integration,
|
||||
note: "Multi-protocol download client",
|
||||
},
|
||||
{
|
||||
integration: slskdIntegration,
|
||||
note: "Soulseek client (list-only; mutation controls are no-ops)",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
### Interactions
|
||||
|
||||
- **Right-click** any download to copy its name or ID; pause, resume, and delete are available only with Interact access
|
||||
- **Click** any row to expand it and see full download details inline
|
||||
- **Hover** a download name for a quick stats tooltip
|
||||
- **Stats toggle** — show or hide the global stats bar in compact mode; advanced view always shows the stats bar without
|
||||
changing the compact choice
|
||||
- **Pause / Resume** actionable queues using the footer controls
|
||||
- **Filter** rows by integration or status using the filter button in the footer
|
||||
- **Sort** by clicking sortable column headers; the default sort is configured per widget, while header changes apply to the current view
|
||||
|
||||
<WidgetInteractionGuide />
|
||||
|
||||
### Adding the widget
|
||||
|
||||
<AddingWidget />
|
||||
|
||||
### Configuration
|
||||
|
||||
<WidgetConfig configuration={downloadsWidget.configuration} />
|
||||
@@ -1,102 +0,0 @@
|
||||
import { WidgetDefinition } from "@site/src/types";
|
||||
import { IconDownload } from "@tabler/icons-react";
|
||||
|
||||
const columnsList = [
|
||||
"name",
|
||||
"progress",
|
||||
"size",
|
||||
"downSpeed",
|
||||
"upSpeed",
|
||||
"time",
|
||||
"state",
|
||||
"added",
|
||||
"ratio",
|
||||
"received",
|
||||
"sent",
|
||||
"category",
|
||||
"integration",
|
||||
"index",
|
||||
"type",
|
||||
];
|
||||
const sortColumns = columnsList.filter((c) => !["state", "category", "integration"].includes(c));
|
||||
|
||||
export const downloadsWidget: WidgetDefinition = {
|
||||
icon: IconDownload,
|
||||
name: "Download Client",
|
||||
description: "Allows you to view and manage your Downloads from both Torrent and Usenet clients.",
|
||||
path: "../../widgets/downloads",
|
||||
configuration: {
|
||||
items: [
|
||||
{
|
||||
name: "Columns to show",
|
||||
description:
|
||||
"Select the columns you want to display in the widget. Compact layouts automatically hide/show selected columns based on widget width and height; advanced view keeps the selected columns visible.",
|
||||
values: `List of columns: ${columnsList.join(", ")}`,
|
||||
defaultValue: ["name", "progress", "downSpeed", "time", "state"].join(", "),
|
||||
},
|
||||
{
|
||||
name: "Default sort column",
|
||||
description:
|
||||
"The column used for initial sorting when the widget loads. Clicking a column header changes the current view only.",
|
||||
defaultValue: "progress",
|
||||
values: `List of columns: ${sortColumns.join(", ")}`,
|
||||
},
|
||||
{
|
||||
name: "Invert sorting",
|
||||
description: "This sets the initial sorting direction.",
|
||||
values: { type: "boolean" },
|
||||
defaultValue: "no",
|
||||
},
|
||||
{
|
||||
name: "Show usenet entries marked as completed",
|
||||
description: "This will show entries that have been completed in your Usenet client.",
|
||||
values: { type: "boolean" },
|
||||
defaultValue: "yes",
|
||||
},
|
||||
{
|
||||
name: "Show torrent entries marked as completed",
|
||||
description: "This will show entries that have been completed in your Torrent client.",
|
||||
values: { type: "boolean" },
|
||||
defaultValue: "yes",
|
||||
},
|
||||
{
|
||||
name: "Show Miscellaneous entries marked as completed",
|
||||
description: "This will show entries that have been completed in your Miscellaneous client.",
|
||||
values: { type: "boolean" },
|
||||
defaultValue: "yes",
|
||||
},
|
||||
{
|
||||
name: "Hide completed torrent under this threshold (in kiB/s)",
|
||||
description: "This will hide completed torrent entries whose upload speed is below the specified threshold.",
|
||||
values: "Any number above 0, 0 to disable",
|
||||
defaultValue: "0",
|
||||
},
|
||||
{
|
||||
name: "Categories/labels to filter",
|
||||
description: "You can filter the items by categories or labels. Use a comma to separate multiple values.",
|
||||
values: "Comma-separated list of categories or labels",
|
||||
defaultValue: "-",
|
||||
},
|
||||
{
|
||||
name: "Filter as a whitelist",
|
||||
description:
|
||||
"If enabled, only items that match the filter will be shown. If disabled, items that do not match the filter will be hidden.",
|
||||
values: { type: "boolean" },
|
||||
defaultValue: "no",
|
||||
},
|
||||
{
|
||||
name: "Use category filter for global torrent ratio",
|
||||
description:
|
||||
"When enabled, the configured category/label filter is applied to the global torrent ratio. Footer client/status filters do not change this ratio.",
|
||||
values: { type: "boolean" },
|
||||
defaultValue: "yes",
|
||||
},
|
||||
{
|
||||
name: "Limit items per integration",
|
||||
description: "This will limit the number of items shown per integration, not globally.",
|
||||
values: "Any whole number from 1 upward",
|
||||
defaultValue: "50",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -1,11 +1,11 @@
|
||||
import { IconDownload } from "@tabler/icons-react";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { getIntegrationKindsByCategory } from "@homarr/definitions";
|
||||
import { getIntegrationKindsByCategory, getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition, widgetQueryInputMatches } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
import { DOWNLOAD_COLUMN_ACCESSORS } from "./helpers";
|
||||
import { widgetIcon } from "./module.generated";
|
||||
|
||||
const sortColumns = [
|
||||
"name",
|
||||
@@ -23,13 +23,15 @@ const sortColumns = [
|
||||
] as const satisfies readonly (typeof DOWNLOAD_COLUMN_ACCESSORS)[number][];
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("downloads", {
|
||||
icon: widgetIcon,
|
||||
icon: IconDownload,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "downloads", "getJobsAndStatuses"]],
|
||||
queryMatcher: ({ input }, scope) =>
|
||||
widgetQueryInputMatches(input, {
|
||||
integrationIds: scope.integrationIds,
|
||||
limitPerIntegration: scope.options.limitPerIntegration,
|
||||
}),
|
||||
refetchInterval: 10,
|
||||
createOptions() {
|
||||
return optionsBuilder.from(
|
||||
(factory) => ({
|
||||
@@ -109,4 +111,5 @@ export const { definition, componentLoader } = createWidgetDefinition("downloads
|
||||
},
|
||||
);
|
||||
},
|
||||
...getWidgetIntegrationConfig("downloads"),
|
||||
}).withDynamicImport(() => import("./component"));
|
||||
@@ -1,3 +0,0 @@
|
||||
// This file is generated by pnpm widgets:sync. Do not edit it directly.
|
||||
|
||||
export { IconDownload as widgetIcon } from "@tabler/icons-react";
|
||||
@@ -1,38 +0,0 @@
|
||||
import { defineWidgetModule } from "@homarr/definitions";
|
||||
|
||||
export default defineWidgetModule({
|
||||
kind: "downloads",
|
||||
icon: "IconDownload",
|
||||
clientEntry: ".",
|
||||
documentation: {
|
||||
slug: "downloads",
|
||||
sourceDirectory: "docs",
|
||||
},
|
||||
integration: {
|
||||
categories: ["downloadClient"],
|
||||
},
|
||||
operations: [
|
||||
{
|
||||
name: "getJobsAndStatuses",
|
||||
path: ["widget", "downloads", "getJobsAndStatuses"],
|
||||
client: {
|
||||
refetchIntervalSeconds: 10,
|
||||
staleTimeSeconds: 10,
|
||||
persist: true,
|
||||
},
|
||||
serverCache: {
|
||||
namespace: "downloads:jobs-and-status",
|
||||
ttlMs: 10 * 1000,
|
||||
scope: "integration",
|
||||
},
|
||||
},
|
||||
],
|
||||
routers: [
|
||||
{
|
||||
namespace: "downloads",
|
||||
module: "./downloads",
|
||||
exportName: "downloadsRouter",
|
||||
mcp: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -12,7 +12,7 @@ export interface BaseWidgetErrorProps {
|
||||
icon: TablerIcon;
|
||||
message: stringOrTranslation;
|
||||
showLogsLink?: boolean;
|
||||
onRetry?: () => void;
|
||||
onRetry: () => void;
|
||||
}
|
||||
|
||||
export const BaseWidgetError = (props: BaseWidgetErrorProps) => {
|
||||
@@ -39,11 +39,9 @@ export const BaseWidgetError = (props: BaseWidgetErrorProps) => {
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
{props.onRetry && (
|
||||
<Button onClick={props.onRetry} size="sm" variant="light">
|
||||
{tCommon("action.tryAgain")}
|
||||
</Button>
|
||||
)}
|
||||
<Button onClick={props.onRetry} size="sm" variant="light">
|
||||
{tCommon("action.tryAgain")}
|
||||
</Button>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconWall, IconWallOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
@@ -7,9 +8,11 @@ import { optionsBuilder } from "../options";
|
||||
export const { definition, componentLoader } = createWidgetDefinition("firewall", {
|
||||
icon: IconWall,
|
||||
supportsAdvancedFocus: true,
|
||||
refetchInterval: 10,
|
||||
createOptions() {
|
||||
return optionsBuilder.from(() => ({}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("firewall"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconWallOff,
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
// This file is generated by pnpm widgets:sync. Do not edit it directly.
|
||||
|
||||
import type * as widgetModule0 from "../downloads";
|
||||
import type * as widgetModule1 from "../weather";
|
||||
|
||||
export const generatedWidgetModuleLoaders = {
|
||||
downloads: () => import("../downloads"),
|
||||
weather: () => import("../weather"),
|
||||
};
|
||||
|
||||
export interface GeneratedWidgetImports {
|
||||
downloads: typeof widgetModule0;
|
||||
weather: typeof widgetModule1;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconHeartRateMonitor, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
@@ -8,6 +9,8 @@ import { createStorageVolumeMultiSelectOptions } from "../storage-volume-options
|
||||
export const { definition, componentLoader } = createWidgetDefinition("healthMonitoring", {
|
||||
icon: IconHeartRateMonitor,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKeys: [[["integration", "byIds"]], [["widget", "healthMonitoring"]]],
|
||||
refetchInterval: 10,
|
||||
createOptions() {
|
||||
return optionsBuilder.from(
|
||||
(factory) => ({
|
||||
@@ -111,6 +114,7 @@ export const { definition, componentLoader } = createWidgetDefinition("healthMon
|
||||
},
|
||||
);
|
||||
},
|
||||
...getWidgetIntegrationConfig("healthMonitoring"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconServerOff,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { IconChevronLeft, IconChevronRight, IconPhoto, IconPlayerPause } from "@
|
||||
import z from "zod";
|
||||
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
import { useI18n } from "@homarr/translation/client";
|
||||
|
||||
import { createWidgetDefinition, widgetQueryInputMatches } from "../../definition";
|
||||
@@ -52,6 +53,7 @@ const createOptions = () =>
|
||||
export const { definition, componentLoader } = createWidgetDefinition("immich-albumCarousel", {
|
||||
icon: IconPhoto,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "immich", "getAlbum"]],
|
||||
queryMatcher: ({ input }, scope) =>
|
||||
widgetQueryInputMatches(input, {
|
||||
integrationId: scope.integrationIds[0] ?? "",
|
||||
@@ -60,6 +62,8 @@ export const { definition, componentLoader } = createWidgetDefinition("immich-al
|
||||
? scope.options.albumId
|
||||
: undefined,
|
||||
}),
|
||||
refetchInterval: null,
|
||||
...getWidgetIntegrationConfig("immich-albumCarousel"),
|
||||
contextActions: ({ widgetRuntimeRef }) => {
|
||||
const actions = widgetRuntimeRef.current.actions;
|
||||
return [
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import { IconGraphFilled } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition, matchesWidgetRuntimeQuery } from "../../definition";
|
||||
import { optionsBuilder } from "../../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("immich-serverStats", {
|
||||
icon: IconGraphFilled,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKeys: [[["widget", "immich", "getServerStats"]], [["widget", "immich", "getAlbums"]]],
|
||||
queryMatcher: matchesWidgetRuntimeQuery,
|
||||
refetchInterval: null,
|
||||
...getWidgetIntegrationConfig("immich-serverStats"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
showUsers: factory.switch({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconReportSearch, IconServerOff, IconTestPipe } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
@@ -27,7 +28,9 @@ export const { definition, componentLoader } = createWidgetDefinition("indexerMa
|
||||
},
|
||||
},
|
||||
],
|
||||
refetchInterval: null,
|
||||
createOptions,
|
||||
...getWidgetIntegrationConfig("indexerManager"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconServerOff,
|
||||
|
||||
@@ -17,7 +17,13 @@ import { widgetQueryRefetchIntervals } from "./refetch-intervals";
|
||||
import { widgetCatalogIcons } from "./catalog";
|
||||
import { getWidgetQueryKeys } from "./definition";
|
||||
|
||||
const serializePollingPolicy = (entry: { queryKey: QueryKey; intervalSeconds: number | null }) => JSON.stringify(entry);
|
||||
const serializePollingPolicy = ({
|
||||
queryKey,
|
||||
intervalSeconds,
|
||||
}: {
|
||||
queryKey: QueryKey;
|
||||
intervalSeconds: number | null;
|
||||
}) => JSON.stringify({ queryKey, intervalSeconds });
|
||||
|
||||
describe("widget manifest promise stability", () => {
|
||||
it("returns the same module promise for every render", () => {
|
||||
@@ -70,6 +76,7 @@ describe("widget manifest promise stability", () => {
|
||||
const canonicalComponent = await module.componentLoader();
|
||||
const component = await loadWidgetComponent(kind);
|
||||
const resources = await loadWidgetResources(kind);
|
||||
expect(module.definition.kind).toBe(kind);
|
||||
expect(definitions.get(kind)).toBe(module.definition);
|
||||
expect(component.default).toBe(canonicalComponent.default);
|
||||
expect(component.default).toBeDefined();
|
||||
|
||||
@@ -7,20 +7,44 @@ import type { SettingsContextProps } from "@homarr/settings/creator";
|
||||
|
||||
import type { WidgetComponentProps, WidgetDefinition } from "./definition";
|
||||
import type { WidgetOptionDefinition } from "./options";
|
||||
import type { WidgetImports } from "./registry";
|
||||
import { widgetModuleLoaders } from "./registry";
|
||||
|
||||
type WidgetComponentModule = {
|
||||
default: ComponentType<WidgetComponentProps<WidgetKind>>;
|
||||
type RegisteredWidgetModule = WidgetImports[WidgetKind];
|
||||
type RegisteredWidgetComponentModule = Awaited<ReturnType<RegisteredWidgetModule["componentLoader"]>>;
|
||||
type WidgetDefinitionFor<TKind extends WidgetKind> = WidgetImports[TKind]["definition"] & WidgetDefinition;
|
||||
|
||||
type WidgetComponentModule<TKind extends WidgetKind> = {
|
||||
default: ComponentType<WidgetComponentProps<TKind>>;
|
||||
};
|
||||
|
||||
type WidgetModule = {
|
||||
definition: WidgetDefinition;
|
||||
componentLoader: () => Promise<WidgetComponentModule>;
|
||||
export type WidgetModule<TKind extends WidgetKind> = {
|
||||
definition: WidgetDefinitionFor<TKind>;
|
||||
componentLoader: () => Promise<WidgetComponentModule<TKind>>;
|
||||
};
|
||||
|
||||
export type WidgetResources = {
|
||||
export type WidgetResources<TKind extends WidgetKind = WidgetKind> = {
|
||||
definition: WidgetDefinitionFor<TKind>;
|
||||
Component: ComponentType<WidgetComponentProps<TKind>>;
|
||||
};
|
||||
|
||||
type RegisteredWidgetResources = {
|
||||
definition: RegisteredWidgetModule["definition"];
|
||||
Component: RegisteredWidgetComponentModule["default"];
|
||||
};
|
||||
|
||||
type WidgetManifestValue<TKind extends WidgetKind> = {
|
||||
module: WidgetModule<TKind>;
|
||||
component: WidgetComponentModule<TKind>;
|
||||
resources: WidgetResources<TKind>;
|
||||
definition: WidgetDefinitionFor<TKind>;
|
||||
};
|
||||
|
||||
type RegisteredWidgetManifestValue = {
|
||||
module: RegisteredWidgetModule;
|
||||
component: RegisteredWidgetComponentModule;
|
||||
resources: RegisteredWidgetResources;
|
||||
definition: WidgetDefinition;
|
||||
Component: ComponentType<WidgetComponentProps<WidgetKind>>;
|
||||
};
|
||||
|
||||
const definitionPromises = new Map<WidgetKind, Promise<WidgetDefinition>>();
|
||||
@@ -47,52 +71,67 @@ export const createRetryableLoader = <TKey, TValue>(loaders: ReadonlyMap<TKey, (
|
||||
};
|
||||
|
||||
const loadRegisteredWidgetModule = createRetryableLoader(
|
||||
new Map(Object.entries(widgetModuleLoaders) as [WidgetKind, () => Promise<WidgetModule>][]),
|
||||
new Map<WidgetKind, () => Promise<RegisteredWidgetModule>>(objectEntries(widgetModuleLoaders)),
|
||||
);
|
||||
|
||||
export const loadWidgetModule = (kind: WidgetKind) => loadRegisteredWidgetModule(kind);
|
||||
// ponytail: TypeScript cannot express a Map whose value depends on its key. This
|
||||
// private assertion restores only the fixed shapes above; the manifest alignment
|
||||
// test checks module.definition.kind. Its ceiling is runtime-only mismatch
|
||||
// detection, so remove it if TypeScript gains dependent Map value types.
|
||||
const correlateWidgetPromise = <TKind extends WidgetKind, TType extends keyof WidgetManifestValue<TKind>>(
|
||||
_kind: TKind,
|
||||
_type: TType,
|
||||
promise: Promise<RegisteredWidgetManifestValue[TType]>,
|
||||
) => promise as Promise<WidgetManifestValue<TKind>[TType]>;
|
||||
|
||||
export const loadWidgetModule = <TKind extends WidgetKind>(kind: TKind) =>
|
||||
correlateWidgetPromise(kind, "module", loadRegisteredWidgetModule(kind));
|
||||
|
||||
const loadRegisteredWidgetComponent = createRetryableLoader(
|
||||
new Map(
|
||||
new Map<WidgetKind, () => Promise<RegisteredWidgetComponentModule>>(
|
||||
widgetKinds.map((kind) => [
|
||||
kind,
|
||||
async () => {
|
||||
const widgetModule = await loadWidgetModule(kind);
|
||||
const widgetModule = await loadRegisteredWidgetModule(kind);
|
||||
return widgetModule.componentLoader();
|
||||
},
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
export const loadWidgetComponent = (kind: WidgetKind) => loadRegisteredWidgetComponent(kind);
|
||||
export const loadWidgetComponent = <TKind extends WidgetKind>(kind: TKind) =>
|
||||
correlateWidgetPromise(kind, "component", loadRegisteredWidgetComponent(kind));
|
||||
|
||||
const loadRegisteredWidgetResources = createRetryableLoader(
|
||||
new Map(
|
||||
new Map<WidgetKind, () => Promise<RegisteredWidgetResources>>(
|
||||
widgetKinds.map((kind) => [
|
||||
kind,
|
||||
async () => {
|
||||
const [{ definition }, { default: Component }] = await Promise.all([
|
||||
loadWidgetModule(kind),
|
||||
loadWidgetComponent(kind),
|
||||
loadRegisteredWidgetModule(kind),
|
||||
loadRegisteredWidgetComponent(kind),
|
||||
]);
|
||||
return { definition, Component } satisfies WidgetResources;
|
||||
return { definition, Component };
|
||||
},
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
export const loadWidgetResources = (kind: WidgetKind) => loadRegisteredWidgetResources(kind);
|
||||
export const loadWidgetResources = <TKind extends WidgetKind>(kind: TKind) =>
|
||||
correlateWidgetPromise(kind, "resources", loadRegisteredWidgetResources(kind));
|
||||
|
||||
export const loadWidgetDefinition = (kind: WidgetKind) => {
|
||||
export const loadWidgetDefinition = <TKind extends WidgetKind>(kind: TKind) => {
|
||||
const existing = definitionPromises.get(kind);
|
||||
if (existing) return existing;
|
||||
if (existing) {
|
||||
return correlateWidgetPromise(kind, "definition", existing);
|
||||
}
|
||||
|
||||
const promise = loadWidgetModule(kind).then(({ definition }) => definition);
|
||||
const promise = loadRegisteredWidgetModule(kind).then(({ definition }) => definition);
|
||||
definitionPromises.set(kind, promise);
|
||||
void promise.catch(() => {
|
||||
if (definitionPromises.get(kind) === promise) definitionPromises.delete(kind);
|
||||
});
|
||||
return promise;
|
||||
return correlateWidgetPromise(kind, "definition", promise);
|
||||
};
|
||||
|
||||
let allWidgetDefinitionsPromise: Promise<Map<WidgetKind, WidgetDefinition>> | undefined;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconMovie } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition, matchesWidgetRuntimeQuery } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
@@ -9,6 +10,7 @@ const pageSizeOptions = ["10", "20", "30", "50"] as const;
|
||||
export const { componentLoader, definition } = createWidgetDefinition("mediaMissing", {
|
||||
icon: IconMovie,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "mediaOrganizer", "getData"]],
|
||||
queryMatcher: matchesWidgetRuntimeQuery,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
@@ -23,4 +25,5 @@ export const { componentLoader, definition } = createWidgetDefinition("mediaMiss
|
||||
}),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("mediaMissing"),
|
||||
}).withDynamicImport(() => import("./component"));
|
||||
@@ -1,11 +1,15 @@
|
||||
import { IconTicket } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("mediaReleases", {
|
||||
icon: IconTicket,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "mediaRelease"]],
|
||||
refetchInterval: null,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
layout: factory.select({
|
||||
@@ -32,4 +36,5 @@ export const { definition, componentLoader } = createWidgetDefinition("mediaRele
|
||||
}),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("mediaReleases"),
|
||||
}).withDynamicImport(() => import("./component"));
|
||||
@@ -1,6 +1,7 @@
|
||||
import { IconSearch, IconZoomQuestion } from "@tabler/icons-react";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
import { openMediaRequestSearch } from "@homarr/spotlight";
|
||||
|
||||
import { createWidgetDefinition, widgetQueryInputMatches } from "../../definition";
|
||||
@@ -28,6 +29,7 @@ const createOptions = () =>
|
||||
export const { componentLoader, definition } = createWidgetDefinition("mediaRequests-requestList", {
|
||||
supportsAdvancedFocus: false,
|
||||
icon: IconZoomQuestion,
|
||||
queryKey: [["widget", "mediaRequests", "getLatestRequests"]],
|
||||
queryMatcher: ({ input }, scope) =>
|
||||
widgetQueryInputMatches(input, {
|
||||
integrationIds: scope.integrationIds,
|
||||
@@ -48,4 +50,5 @@ export const { componentLoader, definition } = createWidgetDefinition("mediaRequ
|
||||
},
|
||||
},
|
||||
],
|
||||
...getWidgetIntegrationConfig("mediaRequests-requestList"),
|
||||
}).withDynamicImport(() => import("./component"));
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconChartBar, IconSearch } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
import { openMediaRequestSearch } from "@homarr/spotlight";
|
||||
|
||||
import { createWidgetDefinition } from "../../definition";
|
||||
@@ -9,6 +10,7 @@ const createOptions = () => ({});
|
||||
export const { componentLoader, definition } = createWidgetDefinition("mediaRequests-requestStats", {
|
||||
supportsAdvancedFocus: false,
|
||||
icon: IconChartBar,
|
||||
queryKey: [["widget", "mediaRequests", "getStats"]],
|
||||
createOptions,
|
||||
contextActions: ({ integrationIds }) => [
|
||||
{
|
||||
@@ -20,4 +22,5 @@ export const { componentLoader, definition } = createWidgetDefinition("mediaRequ
|
||||
},
|
||||
},
|
||||
],
|
||||
...getWidgetIntegrationConfig("mediaRequests-requestStats"),
|
||||
}).withDynamicImport(() => import("./component"));
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconVideo } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition, widgetQueryInputMatches } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
@@ -7,11 +8,13 @@ import { optionsBuilder } from "../options";
|
||||
export const { componentLoader, definition } = createWidgetDefinition("mediaServer", {
|
||||
icon: IconVideo,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "mediaServer", "getCurrentStreams"]],
|
||||
queryMatcher: ({ input }, scope) =>
|
||||
widgetQueryInputMatches(input, {
|
||||
integrationIds: scope.integrationIds,
|
||||
showOnlyPlaying: scope.options.showOnlyPlaying,
|
||||
}),
|
||||
refetchInterval: 10,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
showOnlyPlaying: factory.switch({ defaultValue: true, withDescription: true }),
|
||||
@@ -19,4 +22,5 @@ export const { componentLoader, definition } = createWidgetDefinition("mediaServ
|
||||
showLocation: factory.switch({ defaultValue: true, withDescription: true }),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("mediaServer"),
|
||||
}).withDynamicImport(() => import("./component"));
|
||||
@@ -2,6 +2,7 @@ import { IconTransform } from "@tabler/icons-react";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { capitalize } from "@homarr/common";
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition, matchesWidgetRuntimeQuery } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
@@ -11,7 +12,10 @@ export const views = ["workers", "queue", "statistics"] as const;
|
||||
export const { componentLoader, definition } = createWidgetDefinition("mediaTranscoding", {
|
||||
icon: IconTransform,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "mediaTranscoding", "getDataAsync"]],
|
||||
queryMatcher: matchesWidgetRuntimeQuery,
|
||||
...getWidgetIntegrationConfig("mediaTranscoding"),
|
||||
refetchInterval: null,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
defaultView: factory.select({
|
||||
|
||||
@@ -7,12 +7,14 @@ import { optionsBuilder } from "../../options";
|
||||
export const { componentLoader, definition } = createWidgetDefinition("minecraftServerStatus", {
|
||||
supportsAdvancedFocus: false,
|
||||
icon: IconBrandMinecraft,
|
||||
queryKey: [["widget", "minecraft", "getServerStatus"]],
|
||||
queryMatcher: ({ input }, scope) =>
|
||||
widgetQueryInputMatches(input, {
|
||||
title: scope.options.title,
|
||||
domain: scope.options.domain,
|
||||
isBedrockServer: scope.options.isBedrockServer,
|
||||
}),
|
||||
refetchInterval: null,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
title: factory.text({ defaultValue: "" }),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconServerOff, IconTopologyFull } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../../definition";
|
||||
import { optionsBuilder } from "../../options";
|
||||
@@ -7,6 +8,8 @@ import { optionsBuilder } from "../../options";
|
||||
export const { definition, componentLoader } = createWidgetDefinition("networkControllerStatus", {
|
||||
icon: IconTopologyFull,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "networkController"]],
|
||||
refetchInterval: null,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
content: factory.select({
|
||||
@@ -18,6 +21,7 @@ export const { definition, componentLoader } = createWidgetDefinition("networkCo
|
||||
}),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("networkControllerStatus"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconServerOff,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconServerOff, IconTopologyFull } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../../definition";
|
||||
import { optionsBuilder } from "../../options";
|
||||
@@ -7,9 +8,12 @@ import { optionsBuilder } from "../../options";
|
||||
export const { definition, componentLoader } = createWidgetDefinition("networkControllerSummary", {
|
||||
supportsAdvancedFocus: true,
|
||||
icon: IconTopologyFull,
|
||||
queryKey: [["widget", "networkController"]],
|
||||
refetchInterval: null,
|
||||
createOptions() {
|
||||
return optionsBuilder.from(() => ({}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("networkControllerSummary"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconServerOff,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconMessage } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition, widgetQueryInputMatches } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
@@ -7,6 +8,7 @@ import { optionsBuilder } from "../options";
|
||||
export const { componentLoader, definition } = createWidgetDefinition("notifications", {
|
||||
supportsAdvancedFocus: true,
|
||||
icon: IconMessage,
|
||||
queryKey: [["widget", "notifications", "getNotifications"]],
|
||||
queryMatcher: ({ input }, scope) =>
|
||||
widgetQueryInputMatches(input, {
|
||||
hideLogos: scope.options.hideLogos,
|
||||
@@ -17,4 +19,5 @@ export const { componentLoader, definition } = createWidgetDefinition("notificat
|
||||
hideLogos: factory.switch({ defaultValue: false }),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("notifications"),
|
||||
}).withDynamicImport(() => import("./component"));
|
||||
@@ -1,11 +1,15 @@
|
||||
import { IconFileText, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("paperlessNgx", {
|
||||
supportsAdvancedFocus: false,
|
||||
icon: IconFileText,
|
||||
refetchInterval: null,
|
||||
...getWidgetIntegrationConfig("paperlessNgx"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
showInboxRatio: factory.switch({
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { IconServerOff, IconShieldCheck } from "@tabler/icons-react";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
import { PATCHMON_STAT_COLOR_PRESETS } from "./stat-colors";
|
||||
@@ -9,6 +11,7 @@ import { patchmonOptionsSuperRefine } from "./threshold-validation";
|
||||
export const { definition, componentLoader } = createWidgetDefinition("patchmon", {
|
||||
supportsAdvancedFocus: true,
|
||||
icon: IconShieldCheck,
|
||||
...getWidgetIntegrationConfig("patchmon"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from(
|
||||
(factory) => ({
|
||||
|
||||
@@ -1,61 +1,45 @@
|
||||
import { generatedWidgetOperationPolicies, widgetFeatureCatalog } from "@homarr/definitions";
|
||||
|
||||
interface WidgetQueryRefetchInterval {
|
||||
queryKey: readonly [readonly string[]];
|
||||
intervalSeconds: number | null;
|
||||
staleTimeSeconds?: number;
|
||||
}
|
||||
|
||||
const createWidgetQueryRefetchIntervals = (): WidgetQueryRefetchInterval[] => {
|
||||
const policies = new Map<string, WidgetQueryRefetchInterval>();
|
||||
|
||||
for (const descriptor of Object.values(widgetFeatureCatalog)) {
|
||||
if (!("query" in descriptor) || !("refetchIntervalSeconds" in descriptor.query)) continue;
|
||||
|
||||
for (const path of descriptor.query.paths) {
|
||||
if (path[0] !== "widget" && path[0] !== "docker") continue;
|
||||
|
||||
const queryKey = [path] as const;
|
||||
const serializedQueryKey = JSON.stringify(queryKey);
|
||||
const intervalSeconds = descriptor.query.refetchIntervalSeconds;
|
||||
const existing = policies.get(serializedQueryKey);
|
||||
if (existing && existing.intervalSeconds !== intervalSeconds) {
|
||||
throw new Error(`Conflicting widget refetch intervals for ${serializedQueryKey}`);
|
||||
}
|
||||
policies.set(serializedQueryKey, { queryKey, intervalSeconds });
|
||||
}
|
||||
}
|
||||
|
||||
for (const policy of generatedWidgetOperationPolicies) {
|
||||
if (policy.kind !== "query") continue;
|
||||
if (policy.path[0] !== "widget" && policy.path[0] !== "docker") continue;
|
||||
|
||||
const queryKey = [policy.path] as const;
|
||||
const serializedQueryKey = JSON.stringify(queryKey);
|
||||
let existing = policies.get(serializedQueryKey);
|
||||
if (!existing) {
|
||||
if (policy.refetchIntervalSeconds === undefined) continue;
|
||||
existing = { queryKey, intervalSeconds: policy.refetchIntervalSeconds };
|
||||
}
|
||||
if (
|
||||
existing.intervalSeconds !== undefined &&
|
||||
policy.refetchIntervalSeconds !== undefined &&
|
||||
existing.intervalSeconds !== policy.refetchIntervalSeconds
|
||||
) {
|
||||
throw new Error(`Conflicting generated widget refetch interval for ${serializedQueryKey}`);
|
||||
}
|
||||
if (policy.refetchIntervalSeconds !== undefined) {
|
||||
existing.intervalSeconds = policy.refetchIntervalSeconds;
|
||||
}
|
||||
if (policy.staleTimeSeconds !== undefined) existing.staleTimeSeconds = policy.staleTimeSeconds;
|
||||
policies.set(serializedQueryKey, existing);
|
||||
}
|
||||
|
||||
return [...policies.values()];
|
||||
};
|
||||
|
||||
/**
|
||||
* Query policy used by the root client provider. This derives from the
|
||||
* server-safe feature catalog and never imports widget definitions or code.
|
||||
* Lightweight query defaults for the root client provider.
|
||||
*
|
||||
* Keep this list free of widget imports: importing widget definitions here
|
||||
* would put every widget in the initial client bundle.
|
||||
*/
|
||||
export const widgetQueryRefetchIntervals = createWidgetQueryRefetchIntervals();
|
||||
export const widgetQueryRefetchIntervals = [
|
||||
{ queryKey: [["docker", "getContainers"]], intervalSeconds: 30 },
|
||||
{ queryKey: [["widget", "dnsHole"]], intervalSeconds: 10 },
|
||||
{
|
||||
queryKey: [["widget", "downloads", "getJobsAndStatuses"]],
|
||||
intervalSeconds: 10,
|
||||
staleTimeSeconds: 10,
|
||||
},
|
||||
{ queryKey: [["widget", "firewall"]], intervalSeconds: 10 },
|
||||
{ queryKey: [["widget", "healthMonitoring"]], intervalSeconds: 10 },
|
||||
{ queryKey: [["widget", "mediaServer", "getCurrentStreams"]], intervalSeconds: 10 },
|
||||
{ queryKey: [["widget", "tracearr"]], intervalSeconds: 10 },
|
||||
{
|
||||
queryKey: [["widget", "weather", "atLocation"]],
|
||||
intervalSeconds: 600,
|
||||
staleTimeSeconds: 300,
|
||||
},
|
||||
{ queryKey: [["widget", "airQuality", "atLocation"]], intervalSeconds: 900 },
|
||||
{ queryKey: [["widget", "immich", "getAlbum"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "immich", "getServerStats"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "immich", "getAlbums"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "indexerManager"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "mediaRelease"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "mediaTranscoding", "getDataAsync"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "minecraft", "getServerStatus"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "networkController"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "paperlessNgx"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "releases", "getLatest"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "rssFeed", "getFeeds"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "speedtestTracker"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "stockPrice", "getPriceHistory"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "umami", "getVisitorStats"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "umami", "getActiveVisitors"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "umami", "getMultiEventTimeSeries"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "umami", "getTopPages"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "umami", "getTopReferrers"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "vpn"]], intervalSeconds: null },
|
||||
{ queryKey: [["widget", "wud"]], intervalSeconds: null },
|
||||
] as const;
|
||||
@@ -20,6 +20,7 @@ import type * as customApi from "./custom-api";
|
||||
import type * as dnsHoleControls from "./dns-hole/controls";
|
||||
import type * as dnsHoleSummary from "./dns-hole/summary";
|
||||
import type * as dockerContainers from "./docker";
|
||||
import type * as downloads from "./downloads";
|
||||
import type * as firewall from "./firewall";
|
||||
import type * as healthMonitoring from "./health-monitoring";
|
||||
import type * as iframe from "./iframe";
|
||||
@@ -56,9 +57,8 @@ import type * as ups from "./ups";
|
||||
import type * as uptimeKuma from "./uptime-kuma";
|
||||
import type * as video from "./video";
|
||||
import type * as vpn from "./vpn";
|
||||
import type * as weather from "./weather";
|
||||
import type * as wud from "./wud";
|
||||
import { generatedWidgetModuleLoaders } from "./generated/widget-modules";
|
||||
import type { GeneratedWidgetImports } from "./generated/widget-modules";
|
||||
|
||||
type WidgetModule = {
|
||||
definition: unknown;
|
||||
@@ -86,6 +86,7 @@ export const widgetModuleLoaders = {
|
||||
stockPrice: () => import("./stocks"),
|
||||
mediaServer: () => import("./media-server"),
|
||||
calendar: () => import("./calendar"),
|
||||
downloads: () => import("./downloads"),
|
||||
"mediaRequests-requestList": () => import("./media-requests/list"),
|
||||
"mediaRequests-requestStats": () => import("./media-requests/stats"),
|
||||
mediaMissing: () => import("./media-missing"),
|
||||
@@ -124,8 +125,8 @@ export const widgetModuleLoaders = {
|
||||
beszelSystemStats: () => import("./beszel-system-stats"),
|
||||
traefik: () => import("./traefik"),
|
||||
customApi: () => import("./custom-api"),
|
||||
weather: () => import("./weather"),
|
||||
wud: () => import("./wud"),
|
||||
...generatedWidgetModuleLoaders,
|
||||
} satisfies Record<WidgetKind, () => Promise<WidgetModule>>;
|
||||
|
||||
export type WidgetImports = {
|
||||
@@ -147,6 +148,7 @@ export type WidgetImports = {
|
||||
stockPrice: typeof stockPrice;
|
||||
mediaServer: typeof mediaServer;
|
||||
calendar: typeof calendar;
|
||||
downloads: typeof downloads;
|
||||
"mediaRequests-requestList": typeof mediaRequestsList;
|
||||
"mediaRequests-requestStats": typeof mediaRequestsStats;
|
||||
mediaMissing: typeof mediaMissing;
|
||||
@@ -185,8 +187,9 @@ export type WidgetImports = {
|
||||
beszelSystemStats: typeof beszelSystemStats;
|
||||
traefik: typeof traefik;
|
||||
customApi: typeof customApi;
|
||||
weather: typeof weather;
|
||||
wud: typeof wud;
|
||||
} & GeneratedWidgetImports;
|
||||
};
|
||||
|
||||
export type WidgetImportKey = keyof WidgetImports;
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@ const relativeDateSchema = z
|
||||
export const { definition, componentLoader } = createWidgetDefinition("releases", {
|
||||
supportsAdvancedFocus: true,
|
||||
icon: IconRocket,
|
||||
queryKey: [["widget", "releases", "getLatest"]],
|
||||
queryMatcher: ({ input }, scope) => widgetQueryInputMatches(input, { itemId: scope.itemId }),
|
||||
refetchInterval: null,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
newReleaseWithin: factory.text({
|
||||
|
||||
@@ -13,11 +13,13 @@ import { optionsBuilder } from "../options";
|
||||
export const { definition, componentLoader } = createWidgetDefinition("rssFeed", {
|
||||
supportsAdvancedFocus: true,
|
||||
icon: IconRss,
|
||||
queryKey: [["widget", "rssFeed", "getFeeds"]],
|
||||
queryMatcher: ({ input }, scope) =>
|
||||
widgetQueryInputMatches(input, {
|
||||
urls: scope.options.feedUrls,
|
||||
maximumAmountPosts: scope.options.maximumAmountPosts,
|
||||
}),
|
||||
refetchInterval: null,
|
||||
errors: {
|
||||
BAD_GATEWAY: {
|
||||
icon: IconServerOff,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconBinaryTree, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../../definition";
|
||||
import { optionsBuilder } from "../../options";
|
||||
@@ -7,6 +8,8 @@ import { optionsBuilder } from "../../options";
|
||||
export const { definition, componentLoader } = createWidgetDefinition("smartHome-entityState", {
|
||||
icon: IconBinaryTree,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "smartHome"]],
|
||||
...getWidgetIntegrationConfig("smartHome-entityState"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
entityId: factory.text({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconBinaryTree } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../../definition";
|
||||
import { optionsBuilder } from "../../options";
|
||||
@@ -7,6 +8,7 @@ import { optionsBuilder } from "../../options";
|
||||
export const { definition, componentLoader } = createWidgetDefinition("smartHome-executeAutomation", {
|
||||
icon: IconBinaryTree,
|
||||
supportsAdvancedFocus: true,
|
||||
...getWidgetIntegrationConfig("smartHome-executeAutomation"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
displayName: factory.text(),
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { IconServerOff, IconSpeedboat } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("speedtestTracker", {
|
||||
icon: IconSpeedboat,
|
||||
supportsAdvancedFocus: true,
|
||||
refetchInterval: null,
|
||||
createOptions() {
|
||||
return optionsBuilder.from(
|
||||
(factory) => ({
|
||||
@@ -29,6 +32,7 @@ export const { definition, componentLoader } = createWidgetDefinition("speedtest
|
||||
},
|
||||
);
|
||||
},
|
||||
...getWidgetIntegrationConfig("speedtestTracker"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconServerOff,
|
||||
|
||||
@@ -14,12 +14,14 @@ const timeIntervalOptions = stockPriceTimeFrames.interval;
|
||||
export const { definition, componentLoader } = createWidgetDefinition("stockPrice", {
|
||||
supportsAdvancedFocus: true,
|
||||
icon: IconBuildingBank,
|
||||
queryKey: [["widget", "stockPrice", "getPriceHistory"]],
|
||||
queryMatcher: ({ input }, scope) =>
|
||||
widgetQueryInputMatches(input, {
|
||||
stock: scope.options.stock,
|
||||
timeRange: scope.options.timeRange,
|
||||
timeInterval: scope.options.timeInterval,
|
||||
}),
|
||||
refetchInterval: null,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
stock: factory.text({
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { IconServer2 } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
import { createStorageVolumeMultiSelectOptions } from "../storage-volume-options";
|
||||
@@ -7,6 +9,9 @@ import { createStorageVolumeMultiSelectOptions } from "../storage-volume-options
|
||||
export const { definition, componentLoader } = createWidgetDefinition("systemDisks", {
|
||||
supportsAdvancedFocus: true,
|
||||
icon: IconServer2,
|
||||
queryKey: [["widget", "healthMonitoring"]],
|
||||
refetchInterval: 10,
|
||||
...getWidgetIntegrationConfig("systemDisks"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from(
|
||||
(factory) => ({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IconAlignLeft, IconEyeOff, IconGraphFilled, IconListDetails, IconPhoto } from "@tabler/icons-react";
|
||||
|
||||
import { objectEntries } from "@homarr/common";
|
||||
import { invariantTechnicalLabels } from "@homarr/definitions";
|
||||
import { getWidgetIntegrationConfig, invariantTechnicalLabels } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
@@ -22,6 +22,9 @@ const getChartOptionLabel = (key: "cpu" | "memory" | "gpu" | "network", t: (key:
|
||||
export const { definition, componentLoader } = createWidgetDefinition("systemResources", {
|
||||
icon: IconGraphFilled,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "healthMonitoring"]],
|
||||
refetchInterval: 10,
|
||||
...getWidgetIntegrationConfig("systemResources"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
hasShadow: factory.switch({ defaultValue: true }),
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { IconActivityHeartbeat, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("tracearr", {
|
||||
icon: IconActivityHeartbeat,
|
||||
supportsAdvancedFocus: true,
|
||||
refetchInterval: 10,
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
showStreams: factory.switch({
|
||||
@@ -23,6 +26,7 @@ export const { definition, componentLoader } = createWidgetDefinition("tracearr"
|
||||
}),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("tracearr"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconServerOff,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { IconRoute, IconRouteOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
@@ -19,6 +21,7 @@ export const { definition, componentLoader } = createWidgetDefinition("traefik",
|
||||
}),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("traefik"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconRouteOff,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { IconChartBar, IconServerOff } from "@tabler/icons-react";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition, matchesWidgetRuntimeQuery } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
@@ -9,7 +11,16 @@ export const timeFrameValues = ["today", "24h", "7d", "30d", "month", "lastMonth
|
||||
export const { definition, componentLoader } = createWidgetDefinition("umami", {
|
||||
icon: IconChartBar,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKeys: [
|
||||
[["widget", "umami", "getVisitorStats"]],
|
||||
[["widget", "umami", "getActiveVisitors"]],
|
||||
[["widget", "umami", "getMultiEventTimeSeries"]],
|
||||
[["widget", "umami", "getTopPages"]],
|
||||
[["widget", "umami", "getTopReferrers"]],
|
||||
],
|
||||
queryMatcher: matchesWidgetRuntimeQuery,
|
||||
refetchInterval: null,
|
||||
...getWidgetIntegrationConfig("umami"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from(
|
||||
(factory) => ({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconBatteryCharging, IconBatteryOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
@@ -20,6 +21,7 @@ export const { definition, componentLoader } = createWidgetDefinition("ups", {
|
||||
}),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("ups"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconBatteryOff,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { IconHeartbeat, IconServerOff } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
@@ -34,6 +36,7 @@ export const { definition, componentLoader } = createWidgetDefinition("uptimeKum
|
||||
}),
|
||||
}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("uptimeKuma"),
|
||||
errors: {
|
||||
INTERNAL_SERVER_ERROR: {
|
||||
icon: IconServerOff,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IconShieldLock } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
@@ -7,7 +8,9 @@ import { optionsBuilder } from "../options";
|
||||
export const { componentLoader, definition } = createWidgetDefinition("vpn", {
|
||||
supportsAdvancedFocus: false,
|
||||
icon: IconShieldLock,
|
||||
refetchInterval: null,
|
||||
createOptions() {
|
||||
return optionsBuilder.from(() => ({}));
|
||||
},
|
||||
...getWidgetIntegrationConfig("vpn"),
|
||||
}).withDynamicImport(() => import("./component"));
|
||||
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
@@ -1,50 +0,0 @@
|
||||
---
|
||||
title: "Weather"
|
||||
description: "Displays the current weather information of a set location."
|
||||
hide_title: true
|
||||
---
|
||||
|
||||
import { WidgetInteractionGuide } from "@site/src/components/widgets/interactions";
|
||||
|
||||
import { AddingWidget } from "@site/src/components/widgets/adding";
|
||||
import { WidgetConfig } from "@site/src/components/widgets/configuration";
|
||||
import { WidgetHeader } from "@site/src/components/widgets/header";
|
||||
import { weatherWidget } from ".";
|
||||
|
||||
<WidgetHeader widget={weatherWidget} categories={["Weather"]} />
|
||||
|
||||
The Weather Widget displays current conditions and a responsive forecast for a selected location. New widgets start
|
||||
with the city and a three-day forecast visible. As the widget gets smaller, it keeps the current condition and
|
||||
temperature readable before removing secondary details or forecast days.
|
||||
|
||||
Select a forecast day to inspect precipitation, apparent temperature, humidity, wind, UV index, sunrise, sunset and
|
||||
daylight duration with a mouse, keyboard or touch. Open the advanced view for a current-condition summary, a 24-hour
|
||||
temperature and precipitation chart, and the complete seven-day forecast. The chart has an equivalent data table for
|
||||
assistive technologies.
|
||||
|
||||
The **Show humidity** option controls humidity across the compact current-conditions view, advanced summary, hourly
|
||||
details, and daily forecast details. Forecast cards use a roomier adaptive grid in advanced view, with four columns on
|
||||
the standard desktop surface and fewer columns as the surface narrows.
|
||||
|
||||
Weather icons are static by default. Animation can be enabled in the widget configuration, but the operating system's
|
||||
reduced-motion preference always disables it.
|
||||
|
||||
<WidgetInteractionGuide />
|
||||
|
||||
### Adding the widget
|
||||
|
||||
<AddingWidget />
|
||||
|
||||
### Configuration
|
||||
|
||||
<WidgetConfig configuration={weatherWidget.configuration} />
|
||||
|
||||
### Data source
|
||||
|
||||
We use the Open Meteo API to fetch the weather and locations. Active weather data refreshes every ten minutes, while
|
||||
identical location requests can reuse a server response for five minutes. A manual refresh may therefore return the
|
||||
same still-current server response. If a refresh fails, Homarr keeps the last successful data visible and shows an
|
||||
error indicator.
|
||||
|
||||
Set `NO_EXTERNAL_CONNECTION=true` to disable this and other internet-backed requests.
|
||||
If you need to whitelist the api, please use the following URL: `https://open-meteo.com`
|
||||
@@ -1,96 +0,0 @@
|
||||
import { WidgetDefinition } from "@site/src/types";
|
||||
import { IconCloud } from "@tabler/icons-react";
|
||||
|
||||
export const weatherWidget: WidgetDefinition = {
|
||||
icon: IconCloud,
|
||||
name: "Weather",
|
||||
description: "Displays the current weather information of a set location.",
|
||||
path: "../../widgets/weather",
|
||||
configuration: {
|
||||
items: [
|
||||
{
|
||||
name: "Temperature in Fahrenheit",
|
||||
description: "Display temperature in Fahrenheit instead of Celsius",
|
||||
values: { type: "boolean" },
|
||||
defaultValue: "no",
|
||||
},
|
||||
{
|
||||
name: "Disable temperature decimals",
|
||||
description: "Show temperature as full number",
|
||||
values: {
|
||||
type: "boolean",
|
||||
},
|
||||
defaultValue: "no",
|
||||
},
|
||||
{
|
||||
name: "Show current wind speed",
|
||||
description: "Display current wind speed, only for current weather",
|
||||
values: {
|
||||
type: "boolean",
|
||||
},
|
||||
defaultValue: "no",
|
||||
},
|
||||
{
|
||||
name: "Show humidity",
|
||||
description: "Display humidity in current conditions, hourly details, and daily forecasts",
|
||||
values: {
|
||||
type: "boolean",
|
||||
},
|
||||
defaultValue: "yes",
|
||||
},
|
||||
{
|
||||
name: "Animate weather icons",
|
||||
description: "Animate condition icons unless the operating system requests reduced motion",
|
||||
values: {
|
||||
type: "boolean",
|
||||
},
|
||||
defaultValue: "no",
|
||||
},
|
||||
{
|
||||
name: "Use imperial speed units",
|
||||
description: "Display wind speed in mph instead of km/h",
|
||||
values: {
|
||||
type: "boolean",
|
||||
},
|
||||
defaultValue: "no",
|
||||
},
|
||||
{
|
||||
name: "Weather location",
|
||||
description: "Location for which to display the weather information",
|
||||
values: "Select location through search or longitude/latitude",
|
||||
defaultValue: "Paris / 48.85341, 2.3488",
|
||||
},
|
||||
{
|
||||
name: "Date format",
|
||||
description: "Format for displaying the date in the widget",
|
||||
values: {
|
||||
type: "select",
|
||||
options: ["dddd, MMMM D", "dddd, D MMMM", "MMM D", "D MMM", "DD/MM/YYYY", "MM/DD/YYYY", "DD/MM", "MM/DD"],
|
||||
},
|
||||
defaultValue: "dddd, MMMM D",
|
||||
},
|
||||
{
|
||||
name: "Show city",
|
||||
description: "Display the city name in the widget",
|
||||
values: {
|
||||
type: "boolean",
|
||||
},
|
||||
defaultValue: "yes",
|
||||
},
|
||||
{
|
||||
name: "Has forecast",
|
||||
description: "Display a forecast for the next few days",
|
||||
values: {
|
||||
type: "boolean",
|
||||
},
|
||||
defaultValue: "yes",
|
||||
},
|
||||
{
|
||||
name: "Amount of forecast days",
|
||||
description: "Number of days to show in the forecast",
|
||||
values: "1-7",
|
||||
defaultValue: "3",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -1,13 +1,15 @@
|
||||
import { IconCloud } from "@tabler/icons-react";
|
||||
import dayjs from "dayjs";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { createWidgetDefinition, widgetQueryInputMatches } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
import { widgetIcon } from "./module.generated";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("weather", {
|
||||
icon: widgetIcon,
|
||||
icon: IconCloud,
|
||||
supportsAdvancedFocus: true,
|
||||
queryKey: [["widget", "weather", "atLocation"]],
|
||||
refetchInterval: 600,
|
||||
queryMatcher: ({ input }, scope) => {
|
||||
const location = scope.options.location;
|
||||
if (location === null || typeof location !== "object" || !("latitude" in location) || !("longitude" in location)) {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// This file is generated by pnpm widgets:sync. Do not edit it directly.
|
||||
|
||||
export { IconCloud as widgetIcon } from "@tabler/icons-react";
|
||||
@@ -1,36 +0,0 @@
|
||||
import { defineWidgetModule } from "@homarr/definitions";
|
||||
|
||||
export default defineWidgetModule({
|
||||
kind: "weather",
|
||||
icon: "IconCloud",
|
||||
clientEntry: ".",
|
||||
documentation: {
|
||||
slug: "weather",
|
||||
sourceDirectory: "docs",
|
||||
},
|
||||
defaultSize: { width: 2, height: 1 },
|
||||
operations: [
|
||||
{
|
||||
name: "atLocation",
|
||||
path: ["widget", "weather", "atLocation"],
|
||||
client: {
|
||||
refetchIntervalSeconds: 600,
|
||||
staleTimeSeconds: 300,
|
||||
persist: true,
|
||||
},
|
||||
serverCache: {
|
||||
namespace: "weather:at-location",
|
||||
ttlMs: 5 * 60 * 1000,
|
||||
scope: "shared",
|
||||
},
|
||||
},
|
||||
],
|
||||
routers: [
|
||||
{
|
||||
namespace: "weather",
|
||||
module: "./weather",
|
||||
exportName: "weatherRouter",
|
||||
additionalWidgetKinds: ["clock"],
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -1,11 +1,15 @@
|
||||
import { IconBrandDocker } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("wud", {
|
||||
icon: IconBrandDocker,
|
||||
supportsAdvancedFocus: true,
|
||||
refetchInterval: null,
|
||||
...getWidgetIntegrationConfig("wud"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
showTitle: factory.switch({ defaultValue: true }),
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||
},
|
||||
"include": ["*.ts", "src", "*.tsx"],
|
||||
"exclude": ["node_modules", "src/**/docs/**"]
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||