diff --git a/public/app/features/dashboard/dashboard_ctrl.ts b/public/app/features/dashboard/dashboard_ctrl.ts index ac47d7d6440..4daf8ef6a68 100644 --- a/public/app/features/dashboard/dashboard_ctrl.ts +++ b/public/app/features/dashboard/dashboard_ctrl.ts @@ -87,6 +87,7 @@ export class DashboardCtrl { }; $scope.templateVariableUpdated = function() { + dynamicDashboardSrv.update($scope.dashboard); }; $scope.updateSubmenuVisibility = function() { diff --git a/public/app/features/templating/custom_variable.ts b/public/app/features/templating/custom_variable.ts index bfd42f61eff..6095bdd1582 100644 --- a/public/app/features/templating/custom_variable.ts +++ b/public/app/features/templating/custom_variable.ts @@ -23,13 +23,15 @@ export class CustomVariable implements Variable { multi: false, }; + supportsMulti = true; + /** @ngInject */ constructor(private model, private timeSrv, private templateSrv, private variableSrv) { assignModelProperties(this, model, this.defaults); } setValue(option) { - this.variableSrv.setOptionAsCurrent(this, option); + return this.variableSrv.setOptionAsCurrent(this, option); } getModel() { @@ -47,7 +49,7 @@ export class CustomVariable implements Variable { this.addAllOption(); } - return Promise.resolve(); + return this.variableSrv.validateVariableSelectionState(this); } addAllOption() { diff --git a/public/app/features/templating/datasource_variable.ts b/public/app/features/templating/datasource_variable.ts index e8612379c5f..8bc13c9f44b 100644 --- a/public/app/features/templating/datasource_variable.ts +++ b/public/app/features/templating/datasource_variable.ts @@ -15,7 +15,7 @@ export class DatasourceVariable implements Variable { name: '', hide: 0, label: '', - current: {text: '', value: ''} + current: {text: '', value: ''}, regex: '', options: [], query: '', @@ -32,7 +32,7 @@ export class DatasourceVariable implements Variable { } setValue(option) { - this.variableSrv.setOptionAsCurrent(this, option); + return this.variableSrv.setOptionAsCurrent(this, option); } updateOptions() { @@ -63,6 +63,7 @@ export class DatasourceVariable implements Variable { } this.options = options; + return this.variableSrv.validateVariableSelectionState(this); } dependsOn(variable) { diff --git a/public/app/features/templating/editor_ctrl.ts b/public/app/features/templating/editor_ctrl.ts index 04cf082d9c9..a185d7d838d 100644 --- a/public/app/features/templating/editor_ctrl.ts +++ b/public/app/features/templating/editor_ctrl.ts @@ -10,7 +10,7 @@ import appEvents from 'app/core/app_events'; export class VariableEditorCtrl { /** @ngInject */ - constructor(private $scope, private datasourceSrv, private variableSrv) { + constructor(private $scope, private datasourceSrv, private variableSrv, templateSrv) { $scope.variableTypes = [ {value: "query", text: "Query"}, {value: "adhoc", text: "Ad hoc filters"}, @@ -27,7 +27,7 @@ export class VariableEditorCtrl { ]; $scope.sortOptions = [ - {value: 0, text: "Query sort"}, + {value: 0, text: "Disabled"}, {value: 1, text: "Alphabetical (asc)"}, {value: 2, text: "Alphabetical (desc)"}, {value: 3, text: "Numerical (asc)"}, @@ -115,6 +115,7 @@ export class VariableEditorCtrl { $scope.runQuery().then(function() { $scope.reset(); $scope.mode = 'list'; + templateSrv.updateTemplateData(); }); } }; @@ -124,18 +125,6 @@ export class VariableEditorCtrl { $scope.current = variableSrv.createVariableFromModel({type: 'query'}); }; - $scope.showSelectionOptions = function() { - if ($scope.current) { - if ($scope.current.type === 'query') { - return true; - } - if ($scope.current.type === 'custom') { - return true; - } - } - return false; - }; - $scope.typeChanged = function() { var old = $scope.current; $scope.current = variableSrv.createVariableFromModel({type: $scope.current.type}); @@ -147,27 +136,6 @@ export class VariableEditorCtrl { if (oldIndex !== -1) { this.variables[oldIndex] = $scope.current; } - - // if ($scope.current.type === 'interval') { - // $scope.current.query = '1m,10m,30m,1h,6h,12h,1d,7d,14d,30d'; - // $scope.current.refresh = 0; - // } - // - // if ($scope.current.type === 'query') { - // $scope.current.query = ''; - // } - // - // if ($scope.current.type === 'constant') { - // $scope.current.query = ''; - // $scope.current.refresh = 0; - // $scope.current.hide = 2; - // } - // - // if ($scope.current.type === 'datasource') { - // $scope.current.query = $scope.datasourceTypes[0].value; - // $scope.current.regex = ''; - // $scope.current.refresh = 1; - // } }; $scope.removeVariable = function(variable) { diff --git a/public/app/features/templating/interval_variable.ts b/public/app/features/templating/interval_variable.ts index 260a8b9bb8e..e532a054188 100644 --- a/public/app/features/templating/interval_variable.ts +++ b/public/app/features/templating/interval_variable.ts @@ -11,12 +11,14 @@ export class IntervalVariable implements Variable { options: any; auto: boolean; query: string; + refresh: number; defaults = { type: 'interval', name: '', hide: 0, label: '', + refresh: 2, options: [], current: {text: '', value: ''}, query: '1m,10m,30m,1h,6h,12h,1d,7d,14d,30d', @@ -28,6 +30,7 @@ export class IntervalVariable implements Variable { /** @ngInject */ constructor(private model, private timeSrv, private templateSrv, private variableSrv) { assignModelProperties(this, model, this.defaults); + this.refresh = 2; } getModel() { @@ -37,7 +40,7 @@ export class IntervalVariable implements Variable { setValue(option) { this.updateAutoValue(); - this.variableSrv.setOptionAsCurrent(this, option); + return this.variableSrv.setOptionAsCurrent(this, option); } updateAutoValue() { @@ -61,6 +64,7 @@ export class IntervalVariable implements Variable { }); this.updateAutoValue(); + return this.variableSrv.validateVariableSelectionState(this); } dependsOn(variable) { diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index 37d21a6e495..8158846f790 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -181,19 +181,8 @@ -