signoz/frontend/src/lib/dashbaordVariables/getDashboardVariables.ts
dnazarenkosignoz 37fc00b55f
feat: add the Trace Explorer page with Query Builder (#2843)
* feat: update the SideNav component

* feat: add the Trace Explorer page with Query Builder

* chore: build is fixed

* chore: tsc build is fixed

* chore: menu items is updated

---------

Co-authored-by: Nazarenko19 <danil.nazarenko2000@gmail.com>
Co-authored-by: Palash Gupta <palashgdev@gmail.com>
2023-06-19 18:27:58 +05:30

33 lines
804 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 {};
};