signoz/frontend/src/lib/dashbaordVariables/getDashboardVariables.ts
Palash Gupta 9b8f7a091c
fix: step size is made dynamic (#2903)
* fix: step size is made dynamic

* test: get step test is added

* chore: alerts step is updated

* chore: query is updated

* chore: provider query is updated

* fix: user input is being take care of

* chore: query builder step interval is updated

* test: lib/getStep is updated

* test: test for getStep is updated

* fix: step interval is taken care when we change from top nav

* chore: while saving the dashboard query is updated

* chore: updated when selected widget is present

* chore: getStep is now multiple of 60 and test is updated accordingly

* chore: user input is overriden from global step

---------

Co-authored-by: Vishal Sharma <makeavish786@gmail.com>
2023-06-28 15:19:52 +05:30

33 lines
810 B
TypeScript

import getStartEndRangeTime from 'lib/getStartEndRangeTime';
import store from 'store';
export const getDashboardVariables = (): Record<string, unknown> => {
try {
const {
globalTime,
dashboards: { dashboards },
} = store.getState();
const [selectedDashboard] = dashboards || [];
const {
data: { variables = {} },
} = selectedDashboard;
const { start, end } = getStartEndRangeTime({
type: 'GLOBAL_TIME',
interval: globalTime.selectedTime,
});
const variablesTuple: Record<string, unknown> = {
SIGNOZ_START_TIME: parseInt(start, 10) * 1e3,
SIGNOZ_END_TIME: parseInt(end, 10) * 1e3,
};
Object.keys(variables).forEach((key) => {
variablesTuple[key] = variables[key].selectedValue;
});
return variablesTuple;
} catch (e) {
console.error(e);
}
return {};
};