You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
874 B
27 lines
874 B
import { ScopedVars, UrlQueryMap } from '@grafana/data';
|
|
import { getTemplateSrv } from '@grafana/runtime';
|
|
import { variableAdapters } from './adapters';
|
|
|
|
export function getVariablesUrlParams(scopedVars?: ScopedVars): UrlQueryMap {
|
|
const params: UrlQueryMap = {};
|
|
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;
|
|
}
|
|
|