mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
3c6e0e8ef8
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
28 lines
847 B
TypeScript
28 lines
847 B
TypeScript
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();
|
|
|
|
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;
|
|
}
|