fix(plugins): Fix dashboard filter for Table and Big Number with Time Comparison (#29517)
This commit is contained in:
parent
1682994b7e
commit
9052f9fbb4
|
|
@ -81,6 +81,7 @@ export default function PopKPI(props: PopKPIProps) {
|
|||
currentTimeRangeFilter,
|
||||
startDateOffset,
|
||||
shift,
|
||||
dashboardTimeRange,
|
||||
} = props;
|
||||
|
||||
const [comparisonRange, setComparisonRange] = useState<string>('');
|
||||
|
|
@ -90,12 +91,16 @@ export default function PopKPI(props: PopKPIProps) {
|
|||
setComparisonRange('');
|
||||
} else if (!isEmpty(shift) || startDateOffset) {
|
||||
const newShift = getTimeOffset({
|
||||
timeRangeFilter: currentTimeRangeFilter,
|
||||
timeRangeFilter: {
|
||||
...currentTimeRangeFilter,
|
||||
comparator:
|
||||
dashboardTimeRange ?? (currentTimeRangeFilter as any).comparator,
|
||||
},
|
||||
shifts: ensureIsArray(shift),
|
||||
startDate: startDateOffset || '',
|
||||
});
|
||||
const promise: any = fetchTimeRange(
|
||||
(currentTimeRangeFilter as any).comparator,
|
||||
dashboardTimeRange ?? (currentTimeRangeFilter as any).comparator,
|
||||
currentTimeRangeFilter.subject,
|
||||
newShift || [],
|
||||
);
|
||||
|
|
@ -108,7 +113,7 @@ export default function PopKPI(props: PopKPIProps) {
|
|||
);
|
||||
});
|
||||
}
|
||||
}, [currentTimeRangeFilter, shift, startDateOffset]);
|
||||
}, [currentTimeRangeFilter, shift, startDateOffset, dashboardTimeRange]);
|
||||
|
||||
const theme = useTheme();
|
||||
const flexGap = theme.gridUnit * 5;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,12 @@ export default function buildQuery(formData: QueryFormData) {
|
|||
const timeOffsets = ensureIsArray(
|
||||
isTimeComparison(formData, baseQueryObject)
|
||||
? getTimeOffset({
|
||||
timeRangeFilter: TimeRangeFilters[0],
|
||||
timeRangeFilter: {
|
||||
...TimeRangeFilters[0],
|
||||
comparator:
|
||||
baseQueryObject?.time_range ??
|
||||
(TimeRangeFilters[0] as any)?.comparator,
|
||||
},
|
||||
shifts: formData.time_compare,
|
||||
startDate:
|
||||
previousCustomStartDate && !formData.start_date_offset
|
||||
|
|
|
|||
|
|
@ -118,7 +118,12 @@ export default function transformProps(chartProps: ChartProps) {
|
|||
let dataOffset: string[] = [];
|
||||
if (isCustomOrInherit) {
|
||||
dataOffset = getTimeOffset({
|
||||
timeRangeFilter: currentTimeRangeFilter,
|
||||
timeRangeFilter: {
|
||||
...currentTimeRangeFilter,
|
||||
comparator:
|
||||
formData?.extra_form_data?.time_range ??
|
||||
(currentTimeRangeFilter as any)?.comparator,
|
||||
},
|
||||
shifts: ensureIsArray(timeComparison),
|
||||
startDate:
|
||||
previousCustomStartDate && !startDateOffset
|
||||
|
|
@ -207,5 +212,6 @@ export default function transformProps(chartProps: ChartProps) {
|
|||
currentTimeRangeFilter,
|
||||
startDateOffset,
|
||||
shift: timeComparison,
|
||||
dashboardTimeRange: formData?.extraFormData?.time_range,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ export type PopKPIProps = PopKPIStylesProps &
|
|||
currentTimeRangeFilter?: SimpleAdhocFilter;
|
||||
startDateOffset?: string;
|
||||
shift: string;
|
||||
dashboardTimeRange?: string;
|
||||
};
|
||||
|
||||
export enum ColorSchemeEnum {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,12 @@ const buildQuery: BuildQuery<TableChartFormData> = (
|
|||
const timeOffsets = ensureIsArray(
|
||||
isTimeComparison(formData, baseQueryObject)
|
||||
? getTimeOffset({
|
||||
timeRangeFilter: TimeRangeFilters[0],
|
||||
timeRangeFilter: {
|
||||
...TimeRangeFilters[0],
|
||||
comparator:
|
||||
baseQueryObject?.time_range ??
|
||||
(TimeRangeFilters[0] as any)?.comparator,
|
||||
},
|
||||
shifts: formData.time_compare,
|
||||
startDate:
|
||||
previousCustomStartDate && !formData.start_date_offset
|
||||
|
|
|
|||
|
|
@ -542,7 +542,12 @@ const transformProps = (
|
|||
}
|
||||
|
||||
const timeOffsets = getTimeOffset({
|
||||
timeRangeFilter: TimeRangeFilters[0],
|
||||
timeRangeFilter: {
|
||||
...TimeRangeFilters[0],
|
||||
comparator:
|
||||
formData?.extra_form_data?.time_range ??
|
||||
(TimeRangeFilters[0] as any)?.comparator,
|
||||
},
|
||||
shifts: formData.time_compare,
|
||||
startDate:
|
||||
previousCustomStartDate && !formData.start_date_offset
|
||||
|
|
|
|||
|
|
@ -592,8 +592,9 @@ class QueryContextProcessor:
|
|||
|
||||
if time_grain:
|
||||
# move the temporal column to the first column in df
|
||||
col = df.pop(join_keys[0])
|
||||
df.insert(0, col.name, col)
|
||||
if join_keys:
|
||||
col = df.pop(join_keys[0])
|
||||
df.insert(0, col.name, col)
|
||||
|
||||
# removes columns created only for join purposes
|
||||
df.drop(
|
||||
|
|
|
|||
Loading…
Reference in New Issue