radio
This commit is contained in:
1 parent
b5bdd73a90
commit
33aab936fe
5 files changed
+60
-34
No files matched your search
@@ -7,7 +7,7 @@ import { HeatmapResponseTimeTooltip } from "./HeatmapResponseTimeTooltip";
|
|||||||
|
|
||||||
interface HistogramResponseTimeProps {
|
interface HistogramResponseTimeProps {
|
||||||
checks: ICheck[];
|
checks: ICheck[];
|
||||||
height?: number | string;
|
height?: ResponsiveStyleValue<number | string>;
|
||||||
gap?: ResponsiveStyleValue<number | string>;
|
gap?: ResponsiveStyleValue<number | string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
import Grid from "@mui/material/Grid";
|
import Grid from "@mui/material/Grid";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { HeatmapResponseTime } from "../common/HeatmapResponseTime";
|
import { HeatmapResponseTime } from "../common/HeatmapResponseTime";
|
||||||
|
import { HistogramResponseTime } from "../common/HistogramResponseTime";
|
||||||
import { StatusLabel } from "@/components/design-elements";
|
import { StatusLabel } from "@/components/design-elements";
|
||||||
import { useTheme } from "@mui/material/styles";
|
|
||||||
|
|
||||||
|
import { useTheme } from "@mui/material/styles";
|
||||||
|
import { useAppSelector } from "@/hooks/AppHooks";
|
||||||
import type { IMonitor } from "@/types/monitor";
|
import type { IMonitor } from "@/types/monitor";
|
||||||
|
|
||||||
export const StatusPageRow = ({ monitor }: { monitor: IMonitor }) => {
|
export const StatusPageRow = ({ monitor }: { monitor: IMonitor }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const type = useAppSelector((state) => state?.ui?.chartType || "heatmap");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container>
|
<Grid container>
|
||||||
@@ -23,22 +26,31 @@ export const StatusPageRow = ({ monitor }: { monitor: IMonitor }) => {
|
|||||||
<StatusLabel status={monitor?.status} sx={{ py: 1 }} />
|
<StatusLabel status={monitor?.status} sx={{ py: 1 }} />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid size={12} marginTop={theme.spacing(2)}>
|
<Grid size={12} marginTop={theme.spacing(2)}>
|
||||||
<HeatmapResponseTime
|
{type === "heatmap" && (
|
||||||
gap={{ xs: theme.spacing(0.5), md: theme.spacing(2) }}
|
<HeatmapResponseTime
|
||||||
checks={monitor?.latestChecks}
|
gap={{ xs: theme.spacing(0.5), md: theme.spacing(2) }}
|
||||||
availabilityCellSx={{
|
checks={monitor?.latestChecks}
|
||||||
borderRadius: {
|
availabilityCellSx={{
|
||||||
xs: theme.spacing(0.5),
|
borderRadius: {
|
||||||
md: theme.shape.borderRadius,
|
xs: theme.spacing(0.5),
|
||||||
},
|
md: theme.shape.borderRadius,
|
||||||
}}
|
},
|
||||||
responseCellSx={{
|
}}
|
||||||
borderRadius: {
|
responseCellSx={{
|
||||||
xs: theme.spacing(0.5),
|
borderRadius: {
|
||||||
md: theme.shape.borderRadius,
|
xs: theme.spacing(0.5),
|
||||||
},
|
md: theme.shape.borderRadius,
|
||||||
}}
|
},
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{type === "histogram" && (
|
||||||
|
<HistogramResponseTime
|
||||||
|
checks={monitor?.latestChecks}
|
||||||
|
height={{ xs: 50, md: 100 }}
|
||||||
|
gap={{ xs: 0.5, md: theme.spacing(4) }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import { BasePage, ConfigBox } from "@/components/design-elements";
|
import { BasePage, ConfigBox } from "@/components/design-elements";
|
||||||
import { AutoComplete, Select, LanguageSelector } from "@/components/inputs";
|
import { AutoComplete, Select, LanguageSelector } from "@/components/inputs";
|
||||||
|
import { RadioWithDescription } from "@/components/inputs/RadioInput";
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { SettingsForm } from "@/pages/settings/SettingsForm";
|
import { SettingsForm } from "@/pages/settings/SettingsForm";
|
||||||
@@ -100,22 +101,26 @@ const SettingsPage = () => {
|
|||||||
subtitle="Choose what type of Uptime chart you want to see on the dashboard and status page"
|
subtitle="Choose what type of Uptime chart you want to see on the dashboard and status page"
|
||||||
leftContent={<DummyChart type={chartType} />}
|
leftContent={<DummyChart type={chartType} />}
|
||||||
rightContent={
|
rightContent={
|
||||||
<Stack spacing={theme.spacing(2)}>
|
<Stack gap={theme.spacing(4)}>
|
||||||
<Typography>Chart Type</Typography>
|
<Typography>Chart Type</Typography>
|
||||||
<Select
|
<Stack gap={theme.spacing(4)}>
|
||||||
value={chartType}
|
<RadioWithDescription
|
||||||
onChange={(e: SelectChangeEvent<string>) => {
|
checked={chartType === "heatmap"}
|
||||||
dispatch(setChartType(e.target.value as ChartType));
|
onChange={() => dispatch(setChartType("heatmap"))}
|
||||||
}}
|
value="heatmap"
|
||||||
>
|
label="Heatmap"
|
||||||
<MenuItem value="heatmap">Heatmap</MenuItem>
|
description="Compact tiles; color shows response speed, top strip shows availability."
|
||||||
<MenuItem value="histogram">Histogram</MenuItem>
|
name="chart-type"
|
||||||
</Select>
|
/>
|
||||||
<Typography>
|
<RadioWithDescription
|
||||||
{chartType === "heatmap"
|
checked={chartType === "histogram"}
|
||||||
? "Heatmap: colored line indicates status"
|
onChange={() => dispatch(setChartType("histogram"))}
|
||||||
: "Bar chart: color denotes status (up/down). height denotes response time"}
|
value="histogram"
|
||||||
</Typography>
|
label="Histogram"
|
||||||
|
description="One bar per check; height shows response time, color shows status."
|
||||||
|
name="chart-type"
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import type { ApiResponse } from "@/hooks/UseApi";
|
|||||||
import { useParams } from "react-router";
|
import { useParams } from "react-router";
|
||||||
import type { IStatusPageWithMonitors } from "@/types/status-page";
|
import type { IStatusPageWithMonitors } from "@/types/status-page";
|
||||||
import { NameHeader } from "@/components/status-pages/NameHeader";
|
import { NameHeader } from "@/components/status-pages/NameHeader";
|
||||||
|
|
||||||
const GLOBAL_REFRESH = import.meta.env.VITE_APP_GLOBAL_REFRESH;
|
const GLOBAL_REFRESH = import.meta.env.VITE_APP_GLOBAL_REFRESH;
|
||||||
const StatusPages = () => {
|
const StatusPages = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import type { Header } from "@/components/design-elements/Table";
|
|||||||
import { ActionsMenu } from "@/components/actions-menu";
|
import { ActionsMenu } from "@/components/actions-menu";
|
||||||
import { ArrowDown, ArrowUp } from "lucide-react";
|
import { ArrowDown, ArrowUp } from "lucide-react";
|
||||||
|
|
||||||
|
import { useAppSelector } from "@/hooks/AppHooks";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
@@ -139,6 +140,9 @@ export const MonitorTable = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getHeaders = () => {
|
const getHeaders = () => {
|
||||||
|
const chartType = useAppSelector(
|
||||||
|
(state) => state?.ui?.chartType || "heatmap"
|
||||||
|
);
|
||||||
const renderSortIcon = (isActive: boolean) => (
|
const renderSortIcon = (isActive: boolean) => (
|
||||||
<Box width={16} display="inline-flex" justifyContent="center">
|
<Box width={16} display="inline-flex" justifyContent="center">
|
||||||
{isActive ? (
|
{isActive ? (
|
||||||
@@ -193,7 +197,11 @@ export const MonitorTable = ({
|
|||||||
id: "histogram",
|
id: "histogram",
|
||||||
content: t("responseTime"),
|
content: t("responseTime"),
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
return <HeatmapResponseTime checks={row.latestChecks} />;
|
if (chartType === "histogram") {
|
||||||
|
return <HistogramResponseTime checks={row.latestChecks} />;
|
||||||
|
} else {
|
||||||
|
return <HeatmapResponseTime checks={row.latestChecks} />;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user