fix(UI): latest timestamp bug is resolved (#494)

fix(UI): latest timestamp bug is resolved (#494)
This commit is contained in:
pal-sig 2021-12-24 12:00:26 +05:30 committed by GitHub
parent 0f39643a56
commit 7f800c94ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 9 deletions

View File

@ -21,6 +21,7 @@ import { AppState } from 'store/reducers';
import AppActions from 'types/actions';
import { GlobalTime } from 'types/actions/globalTime';
import DashboardReducer from 'types/reducer/dashboards';
import { GlobalReducer } from 'types/reducer/globalTime';
import LeftContainer from './LeftContainer';
import RightContainer from './RightContainer';
@ -42,9 +43,10 @@ const NewWidget = ({
const { dashboards } = useSelector<AppState, DashboardReducer>(
(state) => state.dashboards,
);
const { maxTime, minTime } = useSelector<AppState, GlobalTime>(
(state) => state.globalTime,
);
const { maxTime, minTime, selectedTime: globalSelectedInterval } = useSelector<
AppState,
GlobalReducer
>((state) => state.globalTime);
const [selectedDashboard] = dashboards;
@ -146,12 +148,11 @@ const NewWidget = ({
const getQueryResult = useCallback(() => {
if (selectedWidget?.id.length !== 0) {
getQueryResults({
maxTime,
minTime,
query: selectedWidget?.query || [],
selectedTime: selectedTime.enum,
widgetId: selectedWidget?.id || '',
graphType: selectedGraph,
globalSelectedInterval,
});
}
}, [

View File

@ -3,10 +3,13 @@ import { AxiosError } from 'axios';
import { ITEMS } from 'container/NewDashboard/ComponentsSlider/menuItems';
import { timePreferenceType } from 'container/NewWidget/RightContainer/timeItems';
import GetMaxMinTime from 'lib/getMaxMinTime';
import GetMinMax from 'lib/getMinMax';
import GetStartAndEndTime from 'lib/getStartAndEndTime';
import { Dispatch } from 'redux';
import AppActions from 'types/actions';
import { Query } from 'types/api/dashboard/getAll';
import { GlobalReducer } from 'types/reducer/globalTime';
import store from 'store';
export const GetQueryResults = (
props: GetQueryResultsProps,
@ -15,10 +18,17 @@ export const GetQueryResults = (
try {
const queryData = props.query;
const { globalTime } = store.getState();
const minMax = GetMinMax(props.globalSelectedInterval, [
globalTime.minTime / 1000000,
globalTime.maxTime / 1000000,
]);
const getMaxMinTime = GetMaxMinTime({
graphType: props.graphType,
maxTime: props.maxTime,
minTime: props.minTime,
maxTime: minMax.maxTime,
minTime: minMax.minTime,
});
const { end, start } = GetStartAndEndTime({
@ -92,8 +102,7 @@ export const GetQueryResults = (
export interface GetQueryResultsProps {
widgetId: string;
selectedTime: timePreferenceType;
maxTime: number;
minTime: number;
query: Query[];
graphType: ITEMS;
globalSelectedInterval: GlobalReducer['selectedTime'];
}