Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
chore: add chart filter details (#598)
Maximilian Kaskedda921ed8978
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/date-picker-preset.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/date-picker-preset.tsxindex 822c7adcc..ea1cf1be9 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/date-picker-preset.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/date-picker-preset.tsx@@ -2,9 +2,13 @@import * as React from "react";import { usePathname, useRouter } from "next/navigation";-import { CalendarIcon } from "lucide-react";+import { CalendarIcon, HelpCircle } from "lucide-react";import {+ Label,+ Popover,+ PopoverContent,+ PopoverTrigger,Select,SelectContent,SelectItem,@@ -34,20 +38,33 @@ export function DatePickerPreset({ period }: { period: Period }) {}return (- <Select defaultValue={period} onValueChange={onSelect}>- <SelectTrigger className="w-[150px] text-left">- <span className="flex items-center gap-2">- <CalendarIcon className="h-4 w-4" />- <SelectValue placeholder="Pick a range" />- </span>- </SelectTrigger>- <SelectContent>- {periods.map((period) => (- <SelectItem key={period} value={period}>- {renderLabel(period)}- </SelectItem>- ))}- </SelectContent>- </Select>+ <div className="grid gap-1">+ <div className="flex items-center gap-1.5">+ <Label htmlFor="period">Period</Label>+ <Popover>+ <PopoverTrigger>+ <HelpCircle className="text-muted-foreground h-4 w-4" />+ </PopoverTrigger>+ <PopoverContent side="top" className="text-sm">+ <p>Specifies a time range for analysis.</p>+ </PopoverContent>+ </Popover>+ </div>+ <Select defaultValue={period} onValueChange={onSelect}>+ <SelectTrigger className="w-[150px] text-left" id="period">+ <span className="flex items-center gap-2">+ <CalendarIcon className="h-4 w-4" />+ <SelectValue placeholder="Pick a range" />+ </span>+ </SelectTrigger>+ <SelectContent>+ {periods.map((period) => (+ <SelectItem key={period} value={period}>+ {renderLabel(period)}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div>);}diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/interval-preset.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/interval-preset.tsxindex 6fe12009b..9a99fce21 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/interval-preset.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/interval-preset.tsx@@ -2,14 +2,19 @@import * as React from "react";import { usePathname, useRouter } from "next/navigation";-import { Hourglass } from "lucide-react";+import { HelpCircle, Hourglass } from "lucide-react";import {+ Label,+ Popover,+ PopoverContent,+ PopoverTrigger,Select,SelectContent,SelectItem,SelectTrigger,SelectValue,+ Separator,} from "@openstatus/ui";import useUpdateSearchParams from "@/hooks/use-update-search-params";@@ -27,20 +32,38 @@ export function IntervalPreset({ interval }: { interval: Interval }) {}return (- <Select onValueChange={onSelect} defaultValue={interval}>- <SelectTrigger className="w-[100px]">- <span className="flex items-center gap-2">- <Hourglass className="h-4 w-4" />- <SelectValue />- </span>- </SelectTrigger>- <SelectContent>- {intervals.map((interval) => (- <SelectItem key={interval} value={interval}>- {interval}- </SelectItem>- ))}- </SelectContent>- </Select>+ <div className="grid gap-1">+ <div className="flex items-center gap-1.5">+ <Label htmlFor="interval">Interval</Label>+ <Popover>+ <PopoverTrigger>+ <HelpCircle className="text-muted-foreground h-4 w-4" />+ </PopoverTrigger>+ <PopoverContent side="top" className="text-sm">+ <p>Aggregate and process data at regular time intervals.</p>+ <Separator className="my-1" />+ <p className="text-muted-foreground">+ 30m should be aligned to the beginning of 30-minute intervals for+ data analysis and aggregation purposes+ </p>+ </PopoverContent>+ </Popover>+ </div>+ <Select onValueChange={onSelect} defaultValue={interval}>+ <SelectTrigger className="w-[150px]" id="interval">+ <span className="flex items-center gap-2">+ <Hourglass className="h-4 w-4" />+ <SelectValue />+ </span>+ </SelectTrigger>+ <SelectContent>+ {intervals.map((interval) => (+ <SelectItem key={interval} value={interval}>+ {interval}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div>);}diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/quantile-preset.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/quantile-preset.tsxindex f11d2075f..09c40ccd4 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/quantile-preset.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/_components/quantile-preset.tsx@@ -2,22 +2,33 @@import * as React from "react";import { usePathname, useRouter } from "next/navigation";-import { CandlestickChart } from "lucide-react";+import { CandlestickChart, HelpCircle } from "lucide-react";import {+ Label,+ Popover,+ PopoverContent,+ PopoverTrigger,Select,SelectContent,SelectItem,SelectSeparator,SelectTrigger,SelectValue,+ Separator,} from "@openstatus/ui";import useUpdateSearchParams from "@/hooks/use-update-search-params";import { quantiles } from "../utils";import type { Quantile } from "../utils";-export function QuantilePreset({ quantile }: { quantile: Quantile }) {+export function QuantilePreset({+ quantile,+ disabled,+}: {+ quantile: Quantile;+ disabled?: boolean;+}) {const router = useRouter();const pathname = usePathname();const updateSearchParams = useUpdateSearchParams();@@ -28,25 +39,50 @@ export function QuantilePreset({ quantile }: { quantile: Quantile }) {}return (- <Select onValueChange={onSelect} defaultValue={quantile}>- <SelectTrigger className="w-[100px] uppercase">- <span className="flex items-center gap-2">- <CandlestickChart className="h-4 w-4" />- <SelectValue />- </span>- </SelectTrigger>- <SelectContent>- {quantiles.map((quantile) => {- return (- <React.Fragment key={quantile}>- {quantile === "avg" && <SelectSeparator />}- <SelectItem value={quantile} className="uppercase">- {quantile}- </SelectItem>- </React.Fragment>- );- })}- </SelectContent>- </Select>+ <div className="grid gap-1">+ <div className="flex items-center gap-1.5">+ <Label htmlFor="quantile">Quantile</Label>+ <Popover>+ <PopoverTrigger>+ <HelpCircle className="text-muted-foreground h-4 w-4" />+ </PopoverTrigger>+ <PopoverContent side="top" className="text-sm">+ <p>+ Defines a statistical measure representing a specific percentile.+ </p>+ <Separator className="my-1" />+ <p className="text-muted-foreground">+ The p95 quantile represents the value below which 95% of the data+ points in a dataset fall, indicating a high percentile level+ within the distribution.+ </p>+ </PopoverContent>+ </Popover>+ </div>+ <Select+ onValueChange={onSelect}+ defaultValue={quantile}+ disabled={disabled}+ >+ <SelectTrigger className="w-[150px] uppercase" id="quantile">+ <span className="flex items-center gap-2">+ <CandlestickChart className="h-4 w-4" />+ <SelectValue />+ </span>+ </SelectTrigger>+ <SelectContent>+ {quantiles.map((quantile) => {+ return (+ <React.Fragment key={quantile}>+ {quantile === "avg" && <SelectSeparator />}+ <SelectItem value={quantile} className="uppercase">+ {quantile}+ </SelectItem>+ </React.Fragment>+ );+ })}+ </SelectContent>+ </Select>+ </div>);}diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/data/loading.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/data/loading.tsxindex 01f887cf3..94c7bcd07 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/data/loading.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/data/loading.tsx@@ -6,7 +6,10 @@ export default function Loading() {return (<div className="grid gap-4"><div className="flex flex-wrap items-center gap-2 sm:justify-end">- <Skeleton className="h-10 w-32" />+ <div className="grid gap-1">+ <Skeleton className="h-4 w-12" />+ <Skeleton className="h-10 w-[150px]" />+ </div></div><div className="grid gap-3"><div className="flex items-center gap-2">diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/_components/chart.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/_components/chart.tsxindex c33d71918..2b7280982 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/_components/chart.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/_components/chart.tsx@@ -40,6 +40,7 @@ export function Chart({ data, regions }: ChartProps) {]}onValueChange={(v) => void 0} // that prop makes the chart interactivevalueFormatter={dataFormatter}+ curveType="natural"/></Card>);diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/loading.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/loading.tsxindex 0ab352b88..edb57e1f3 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/loading.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/loading.tsx@@ -5,8 +5,18 @@ export default function Loading() {<div className="grid gap-4"><Skeleton className="h-5 w-40" /><div className="flex flex-wrap items-center gap-2 sm:justify-end">- <Skeleton className="h-10 w-32" />- <Skeleton className="h-10 w-24" />+ <div className="grid gap-1">+ <Skeleton className="h-4 w-12" />+ <Skeleton className="h-10 w-[150px]" />+ </div>+ <div className="grid gap-1">+ <Skeleton className="h-4 w-12" />+ <Skeleton className="h-10 w-[150px]" />+ </div>+ <div className="grid gap-1">+ <Skeleton className="h-4 w-12" />+ <Skeleton className="h-10 w-[150px]" />+ </div></div><Skeleton className="h-[396px] w-full" /></div>diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/page.tsxindex f42f57050..031f258d3 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/page.tsx+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/overview/page.tsx@@ -53,7 +53,11 @@ export default async function Page({}const date = getDateByPeriod(search.data.period);- const minutes = getMinutesByInterval(search.data.interval);+ const intervalMinutes = getMinutesByInterval(search.data.interval);+ const periodicityMinutes = getMinutesByInterval(monitor.periodicity);++ const isQuantileDisabled = intervalMinutes <= periodicityMinutes;+ const minutes = isQuantileDisabled ? periodicityMinutes : intervalMinutes;const data = await getResponseGraphData({monitorId: id,@@ -89,7 +93,7 @@ export default async function Page({<div className="flex flex-wrap items-center gap-2 sm:justify-end">{/* IDEA: add tooltip for description */}<DatePickerPreset period={period} />- <QuantilePreset quantile={quantile} />+ <QuantilePreset quantile={quantile} disabled={isQuantileDisabled} /><IntervalPreset interval={interval} /></div><ChartWrapper period={period} quantile={quantile} data={data} />diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/utils.ts b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/utils.tsindex 4fde3beeb..b91e44c02 100644--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/utils.ts+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/[id]/utils.ts@@ -7,6 +7,8 @@ import {subHours,} from "date-fns";+import type { MonitorPeriodicity } from "@openstatus/db/src/schema";+export const periods = ["1h", "1d", "3d"] as const; // If neeeded (e.g. Pro plans), "7d", "30d"export const quantiles = ["p99", "p95", "p90", "p75", "avg"] as const;export const intervals = ["1m", "10m", "30m", "1h"] as const;@@ -38,16 +40,23 @@ export function getDateByPeriod(period: Period) {}}-export function getMinutesByInterval(interval: Interval) {+export function getMinutesByInterval(interval: MonitorPeriodicity) {switch (interval) {+ case "30s":+ // return 0.5;+ return 1; // FIX TINYBIRDcase "1m":return 1;+ case "5m":+ return 5;case "10m":return 10;case "30m":return 30;case "1h":return 60;+ case "other":+ return 60; // TODO: remove "other" from heredefault:const _exhaustiveCheck: never = interval;throw new Error(`Unhandled interval: ${_exhaustiveCheck}`);