mirror of
https://github.com/grafana/grafana.git
synced 2025-01-16 03:32:37 -06:00
ff0642bf6e
* fix some e2e flows types * some type fixes * must... fix... more... * MOAR * MOREMOREMORE * 1 more
28 lines
810 B
TypeScript
28 lines
810 B
TypeScript
import { ScopedVars, UrlQueryMap } from '@grafana/data';
|
|
import { getTemplateSrv } from '@grafana/runtime';
|
|
|
|
import { variableAdapters } from './adapters';
|
|
import { VARIABLE_PREFIX } from './constants';
|
|
|
|
export function getVariablesUrlParams(scopedVars?: ScopedVars): UrlQueryMap {
|
|
const params: UrlQueryMap = {};
|
|
const variables = getTemplateSrv().getVariables();
|
|
|
|
for (let i = 0; i < variables.length; i++) {
|
|
const variable = variables[i];
|
|
const scopedVar = scopedVars && scopedVars[variable.name];
|
|
|
|
if (variable.skipUrlSync) {
|
|
continue;
|
|
}
|
|
|
|
if (scopedVar) {
|
|
params[VARIABLE_PREFIX + variable.name] = scopedVar.value;
|
|
} else {
|
|
params[VARIABLE_PREFIX + variable.name] = variableAdapters.get(variable.type).getValueForUrl(variable);
|
|
}
|
|
}
|
|
|
|
return params;
|
|
}
|