grafana/public/app/features/templating/constant_variable.ts
Tobias Skarhed 0ef4060b98
Chore: Fix about 200 noImplicitAny errors (#18067)
* Fix 200 ish errors

* Add interface
2019-07-16 11:35:42 +02:00

59 lines
1.3 KiB
TypeScript

import { Variable, assignModelProperties, variableTypes } from './variable';
import { VariableSrv } from './all';
export class ConstantVariable implements Variable {
query: string;
options: any[];
current: any;
skipUrlSync: boolean;
defaults: any = {
type: 'constant',
name: '',
hide: 2,
label: '',
query: '',
current: {},
options: [],
skipUrlSync: false,
};
/** @ngInject */
constructor(private model: any, private variableSrv: VariableSrv) {
assignModelProperties(this, model, this.defaults);
}
getSaveModel() {
assignModelProperties(this.model, this, this.defaults);
return this.model;
}
setValue(option: any) {
this.variableSrv.setOptionAsCurrent(this, option);
}
updateOptions() {
this.options = [{ text: this.query.trim(), value: this.query.trim() }];
this.setValue(this.options[0]);
return Promise.resolve();
}
dependsOn(variable: any) {
return false;
}
setValueFromUrl(urlValue: string) {
return this.variableSrv.setOptionFromUrl(this, urlValue);
}
getValueForUrl() {
return this.current.value;
}
}
variableTypes['constant'] = {
name: 'Constant',
ctor: ConstantVariable,
description: 'Define a hidden constant variable, useful for metric prefixes in dashboards you want to share',
};