Skip to content

Commit dac8b35

Browse files
committed
feat(alerting): renamed scheduler to handler
1 parent 7f22b9e commit dac8b35

File tree

7 files changed

+25
-47
lines changed

7 files changed

+25
-47
lines changed

pkg/models/alert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Alert struct {
1414
Name string
1515
Description string
1616
State string
17-
Scheduler int64
17+
Handler int64
1818
Enabled bool
1919

2020
Created time.Time

pkg/services/alerting/extractor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (e *DashAlertExtractor) GetAlerts() ([]*m.Alert, error) {
6969
PanelId: panel.Get("id").MustInt64(),
7070
Id: jsonAlert.Get("id").MustInt64(),
7171
Name: jsonAlert.Get("name").MustString(),
72-
Scheduler: jsonAlert.Get("scheduler").MustInt64(),
72+
Handler: jsonAlert.Get("handler").MustInt64(),
7373
Enabled: jsonAlert.Get("enabled").MustBool(),
7474
Description: jsonAlert.Get("description").MustString(),
7575
}

pkg/services/alerting/extractor_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestAlertRuleExtraction(t *testing.T) {
3939
"alert": {
4040
"name": "name1",
4141
"description": "desc1",
42-
"scheduler": 1,
42+
"handler": 1,
4343
"enabled": true,
4444
"critical": {
4545
"level": 20,
@@ -74,7 +74,7 @@ func TestAlertRuleExtraction(t *testing.T) {
7474
"alert": {
7575
"name": "name2",
7676
"description": "desc2",
77-
"scheduler": 0,
77+
"handler": 0,
7878
"enabled": true,
7979
"critical": {
8080
"level": 20,
@@ -197,9 +197,9 @@ func TestAlertRuleExtraction(t *testing.T) {
197197
So(v.Description, ShouldNotBeEmpty)
198198
}
199199

200-
Convey("should extract scheduler property", func() {
201-
So(alerts[0].Scheduler, ShouldEqual, 1)
202-
So(alerts[1].Scheduler, ShouldEqual, 0)
200+
Convey("should extract handler property", func() {
201+
So(alerts[0].Handler, ShouldEqual, 1)
202+
So(alerts[1].Handler, ShouldEqual, 0)
203203
})
204204

205205
Convey("should extract panel idc", func() {

pkg/services/sqlstore/migrations/alert_mig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func addAlertMigrations(mg *Migrator) {
1717
{Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false},
1818
{Name: "state", Type: DB_NVarchar, Length: 255, Nullable: false},
1919
{Name: "settings", Type: DB_Text, Nullable: false},
20-
{Name: "scheduler", Type: DB_BigInt, Nullable: false},
20+
{Name: "handler", Type: DB_BigInt, Nullable: false},
2121
{Name: "enabled", Type: DB_Bool, Nullable: false},
2222
{Name: "created", Type: DB_DateTime, Nullable: false},
2323
{Name: "updated", Type: DB_DateTime, Nullable: false},

public/app/plugins/panel/graph/alert_handle.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,11 @@ export class AlertHandleManager {
5858
isMoving = false;
5959
// calculate graph level
6060
var graphLevel = plot.c2p({left: 0, top: posTop}).y;
61-
console.log('canvasPos:' + posTop + ' Graph level: ' + graphLevel);
6261
graphLevel = parseInt(graphLevel.toFixed(0));
6362
levelModel.level = graphLevel;
64-
console.log(levelModel);
6563

6664
var levelCanvasPos = plot.p2c({x: 0, y: graphLevel});
67-
console.log('canvas pos', levelCanvasPos);
6865

69-
console.log('stopped');
7066
handleElem.off("mousemove", dragging);
7167
handleElem.off("mouseup", dragging);
7268

@@ -80,7 +76,6 @@ export class AlertHandleManager {
8076
isMoving = true;
8177
lastY = null;
8278
posTop = handleElem.position().top;
83-
console.log('start pos', posTop);
8479

8580
handleElem.on("mousemove", dragging);
8681
handleElem.on("mouseup", stopped);
@@ -109,12 +104,10 @@ export class AlertHandleManager {
109104
}
110105

111106
if (handleElem.length === 0) {
112-
console.log('creating handle');
113107
handleElem = $(this.getFullHandleHtml(type, model.op, levelStr));
114108
this.placeholder.append(handleElem);
115109
this.setupDragging(handleElem, model);
116110
} else {
117-
console.log('reusing handle!');
118111
handleElem.html(this.getHandleInnerHtml(type, model.op, levelStr));
119112
}
120113

public/app/plugins/panel/graph/alert_tab_ctrl.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class AlertTabCtrl {
2323
panel: any;
2424
panelCtrl: any;
2525
metricTargets = [{ refId: '- select query -' } ];
26-
schedulers = [{text: 'Grafana', value: 1}, {text: 'External', value: 0}];
26+
handlers = [{text: 'Grafana', value: 1}, {text: 'External', value: 0}];
2727
transforms = [
2828
{
2929
text: 'Aggregation',
@@ -49,7 +49,7 @@ export class AlertTabCtrl {
4949
frequency: '60s',
5050
notify: [],
5151
enabled: false,
52-
scheduler: 1,
52+
handler: 1,
5353
warn: { op: '>', level: undefined },
5454
critical: { op: '>', level: undefined },
5555
query: {
@@ -104,7 +104,6 @@ export class AlertTabCtrl {
104104

105105
// init the query part components model
106106
this.query = new QueryPart(this.queryParams, alertQueryDef);
107-
this.convertThresholdsToAlertThresholds();
108107
this.transformDef = _.findWhere(this.transforms, {type: this.alert.transform.type});
109108

110109
this.panelCtrl.editingAlert = true;
@@ -136,22 +135,8 @@ export class AlertTabCtrl {
136135
}
137136
}
138137

139-
convertThresholdsToAlertThresholds() {
140-
// if (this.panel.grid
141-
// && this.panel.grid.threshold1
142-
// && this.alert.warnLevel === undefined
143-
// ) {
144-
// this.alert.warning.op = '>';
145-
// this.alert.warning.level = this.panel.grid.threshold1;
146-
// }
147-
//
148-
// if (this.panel.grid
149-
// && this.panel.grid.threshold2
150-
// && this.alert.critical.level === undefined
151-
// ) {
152-
// this.alert.critical.op = '>';
153-
// this.alert.critical.level = this.panel.grid.threshold2;
154-
// }
138+
operatorChanged() {
139+
this.panelCtrl.render();
155140
}
156141

157142
delete() {

public/app/plugins/panel/graph/partials/tab_alerting.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ <h5 class="section-heading">Alert Query</h5>
4141
<div class="gf-form-group section">
4242
<h5 class="section-heading">Levels</h5>
4343
<div class="gf-form-inline">
44-
<div class="gf-form">
45-
<span class="gf-form-label">
46-
<i class="icon-gf icon-gf-warn alert-icon-warn"></i>
47-
Warn if
48-
</span>
49-
<metric-segment-model property="ctrl.alert.warn.op" options="ctrl.levelOpList" custom="false" css-class="query-segment-operator"></metric-segment-model>
50-
<input class="gf-form-input max-width-7" type="number" ng-model="ctrl.alert.warn.level" ng-change="ctrl.levelsUpdated()"></input>
51-
</div>
52-
<div class="gf-form">
44+
<div class="gf-form">
5345
<span class="gf-form-label">
5446
<i class="icon-gf icon-gf-warn alert-icon-critical"></i>
5547
Critcal if
5648
</span>
57-
<metric-segment-model property="ctrl.alert.critical.op" options="ctrl.levelOpList" custom="false" css-class="query-segment-operator"></metric-segment-model>
49+
<metric-segment-model property="ctrl.alert.critical.op" options="ctrl.levelOpList" custom="false" css-class="query-segment-operator" on-change="ctrl.operatorChanged()"></metric-segment-model>
5850
<input class="gf-form-input max-width-7" type="number" ng-model="ctrl.alert.critical.level" ng-change="ctrl.levelsUpdated()"></input>
51+
</div>
52+
<div class="gf-form">
53+
<span class="gf-form-label">
54+
<i class="icon-gf icon-gf-warn alert-icon-warn"></i>
55+
Warn if
56+
</span>
57+
<metric-segment-model property="ctrl.alert.warn.op" options="ctrl.levelOpList" custom="false" css-class="query-segment-operator" on-change="ctrl.operatorChanged()"></metric-segment-model>
58+
<input class="gf-form-input max-width-7" type="number" ng-model="ctrl.alert.warn.level" ng-change="ctrl.levelsUpdated()"></input>
5959
</div>
6060
</div>
6161
</div>
@@ -66,11 +66,11 @@ <h5 class="section-heading">Levels</h5>
6666
<h5 class="section-heading">Execution</h5>
6767
<div class="gf-form-inline">
6868
<div class="gf-form">
69-
<span class="gf-form-label">Scheduler</span>
69+
<span class="gf-form-label">Handler</span>
7070
<div class="gf-form-select-wrapper">
7171
<select class="gf-form-input"
72-
ng-model="ctrl.alert.scheduler"
73-
ng-options="f.value as f.text for f in ctrl.schedulers">
72+
ng-model="ctrl.alert.handler"
73+
ng-options="f.value as f.text for f in ctrl.handlers">
7474
</select>
7575
</div>
7676
</div>

0 commit comments

Comments
 (0)