diff --git a/public/app/core/components/query_part/query_part_editor.ts b/public/app/core/components/query_part/query_part_editor.ts index 4699f529b20..7bc309d1bd2 100644 --- a/public/app/core/components/query_part/query_part_editor.ts +++ b/public/app/core/components/query_part/query_part_editor.ts @@ -136,7 +136,7 @@ export function queryPartEditorDirective($compile, templateSrv) { }; $scope.triggerPartAction = function(action) { - $scope.handleEvent({$event: {name: 'action-' + action.value}}); + $scope.handleEvent({$event: {name: 'action', action: action}}); }; function addElementsAndCompile() { diff --git a/public/app/features/alerting/alert_tab_ctrl.ts b/public/app/features/alerting/alert_tab_ctrl.ts index 684b3071113..0dd228e7040 100644 --- a/public/app/features/alerting/alert_tab_ctrl.ts +++ b/public/app/features/alerting/alert_tab_ctrl.ts @@ -16,13 +16,12 @@ export class AlertTabCtrl { conditionModels: any; evalFunctions: any; severityLevels: any; - reducerTypes: any; addNotificationSegment; notifications; alertNotifications; /** @ngInject */ - constructor(private $scope, private $timeout, private backendSrv, private dashboardSrv, private uiSegmentSrv) { + constructor(private $scope, private $timeout, private backendSrv, private dashboardSrv, private uiSegmentSrv, private $q) { this.panelCtrl = $scope.ctrl; this.panel = this.panelCtrl.panel; this.$scope.ctrl = this; @@ -30,7 +29,6 @@ export class AlertTabCtrl { this.evalFunctions = alertDef.evalFunctions; this.conditionTypes = alertDef.conditionTypes; this.severityLevels = alertDef.severityLevels; - this.reducerTypes = alertDef.reducerTypes; } $onInit() { @@ -156,12 +154,34 @@ export class AlertTabCtrl { return cm; } - queryPartUpdated(conditionModel) { + handleQueryPartEvent(conditionModel, evt) { + switch (evt.name) { + case "action-remove-part": { + break; + } + case "get-part-actions": { + return this.$q.when([]); + } + } } - changeReducerType(conditionModel, value) { - conditionModel.source.reducer.type = value; - conditionModel.reducerPart = alertDef.createReducerPart(conditionModel.source.reducer); + handleReducerPartEvent(conditionModel, evt) { + switch (evt.name) { + case "action": { + conditionModel.source.reducer.type = evt.action.value; + conditionModel.reducerPart = alertDef.createReducerPart(conditionModel.source.reducer); + break; + } + case "get-part-actions": { + var result = []; + for (var type of alertDef.reducerTypes) { + if (type.value !== conditionModel.source.reducer.type) { + result.push(type); + } + } + return this.$q.when(result); + } + } } addCondition(type) { diff --git a/public/app/features/alerting/partials/alert_tab.html b/public/app/features/alerting/partials/alert_tab.html index 65122b279f1..43ac9abaad4 100644 --- a/public/app/features/alerting/partials/alert_tab.html +++ b/public/app/features/alerting/partials/alert_tab.html @@ -49,19 +49,12 @@ WHEN