Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35ee4d3bcb | ||
|
|
162b081858 | ||
|
|
6c0aea46a7 |
No files matched your search
@@ -26,6 +26,18 @@ import SummaryCard from "../SummaryCard/index.jsx";
|
||||
* @param {boolean} props.isLoading - Loading state
|
||||
* @param {Object} props.error - Error object if any
|
||||
*/
|
||||
const formatResolutionTime = (hours) => {
|
||||
if (!hours || hours === 0) return "0m";
|
||||
|
||||
const totalMinutes = Math.round(hours * 60);
|
||||
const h = Math.floor(totalMinutes / 60);
|
||||
const m = totalMinutes % 60;
|
||||
|
||||
if (h === 0) return `${m}m`;
|
||||
if (m === 0) return `${h}h`;
|
||||
return `${h}h ${m}m`;
|
||||
};
|
||||
|
||||
const StatisticsPanel = ({ isLoading = false, error = null, summary = {} }) => {
|
||||
const theme = useTheme();
|
||||
const { t } = useTranslation();
|
||||
@@ -150,7 +162,7 @@ const StatisticsPanel = ({ isLoading = false, error = null, summary = {} }) => {
|
||||
>
|
||||
{t("incidentsPage.avgResolutionTime")}:{" "}
|
||||
{summary.total > 0
|
||||
? `${summary.avgResolutionTimeHours || 0} ${t("incidentsPage.hours")}`
|
||||
? formatResolutionTime(summary.avgResolutionTimeHours)
|
||||
: "N/A"}
|
||||
</Typography>
|
||||
</Stack>
|
||||
|
||||
@@ -8,7 +8,7 @@ import IncidentsSummaryPanel from "./Components/IncidentsSummaryPanel/index.jsx"
|
||||
|
||||
//Utils
|
||||
import { useTheme } from "@emotion/react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import NetworkError from "@/Components/v1/GenericFallback/NetworkError.jsx";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
@@ -53,16 +53,33 @@ const Incidents2 = () => {
|
||||
|
||||
const theme = useTheme();
|
||||
|
||||
useEffect(() => {
|
||||
setPage(0);
|
||||
}, [selectedMonitor, filter, dateRange]);
|
||||
// Track previous filter values to detect changes and reset page
|
||||
const prevFiltersRef = useRef({ selectedMonitor, filter, dateRange });
|
||||
|
||||
useEffect(() => {
|
||||
const prevFilters = prevFiltersRef.current;
|
||||
const filtersChanged =
|
||||
prevFilters.selectedMonitor !== selectedMonitor ||
|
||||
prevFilters.filter !== filter ||
|
||||
prevFilters.dateRange !== dateRange;
|
||||
|
||||
// Determine the effective page - reset to 0 if filters changed
|
||||
const effectivePage = filtersChanged ? 0 : page;
|
||||
|
||||
// Update the ref for next comparison
|
||||
if (filtersChanged) {
|
||||
prevFiltersRef.current = { selectedMonitor, filter, dateRange };
|
||||
// Also update the page state (for pagination component)
|
||||
if (page !== 0) {
|
||||
setPage(0);
|
||||
}
|
||||
}
|
||||
|
||||
const config = {
|
||||
monitorId: selectedMonitor !== "0" ? selectedMonitor : undefined,
|
||||
sortOrder: "desc",
|
||||
dateRange,
|
||||
page,
|
||||
page: effectivePage,
|
||||
rowsPerPage,
|
||||
};
|
||||
|
||||
|
||||
@@ -4,9 +4,21 @@ import { Typography } from "@mui/material";
|
||||
import { getHumanReadableDuration } from "../../../../../Utils/timeUtils.js";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
const PageSpeedStatusBoxes = ({ shouldRender, monitor }) => {
|
||||
const uptimeDuration = getHumanReadableDuration(monitor?.uptimeDuration);
|
||||
const time = getHumanReadableDuration(monitor?.lastChecked);
|
||||
const PageSpeedStatusBoxes = ({ shouldRender, monitorStats }) => {
|
||||
const lastChecked = monitorStats?.lastCheckTimestamp
|
||||
? Date.now() - monitorStats.lastCheckTimestamp
|
||||
: 0;
|
||||
|
||||
// Determine time since last failure
|
||||
const timeOfLastFailure = monitorStats?.timeOfLastFailure;
|
||||
const timeSinceLastFailure =
|
||||
timeOfLastFailure > 0
|
||||
? Date.now() - timeOfLastFailure
|
||||
: Date.now() - new Date(monitorStats?.createdAt);
|
||||
|
||||
const streakTime = getHumanReadableDuration(timeSinceLastFailure);
|
||||
|
||||
const time = getHumanReadableDuration(lastChecked);
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -16,7 +28,7 @@ const PageSpeedStatusBoxes = ({ shouldRender, monitor }) => {
|
||||
heading="checks since"
|
||||
subHeading={
|
||||
<>
|
||||
{uptimeDuration}
|
||||
{streakTime}
|
||||
<Typography component="span">{t("ago")}</Typography>
|
||||
</>
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user