mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 16:55:54 +08:00
fix: logs time is fixed (#1772)
* fix: logs parsing is fixed * fix: start and end time is updated
This commit is contained in:
parent
7e590f4bfb
commit
5ae9557293
@ -1,3 +1,7 @@
|
|||||||
|
import GetMinMax, { GetMinMaxPayload } from 'lib/getMinMax';
|
||||||
|
|
||||||
|
import { Time } from '../DateTimeSelection/config';
|
||||||
|
|
||||||
export const options: IOptions[] = [
|
export const options: IOptions[] = [
|
||||||
{
|
{
|
||||||
label: 'off',
|
label: 'off',
|
||||||
@ -61,3 +65,12 @@ export interface IOptions {
|
|||||||
key: string;
|
key: string;
|
||||||
value: number;
|
value: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getMinMax = (
|
||||||
|
selectedTime: Time,
|
||||||
|
minTime: number,
|
||||||
|
maxTime: number,
|
||||||
|
): GetMinMaxPayload =>
|
||||||
|
selectedTime !== 'custom'
|
||||||
|
? GetMinMax(selectedTime)
|
||||||
|
: GetMinMax(selectedTime, [minTime, maxTime]);
|
||||||
|
@ -12,7 +12,6 @@ import { CheckboxChangeEvent } from 'antd/lib/checkbox';
|
|||||||
import get from 'api/browser/localstorage/get';
|
import get from 'api/browser/localstorage/get';
|
||||||
import set from 'api/browser/localstorage/set';
|
import set from 'api/browser/localstorage/set';
|
||||||
import { DASHBOARD_TIME_IN_DURATION } from 'constants/app';
|
import { DASHBOARD_TIME_IN_DURATION } from 'constants/app';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
import useUrlQuery from 'hooks/useUrlQuery';
|
import useUrlQuery from 'hooks/useUrlQuery';
|
||||||
import _omit from 'lodash-es/omit';
|
import _omit from 'lodash-es/omit';
|
||||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
@ -28,21 +27,19 @@ import {
|
|||||||
} from 'types/actions/globalTime';
|
} from 'types/actions/globalTime';
|
||||||
import { GlobalReducer } from 'types/reducer/globalTime';
|
import { GlobalReducer } from 'types/reducer/globalTime';
|
||||||
|
|
||||||
import { options } from './config';
|
import { getMinMax, options } from './config';
|
||||||
import { ButtonContainer, Container } from './styles';
|
import { ButtonContainer, Container } from './styles';
|
||||||
|
|
||||||
function AutoRefresh({ disabled = false }: AutoRefreshProps): JSX.Element {
|
function AutoRefresh({ disabled = false }: AutoRefreshProps): JSX.Element {
|
||||||
const {
|
const globalTime = useSelector<AppState, GlobalReducer>(
|
||||||
minTime: initialMinTime,
|
(state) => state.globalTime,
|
||||||
selectedTime,
|
);
|
||||||
isAutoRefreshDisabled,
|
|
||||||
} = useSelector<AppState, GlobalReducer>((state) => state.globalTime);
|
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
|
|
||||||
const isDisabled = useMemo(() => disabled || isAutoRefreshDisabled, [
|
const isDisabled = useMemo(
|
||||||
isAutoRefreshDisabled,
|
() => disabled || globalTime.isAutoRefreshDisabled,
|
||||||
disabled,
|
[globalTime.isAutoRefreshDisabled, disabled],
|
||||||
]);
|
);
|
||||||
|
|
||||||
const localStorageData = JSON.parse(get(DASHBOARD_TIME_IN_DURATION) || '{}');
|
const localStorageData = JSON.parse(get(DASHBOARD_TIME_IN_DURATION) || '{}');
|
||||||
|
|
||||||
@ -89,14 +86,18 @@ function AutoRefresh({ disabled = false }: AutoRefreshProps): JSX.Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selectedOption !== 'off' && selectedValue) {
|
if (selectedOption !== 'off' && selectedValue) {
|
||||||
const min = initialMinTime / 1000000;
|
const { maxTime, minTime } = getMinMax(
|
||||||
|
globalTime.selectedTime,
|
||||||
|
globalTime.minTime,
|
||||||
|
globalTime.maxTime,
|
||||||
|
);
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: UPDATE_TIME_INTERVAL,
|
type: UPDATE_TIME_INTERVAL,
|
||||||
payload: {
|
payload: {
|
||||||
maxTime: dayjs().valueOf() * 1000000,
|
maxTime,
|
||||||
minTime: dayjs(min).subtract(selectedValue, 'second').valueOf() * 1000000,
|
minTime,
|
||||||
selectedTime,
|
selectedTime: globalTime.selectedTime,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ const GetMinMax = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
interface GetMinMaxPayload {
|
export interface GetMinMaxPayload {
|
||||||
minTime: GlobalReducer['minTime'];
|
minTime: GlobalReducer['minTime'];
|
||||||
maxTime: GlobalReducer['maxTime'];
|
maxTime: GlobalReducer['maxTime'];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user