alert_tab_ctrl.ts 1004 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import _ from 'lodash';
  3. import $ from 'jquery';
  4. import angular from 'angular';
  5. export class AlertTabCtrl {
  6. panel: any;
  7. panelCtrl: any;
  8. alerting: any;
  9. /** @ngInject */
  10. constructor($scope) {
  11. $scope.alertTab = this;
  12. this.panelCtrl = $scope.ctrl;
  13. this.panel = this.panelCtrl.panel;
  14. this.alerting = this.alerting || {};
  15. this.convertThresholdsToAlertThresholds();
  16. }
  17. convertThresholdsToAlertThresholds() {
  18. if (this.panel.grid && this.panel.grid.threshold1) {
  19. this.panel.alerting.warnLevel = '< ' + this.panel.grid.threshold1;
  20. }
  21. if (this.panel.grid && this.panel.grid.threshold2) {
  22. this.panel.alerting.critLevel = '< ' + this.panel.grid.threshold2;
  23. }
  24. }
  25. }
  26. /** @ngInject */
  27. export function graphAlertEditor() {
  28. 'use strict';
  29. return {
  30. restrict: 'E',
  31. scope: true,
  32. templateUrl: 'public/app/plugins/panel/graph/partials/tab_alerting.html',
  33. controller: AlertTabCtrl,
  34. };
  35. }