grafana/public/app/features/variables/getAllVariableValuesForUrl.ts
Dominik Prokop 683ce69347
Link suppliers: getLinks API update (#29757)
* ContextMenuPlugin WIP

* Remove Add annotations menu item from graph context menu

* ts ifx

* WIP

* Tests updates

* ts check fix

* Fix rebase

* Use replace function in angular graph data links
2020-12-15 13:29:37 +01:00

28 lines
875 B
TypeScript

import { ScopedVars } from '@grafana/data';
import { getTemplateSrv } from '@grafana/runtime';
import { variableAdapters } from './adapters';
export function getAllVariableValuesForUrl(scopedVars?: ScopedVars) {
const params: Record<string, string | string[]> = {};
const variables = getTemplateSrv().getVariables();
// console.log(variables)
for (let i = 0; i < variables.length; i++) {
const variable = variables[i];
if (scopedVars && scopedVars[variable.name] !== void 0) {
if (scopedVars[variable.name].skipUrlSync) {
continue;
}
params['var-' + variable.name] = scopedVars[variable.name].value;
} else {
// @ts-ignore
if (variable.skipUrlSync) {
continue;
}
params['var-' + variable.name] = variableAdapters.get(variable.type).getValueForUrl(variable as any);
}
}
return params;
}