mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Templating: Adds typings to Variables (#20117)
* Refactor: Adds typings and changes AdHocVariable to conform to new typings * Refactor: Adds typings to ConstantVariable * Refactor: Adds typings to IntervalVariable * Refactor: Adds typings to QueryVariable * Refactor: Adds typings to TextBoxVariable * Refactor: Adds typings to CustomVariable
This commit is contained in:
@@ -1,19 +1,31 @@
|
||||
import { Variable, assignModelProperties, variableTypes } from './variable';
|
||||
import {
|
||||
assignModelProperties,
|
||||
TextBoxVariableModel,
|
||||
VariableActions,
|
||||
VariableHide,
|
||||
VariableOption,
|
||||
VariableType,
|
||||
variableTypes,
|
||||
} from './variable';
|
||||
import { VariableSrv } from './variable_srv';
|
||||
|
||||
export class TextBoxVariable implements Variable {
|
||||
query: string;
|
||||
current: any;
|
||||
options: any[];
|
||||
export class TextBoxVariable implements TextBoxVariableModel, VariableActions {
|
||||
type: VariableType;
|
||||
name: string;
|
||||
label: string;
|
||||
hide: VariableHide;
|
||||
skipUrlSync: boolean;
|
||||
query: string;
|
||||
current: VariableOption;
|
||||
options: VariableOption[];
|
||||
|
||||
defaults: any = {
|
||||
defaults: TextBoxVariableModel = {
|
||||
type: 'textbox',
|
||||
name: '',
|
||||
hide: 0,
|
||||
label: '',
|
||||
hide: VariableHide.dontHide,
|
||||
query: '',
|
||||
current: {},
|
||||
current: {} as VariableOption,
|
||||
options: [],
|
||||
skipUrlSync: false,
|
||||
};
|
||||
@@ -33,7 +45,7 @@ export class TextBoxVariable implements Variable {
|
||||
}
|
||||
|
||||
updateOptions() {
|
||||
this.options = [{ text: this.query.trim(), value: this.query.trim() }];
|
||||
this.options = [{ text: this.query.trim(), value: this.query.trim(), selected: false }];
|
||||
this.current = this.options[0];
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user