Skip to content

Commit 18d2bf7

Browse files
github-actions[bot]Kishore Kumaar Natarajan
and
Kishore Kumaar Natarajan
committed
[Bug Fix] Window size changing unexpectedly (#178)
Signed-off-by: Kishore Kumaar Natarajan <[email protected]> Co-authored-by: Kishore Kumaar Natarajan <[email protected]> (cherry picked from commit da66ed6) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 9bc38a0 commit 18d2bf7

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

public/pages/TopNQueries/TopNQueries.tsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,18 +314,26 @@ const TopNQueries = ({
314314
deleteAfterDays: newDeleteAfterDays,
315315
exporterType: newExporterType,
316316
});
317-
await core.http.put('/api/update_settings', {
318-
query: {
319-
metric,
320-
enabled,
321-
top_n_size: newTopN,
322-
window_size: `${newWindowSize}${newTimeUnit === 'MINUTES' ? 'm' : 'h'}`,
323-
exporterType: newExporterType,
324-
group_by: newGroupBy,
325-
delete_after_days: newDeleteAfterDays,
326-
dataSourceId: getDataSourceFromUrl().id, // TODO: get this dynamically from the URL
327-
},
328-
});
317+
const queryParams: Record<string, any> = {
318+
metric,
319+
enabled,
320+
top_n_size: newTopN,
321+
exporterType: newExporterType,
322+
group_by: newGroupBy,
323+
delete_after_days: newDeleteAfterDays,
324+
dataSourceId: getDataSourceFromUrl().id,
325+
};
326+
if (newTimeUnit === 'MINUTES') {
327+
newTimeUnit = 'm';
328+
}
329+
if (newTimeUnit === 'HOURS') {
330+
newTimeUnit = 'h';
331+
}
332+
if (newWindowSize && newTimeUnit) {
333+
queryParams.window_size = `${newWindowSize}${newTimeUnit}`;
334+
}
335+
336+
await core.http.put('/api/update_settings', { query: queryParams });
329337
} catch (error) {
330338
console.error('Failed to set settings:', error);
331339
}

0 commit comments

Comments
 (0)