stackdriver: broadcasting through $scope doesnt work anymore since query_filter_ctrl is now a sibling directive to query_aggregation_ctrl, so broadcasting is now done using $rootScope

This commit is contained in:
Erik Sundell 2018-09-28 11:25:32 +02:00
parent a63877bd4f
commit 5bc6d857a7
3 changed files with 8 additions and 4 deletions

View File

@ -32,7 +32,11 @@ export class StackdriverAggregationCtrl {
this.alignOptions = options.alignOptions;
this.setAggOptions();
this.setAlignOptions();
$scope.$on('metricTypeChanged', this.setAlignOptions.bind(this));
const self = this;
$scope.$on('metricTypeChanged', () => {
self.setAggOptions();
self.setAlignOptions();
});
}
setAlignOptions() {

View File

@ -41,7 +41,7 @@ export class StackdriverFilterCtrl {
datasource: any;
/** @ngInject */
constructor(private $scope, private uiSegmentSrv, private templateSrv) {
constructor(private $scope, private uiSegmentSrv, private templateSrv, private $rootScope) {
this.datasource = $scope.datasource;
this.target = $scope.target;
this.metricType = $scope.defaultDropdownValue;
@ -180,7 +180,7 @@ export class StackdriverFilterCtrl {
this.target.unit = unit;
this.target.valueType = valueType;
this.target.metricKind = metricKind;
this.$scope.$broadcast('metricTypeChanged');
this.$rootScope.$broadcast('metricTypeChanged');
}
async getGroupBys(segment, index, removeText?: string, removeUsed = true) {

View File

@ -420,7 +420,7 @@ function createCtrlWithFakes(existingFilters?: string[]) {
refresh: () => {},
};
return new StackdriverFilterCtrl(scope, fakeSegmentServer, new TemplateSrvStub());
return new StackdriverFilterCtrl(scope, fakeSegmentServer, new TemplateSrvStub(), { $broadcast: param => {} });
}
function createTarget(existingFilters?: string[]) {