5
5
'lodash' ,
6
6
'app/core/utils/kbn' ,
7
7
'./graph_tooltip' ,
8
- './alert_handle ' ,
8
+ './thresholds ' ,
9
9
'jquery.flot' ,
10
10
'jquery.flot.selection' ,
11
11
'jquery.flot.time' ,
@@ -15,15 +15,15 @@ define([
15
15
'jquery.flot.crosshair' ,
16
16
'./jquery.flot.events' ,
17
17
] ,
18
- function ( angular , $ , moment , _ , kbn , GraphTooltip , AlertHandle ) {
18
+ function ( angular , $ , moment , _ , kbn , GraphTooltip , thresholds ) {
19
19
'use strict' ;
20
20
21
21
var module = angular . module ( 'grafana.directives' ) ;
22
22
var labelWidthCache = { } ;
23
23
var panelWidthCache = { } ;
24
24
25
25
// systemjs export
26
- var AlertHandleManager = AlertHandle . AlertHandleManager ;
26
+ var ThresholdControls = thresholds . ThresholdControls ;
27
27
28
28
module . directive ( 'grafanaGraph' , function ( $rootScope , timeSrv ) {
29
29
return {
@@ -38,7 +38,7 @@ function (angular, $, moment, _, kbn, GraphTooltip, AlertHandle) {
38
38
var legendSideLastValue = null ;
39
39
var rootScope = scope . $root ;
40
40
var panelWidth = 0 ;
41
- var alertHandles ;
41
+ var thresholdControls ;
42
42
43
43
rootScope . onAppEvent ( 'setCrosshair' , function ( event , info ) {
44
44
// do not need to to this if event is from this panel
@@ -167,8 +167,8 @@ function (angular, $, moment, _, kbn, GraphTooltip, AlertHandle) {
167
167
rightLabel [ 0 ] . style . marginTop = ( getLabelWidth ( panel . yaxes [ 1 ] . label , rightLabel ) / 2 ) + 'px' ;
168
168
}
169
169
170
- if ( alertHandles ) {
171
- alertHandles . draw ( plot ) ;
170
+ if ( thresholdControls ) {
171
+ thresholdControls . draw ( plot ) ;
172
172
}
173
173
}
174
174
@@ -192,14 +192,14 @@ function (angular, $, moment, _, kbn, GraphTooltip, AlertHandle) {
192
192
193
193
// give space to alert editing
194
194
if ( ctrl . editingAlert ) {
195
- if ( ! alertHandles ) {
195
+ if ( ! thresholdControls ) {
196
196
elem . css ( 'margin-right' , '220px' ) ;
197
- alertHandles = new AlertHandleManager ( ctrl ) ;
197
+ thresholdControls = new ThresholdControls ( ctrl ) ;
198
198
}
199
- } else if ( alertHandles ) {
199
+ } else if ( thresholdControls ) {
200
200
elem . css ( 'margin-right' , '0' ) ;
201
- alertHandles . cleanUp ( ) ;
202
- alertHandles = null ;
201
+ thresholdControls . cleanUp ( ) ;
202
+ thresholdControls = null ;
203
203
}
204
204
205
205
var stack = panel . stack ? true : null ;
@@ -333,70 +333,73 @@ function (angular, $, moment, _, kbn, GraphTooltip, AlertHandle) {
333
333
}
334
334
335
335
function addGridThresholds ( options , panel ) {
336
+ var thresholds = panel . thresholds ;
337
+
338
+ // use alert thresholds if there are any
336
339
if ( panel . alert ) {
337
- var crit = panel . alert . critical ;
338
- var warn = panel . alert . warn ;
339
- var critEdge = Infinity ;
340
- var warnEdge = crit . level ;
341
-
342
- if ( _ . isNumber ( crit . level ) ) {
343
- if ( crit . op === '<' ) {
344
- critEdge = - Infinity ;
345
- }
340
+ thresholds = panel . alert . thresholds ;
341
+ }
346
342
347
- // fill
348
- options . grid . markings . push ( {
349
- yaxis : { from : crit . level , to : critEdge } ,
350
- color : 'rgba(234, 112, 112, 0.10)' ,
351
- } ) ;
352
-
353
- // line
354
- options . grid . markings . push ( {
355
- yaxis : { from : crit . level , to : crit . level } ,
356
- color : '#ed2e18'
357
- } ) ;
358
- }
343
+ var crit = thresholds . crit ;
344
+ var warn = thresholds . warn ;
345
+ var critEdge = Infinity ;
346
+ var warnEdge = crit . value ;
359
347
360
- if ( _ . isNumber ( warn . level ) ) {
361
- // if (warn.op === '<') {
362
- // }
363
-
364
- // fill
365
- options . grid . markings . push ( {
366
- yaxis : { from : warn . level , to : warnEdge } ,
367
- color : 'rgba(216, 200, 27, 0.10)' ,
368
- } ) ;
369
-
370
- // line
371
- options . grid . markings . push ( {
372
- yaxis : { from : warn . level , to : warn . level } ,
373
- color : '#F79520'
374
- } ) ;
348
+ if ( _ . isNumber ( crit . value ) ) {
349
+ if ( crit . op === '<' ) {
350
+ critEdge = - Infinity ;
375
351
}
376
352
377
- return ;
353
+ // fill
354
+ options . grid . markings . push ( {
355
+ yaxis : { from : crit . value , to : critEdge } ,
356
+ color : 'rgba(234, 112, 112, 0.10)' ,
357
+ } ) ;
358
+
359
+ // line
360
+ options . grid . markings . push ( {
361
+ yaxis : { from : crit . value , to : crit . value } ,
362
+ color : '#ed2e18'
363
+ } ) ;
378
364
}
379
365
380
- if ( _ . isNumber ( panel . grid . threshold1 ) ) {
381
- var limit1 = panel . grid . thresholdLine ? panel . grid . threshold1 : ( panel . grid . threshold2 || null ) ;
366
+ if ( _ . isNumber ( warn . value ) ) {
367
+ // if (warn.op === '<') {
368
+ // }
369
+
370
+ // fill
382
371
options . grid . markings . push ( {
383
- yaxis : { from : panel . grid . threshold1 , to : limit1 } ,
384
- color : panel . grid . threshold1Color
372
+ yaxis : { from : warn . value , to : warnEdge } ,
373
+ color : 'rgba(216, 200, 27, 0.10)' ,
385
374
} ) ;
386
375
387
- if ( _ . isNumber ( panel . grid . threshold2 ) ) {
388
- var limit2 ;
389
- if ( panel . grid . thresholdLine ) {
390
- limit2 = panel . grid . threshold2 ;
391
- } else {
392
- limit2 = panel . grid . threshold1 > panel . grid . threshold2 ? - Infinity : + Infinity ;
393
- }
394
- options . grid . markings . push ( {
395
- yaxis : { from : panel . grid . threshold2 , to : limit2 } ,
396
- color : panel . grid . threshold2Color
397
- } ) ;
398
- }
376
+ // line
377
+ options . grid . markings . push ( {
378
+ yaxis : { from : warn . value , to : warn . value } ,
379
+ color : '#F79520'
380
+ } ) ;
399
381
}
382
+
383
+ // if (_.isNumber(panel.grid.threshold1)) {
384
+ // var limit1 = panel.grid.thresholdLine ? panel.grid.threshold1 : (panel.grid.threshold2 || null);
385
+ // options.grid.markings.push({
386
+ // yaxis: { from: panel.grid.threshold1, to: limit1 },
387
+ // color: panel.grid.threshold1Color
388
+ // });
389
+ //
390
+ // if (_.isNumber(panel.grid.threshold2)) {
391
+ // var limit2;
392
+ // if (panel.grid.thresholdLine) {
393
+ // limit2 = panel.grid.threshold2;
394
+ // } else {
395
+ // limit2 = panel.grid.threshold1 > panel.grid.threshold2 ? -Infinity : +Infinity;
396
+ // }
397
+ // options.grid.markings.push({
398
+ // yaxis: { from: panel.grid.threshold2, to: limit2 },
399
+ // color: panel.grid.threshold2Color
400
+ // });
401
+ // }
402
+ // }
400
403
}
401
404
402
405
function addAnnotations ( options ) {
0 commit comments