fix: logs time is fixed (#1772)

* fix: logs parsing is fixed

* fix: start and end time is updated
This commit is contained in:
Palash Gupta 2022-11-29 14:41:36 +05:30 committed by GitHub
parent 7e590f4bfb
commit 5ae9557293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 16 deletions

View File

@ -1,3 +1,7 @@
import GetMinMax, { GetMinMaxPayload } from 'lib/getMinMax';
import { Time } from '../DateTimeSelection/config';
export const options: IOptions[] = [
{
label: 'off',
@ -61,3 +65,12 @@ export interface IOptions {
key: string;
value: number;
}
export const getMinMax = (
selectedTime: Time,
minTime: number,
maxTime: number,
): GetMinMaxPayload =>
selectedTime !== 'custom'
? GetMinMax(selectedTime)
: GetMinMax(selectedTime, [minTime, maxTime]);

View File

@ -12,7 +12,6 @@ import { CheckboxChangeEvent } from 'antd/lib/checkbox';
import get from 'api/browser/localstorage/get';
import set from 'api/browser/localstorage/set';
import { DASHBOARD_TIME_IN_DURATION } from 'constants/app';
import dayjs from 'dayjs';
import useUrlQuery from 'hooks/useUrlQuery';
import _omit from 'lodash-es/omit';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
@ -28,21 +27,19 @@ import {
} from 'types/actions/globalTime';
import { GlobalReducer } from 'types/reducer/globalTime';
import { options } from './config';
import { getMinMax, options } from './config';
import { ButtonContainer, Container } from './styles';
function AutoRefresh({ disabled = false }: AutoRefreshProps): JSX.Element {
const {
minTime: initialMinTime,
selectedTime,
isAutoRefreshDisabled,
} = useSelector<AppState, GlobalReducer>((state) => state.globalTime);
const globalTime = useSelector<AppState, GlobalReducer>(
(state) => state.globalTime,
);
const { pathname } = useLocation();
const isDisabled = useMemo(() => disabled || isAutoRefreshDisabled, [
isAutoRefreshDisabled,
disabled,
]);
const isDisabled = useMemo(
() => disabled || globalTime.isAutoRefreshDisabled,
[globalTime.isAutoRefreshDisabled, disabled],
);
const localStorageData = JSON.parse(get(DASHBOARD_TIME_IN_DURATION) || '{}');
@ -89,14 +86,18 @@ function AutoRefresh({ disabled = false }: AutoRefreshProps): JSX.Element {
}
if (selectedOption !== 'off' && selectedValue) {
const min = initialMinTime / 1000000;
const { maxTime, minTime } = getMinMax(
globalTime.selectedTime,
globalTime.minTime,
globalTime.maxTime,
);
dispatch({
type: UPDATE_TIME_INTERVAL,
payload: {
maxTime: dayjs().valueOf() * 1000000,
minTime: dayjs(min).subtract(selectedValue, 'second').valueOf() * 1000000,
selectedTime,
maxTime,
minTime,
selectedTime: globalTime.selectedTime,
},
});
}

View File

@ -53,7 +53,7 @@ const GetMinMax = (
};
};
interface GetMinMaxPayload {
export interface GetMinMaxPayload {
minTime: GlobalReducer['minTime'];
maxTime: GlobalReducer['maxTime'];
}