Commit 3e24a87e by Torkel Ödegaard

trying to get this PR working. a lot has changed and is broken

parent 992bccce
......@@ -52,21 +52,23 @@ function (angular, $, config, _) {
$scope.init = function() {
$scope.config = config;
// Make stuff, including underscore.js available to views
$scope._ = _;
$scope.dashboard = dashboard;
$scope.dashAlerts = alertSrv;
$scope.filter = filterSrv;
$scope.filter.init( dashboard.current );
$scope.filter.init(dashboard.current);
$scope.$watch('dashboard.current', function(newValue) {
$scope.filter.init( newValue );
$scope.filter.init(newValue);
});
$scope.$watch('filter.time', function() {
$scope.dashboard.refresh();
}, true);
// Clear existing alerts
alertSrv.clearAll();
......@@ -87,7 +89,7 @@ function (angular, $, config, _) {
}
};
$scope.add_row = function(dash,row) {
$scope.add_row = function(dash, row) {
dash.rows.push(row);
};
......
......@@ -30,25 +30,25 @@ function (angular, app, _) {
// empty. Don't know if I need the function then.
};
$scope.remove = function( templateParameter ) {
this.filter.removeTemplateParameter( templateParameter );
$scope.remove = function(templateParameter) {
$scope.filter.removeTemplateParameter(templateParameter);
// TODO hkraemer: check if this makes sense like this
if(!$rootScope.$$phase) {
$rootScope.$apply();
}
$timeout(function(){
this.dashboard.refresh();
$scope.dashboard.refresh();
},0);
};
$scope.filterOptionSelected = function( templateParameter, option ) {
this.filter.templateOptionSelected(option);
this.applyFilterToOtherFilters(templateParameter);
$scope.filterOptionSelected = function(templateParameter, option) {
$scope.filter.templateOptionSelected(templateParameter, option);
$scope.applyFilterToOtherFilters(templateParameter);
};
$scope.applyFilterToOtherFilters = function(updatedFilter) {
_.each(this.filter.templateParameters, function( templateParameter ) {
_.each($scope.filter.templateParameters, function(templateParameter) {
if (templateParameter === updatedFilter) {
return;
}
......@@ -59,9 +59,8 @@ function (angular, app, _) {
};
$scope.applyFilter = function(filter) {
var query = this.filter.applyTemplateToTarget(filter.query);
datasourceSrv.default.metricFindQuery($scope, query)
datasourceSrv.default.metricFindQuery($scope.filter, filter.query)
.then(function (results) {
filter.editing=undefined;
filter.options = _.map(results, function(node) {
......@@ -77,12 +76,12 @@ function (angular, app, _) {
filter.options.unshift({text: 'All', value: allExpr});
}
this.filter.templateOptionSelected(filter, filter.options[0]);
$scope.filter.templateOptionSelected(filter, filter.options[0]);
});
};
$scope.add = function() {
this.filter.addTemplateParameter({
$scope.filter.addTemplateParameter({
type : 'filter',
name : 'filter name',
editing : true,
......@@ -91,7 +90,7 @@ function (angular, app, _) {
};
$scope.refresh = function() {
this.dashboard.refresh();
$scope.dashboard.refresh();
};
$scope.render = function() {
......
......@@ -16,7 +16,7 @@ define([
};
var result = {
_updateTemplateData : function(initial) {
_updateTemplateData: function(initial) {
var _templateData = {};
_.each(this.templateParameters, function( templateParameter ) {
if (initial) {
......@@ -34,17 +34,18 @@ define([
this._templateData = _templateData;
},
templateOptionSelected : function(templateParameter, option) {
templateOptionSelected: function(templateParameter, option) {
templateParameter.current = option;
this._updateTemplateData();
dashboard.refresh();
},
addTemplateParameter : function( templateParameter ) {
addTemplateParameter: function( templateParameter ) {
this.templateParameters.push( templateParameter );
this._updateTemplateData();
},
applyTemplateToTarget : function(target) {
applyTemplateToTarget: function(target) {
if (target.indexOf('[[') === -1) {
return target;
}
......@@ -52,7 +53,7 @@ define([
return _.template(target, this._templateData, this.templateSettings);
},
setTime : function(time) {
setTime: function(time) {
_.extend(this.time, time);
// disable refresh if we have an absolute time
if (time.to !== 'now') {
......@@ -67,7 +68,7 @@ define([
}
},
timeRange : function(parse) {
timeRange: function(parse) {
var _t = this.time;
if(_.isUndefined(_t) || _.isUndefined(_t.from)) {
return false;
......@@ -88,7 +89,7 @@ define([
}
},
removeTemplateParameter : function( templateParameter ) {
removeTemplateParameter: function(templateParameter) {
this.templateParameters = _.without( this.templateParameters, templateParameter );
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment