Browse Source

feat(alerting): auto convert thresholds if existing

bergquist 9 years ago
parent
commit
9c5b4e6f25

+ 6 - 3
public/app/plugins/panel/graph/alert_tab_ctrl.ts

@@ -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',
   };
   };
 }
 }

+ 0 - 1
public/app/plugins/panel/graph/partials/tab_alerting.html

@@ -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>