Status code 5000 is Checkmate's internal sentinel for "no HTTP response received" (DNS failure, connection refused, timeout, TLS error, etc.). Showing the raw number to admins is confusing — the value isn't a real HTTP code and means nothing without context. This change replaces "5000" with "Down" across all check/incident surfaces, and adds a hover tooltip that explains the underlying cause based on the stored error message. Real HTTP codes (2xx/3xx/4xx/5xx) are unchanged. ## Changes - Add client/src/Utils/statusCode.ts with formatStatusCode, getStatusCodeTooltip, getStatusCodeValueType, extractErrorCode, and a message-to-subtype parser (timeout / dns / refused / tls / reset). - Wire into 6 render sites: Checks table, Uptime details Checks table, GeoChecks table + map popup, Incidents table, Incident details dialog. - Add common.statusCode.* i18n keys in en.json with subtype-specific descriptions. Tooltip appends the raw error code (ECONNREFUSED, ETIMEDOUT, CERT_HAS_EXPIRED, etc.) when present in the message. ## Tooltip examples - "queryA ECONNREFUSED www.example.com" → "The server refused the connection (port closed or service not listening). (ECONNREFUSED)" - "connect ETIMEDOUT 1.2.3.4:443" → "The server didn't respond in time (request timed out). (ETIMEDOUT)" ## Notes - No DB or server changes; statusCode field stays 5000 in storage. - Other locales fall back to English keys until translated.
118 lines
2.9 KiB
TypeScript
118 lines
2.9 KiB
TypeScript
import { Table, Pagination, StatusLabel, Tooltip } from "@/Components/design-elements";
|
|
import Box from "@mui/material/Box";
|
|
import type { Header } from "@/Components/design-elements";
|
|
import type { FlatGeoCheck } from "@/Types/GeoCheck";
|
|
import { useTranslation } from "react-i18next";
|
|
import { formatDateWithTz } from "@/Utils/TimeUtils";
|
|
import { formatStatusCode, getStatusCodeTooltip } from "@/Utils/statusCode";
|
|
import type { RootState } from "@/Types/state";
|
|
import { useSelector } from "react-redux";
|
|
import prettyMilliseconds from "pretty-ms";
|
|
|
|
const getHeaders = (t: (key: string) => string, uiTimezone: string) => {
|
|
const headers: Header<FlatGeoCheck>[] = [
|
|
{
|
|
id: "status",
|
|
content: t("common.table.headers.status"),
|
|
render: (row) => {
|
|
const status = row.status ? "up" : "down";
|
|
return <StatusLabel status={status} />;
|
|
},
|
|
},
|
|
{
|
|
id: "date",
|
|
content: t("common.table.headers.dateTime"),
|
|
render: (row) => {
|
|
return formatDateWithTz(row.createdAt, "ddd, MMMM D, YYYY, HH:mm A", uiTimezone);
|
|
},
|
|
},
|
|
{
|
|
id: "statusCode",
|
|
content: t("pages.checks.table.headers.statusCode"),
|
|
render: (row) => {
|
|
if (!row.statusCode) return "N/A";
|
|
const text = formatStatusCode(row.statusCode, t);
|
|
const tooltip = getStatusCodeTooltip(row.statusCode, undefined, t);
|
|
return tooltip ? (
|
|
<Tooltip title={tooltip}>
|
|
<span>{text}</span>
|
|
</Tooltip>
|
|
) : (
|
|
text
|
|
);
|
|
},
|
|
},
|
|
{
|
|
id: "location",
|
|
content: t("pages.checks.table.headers.location"),
|
|
render: (row) => {
|
|
const location = row.location;
|
|
if (!location) return "N/A";
|
|
const { continent, country, city } = location;
|
|
return `${continent} - ${country}, ${city}`;
|
|
},
|
|
},
|
|
{
|
|
id: "responseTime",
|
|
content: t("common.table.headers.responseTime"),
|
|
render: (row) => {
|
|
if (!row.timings?.total) return "N/A";
|
|
return prettyMilliseconds(row.timings.total, { compact: true });
|
|
},
|
|
},
|
|
];
|
|
return headers;
|
|
};
|
|
|
|
export const GeoChecksTable = ({
|
|
geoChecks,
|
|
count,
|
|
page,
|
|
setPage,
|
|
rowsPerPage,
|
|
setRowsPerPage,
|
|
}: {
|
|
geoChecks: FlatGeoCheck[];
|
|
count: number;
|
|
page: number;
|
|
setPage: (page: number) => void;
|
|
rowsPerPage: number;
|
|
setRowsPerPage: (rowsPerPage: number) => void;
|
|
}) => {
|
|
const { t } = useTranslation();
|
|
const uiTimezone = useSelector((state: RootState) => state.ui.timezone);
|
|
const headers = getHeaders(t, uiTimezone);
|
|
|
|
const handlePageChange = (
|
|
_e: React.MouseEvent<HTMLButtonElement> | null,
|
|
newPage: number
|
|
) => {
|
|
setPage(newPage);
|
|
};
|
|
|
|
const handleRowsPerPageChange = (
|
|
e: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>
|
|
) => {
|
|
const value = Number(e.target.value);
|
|
setPage(0);
|
|
setRowsPerPage(value);
|
|
};
|
|
|
|
return (
|
|
<Box>
|
|
<Table
|
|
headers={headers}
|
|
data={geoChecks}
|
|
/>
|
|
<Pagination
|
|
component="div"
|
|
count={count}
|
|
page={page}
|
|
rowsPerPage={rowsPerPage}
|
|
onPageChange={handlePageChange}
|
|
onRowsPerPageChange={handleRowsPerPageChange}
|
|
/>
|
|
</Box>
|
|
);
|
|
};
|