BUG: refresh button is now fixed (#590)

* chore: issue is fixed

* chore: unused import is removed
This commit is contained in:
palash-signoz 2022-01-26 21:46:59 +05:30 committed by GitHub
parent 0f4e5c9ef0
commit 50a88a8726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,18 +9,21 @@ import GridGraphComponent from 'container/GridGraphComponent';
import { import {
timeItems, timeItems,
timePreferance, timePreferance,
timePreferenceType,
} from 'container/NewWidget/RightContainer/timeItems'; } from 'container/NewWidget/RightContainer/timeItems';
import convertToNanoSecondsToSecond from 'lib/convertToNanoSecondsToSecond';
import getChartData from 'lib/getChartData'; import getChartData from 'lib/getChartData';
import GetMaxMinTime from 'lib/getMaxMinTime'; import GetMaxMinTime from 'lib/getMaxMinTime';
import GetMinMax from 'lib/getMinMax';
import getStartAndEndTime from 'lib/getStartAndEndTime'; import getStartAndEndTime from 'lib/getStartAndEndTime';
import React, { useCallback, useEffect, useState } from 'react'; import React, { useCallback, useEffect, useState } from 'react';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { AppState } from 'store/reducers'; import { AppState } from 'store/reducers';
import { GlobalTime } from 'types/actions/globalTime';
import { Widgets } from 'types/api/dashboard/getAll'; import { Widgets } from 'types/api/dashboard/getAll';
import { GlobalReducer } from 'types/reducer/globalTime';
import EmptyGraph from './EmptyGraph'; import EmptyGraph from './EmptyGraph';
import { GraphContainer, NotFoundContainer, TimeContainer } from './styles'; import { NotFoundContainer, TimeContainer } from './styles';
const FullView = ({ const FullView = ({
widget, widget,
@ -29,9 +32,10 @@ const FullView = ({
noDataGraph = false, noDataGraph = false,
name, name,
}: FullViewProps): JSX.Element => { }: FullViewProps): JSX.Element => {
const { minTime, maxTime } = useSelector<AppState, GlobalTime>( const { minTime, maxTime, selectedTime: globalSelectedTime } = useSelector<
(state) => state.globalTime, AppState,
); GlobalReducer
>((state) => state.globalTime);
const [state, setState] = useState<FullViewState>({ const [state, setState] = useState<FullViewState>({
error: false, error: false,
@ -59,20 +63,33 @@ const FullView = ({
minTime, minTime,
}); });
const { end, start } = getStartAndEndTime({ const getMinMax = (time: timePreferenceType) => {
if (time === 'GLOBAL_TIME') {
const minMax = GetMinMax(globalSelectedTime);
return {
min: convertToNanoSecondsToSecond(minMax.minTime / 1000),
max: convertToNanoSecondsToSecond(minMax.maxTime / 1000),
};
}
const minMax = getStartAndEndTime({
type: selectedTime.enum, type: selectedTime.enum,
maxTime: maxMinTime.maxTime, maxTime: maxMinTime.maxTime,
minTime: maxMinTime.minTime, minTime: maxMinTime.minTime,
}); });
return { min: parseInt(minMax.start, 10), max: parseInt(minMax.end, 10) };
};
const queryMinMax = getMinMax(selectedTime.enum);
const response = await Promise.all( const response = await Promise.all(
widget.query widget.query
.filter((e) => e.query.length !== 0) .filter((e) => e.query.length !== 0)
.map(async (query) => { .map(async (query) => {
const result = await getQueryResult({ const result = await getQueryResult({
end, end: queryMinMax.max.toString(),
query: query.query, query: query.query,
start: start, start: queryMinMax.min.toString(),
step: '60', step: '60',
}); });
return { return {