mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(alerting): can now change reducer
This commit is contained in:
parent
1418cbbd8b
commit
d8d951c810
@ -136,7 +136,7 @@ export function queryPartEditorDirective($compile, templateSrv) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.triggerPartAction = function(action) {
|
$scope.triggerPartAction = function(action) {
|
||||||
$scope.handleEvent({$event: {name: 'action-' + action.value}});
|
$scope.handleEvent({$event: {name: 'action', action: action}});
|
||||||
};
|
};
|
||||||
|
|
||||||
function addElementsAndCompile() {
|
function addElementsAndCompile() {
|
||||||
|
@ -16,13 +16,12 @@ export class AlertTabCtrl {
|
|||||||
conditionModels: any;
|
conditionModels: any;
|
||||||
evalFunctions: any;
|
evalFunctions: any;
|
||||||
severityLevels: any;
|
severityLevels: any;
|
||||||
reducerTypes: any;
|
|
||||||
addNotificationSegment;
|
addNotificationSegment;
|
||||||
notifications;
|
notifications;
|
||||||
alertNotifications;
|
alertNotifications;
|
||||||
|
|
||||||
/** @ngInject */
|
/** @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.panelCtrl = $scope.ctrl;
|
||||||
this.panel = this.panelCtrl.panel;
|
this.panel = this.panelCtrl.panel;
|
||||||
this.$scope.ctrl = this;
|
this.$scope.ctrl = this;
|
||||||
@ -30,7 +29,6 @@ export class AlertTabCtrl {
|
|||||||
this.evalFunctions = alertDef.evalFunctions;
|
this.evalFunctions = alertDef.evalFunctions;
|
||||||
this.conditionTypes = alertDef.conditionTypes;
|
this.conditionTypes = alertDef.conditionTypes;
|
||||||
this.severityLevels = alertDef.severityLevels;
|
this.severityLevels = alertDef.severityLevels;
|
||||||
this.reducerTypes = alertDef.reducerTypes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$onInit() {
|
$onInit() {
|
||||||
@ -156,12 +154,34 @@ export class AlertTabCtrl {
|
|||||||
return cm;
|
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) {
|
handleReducerPartEvent(conditionModel, evt) {
|
||||||
conditionModel.source.reducer.type = value;
|
switch (evt.name) {
|
||||||
conditionModel.reducerPart = alertDef.createReducerPart(conditionModel.source.reducer);
|
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) {
|
addCondition(type) {
|
||||||
|
@ -49,19 +49,12 @@
|
|||||||
<span class="gf-form-label query-keyword width-5" ng-if="$index===0">WHEN</span>
|
<span class="gf-form-label query-keyword width-5" ng-if="$index===0">WHEN</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="gf-form">
|
<div class="gf-form">
|
||||||
<query-part-editor class="gf-form-label query-part" part="conditionModel.queryPart" part-updated="ctrl.queryPartUpdated(conditionModel)">
|
<query-part-editor class="gf-form-label query-part" part="conditionModel.queryPart" handle-event="ctrl.handleQueryPartEvent(conditionModel, $event)">
|
||||||
</query-part-editor>
|
</query-part-editor>
|
||||||
</div>
|
</div>
|
||||||
<div class="gf-form">
|
<div class="gf-form">
|
||||||
<span class="gf-form-label">Reducer</span>
|
<span class="gf-form-label">Reducer</span>
|
||||||
<query-part-editor class="gf-form-label query-part" part="conditionModel.reducerPart" part-updated="ctrl.reducerPartUpdated(conditionModel)">
|
<query-part-editor class="gf-form-label query-part" part="conditionModel.reducerPart" handle-event="ctrl.handleReducerPartEvent(conditionModel, $event)">
|
||||||
<query-part-editor-actions>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li ng-repeat="reducer in ctrl.reducerTypes">
|
|
||||||
<a ng-click="ctrl.changeReducerType(conditionModel, reducer.value)" ng-hide="reducer.value === conditionModel.reducerPart.def.type">{{reducer.text}}</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</query-part-editor-actions>
|
|
||||||
</query-part-editor>
|
</query-part-editor>
|
||||||
</div>
|
</div>
|
||||||
<div class="gf-form">
|
<div class="gf-form">
|
||||||
|
@ -20,7 +20,6 @@ export class InfluxQueryCtrl extends QueryCtrl {
|
|||||||
measurementSegment: any;
|
measurementSegment: any;
|
||||||
removeTagFilterSegment: any;
|
removeTagFilterSegment: any;
|
||||||
|
|
||||||
|
|
||||||
/** @ngInject **/
|
/** @ngInject **/
|
||||||
constructor($scope, $injector, private templateSrv, private $q, private uiSegmentSrv) {
|
constructor($scope, $injector, private templateSrv, private $q, private uiSegmentSrv) {
|
||||||
super($scope, $injector);
|
super($scope, $injector);
|
||||||
@ -123,7 +122,7 @@ export class InfluxQueryCtrl extends QueryCtrl {
|
|||||||
this.panelCtrl.refresh();
|
this.panelCtrl.refresh();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "action-remove-part": {
|
case "action": {
|
||||||
this.queryModel.removeSelectPart(selectParts, part);
|
this.queryModel.removeSelectPart(selectParts, part);
|
||||||
this.panelCtrl.refresh();
|
this.panelCtrl.refresh();
|
||||||
break;
|
break;
|
||||||
@ -146,7 +145,7 @@ export class InfluxQueryCtrl extends QueryCtrl {
|
|||||||
this.panelCtrl.refresh();
|
this.panelCtrl.refresh();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "action-remove-part": {
|
case "action": {
|
||||||
this.queryModel.removeGroupByPart(part, index);
|
this.queryModel.removeGroupByPart(part, index);
|
||||||
this.panelCtrl.refresh();
|
this.panelCtrl.refresh();
|
||||||
break;
|
break;
|
||||||
@ -335,4 +334,3 @@ export class InfluxQueryCtrl extends QueryCtrl {
|
|||||||
return this.queryModel.render(false);
|
return this.queryModel.render(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user