mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 21:09:03 +08:00
adds default options config by route
This commit is contained in:
parent
24416ceabd
commit
8b0abbec79
@ -10,7 +10,11 @@ import CustomDateTimeModal from "./CustomDateTimeModal";
|
|||||||
import { GlobalTime, updateTimeInterval } from "../../../store/actions";
|
import { GlobalTime, updateTimeInterval } from "../../../store/actions";
|
||||||
import { StoreState } from "../../../store/reducers";
|
import { StoreState } from "../../../store/reducers";
|
||||||
import FormItem from "antd/lib/form/FormItem";
|
import FormItem from "antd/lib/form/FormItem";
|
||||||
import { DefaultOptions, ServiceMapOptions } from "./config";
|
import {
|
||||||
|
Options,
|
||||||
|
ServiceMapOptions,
|
||||||
|
DefaultOptionsBasedOnRoute,
|
||||||
|
} from "./config";
|
||||||
import { DateTimeRangeType } from "../../../store/actions";
|
import { DateTimeRangeType } from "../../../store/actions";
|
||||||
import { METRICS_PAGE_QUERY_PARAM } from "Src/constants/query";
|
import { METRICS_PAGE_QUERY_PARAM } from "Src/constants/query";
|
||||||
import { LOCAL_STORAGE } from "Src/constants/localStorage";
|
import { LOCAL_STORAGE } from "Src/constants/localStorage";
|
||||||
@ -36,8 +40,12 @@ This components is mounted all the time. Use event listener to track changes.
|
|||||||
const _DateTimeSelector = (props: DateTimeSelectorProps) => {
|
const _DateTimeSelector = (props: DateTimeSelectorProps) => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const options =
|
const options =
|
||||||
location.pathname === ROUTES.SERVICE_MAP ? ServiceMapOptions : DefaultOptions;
|
location.pathname === ROUTES.SERVICE_MAP ? ServiceMapOptions : Options;
|
||||||
const defaultTime = options[0].value;
|
const defaultTime =
|
||||||
|
location.pathname === ROUTES.SERVICE_MAP ||
|
||||||
|
location.pathname === ROUTES.APPLICATION
|
||||||
|
? DefaultOptionsBasedOnRoute[location.pathname]
|
||||||
|
: DefaultOptionsBasedOnRoute.default;
|
||||||
|
|
||||||
const [customDTPickerVisible, setCustomDTPickerVisible] = useState(false);
|
const [customDTPickerVisible, setCustomDTPickerVisible] = useState(false);
|
||||||
const [timeInterval, setTimeInterval] = useState(defaultTime);
|
const [timeInterval, setTimeInterval] = useState(defaultTime);
|
||||||
@ -84,7 +92,7 @@ const _DateTimeSelector = (props: DateTimeSelectorProps) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateTimeOnQueryParamChange();
|
updateTimeOnQueryParamChange();
|
||||||
if (findIndex(options, (option) => option.value === timeInterval) === -1) {
|
if (findIndex(options, (option) => option.value === timeInterval) === -1) {
|
||||||
setTimeInterval(options[0].value);
|
setTimeInterval(defaultTime);
|
||||||
}
|
}
|
||||||
}, [location]);
|
}, [location]);
|
||||||
|
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
export const DefaultOptions = [
|
import ROUTES from "Src/constants/routes";
|
||||||
{ value: "custom", label: "Custom" },
|
|
||||||
|
export const Options = [
|
||||||
|
{ value: "5min", label: "Last 5 min" },
|
||||||
{ value: "15min", label: "Last 15 min" },
|
{ value: "15min", label: "Last 15 min" },
|
||||||
{ value: "30min", label: "Last 30 min" },
|
{ value: "30min", label: "Last 30 min" },
|
||||||
{ value: "1hr", label: "Last 1 hour" },
|
{ value: "1hr", label: "Last 1 hour" },
|
||||||
{ value: "6hr", label: "Last 6 hour" },
|
{ value: "6hr", label: "Last 6 hour" },
|
||||||
{ value: "1day", label: "Last 1 day" },
|
{ value: "1day", label: "Last 1 day" },
|
||||||
{ value: "1week", label: "Last 1 week" },
|
{ value: "1week", label: "Last 1 week" },
|
||||||
|
{ value: "custom", label: "Custom" },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const ServiceMapOptions = [
|
export const ServiceMapOptions = [
|
||||||
{ value: "1min", label: "Last 1 min" },
|
{ value: "1min", label: "Last 1 min" },
|
||||||
{ value: "5min", label: "Last 5 min" },
|
{ value: "5min", label: "Last 5 min" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const DefaultOptionsBasedOnRoute = {
|
||||||
|
[ROUTES.SERVICE_MAP]: ServiceMapOptions[0].value,
|
||||||
|
[ROUTES.APPLICATION]: Options[0].value,
|
||||||
|
default: Options[2].value,
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user