Skip to content

Commit 7c06757

Browse files
committed
feat(thresholds): new thresholds options are looking ok
1 parent 0f8c851 commit 7c06757

File tree

3 files changed

+45
-16
lines changed

3 files changed

+45
-16
lines changed

public/app/features/alerting/partials/notification_edit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ <h3 class="page-heading">Email addresses</h3>
6060
</div>
6161
</div>
6262

63-
<div class="gf-form-button-group">
63+
<div class="gf-form-button-row">
6464
<button ng-click="ctrl.save()" class="btn btn-success">Save</button>
6565
</div>
6666
</div>

public/app/plugins/panel/graph/graph.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -354,28 +354,36 @@ function (angular, $, moment, _, kbn, GraphTooltip, thresholds) {
354354
}
355355
}
356356

357-
var fillColor, lineColor;
358-
switch(threshold.severity) {
357+
switch(threshold.colorMode) {
359358
case 'critical': {
360-
fillColor = 'rgba(234, 112, 112, 0.12)';
361-
lineColor = 'rgba(237, 46, 24, 0.60)';
359+
threshold.fillColor = 'rgba(234, 112, 112, 0.12)';
360+
threshold.lineColor = 'rgba(237, 46, 24, 0.60)';
362361
break;
363362
}
364363
case 'warning': {
365-
fillColor = 'rgba(235, 138, 14, 0.12)';
366-
lineColor = 'rgba(247, 149, 32, 0.60)';
364+
threshold.fillColor = 'rgba(235, 138, 14, 0.12)';
365+
threshold.lineColor = 'rgba(247, 149, 32, 0.60)';
367366
break;
368367
}
369368
case 'ok': {
370-
fillColor = 'rgba(11, 237, 50, 0.090)';
371-
lineColor = 'rgba(6,163,69, 0.60)';
369+
threshold.fillColor = 'rgba(11, 237, 50, 0.090)';
370+
threshold.lineColor = 'rgba(6,163,69, 0.60)';
371+
break;
372+
}
373+
case 'custom': {
374+
threshold.fillColor = threshold.fillColor;
375+
threshold.lineColor = threshold.lineColor;
372376
break;
373377
}
374378
}
375379

376380
// fill
377-
options.grid.markings.push({yaxis: {from: threshold.value, to: limit}, color: fillColor});
378-
options.grid.markings.push({yaxis: {from: threshold.value, to: threshold.value}, color: lineColor});
381+
if (threshold.fill) {
382+
options.grid.markings.push({yaxis: {from: threshold.value, to: limit}, color: threshold.fillColor});
383+
}
384+
if (threshold.line) {
385+
options.grid.markings.push({yaxis: {from: threshold.value, to: threshold.value}, color: threshold.lineColor});
386+
}
379387
}
380388
}
381389

public/app/plugins/panel/graph/tab_display.html

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,44 @@ <h5>Thresholds</h5>
143143
<select class="gf-form-input" ng-model="threshold.op" ng-options="f for f in ['>', '<']" ng-change="ctrl.render()"></select>
144144
</div>
145145
<input type="number" ng-model="threshold.value" class="gf-form-input width-8" ng-change="ctrl.render()" placeholder="value">
146+
</div>
147+
148+
<div class="gf-form">
146149
<label class="gf-form-label">Color</label>
147150
<div class="gf-form-select-wrapper">
148-
<select class="gf-form-input" ng-model="threshold.severity" ng-options="f for f in ['critical', 'warning', 'ok']" ng-change="ctrl.render()"></select>
151+
<select class="gf-form-input" ng-model="threshold.colorMode" ng-options="f for f in ['custom', 'critical', 'warning', 'ok']" ng-change="ctrl.render()"></select>
149152
</div>
150153
</div>
151154

155+
<gf-form-switch class="gf-form" label="Fill" checked="threshold.fill" on-change="ctrl.render()"></gf-form-switch>
156+
<div class="gf-form" ng-if="threshold.fill && threshold.colorMode === 'custom'">
157+
<label class="gf-form-label">Fill color</label>
158+
<span class="gf-form-label">
159+
<spectrum-picker ng-model="threshold.fillColor" ng-change="ctrl.render()" ></spectrum-picker>
160+
</span>
161+
</div>
162+
163+
<gf-form-switch class="gf-form" label="Line" checked="threshold.line" on-change="ctrl.render()"></gf-form-switch>
164+
<div class="gf-form" ng-if="threshold.line && threshold.colorMode === 'custom'">
165+
<label class="gf-form-label">Line color</label>
166+
<span class="gf-form-label">
167+
<spectrum-picker ng-model="threshold.lineColor" ng-change="ctrl.render()" ></spectrum-picker>
168+
</span>
169+
</div>
170+
152171
<div class="gf-form">
153172
<label class="gf-form-label">
154173
<i class="fa fa-trash pointer" ng-click="ctrl.removeThreshold($index)"></i>
155174
</label>
156175
</div>
157176
</div>
158-
</div>
159177

160-
<button class="btn btn-inverse" ng-click="ctrl.addThreshold()">
161-
<i class="fa fa-plus"></i>&nbsp;Add Threshold
162-
</button>
178+
<div class="gf-form-button-row">
179+
<button class="btn btn-inverse" ng-click="ctrl.addThreshold()">
180+
<i class="fa fa-plus"></i>&nbsp;Add Threshold
181+
</button>
182+
</div>
183+
</div>
163184
</div>
164185

165186
</div>

0 commit comments

Comments
 (0)