divider
This commit is contained in:
1 parent
88a91022c3
commit
83b628c8f9
3 files changed
+59
-49
No files matched your search
@@ -18,7 +18,6 @@ import { useTheme } from "@mui/material/styles";
|
|||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
|
|
||||||
interface IncidentsTableProps {
|
interface IncidentsTableProps {
|
||||||
title?: string;
|
|
||||||
incidents?: Incident[];
|
incidents?: Incident[];
|
||||||
monitors?: Monitor[];
|
monitors?: Monitor[];
|
||||||
incidentsCount: number;
|
incidentsCount: number;
|
||||||
@@ -103,7 +102,11 @@ export const IncidentsTable = ({
|
|||||||
return (
|
return (
|
||||||
<ValueLabel
|
<ValueLabel
|
||||||
value={isActive ? "negative" : "positive"}
|
value={isActive ? "negative" : "positive"}
|
||||||
text={isActive ? t("pages.incidents.table.status.active") : t("pages.incidents.table.status.resolved")}
|
text={
|
||||||
|
isActive
|
||||||
|
? t("pages.incidents.table.status.active")
|
||||||
|
: t("pages.incidents.table.status.resolved")
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -112,11 +115,7 @@ export const IncidentsTable = ({
|
|||||||
id: "startTime",
|
id: "startTime",
|
||||||
content: t("pages.incidents.table.headers.startTime"),
|
content: t("pages.incidents.table.headers.startTime"),
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
return formatDateWithTz(
|
return formatDateWithTz(row.createdAt, "YYYY-MM-DD HH:mm:ss A", uiTimezone);
|
||||||
row.createdAt,
|
|
||||||
"YYYY-MM-DD HH:mm:ss A",
|
|
||||||
uiTimezone
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -124,11 +123,7 @@ export const IncidentsTable = ({
|
|||||||
content: t("pages.incidents.table.headers.endTime"),
|
content: t("pages.incidents.table.headers.endTime"),
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
if (row.endTime) {
|
if (row.endTime) {
|
||||||
return formatDateWithTz(
|
return formatDateWithTz(row.endTime, "YYYY-MM-DD HH:mm:ss A", uiTimezone);
|
||||||
row.endTime,
|
|
||||||
"YYYY-MM-DD HH:mm:ss A",
|
|
||||||
uiTimezone
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return "-";
|
return "-";
|
||||||
},
|
},
|
||||||
@@ -165,7 +160,12 @@ export const IncidentsTable = ({
|
|||||||
let value: ValueType = "neutral";
|
let value: ValueType = "neutral";
|
||||||
if (code < 300) value = "positive";
|
if (code < 300) value = "positive";
|
||||||
else if (code >= 400) value = "negative";
|
else if (code >= 400) value = "negative";
|
||||||
return <ValueLabel value={value} text={String(code)} />;
|
return (
|
||||||
|
<ValueLabel
|
||||||
|
value={value}
|
||||||
|
text={String(code)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -202,14 +202,6 @@ export const IncidentsTable = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
{title && (
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
sx={{ mb: theme.spacing(4), textTransform: "uppercase" }}
|
|
||||||
>
|
|
||||||
{title}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
<Table
|
<Table
|
||||||
headers={getHeaders()}
|
headers={getHeaders()}
|
||||||
data={incidents}
|
data={incidents}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { BasePage } from "@/Components/v2/design-elements";
|
import { BasePage } from "@/Components/v2/design-elements";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import Divider from "@mui/material/Divider";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
SummaryCardActiveIncidents,
|
SummaryCardActiveIncidents,
|
||||||
@@ -47,9 +49,9 @@ const IncidentsPage = () => {
|
|||||||
const incidentsUrl = useMemo(() => {
|
const incidentsUrl = useMemo(() => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
if (selectedMonitor !== "0") params.append("monitorId", selectedMonitor);
|
if (selectedMonitor !== "0") params.append("monitorId", selectedMonitor);
|
||||||
if (filter === "active") params.append("status", "true");
|
// Always show only resolved incidents (active ones are in the separate table above)
|
||||||
else if (filter === "resolved") params.append("status", "false");
|
params.append("status", "false");
|
||||||
else if (filter === "manual" || filter === "automatic")
|
if (filter === "manual" || filter === "automatic")
|
||||||
params.append("resolutionType", filter);
|
params.append("resolutionType", filter);
|
||||||
params.append("sortOrder", "desc");
|
params.append("sortOrder", "desc");
|
||||||
if (dateRange !== "all") params.append("dateRange", dateRange);
|
if (dateRange !== "all") params.append("dateRange", dateRange);
|
||||||
@@ -89,14 +91,12 @@ const IncidentsPage = () => {
|
|||||||
}, [selectedMonitor, activeIncidentsPage, activeIncidentsRowsPerPage]);
|
}, [selectedMonitor, activeIncidentsPage, activeIncidentsRowsPerPage]);
|
||||||
|
|
||||||
// Fetch active incidents
|
// Fetch active incidents
|
||||||
const {
|
const { data: activeIncidentsData, refetch: refetchActiveIncidents } =
|
||||||
data: activeIncidentsData,
|
useGet<IncidentsResponse>(
|
||||||
refetch: refetchActiveIncidents,
|
activeIncidentsUrl,
|
||||||
} = useGet<IncidentsResponse>(
|
{},
|
||||||
activeIncidentsUrl,
|
{ keepPreviousData: true, refreshInterval: 10000 }
|
||||||
{},
|
);
|
||||||
{ keepPreviousData: true, refreshInterval: 10000 }
|
|
||||||
);
|
|
||||||
|
|
||||||
// Fetch incident summary
|
// Fetch incident summary
|
||||||
const {
|
const {
|
||||||
@@ -129,7 +129,10 @@ const IncidentsPage = () => {
|
|||||||
void networkError;
|
void networkError;
|
||||||
|
|
||||||
const handleOpenDetails = (incidentId: string) => {
|
const handleOpenDetails = (incidentId: string) => {
|
||||||
const incident = incidents.find((i) => i.id === incidentId) ?? activeIncidents.find((i) => i.id === incidentId) ?? null;
|
const incident =
|
||||||
|
incidents.find((i) => i.id === incidentId) ??
|
||||||
|
activeIncidents.find((i) => i.id === incidentId) ??
|
||||||
|
null;
|
||||||
const monitor = monitorsData?.find((m) => m.id === incident?.monitorId) ?? null;
|
const monitor = monitorsData?.find((m) => m.id === incident?.monitorId) ?? null;
|
||||||
setIsDetailsDialogOpen(true);
|
setIsDetailsDialogOpen(true);
|
||||||
setSelectedIncident(incident);
|
setSelectedIncident(incident);
|
||||||
@@ -173,27 +176,42 @@ const IncidentsPage = () => {
|
|||||||
<SummaryCardLatestIncidents summary={summaryData} />
|
<SummaryCardLatestIncidents summary={summaryData} />
|
||||||
<SummaryCardStats summary={summaryData} />
|
<SummaryCardStats summary={summaryData} />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
<Typography
|
||||||
|
variant="h6"
|
||||||
|
sx={{ mb: theme.spacing(4), textTransform: "uppercase" }}
|
||||||
|
>
|
||||||
|
{t("pages.incidents.table.activeIncidents")}
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
{activeIncidentsCount > 0 && (
|
||||||
|
<>
|
||||||
|
<IncidentsTable
|
||||||
|
incidents={activeIncidents}
|
||||||
|
monitors={monitorsData ?? undefined}
|
||||||
|
incidentsCount={activeIncidentsCount}
|
||||||
|
page={activeIncidentsPage}
|
||||||
|
setPage={setActiveIncidentsPage}
|
||||||
|
rowsPerPage={activeIncidentsRowsPerPage}
|
||||||
|
setRowsPerPage={setActiveIncidentsRowsPerPage}
|
||||||
|
onOpenDetails={handleOpenDetails}
|
||||||
|
onResolve={handleResolve}
|
||||||
|
/>
|
||||||
|
<Divider />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Typography
|
||||||
|
variant="h6"
|
||||||
|
sx={{ mb: theme.spacing(4), textTransform: "uppercase" }}
|
||||||
|
>
|
||||||
|
{t("pages.incidents.table.resolvedIncidents")}
|
||||||
|
</Typography>
|
||||||
<HeaderTimeRange
|
<HeaderTimeRange
|
||||||
dateRange={dateRange}
|
dateRange={dateRange}
|
||||||
setDateRange={setDateRange}
|
setDateRange={setDateRange}
|
||||||
isLoading={isLoadingIncidents}
|
isLoading={isLoadingIncidents}
|
||||||
/>
|
/>
|
||||||
{activeIncidentsCount > 0 && (
|
|
||||||
<IncidentsTable
|
|
||||||
title={t("pages.incidents.table.activeIncidents")}
|
|
||||||
incidents={activeIncidents}
|
|
||||||
monitors={monitorsData ?? undefined}
|
|
||||||
incidentsCount={activeIncidentsCount}
|
|
||||||
page={activeIncidentsPage}
|
|
||||||
setPage={setActiveIncidentsPage}
|
|
||||||
rowsPerPage={activeIncidentsRowsPerPage}
|
|
||||||
setRowsPerPage={setActiveIncidentsRowsPerPage}
|
|
||||||
onOpenDetails={handleOpenDetails}
|
|
||||||
onResolve={handleResolve}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<IncidentsTable
|
<IncidentsTable
|
||||||
title={t("pages.incidents.table.allIncidents")}
|
|
||||||
incidents={incidents}
|
incidents={incidents}
|
||||||
monitors={monitorsData ?? undefined}
|
monitors={monitorsData ?? undefined}
|
||||||
incidentsCount={incidentsCount}
|
incidentsCount={incidentsCount}
|
||||||
|
|||||||
@@ -397,7 +397,7 @@
|
|||||||
|
|
||||||
"table": {
|
"table": {
|
||||||
"activeIncidents": "Active Incidents",
|
"activeIncidents": "Active Incidents",
|
||||||
"allIncidents": "All Incidents",
|
"resolvedIncidents": "Resolved Incidents",
|
||||||
"headers": {
|
"headers": {
|
||||||
"startTime": "Start Time",
|
"startTime": "Start Time",
|
||||||
"endTime": "End Time",
|
"endTime": "End Time",
|
||||||
|
|||||||
Reference in new issue
Block a user