diff --git a/client/src/Pages/CreateMonitor/index.tsx b/client/src/Pages/CreateMonitor/index.tsx index 235ac95bf..3aae2e5e1 100644 --- a/client/src/Pages/CreateMonitor/index.tsx +++ b/client/src/Pages/CreateMonitor/index.tsx @@ -18,7 +18,7 @@ import { Trash2 } from "lucide-react"; import { HeaderDeleteControls } from "@/Components/monitors"; import { GeoContinents } from "@/Types/GeoCheck"; -import { BasePage, ConfigBox } from "@/Components/design-elements"; +import { BasePage, ColoredLabel, ConfigBox } from "@/Components/design-elements"; import { RadioWithDescription, Button, @@ -40,6 +40,7 @@ import { DefaultPageSpeedStrategy, } from "@/Types/Monitor"; import type { Notification } from "@/Types/Notification"; +import type { Tag } from "@/Types/Tag"; import type { MonitorFormData } from "@/Validation/monitor"; interface GeneralSettingsConfig { @@ -237,6 +238,7 @@ const CreateMonitorPage = () => { const { data: notifications } = useGet("/notifications/team"); const { data: games } = useGet("/monitors/games"); + const { data: tags } = useGet("/tags/team"); const { schema, defaults } = useMonitorForm({ data: existingMonitor ?? null, @@ -923,6 +925,78 @@ const CreateMonitorPage = () => { } /> + { + const tagOptions = tags ?? []; + const selectedTags = tagOptions.filter((tag) => + (field.value ?? []).includes(tag.id) + ); + return ( + + option.name} + onChange={(_: unknown, newValue: typeof tagOptions) => { + field.onChange(newValue.map((tag) => tag.id)); + }} + isOptionEqualToValue={(option, value) => option.id === value.id} + renderOptionContent={(option) => ( + + )} + /> + {selectedTags.length > 0 && ( + + {selectedTags.map((tag, index) => ( + + +
+ { + field.onChange( + (field.value ?? []).filter((id: string) => id !== tag.id) + ); + }} + aria-label="Remove tag" + > + + + {index < selectedTags.length - 1 && } + + ))} + + )} + + ); + }} + /> + } + /> + {(watchedType === "http" || watchedType === "grpc" || watchedType === "websocket") && ( diff --git a/client/src/Pages/Uptime/Monitors/Components/UptimeMonitorsTable.tsx b/client/src/Pages/Uptime/Monitors/Components/UptimeMonitorsTable.tsx index 048998776..a9344f4ce 100644 --- a/client/src/Pages/Uptime/Monitors/Components/UptimeMonitorsTable.tsx +++ b/client/src/Pages/Uptime/Monitors/Components/UptimeMonitorsTable.tsx @@ -6,6 +6,7 @@ import { type Header, Pagination, StatusLabel, + ColoredLabel, } from "@/Components/design-elements"; import { HeatmapResponseTime, HistogramResponseTime } from "@/Components/common"; import { ActionsMenu } from "@/Components/actions-menu"; @@ -16,14 +17,18 @@ import { useTheme } from "@mui/material/styles"; import { useNavigate } from "react-router-dom"; import { usePost } from "@/Hooks/UseApi"; import { useSelector } from "react-redux"; +import useMediaQuery from "@mui/material/useMediaQuery"; import type { Monitor } from "@/Types/Monitor"; import type { ActionMenuItem } from "@/Components/actions-menu"; import type { RootState } from "@/Types/state"; import { Checkbox } from "@/Components/inputs"; +import type { Tag } from "@/Types/Tag"; +import { SPACING } from "@/Utils/Theme/constants"; interface MonitorTableProps { monitors: Monitor[]; + tags: Tag[]; refetch: () => void; setSelectedMonitor: (monitor: Monitor | null) => void; sortField: string; @@ -41,6 +46,7 @@ interface MonitorTableProps { export const MonitorTable = ({ monitors, + tags, refetch, setSelectedMonitor, sortField, @@ -60,6 +66,7 @@ export const MonitorTable = ({ const navigate = useNavigate(); const chartType = useSelector((state: RootState) => state.ui?.chartType ?? "histogram"); const { post } = usePost, Monitor>(); + const isSmall = useMediaQuery(theme.breakpoints.down("md")); const selectedSet = new Set(selectedRows); const isAllSelected = @@ -252,6 +259,33 @@ export const MonitorTable = ({ } }, }, + { + id: "tags", + content: t("pages.uptime.table.headers.responseTime"), + render: (row) => { + if (row.tags.length === 0) return "-"; + + return ( + + {row.tags.map((tag) => { + const fullTag = tags.find((t) => t.id === tag); + if (!fullTag) return null; + return ( + + ); + })} + + ); + }, + }, { id: "type", mobileLabel: t("common.table.headers.type"), diff --git a/client/src/Pages/Uptime/Monitors/index.tsx b/client/src/Pages/Uptime/Monitors/index.tsx index 85db2cb11..73dbfa511 100644 --- a/client/src/Pages/Uptime/Monitors/index.tsx +++ b/client/src/Pages/Uptime/Monitors/index.tsx @@ -14,6 +14,7 @@ import { useTranslation } from "react-i18next"; import useMediaQuery from "@mui/material/useMediaQuery"; import { useGet, useDelete } from "@/Hooks/UseApi"; import type { Monitor, MonitorType, MonitorsWithChecksResponse } from "@/Types/Monitor"; +import type { Tag } from "@/Types/Tag"; import { useState, useMemo, useCallback } from "react"; import { useSelector, useDispatch } from "react-redux"; import { setRowsPerPage } from "@/Features/UI/uiSlice.js"; @@ -103,6 +104,8 @@ const UptimeMonitorsPage = () => { { refreshInterval: 5000, keepPreviousData: true } ); + const { data: tags } = useGet("/tags/team"); + const { monitors: monitorsWithChecks, summary, @@ -218,6 +221,7 @@ const UptimeMonitorsPage = () => {