A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.
import type { WidgetKind } from "@homarr/definitions";
import { beszelMetricOptionKeys } from "@homarr/definitions/beszel";
const BESZEL_OPTION_PROPERTIES = new Set<string>(["statusFilter", ...beszelMetricOptionKeys]);
const TABLE_OPTION_PROPERTIES = new Set(["columnOrder", "columnWidths", "columns"]);
const LAYOUT_WIDGET_KINDS = new Set(["app", "bookmarks", "wud", "dnsHoleSummary"]);
const PATCHMON_SHARED_WARNING_PROPERTIES = new Set([
"hostsNeedingUpdatesWarningAt",
"securityUpdatesWarningAt",
"hostsWithSecurityUpdatesWarningAt",
"totalOutdatedPackagesWarningAt",
]);
const PATCHMON_SHARED_CRITICAL_PROPERTIES = new Set([
"hostsNeedingUpdatesCriticalAt",
"securityUpdatesCriticalAt",
"hostsWithSecurityUpdatesCriticalAt",
"totalOutdatedPackagesCriticalAt",
]);
export const getWidgetOptionTranslationNamespace = (kind: WidgetKind, property: string): string => {
const sharedNamespace = getSharedOptionNamespace(kind, property);
const sharedProperty = getSharedOptionProperty(kind, property);
return `${sharedNamespace ?? `widget.${kind}.option`}.${sharedProperty}`;
};
export const getWidgetOptionDescriptionTranslationNamespace = (
kind: WidgetKind,
property: string,
): string | undefined => {
if (kind !== "patchmon") return undefined;
if (PATCHMON_SHARED_WARNING_PROPERTIES.has(property)) return "widget.patchmon.option.threshold.warningAt";
if (PATCHMON_SHARED_CRITICAL_PROPERTIES.has(property)) return "widget.patchmon.option.threshold.criticalAt";
return undefined;
};
const getSharedOptionProperty = (kind: WidgetKind, property: string): string => {
if (property === "descendingDefaultSort") return "invertSorting";
if (kind === "bookmarks" && property === "openNewTab") return "openInNewTab";
if (kind === "clock" && property === "customTitle") return "title";
if (kind === "weather" && property === "location") return "weatherLocation";
return property;
};
const getSharedOptionNamespace = (kind: WidgetKind, property: string): string | undefined => {
if (kind.startsWith("thingport-") && (property === "showTitle" || property === "openInNewTab")) {
return "widget.common";
}
if ((kind === "beszelSystemTable" || kind === "beszelSystemGrid") && BESZEL_OPTION_PROPERTIES.has(property)) {
return "widget.beszel.options";
}
if (
["dockerContainers", "downloads", "beszelSystemTable", "wazuh"].includes(kind) &&
TABLE_OPTION_PROPERTIES.has(property)
) {
return "widget.common.tableOptions";
}
if (["dockerContainers", "downloads"].includes(kind)) {
if (property === "enableRowSorting" || property === "defaultSort" || property === "descendingDefaultSort") {
return "widget.common.tableOptions";
}
}
if (kind === "weather" && property === "dateFormat") return "widget.common";
if ((kind === "healthMonitoring" || kind === "systemDisks") && property === "visibleStorageVolumes") {
return "widget.common";
}
if (property === "layout" && LAYOUT_WIDGET_KINDS.has(kind)) return "widget.common";
if (
(kind === "bookmarks" && property === "title") ||
(kind === "clock" && property === "customTitle") ||
(kind === "minecraftServerStatus" && property === "title") ||
(kind === "bookmarks" && property === "openNewTab") ||
(kind === "wud" && property === "showTitle") ||
(kind === "anchorNote" && property === "showTitle") ||
(kind === "clock" && property === "weatherLocation") ||
(kind === "weather" && property === "location")
) {
return "widget.common";
}
return undefined;
};