Merge branch 'develop' into feat/fe/statuspage-3
This commit is contained in:
commit
12b14e1938
110 files changed
+3944
-4077
No files matched your search
@@ -614,6 +614,7 @@ class NetworkService {
|
||||
if (config.filter) params.append("filter", config.filter);
|
||||
if (config.page) params.append("page", config.page);
|
||||
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
||||
if (config.status !== undefined) params.append("status", config.status);
|
||||
|
||||
return this.axiosInstance.get(`/checks/${config.monitorId}?${params.toString()}`, {
|
||||
headers: { Authorization: `Bearer ${config.authToken}` },
|
||||
@@ -646,6 +647,7 @@ class NetworkService {
|
||||
if (config.filter) params.append("filter", config.filter);
|
||||
if (config.page) params.append("page", config.page);
|
||||
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
||||
if (config.status !== undefined) params.append("status", config.status);
|
||||
return this.axiosInstance.get(`/checks/team/${config.teamId}?${params.toString()}`, {
|
||||
headers: { Authorization: `Bearer ${config.authToken}` },
|
||||
});
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useNavigate } from "react-router";
|
||||
import { setNetworkService } from "./NetworkService";
|
||||
import NetworkService from "./NetworkService";
|
||||
import NetworkService, { networkService } from "./NetworkService";
|
||||
import { store } from "../store";
|
||||
|
||||
const NetworkServiceProvider = ({ children }) => {
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const networkService = new NetworkService(store, dispatch, navigate);
|
||||
setNetworkService(networkService);
|
||||
if (!networkService) {
|
||||
setNetworkService(new NetworkService(store, dispatch, navigate));
|
||||
}
|
||||
return children;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import dayjs from "dayjs";
|
||||
import duration from "dayjs/plugin/duration";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import customParseFormat from "dayjs/plugin/customParseFormat";
|
||||
@@ -6,6 +7,7 @@ import customParseFormat from "dayjs/plugin/customParseFormat";
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(customParseFormat);
|
||||
dayjs.extend(duration);
|
||||
|
||||
export const MS_PER_SECOND = 1000;
|
||||
export const MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
||||
@@ -75,6 +77,23 @@ export const formatDurationSplit = (ms) => {
|
||||
: { time: 0, format: "seconds" };
|
||||
};
|
||||
|
||||
export const getHumanReadableDuration = (ms) => {
|
||||
const durationObj = dayjs.duration(ms);
|
||||
if (durationObj.asDays() >= 1) {
|
||||
const days = Math.floor(durationObj.asDays());
|
||||
return { time: days, units: days === 1 ? "day" : "days" };
|
||||
} else if (durationObj.asHours() >= 1) {
|
||||
const hours = Math.floor(durationObj.asHours());
|
||||
return { time: hours, units: hours === 1 ? "hour" : "hours" };
|
||||
} else if (durationObj.asMinutes() >= 1) {
|
||||
const minutes = Math.floor(durationObj.asMinutes());
|
||||
return { time: minutes, units: minutes === 1 ? "minute" : "minutes" };
|
||||
} else {
|
||||
const seconds = Math.floor(durationObj.asSeconds());
|
||||
return { time: seconds, units: seconds === 1 ? "second" : "seconds" };
|
||||
}
|
||||
};
|
||||
|
||||
export const formatDate = (date, customOptions) => {
|
||||
const options = {
|
||||
year: "numeric",
|
||||
|
||||
Reference in new issue
Block a user