feat(alerting): auto convert thresholds if existing

This commit is contained in:
bergquist 2016-05-02 14:41:29 +02:00
parent bc892789c1
commit 9c5b4e6f25
2 changed files with 6 additions and 4 deletions

View File

@ -7,15 +7,20 @@ import angular from 'angular';
export class AlertTabCtrl { export class AlertTabCtrl {
panel: any; panel: any;
panelCtrl: any; panelCtrl: any;
alerting: any;
/** @ngInject */ /** @ngInject */
constructor($scope) { constructor($scope) {
$scope.alertTab = this; $scope.alertTab = this;
this.panelCtrl = $scope.ctrl; this.panelCtrl = $scope.ctrl;
this.panel = this.panelCtrl.panel; this.panel = this.panelCtrl.panel;
this.alerting = this.alerting || {};
this.convertThresholdsToAlertThresholds();
} }
convertThresholdsToAlerts() { convertThresholdsToAlertThresholds() {
if (this.panel.grid && this.panel.grid.threshold1) { if (this.panel.grid && this.panel.grid.threshold1) {
this.panel.alerting.warnLevel = '< ' + this.panel.grid.threshold1; this.panel.alerting.warnLevel = '< ' + this.panel.grid.threshold1;
} }
@ -34,7 +39,5 @@ export function graphAlertEditor() {
scope: true, scope: true,
templateUrl: 'public/app/plugins/panel/graph/partials/tab_alerting.html', templateUrl: 'public/app/plugins/panel/graph/partials/tab_alerting.html',
controller: AlertTabCtrl, controller: AlertTabCtrl,
//bindToController: true,
//controllerAs: 'ctrl',
}; };
} }

View File

@ -14,7 +14,6 @@
</div> </div>
<h5 class="section-heading">Thresholds</h5> <h5 class="section-heading">Thresholds</h5>
<p ng-show="ctrl.panel.grid.threshold1 || ctrl.panel.grid.threshold2">We noticed you have existing threshholds.<a ng-click="alertTab.convertThresholdsToAlerts()">Convert them</a></p>
<div class="gf-form"> <div class="gf-form">
<span class="gf-form-label width-7">Warn level</span> <span class="gf-form-label width-7">Warn level</span>
<input class="gf-form-input max-width-7" type="text" ng-model="ctrl.panel.alerting.warnLevel"></input> <input class="gf-form-input max-width-7" type="text" ng-model="ctrl.panel.alerting.warnLevel"></input>