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 {boolean} props.isLoading - Loading state
|
||||||
* @param {Object} props.error - Error object if any
|
* @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 StatisticsPanel = ({ isLoading = false, error = null, summary = {} }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -150,7 +162,7 @@ const StatisticsPanel = ({ isLoading = false, error = null, summary = {} }) => {
|
|||||||
>
|
>
|
||||||
{t("incidentsPage.avgResolutionTime")}:{" "}
|
{t("incidentsPage.avgResolutionTime")}:{" "}
|
||||||
{summary.total > 0
|
{summary.total > 0
|
||||||
? `${summary.avgResolutionTimeHours || 0} ${t("incidentsPage.hours")}`
|
? formatResolutionTime(summary.avgResolutionTimeHours)
|
||||||
: "N/A"}
|
: "N/A"}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import IncidentsSummaryPanel from "./Components/IncidentsSummaryPanel/index.jsx"
|
|||||||
|
|
||||||
//Utils
|
//Utils
|
||||||
import { useTheme } from "@emotion/react";
|
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 NetworkError from "@/Components/v1/GenericFallback/NetworkError.jsx";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
@@ -53,16 +53,33 @@ const Incidents2 = () => {
|
|||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
useEffect(() => {
|
// Track previous filter values to detect changes and reset page
|
||||||
setPage(0);
|
const prevFiltersRef = useRef({ selectedMonitor, filter, dateRange });
|
||||||
}, [selectedMonitor, filter, dateRange]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
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 = {
|
const config = {
|
||||||
monitorId: selectedMonitor !== "0" ? selectedMonitor : undefined,
|
monitorId: selectedMonitor !== "0" ? selectedMonitor : undefined,
|
||||||
sortOrder: "desc",
|
sortOrder: "desc",
|
||||||
dateRange,
|
dateRange,
|
||||||
page,
|
page: effectivePage,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,21 @@ import { Typography } from "@mui/material";
|
|||||||
import { getHumanReadableDuration } from "../../../../../Utils/timeUtils.js";
|
import { getHumanReadableDuration } from "../../../../../Utils/timeUtils.js";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const PageSpeedStatusBoxes = ({ shouldRender, monitor }) => {
|
const PageSpeedStatusBoxes = ({ shouldRender, monitorStats }) => {
|
||||||
const uptimeDuration = getHumanReadableDuration(monitor?.uptimeDuration);
|
const lastChecked = monitorStats?.lastCheckTimestamp
|
||||||
const time = getHumanReadableDuration(monitor?.lastChecked);
|
? 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();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -16,7 +28,7 @@ const PageSpeedStatusBoxes = ({ shouldRender, monitor }) => {
|
|||||||
heading="checks since"
|
heading="checks since"
|
||||||
subHeading={
|
subHeading={
|
||||||
<>
|
<>
|
||||||
{uptimeDuration}
|
{streakTime}
|
||||||
<Typography component="span">{t("ago")}</Typography>
|
<Typography component="span">{t("ago")}</Typography>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user