table and createMonitor
This commit is contained in:
1 parent
4aabc16096
commit
4d273a6dce
2 files changed
+25
-23
No files matched your search
@@ -29,6 +29,7 @@ import type { TablePaginationOwnProps } from "@mui/material/TablePagination";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useState, Fragment, useEffect } from "react";
|
import { useState, Fragment, useEffect } from "react";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
|
import { SPACING, LAYOUT } from "@/Utils/Theme/constants";
|
||||||
import type { SxProps, Theme } from "@mui/material/styles";
|
import type { SxProps, Theme } from "@mui/material/styles";
|
||||||
import useMediaQuery from "@mui/material/useMediaQuery";
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
||||||
|
|
||||||
@@ -90,20 +91,20 @@ export function DataTable<
|
|||||||
// Return stack of cards for small screens
|
// Return stack of cards for small screens
|
||||||
if (isSmall && cardsOnSmallScreens) {
|
if (isSmall && cardsOnSmallScreens) {
|
||||||
return (
|
return (
|
||||||
<Stack spacing={theme.spacing(4)}>
|
<Stack spacing={theme.spacing(LAYOUT.XS)}>
|
||||||
{data.map((row) => {
|
{data.map((row) => {
|
||||||
const key = row.id || row._id || Math.random();
|
const key = row.id || row._id || Math.random();
|
||||||
keys.push(key);
|
keys.push(key);
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
onClick={() => (onRowClick ? onRowClick(row) : null)}
|
onClick={() => (onRowClick ? onRowClick(row) : null)}
|
||||||
spacing={theme.spacing(4)}
|
spacing={theme.spacing(LAYOUT.XS)}
|
||||||
sx={{
|
sx={{
|
||||||
borderStyle: "solid",
|
borderStyle: "solid",
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: theme.palette.divider,
|
borderColor: theme.palette.divider,
|
||||||
borderRadius: theme.shape.borderRadius,
|
borderRadius: theme.shape.borderRadius,
|
||||||
padding: theme.spacing(4),
|
padding: theme.spacing(LAYOUT.XS),
|
||||||
cursor: onRowClick ? "pointer" : "default",
|
cursor: onRowClick ? "pointer" : "default",
|
||||||
}}
|
}}
|
||||||
key={key}
|
key={key}
|
||||||
@@ -155,7 +156,7 @@ export function DataTable<
|
|||||||
<Table
|
<Table
|
||||||
sx={{
|
sx={{
|
||||||
"&.MuiTable-root :is(.MuiTableHead-root, .MuiTableBody-root) :is(th, td)": {
|
"&.MuiTable-root :is(.MuiTableHead-root, .MuiTableBody-root) :is(th, td)": {
|
||||||
paddingLeft: theme.spacing(8),
|
paddingLeft: theme.spacing(LAYOUT.MD),
|
||||||
},
|
},
|
||||||
"& .MuiTableCell-root": {
|
"& .MuiTableCell-root": {
|
||||||
borderBottom: `1px solid ${theme.palette.divider}`,
|
borderBottom: `1px solid ${theme.palette.divider}`,
|
||||||
@@ -168,13 +169,13 @@ export function DataTable<
|
|||||||
color: theme.palette.text.secondary,
|
color: theme.palette.text.secondary,
|
||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
textTransform: "uppercase",
|
textTransform: "uppercase",
|
||||||
padding: `${theme.spacing(2)} ${theme.spacing(8)}`,
|
padding: `${theme.spacing(SPACING.LG)} ${theme.spacing(LAYOUT.MD)}`,
|
||||||
fontSize: theme.typography.fontSize,
|
fontSize: theme.typography.fontSize,
|
||||||
},
|
},
|
||||||
"& :is(td)": {
|
"& :is(td)": {
|
||||||
backgroundColor: theme.palette.background.paper,
|
backgroundColor: theme.palette.background.paper,
|
||||||
color: theme.palette.text.secondary,
|
color: theme.palette.text.secondary,
|
||||||
padding: `${theme.spacing(7)} ${theme.spacing(8)}`,
|
padding: `${theme.spacing(LAYOUT.MD)} ${theme.spacing(LAYOUT.MD)}`,
|
||||||
fontSize: theme.typography.fontSize,
|
fontSize: theme.typography.fontSize,
|
||||||
overflowX: "hidden",
|
overflowX: "hidden",
|
||||||
},
|
},
|
||||||
@@ -514,7 +515,7 @@ export const Pagination = ({ ...props }: PaginationProps) => {
|
|||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: "1fr 1fr",
|
gridTemplateColumns: "1fr 1fr",
|
||||||
gridAutoRows: "auto",
|
gridAutoRows: "auto",
|
||||||
rowGap: theme.spacing(1),
|
rowGap: theme.spacing(SPACING.SM),
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyItems: "center",
|
justifyItems: "center",
|
||||||
paddingLeft: 0,
|
paddingLeft: 0,
|
||||||
@@ -556,8 +557,8 @@ const EmptyView = ({ text, positive }: { text?: string; positive?: boolean }) =>
|
|||||||
alignItems={"center"}
|
alignItems={"center"}
|
||||||
justifyContent={"center"}
|
justifyContent={"center"}
|
||||||
sx={{
|
sx={{
|
||||||
py: theme.spacing(12),
|
py: theme.spacing(LAYOUT.XL),
|
||||||
px: theme.spacing(4),
|
px: theme.spacing(LAYOUT.XS),
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderStyle: "solid",
|
borderStyle: "solid",
|
||||||
borderColor: theme.palette.divider,
|
borderColor: theme.palette.divider,
|
||||||
@@ -574,7 +575,7 @@ const EmptyView = ({ text, positive }: { text?: string; positive?: boolean }) =>
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
mb: theme.spacing(2),
|
mb: theme.spacing(SPACING.LG),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import {
|
|||||||
SliderWithLabel,
|
SliderWithLabel,
|
||||||
Dialog,
|
Dialog,
|
||||||
} from "@/Components/inputs";
|
} from "@/Components/inputs";
|
||||||
|
import { SPACING, LAYOUT } from "@/Utils/Theme/constants";
|
||||||
import { useGet, usePost, usePatch, useDelete } from "@/Hooks/UseApi";
|
import { useGet, usePost, usePatch, useDelete } from "@/Hooks/UseApi";
|
||||||
import { useMonitorForm } from "@/Hooks/useMonitorForm";
|
import { useMonitorForm } from "@/Hooks/useMonitorForm";
|
||||||
import type { Monitor, MonitorType, GamesMap } from "@/Types/Monitor";
|
import type { Monitor, MonitorType, GamesMap } from "@/Types/Monitor";
|
||||||
@@ -281,7 +282,7 @@ const CreateMonitorPage = () => {
|
|||||||
<FormControl error={!!fieldState.error}>
|
<FormControl error={!!fieldState.error}>
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
{...field}
|
{...field}
|
||||||
sx={{ gap: theme.spacing(6) }}
|
sx={{ gap: theme.spacing(LAYOUT.MD) }}
|
||||||
>
|
>
|
||||||
<RadioWithDescription
|
<RadioWithDescription
|
||||||
value="http"
|
value="http"
|
||||||
@@ -337,7 +338,7 @@ const CreateMonitorPage = () => {
|
|||||||
title={t("pages.createMonitor.form.general.title")}
|
title={t("pages.createMonitor.form.general.title")}
|
||||||
subtitle={t(`pages.createMonitor.form.general.description.${watchedType}`)}
|
subtitle={t(`pages.createMonitor.form.general.description.${watchedType}`)}
|
||||||
rightContent={
|
rightContent={
|
||||||
<Stack spacing={theme.spacing(8)}>
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
{/* URL/Host/Container field - not shown for hardware */}
|
{/* URL/Host/Container field - not shown for hardware */}
|
||||||
{generalSettingsConfig.showUrl && (
|
{generalSettingsConfig.showUrl && (
|
||||||
<Controller
|
<Controller
|
||||||
@@ -556,7 +557,7 @@ const CreateMonitorPage = () => {
|
|||||||
title={t("pages.createMonitor.form.thresholds.title")}
|
title={t("pages.createMonitor.form.thresholds.title")}
|
||||||
subtitle={t("pages.createMonitor.form.thresholds.description")}
|
subtitle={t("pages.createMonitor.form.thresholds.description")}
|
||||||
rightContent={
|
rightContent={
|
||||||
<Stack spacing={theme.spacing(8)}>
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
<Controller
|
<Controller
|
||||||
name="cpuAlertThreshold"
|
name="cpuAlertThreshold"
|
||||||
control={control}
|
control={control}
|
||||||
@@ -638,7 +639,7 @@ const CreateMonitorPage = () => {
|
|||||||
title={t("pages.createMonitor.form.incidents.title")}
|
title={t("pages.createMonitor.form.incidents.title")}
|
||||||
subtitle={t("pages.createMonitor.form.incidents.description")}
|
subtitle={t("pages.createMonitor.form.incidents.description")}
|
||||||
rightContent={
|
rightContent={
|
||||||
<Stack spacing={theme.spacing(12)}>
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
<Controller
|
<Controller
|
||||||
name="statusWindowSize"
|
name="statusWindowSize"
|
||||||
control={control}
|
control={control}
|
||||||
@@ -690,7 +691,7 @@ const CreateMonitorPage = () => {
|
|||||||
(field.value ?? []).includes(n.id)
|
(field.value ?? []).includes(n.id)
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Stack spacing={theme.spacing(4)}>
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
multiple
|
multiple
|
||||||
options={notificationOptions}
|
options={notificationOptions}
|
||||||
@@ -753,7 +754,7 @@ const CreateMonitorPage = () => {
|
|||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
spacing={theme.spacing(2)}
|
spacing={theme.spacing(SPACING.LG)}
|
||||||
>
|
>
|
||||||
<Switch
|
<Switch
|
||||||
checked={field.value ?? false}
|
checked={field.value ?? false}
|
||||||
@@ -774,7 +775,7 @@ const CreateMonitorPage = () => {
|
|||||||
title={t("pages.createMonitor.form.advanced.title")}
|
title={t("pages.createMonitor.form.advanced.title")}
|
||||||
subtitle={t("pages.createMonitor.form.advanced.description")}
|
subtitle={t("pages.createMonitor.form.advanced.description")}
|
||||||
rightContent={
|
rightContent={
|
||||||
<Stack spacing={theme.spacing(8)}>
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
<Controller
|
<Controller
|
||||||
name="useAdvancedMatching"
|
name="useAdvancedMatching"
|
||||||
control={control}
|
control={control}
|
||||||
@@ -782,7 +783,7 @@ const CreateMonitorPage = () => {
|
|||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
spacing={theme.spacing(2)}
|
spacing={theme.spacing(SPACING.LG)}
|
||||||
>
|
>
|
||||||
<Switch
|
<Switch
|
||||||
checked={field.value ?? false}
|
checked={field.value ?? false}
|
||||||
@@ -797,7 +798,7 @@ const CreateMonitorPage = () => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{watchedUseAdvancedMatching && (
|
{watchedUseAdvancedMatching && (
|
||||||
<Stack spacing={theme.spacing(8)}>
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
<Controller
|
<Controller
|
||||||
name="matchMethod"
|
name="matchMethod"
|
||||||
control={control}
|
control={control}
|
||||||
@@ -889,7 +890,7 @@ const CreateMonitorPage = () => {
|
|||||||
title={t("pages.createMonitor.form.geoChecks.title")}
|
title={t("pages.createMonitor.form.geoChecks.title")}
|
||||||
subtitle={t("pages.createMonitor.form.geoChecks.description")}
|
subtitle={t("pages.createMonitor.form.geoChecks.description")}
|
||||||
rightContent={
|
rightContent={
|
||||||
<Stack spacing={theme.spacing(8)}>
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
<Controller
|
<Controller
|
||||||
name="geoCheckEnabled"
|
name="geoCheckEnabled"
|
||||||
control={control}
|
control={control}
|
||||||
@@ -897,7 +898,7 @@ const CreateMonitorPage = () => {
|
|||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
spacing={theme.spacing(2)}
|
spacing={theme.spacing(SPACING.LG)}
|
||||||
>
|
>
|
||||||
<Switch
|
<Switch
|
||||||
checked={field.value ?? false}
|
checked={field.value ?? false}
|
||||||
@@ -910,7 +911,7 @@ const CreateMonitorPage = () => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{watchGeoCheckEnabled && (
|
{watchGeoCheckEnabled && (
|
||||||
<Stack spacing={theme.spacing(8)}>
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
<Controller
|
<Controller
|
||||||
name="geoCheckLocations"
|
name="geoCheckLocations"
|
||||||
control={control}
|
control={control}
|
||||||
@@ -926,7 +927,7 @@ const CreateMonitorPage = () => {
|
|||||||
(field.value ?? []).includes(loc.id)
|
(field.value ?? []).includes(loc.id)
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Stack spacing={theme.spacing(4)}>
|
<Stack spacing={theme.spacing(LAYOUT.MD)}>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
multiple
|
multiple
|
||||||
options={locationOptions}
|
options={locationOptions}
|
||||||
|
|||||||
Reference in new issue
Block a user