mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-30 07:41:58 +08:00

* feat: update time range selection flows to handle relative and absolute times * fix: lint error * fix: lint error * feat: update logic to handle custom relative times on load and standardize relative time formats * fix: type issue * fix: handle light mode and on custom time range select * chore: update alert frequency corresponding times * chore: update copy URL * feat: update styles
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { PANEL_TYPES } from 'constants/queryBuilder';
|
|
import { timePreferenceType } from 'container/NewWidget/RightContainer/timeItems';
|
|
import { Time } from 'container/TopNav/DateTimeSelection/config';
|
|
import {
|
|
CustomTimeType,
|
|
Time as TimeV2,
|
|
} from 'container/TopNav/DateTimeSelectionV2/config';
|
|
import store from 'store';
|
|
|
|
import getMaxMinTime from './getMaxMinTime';
|
|
import getMinMax from './getMinMax';
|
|
import getStartAndEndTime from './getStartAndEndTime';
|
|
|
|
const getStartEndRangeTime = ({
|
|
type = 'GLOBAL_TIME',
|
|
graphType = null,
|
|
interval = 'custom',
|
|
}: GetStartEndRangeTimesProps): GetStartEndRangeTimesPayload => {
|
|
const { globalTime } = store.getState();
|
|
|
|
const minMax = getMinMax(interval, [
|
|
globalTime.minTime / 1000000,
|
|
globalTime.maxTime / 1000000,
|
|
]);
|
|
|
|
const maxMinTime = getMaxMinTime({
|
|
graphType,
|
|
maxTime: minMax.maxTime,
|
|
minTime: minMax.minTime,
|
|
});
|
|
|
|
const { end, start } = getStartAndEndTime({
|
|
type,
|
|
maxTime: maxMinTime.maxTime,
|
|
minTime: maxMinTime.minTime,
|
|
});
|
|
|
|
return { start, end };
|
|
};
|
|
|
|
interface GetStartEndRangeTimesProps {
|
|
type?: timePreferenceType;
|
|
graphType?: PANEL_TYPES | null;
|
|
interval?: Time | TimeV2 | CustomTimeType;
|
|
}
|
|
|
|
interface GetStartEndRangeTimesPayload {
|
|
start: string;
|
|
end: string;
|
|
}
|
|
|
|
export default getStartEndRangeTime;
|