diff --git a/pkg/models/alert.go b/pkg/models/alert.go index 6a85de98c86..148a85cc7c5 100644 --- a/pkg/models/alert.go +++ b/pkg/models/alert.go @@ -14,7 +14,7 @@ type Alert struct { Name string Description string State string - Scheduler int64 + Handler int64 Enabled bool Created time.Time diff --git a/pkg/services/alerting/extractor.go b/pkg/services/alerting/extractor.go index eb91d267702..76603c4a131 100644 --- a/pkg/services/alerting/extractor.go +++ b/pkg/services/alerting/extractor.go @@ -69,7 +69,7 @@ func (e *DashAlertExtractor) GetAlerts() ([]*m.Alert, error) { PanelId: panel.Get("id").MustInt64(), Id: jsonAlert.Get("id").MustInt64(), Name: jsonAlert.Get("name").MustString(), - Scheduler: jsonAlert.Get("scheduler").MustInt64(), + Handler: jsonAlert.Get("handler").MustInt64(), Enabled: jsonAlert.Get("enabled").MustBool(), Description: jsonAlert.Get("description").MustString(), } diff --git a/pkg/services/alerting/extractor_test.go b/pkg/services/alerting/extractor_test.go index 7cab1d94c7c..cfcf2b2e4db 100644 --- a/pkg/services/alerting/extractor_test.go +++ b/pkg/services/alerting/extractor_test.go @@ -39,7 +39,7 @@ func TestAlertRuleExtraction(t *testing.T) { "alert": { "name": "name1", "description": "desc1", - "scheduler": 1, + "handler": 1, "enabled": true, "critical": { "level": 20, @@ -74,7 +74,7 @@ func TestAlertRuleExtraction(t *testing.T) { "alert": { "name": "name2", "description": "desc2", - "scheduler": 0, + "handler": 0, "enabled": true, "critical": { "level": 20, @@ -197,9 +197,9 @@ func TestAlertRuleExtraction(t *testing.T) { So(v.Description, ShouldNotBeEmpty) } - Convey("should extract scheduler property", func() { - So(alerts[0].Scheduler, ShouldEqual, 1) - So(alerts[1].Scheduler, ShouldEqual, 0) + Convey("should extract handler property", func() { + So(alerts[0].Handler, ShouldEqual, 1) + So(alerts[1].Handler, ShouldEqual, 0) }) Convey("should extract panel idc", func() { diff --git a/pkg/services/sqlstore/migrations/alert_mig.go b/pkg/services/sqlstore/migrations/alert_mig.go index dbebd2b5d25..ff9ad5abf51 100644 --- a/pkg/services/sqlstore/migrations/alert_mig.go +++ b/pkg/services/sqlstore/migrations/alert_mig.go @@ -17,7 +17,7 @@ func addAlertMigrations(mg *Migrator) { {Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false}, {Name: "state", Type: DB_NVarchar, Length: 255, Nullable: false}, {Name: "settings", Type: DB_Text, Nullable: false}, - {Name: "scheduler", Type: DB_BigInt, Nullable: false}, + {Name: "handler", Type: DB_BigInt, Nullable: false}, {Name: "enabled", Type: DB_Bool, Nullable: false}, {Name: "created", Type: DB_DateTime, Nullable: false}, {Name: "updated", Type: DB_DateTime, Nullable: false}, diff --git a/public/app/plugins/panel/graph/alert_handle.ts b/public/app/plugins/panel/graph/alert_handle.ts index c1914196e89..cc37a346cec 100644 --- a/public/app/plugins/panel/graph/alert_handle.ts +++ b/public/app/plugins/panel/graph/alert_handle.ts @@ -58,15 +58,11 @@ export class AlertHandleManager { isMoving = false; // calculate graph level var graphLevel = plot.c2p({left: 0, top: posTop}).y; - console.log('canvasPos:' + posTop + ' Graph level: ' + graphLevel); graphLevel = parseInt(graphLevel.toFixed(0)); levelModel.level = graphLevel; - console.log(levelModel); var levelCanvasPos = plot.p2c({x: 0, y: graphLevel}); - console.log('canvas pos', levelCanvasPos); - console.log('stopped'); handleElem.off("mousemove", dragging); handleElem.off("mouseup", dragging); @@ -80,7 +76,6 @@ export class AlertHandleManager { isMoving = true; lastY = null; posTop = handleElem.position().top; - console.log('start pos', posTop); handleElem.on("mousemove", dragging); handleElem.on("mouseup", stopped); @@ -109,12 +104,10 @@ export class AlertHandleManager { } if (handleElem.length === 0) { - console.log('creating handle'); handleElem = $(this.getFullHandleHtml(type, model.op, levelStr)); this.placeholder.append(handleElem); this.setupDragging(handleElem, model); } else { - console.log('reusing handle!'); handleElem.html(this.getHandleInnerHtml(type, model.op, levelStr)); } diff --git a/public/app/plugins/panel/graph/alert_tab_ctrl.ts b/public/app/plugins/panel/graph/alert_tab_ctrl.ts index 82ac33e3d47..7e3c8d7b963 100644 --- a/public/app/plugins/panel/graph/alert_tab_ctrl.ts +++ b/public/app/plugins/panel/graph/alert_tab_ctrl.ts @@ -23,7 +23,7 @@ export class AlertTabCtrl { panel: any; panelCtrl: any; metricTargets = [{ refId: '- select query -' } ]; - schedulers = [{text: 'Grafana', value: 1}, {text: 'External', value: 0}]; + handlers = [{text: 'Grafana', value: 1}, {text: 'External', value: 0}]; transforms = [ { text: 'Aggregation', @@ -49,7 +49,7 @@ export class AlertTabCtrl { frequency: '60s', notify: [], enabled: false, - scheduler: 1, + handler: 1, warn: { op: '>', level: undefined }, critical: { op: '>', level: undefined }, query: { @@ -104,7 +104,6 @@ export class AlertTabCtrl { // init the query part components model this.query = new QueryPart(this.queryParams, alertQueryDef); - this.convertThresholdsToAlertThresholds(); this.transformDef = _.findWhere(this.transforms, {type: this.alert.transform.type}); this.panelCtrl.editingAlert = true; @@ -136,22 +135,8 @@ export class AlertTabCtrl { } } - convertThresholdsToAlertThresholds() { - // if (this.panel.grid - // && this.panel.grid.threshold1 - // && this.alert.warnLevel === undefined - // ) { - // this.alert.warning.op = '>'; - // this.alert.warning.level = this.panel.grid.threshold1; - // } - // - // if (this.panel.grid - // && this.panel.grid.threshold2 - // && this.alert.critical.level === undefined - // ) { - // this.alert.critical.op = '>'; - // this.alert.critical.level = this.panel.grid.threshold2; - // } + operatorChanged() { + this.panelCtrl.render(); } delete() { diff --git a/public/app/plugins/panel/graph/partials/tab_alerting.html b/public/app/plugins/panel/graph/partials/tab_alerting.html index c2cce48a073..0b6ed66f066 100644 --- a/public/app/plugins/panel/graph/partials/tab_alerting.html +++ b/public/app/plugins/panel/graph/partials/tab_alerting.html @@ -41,21 +41,21 @@