Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

feat(uptime-kuma): add summary-only mode and per-widget status pages (#7264)

Thomasb926f29a4daa
diff --git a/packages/api/src/router/widgets/uptime-kuma.ts b/packages/api/src/router/widgets/uptime-kuma.ts
index 23304f12c..90e87b9a7 100644
--- a/packages/api/src/router/widgets/uptime-kuma.ts
+++ b/packages/api/src/router/widgets/uptime-kuma.ts
@@ -1,5 +1,8 @@
+import { z } from "zod/v4";
+
import { uptimeKumaRequestHandler } from "@homarr/request-handler/uptime-kuma";
import { mockWidgetData } from "@homarr/integrations";
+import { uptimeKumaStatusPageSlugSchema } from "@homarr/validation/uptime-kuma";
import { createManyWidgetIntegrationMiddleware } from "../../middlewares/integration";
import { settleIntegrationQueries, toPublicIntegrationError } from "../../settle-integrations";
@@ -8,7 +11,8 @@ import { createTRPCRouter, publicProcedure } from "../../trpc";
export const uptimeKumaRouter = createTRPCRouter({
getStatusPages: publicProcedure
.concat(createManyWidgetIntegrationMiddleware("query", "uptimeKuma"))
- .query(async ({ ctx }) => {
+ .input(z.object({ statusPageSlug: uptimeKumaStatusPageSlugSchema.optional() }))
+ .query(async ({ ctx, input }) => {
return await settleIntegrationQueries(
ctx.integrations,
async (integration) => {
@@ -22,7 +26,10 @@ export const uptimeKumaRouter = createTRPCRouter({
error: undefined,
};
}
- const innerHandler = uptimeKumaRequestHandler.handler({ ...integration, kind: "uptimeKuma" }, {});
+ const innerHandler = uptimeKumaRequestHandler.handler(
+ { ...integration, kind: "uptimeKuma" },
+ { statusPageSlug: input.statusPageSlug },
+ );
const { data, timestamp } = await innerHandler.getDataAsync();
return {
diff --git a/packages/integrations/src/uptime-kuma/uptime-kuma-integration.ts b/packages/integrations/src/uptime-kuma/uptime-kuma-integration.ts
index 017b098ab..ed0decc4a 100644
--- a/packages/integrations/src/uptime-kuma/uptime-kuma-integration.ts
+++ b/packages/integrations/src/uptime-kuma/uptime-kuma-integration.ts
@@ -60,15 +60,15 @@ export class UptimeKumaIntegration extends Integration {
return { success: true };
}
- public async getStatusPageAsync(signal?: AbortSignal): Promise<UptimeKumaStatusPage> {
+ public async getStatusPageAsync(signal?: AbortSignal, statusPageSlug?: string): Promise<UptimeKumaStatusPage> {
+ const slug = statusPageSlug?.trim().toLowerCase() || this.getSlug();
const [statusPageResponse, heartbeatResponse] = await Promise.all([
- this.fetchOkAsync(this.statusPageApiUrl(), signal),
- this.fetchOkAsync(this.heartbeatApiUrl(), signal),
+ this.fetchOkAsync(this.statusPageApiUrl(slug), signal),
+ this.fetchOkAsync(this.heartbeatApiUrl(slug), signal),
]);
const statusPage = uptimeKumaStatusPageResponseSchema.parse(await statusPageResponse.json());
const heartbeat = uptimeKumaHeartbeatResponseSchema.parse(await heartbeatResponse.json());
- const slug = this.getSlug();
const heartbeatsByMonitor = new Map(
Object.entries(heartbeat.heartbeatList).map(([monitorId, heartbeats]) => [
Number(monitorId),
@@ -109,12 +109,12 @@ export class UptimeKumaIntegration extends Integration {
return response;
}
- private statusPageApiUrl() {
- return this.url(`/api/status-page/${encodeURIComponent(this.getSlug())}`);
+ private statusPageApiUrl(slug = this.getSlug()) {
+ return this.url(`/api/status-page/${encodeURIComponent(slug)}`);
}
- private heartbeatApiUrl() {
- return this.url(`/api/status-page/heartbeat/${encodeURIComponent(this.getSlug())}`);
+ private heartbeatApiUrl(slug = this.getSlug()) {
+ return this.url(`/api/status-page/heartbeat/${encodeURIComponent(slug)}`);
}
private getSlug() {
diff --git a/packages/request-handler/src/uptime-kuma.ts b/packages/request-handler/src/uptime-kuma.ts
index 06c3edead..3e1b70acc 100644
--- a/packages/request-handler/src/uptime-kuma.ts
+++ b/packages/request-handler/src/uptime-kuma.ts
@@ -6,13 +6,13 @@ import { createIntegrationRequestHandler } from "./lib/integration-request-handl
export const uptimeKumaRequestHandler = createIntegrationRequestHandler<
UptimeKumaStatusPage,
"uptimeKuma",
- Record<string, never>
+ { statusPageSlug?: string }
>({
cacheNamespace: "uptime-kuma:status-page",
cacheVersion: "stale-status-v1",
cacheTtlMs: 30_000,
- async requestAsync(integration, _input, signal) {
+ async requestAsync(integration, input, signal) {
const integrationInstance = await createIntegrationAsync(integration);
- return await integrationInstance.getStatusPageAsync(signal);
+ return await integrationInstance.getStatusPageAsync(signal, input.statusPageSlug);
},
});
diff --git a/packages/translation/src/lang/en.json b/packages/translation/src/lang/en.json
index 28f8c1f0b..cc4f5d04b 100644
--- a/packages/translation/src/lang/en.json
+++ b/packages/translation/src/lang/en.json
@@ -5054,6 +5054,14 @@
"uptimeKuma": {
"description": "Live status, heartbeats and uptime of the monitors on an Uptime Kuma status page",
"option": {
+ "statusPageSlug": {
+ "label": "Status page slug",
+ "description": "The part after /status/ in the page URL, such as homelab. Leave blank to use each integration's configured page."
+ },
+ "summaryOnly": {
+ "label": "General status only",
+ "description": "Hide monitor rows and chips. Overrides Show summary; full details remain available in the advanced view."
+ },
"showSummary": {
"label": "Show summary",
"description": "Overall status, counts and averages"
diff --git a/packages/validation/src/uptime-kuma.ts b/packages/validation/src/uptime-kuma.ts
new file mode 100644
index 000000000..b354d4b57
--- /dev/null
+++ b/packages/validation/src/uptime-kuma.ts
@@ -0,0 +1,8 @@
+import { z } from "zod/v4";
+
+export const uptimeKumaStatusPageSlugSchema = z
+ .string()
+ .trim()
+ .toLowerCase()
+ .max(255)
+ .regex(/^(?:[a-z0-9]+(?:-[a-z0-9]+)*)?$/);
diff --git a/packages/widgets/src/uptime-kuma/component.module.css b/packages/widgets/src/uptime-kuma/component.module.css
index 6198561b8..52e35ad4b 100644
--- a/packages/widgets/src/uptime-kuma/component.module.css
+++ b/packages/widgets/src/uptime-kuma/component.module.css
@@ -199,6 +199,10 @@
min-width: 0;
}
+.tile[data-compact] .overallStatusIcon {
+ display: none;
+}
+
.tileNotice {
position: absolute;
top: rem(6px);
diff --git a/packages/widgets/src/uptime-kuma/component.tsx b/packages/widgets/src/uptime-kuma/component.tsx
index b72d1c2d4..6e994ffc8 100644
--- a/packages/widgets/src/uptime-kuma/component.tsx
+++ b/packages/widgets/src/uptime-kuma/component.tsx
@@ -94,7 +94,10 @@ function UptimeKumaContent({
}: UptimeKumaContentProps) {
const t = useI18n("widget.uptimeKuma");
const now = useWidgetNow("minute");
- const statusPagesQuery = clientApi.widget.uptimeKuma.getStatusPages.useQuery({ integrationIds });
+ const statusPagesQuery = clientApi.widget.uptimeKuma.getStatusPages.useQuery({
+ integrationIds,
+ statusPageSlug: options.statusPageSlug,
+ });
const results = getUsableWidgetQueryData(statusPagesQuery);
if (!results) return <WidgetQueryLoadingState />;
@@ -104,7 +107,7 @@ function UptimeKumaContent({
);
const uiScale = isAdvanced ? 1 : calculateBoardUiScale(displayScale);
const size = { width: width / uiScale, height: height / uiScale };
- const layout = getUptimeKumaLayout(size.width, size.height, isAdvanced);
+ const layout = getUptimeKumaLayout(size.width, size.height, isAdvanced, options.summaryOnly);
const summary = summarizeUptimeKumaMonitors(getAllMonitors(pages));
const notices = isAdvanced || options.showIncidents ? getNotices(pages, t("notice.untitled")) : [];
const errorIndicator = <IntegrationErrorIndicator results={results} />;
@@ -195,12 +198,12 @@ interface TileLayoutProps {
const TileLayout = ({ summary, notices, size, showUptime }: TileLayoutProps) => {
const t = useI18n("widget.uptimeKuma");
- const showAverageUptime = showUptime && summary.averageUptime24h !== null;
+ const showAverageUptime = showUptime && summary.averageUptime24h !== null && size.width >= 100 && size.height >= 100;
const textHeight = 26 + (showAverageUptime ? 18 : 0);
- const ringSize = clamp(Math.min(size.width - 16, size.height - 20 - textHeight), 48, 160);
+ const ringSize = clamp(Math.min(size.width - 16, size.height - 20 - textHeight), 24, 160);
return (
- <div className={classes.tile}>
+ <div className={classes.tile} data-compact={size.width < 100 || undefined}>
{notices.length > 0 && (
<div className={classes.tileNotice}>
<NoticeIndicator notices={notices} />
@@ -242,7 +245,10 @@ const StripLayout = ({ pages, summary, notices, size, options }: StripLayoutProp
const breakdownHeight = breakdown.rows * stripLineHeight;
const showBreakdown = stripChromeHeight + breakdownHeight <= size.height;
const usedHeight = stripChromeHeight + (showBreakdown ? breakdownHeight : 0);
- const chipMonitors = sortMonitors(getAllMonitors(pages).filter(needsAttention), options.sortBy);
+ const chipMonitors = sortMonitors(
+ getAllMonitors(pages).filter((monitor) => !options.summaryOnly && needsAttention(monitor)),
+ options.sortBy,
+ );
const chipRows = chipMonitors.length > 0 ? clamp(Math.floor((size.height - usedHeight) / chipRowHeight), 0, 3) : 0;
const uptime = options.showUptime ? getAverageUptimeText(summary) : null;
const uptimeLine = usedHeight + chipRows * chipRowHeight + stripLineHeight <= size.height ? uptime : null;
diff --git a/packages/widgets/src/uptime-kuma/index.ts b/packages/widgets/src/uptime-kuma/index.ts
index a0a9dbc71..d40f64507 100644
--- a/packages/widgets/src/uptime-kuma/index.ts
+++ b/packages/widgets/src/uptime-kuma/index.ts
@@ -1,6 +1,7 @@
import { IconHeartbeat, IconServerOff } from "@tabler/icons-react";
import { getWidgetIntegrationConfig } from "@homarr/definitions";
+import { uptimeKumaStatusPageSlugSchema } from "@homarr/validation/uptime-kuma";
import { createWidgetDefinition } from "../definition";
import { optionsBuilder } from "../options";
@@ -10,6 +11,12 @@ export const { definition, componentLoader } = createWidgetDefinition("uptimeKum
supportsAdvancedFocus: true,
createOptions() {
return optionsBuilder.from((factory) => ({
+ statusPageSlug: factory.text({
+ defaultValue: "",
+ validate: uptimeKumaStatusPageSlugSchema,
+ withDescription: true,
+ }),
+ summaryOnly: factory.switch({ defaultValue: false, withDescription: true }),
showSummary: factory.switch({ defaultValue: true, withDescription: true }),
showIncidents: factory.switch({ defaultValue: true, withDescription: true }),
groupByStatusPageGroup: factory.switch({ defaultValue: false, withDescription: true }),
diff --git a/packages/widgets/src/uptime-kuma/layout.ts b/packages/widgets/src/uptime-kuma/layout.ts
index beb621f5e..8586ed48a 100644
--- a/packages/widgets/src/uptime-kuma/layout.ts
+++ b/packages/widgets/src/uptime-kuma/layout.ts
@@ -6,10 +6,16 @@ const minimumInlineRowWidth = 430;
const minimumTaggedRowWidth = 600;
const maximumColumns = 3;
-export const getUptimeKumaLayout = (width: number, height: number, isAdvanced: boolean): UptimeKumaLayout => {
+export const getUptimeKumaLayout = (
+ width: number,
+ height: number,
+ isAdvanced: boolean,
+ summaryOnly = false,
+): UptimeKumaLayout => {
if (isAdvanced) return "board";
const isNarrow = width < compactBreakpoint;
const isShort = height < compactBreakpoint;
+ if (summaryOnly && !isShort) return "tile";
if (isNarrow && isShort) return "tile";
if (isShort) return "strip";
if (isNarrow) return "column";