diff --git a/package.json b/package.json index 5490435309f..bc356554859 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "devDependencies": { "zone.js": "^0.6.6", - "autoprefixer": "^6.3.3", + "autoprefixer": "^6.4.0", "es6-promise": "^3.0.2", "es6-shim": "^0.35.1", "expect.js": "~0.2.0", diff --git a/pkg/services/alerting/conditions/evaluator.go b/pkg/services/alerting/conditions/evaluator.go index 943d18506b5..3ef8576afc7 100644 --- a/pkg/services/alerting/conditions/evaluator.go +++ b/pkg/services/alerting/conditions/evaluator.go @@ -19,9 +19,9 @@ type DefaultAlertEvaluator struct { func (e *DefaultAlertEvaluator) Eval(series *tsdb.TimeSeries, reducedValue float64) bool { switch e.Type { - case ">": + case "gt": return reducedValue > e.Threshold - case "<": + case "lt": return reducedValue < e.Threshold } diff --git a/pkg/services/alerting/conditions/query_test.go b/pkg/services/alerting/conditions/query_test.go index 558293ba4be..f12562dec0b 100644 --- a/pkg/services/alerting/conditions/query_test.go +++ b/pkg/services/alerting/conditions/query_test.go @@ -18,7 +18,7 @@ func TestQueryCondition(t *testing.T) { queryConditionScenario("Given avg() and > 100", func(ctx *queryConditionTestContext) { ctx.reducer = `{"type": "avg"}` - ctx.evaluator = `{"type": ">", "params": [100]}` + ctx.evaluator = `{"type": "gt "params": [100]}` Convey("Can read query condition from json model", func() { ctx.exec() diff --git a/public/app/features/alerting/alert_tab_ctrl.ts b/public/app/features/alerting/alert_tab_ctrl.ts index 328c8d0f874..217f67124ef 100644 --- a/public/app/features/alerting/alert_tab_ctrl.ts +++ b/public/app/features/alerting/alert_tab_ctrl.ts @@ -172,7 +172,9 @@ export class AlertTabCtrl { delete() { this.panel.alert = {enabled: false}; - this.initModel(); + this.panel.thresholds = []; + this.conditionModels = []; + this.panelCtrl.render(); } enable() { diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index 3c2894ba922..05da5652b74 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -3,6 +3,7 @@ import './graph'; import './legend'; import './series_overrides_ctrl'; +import './thresholds_form'; import template from './template'; import angular from 'angular'; @@ -327,14 +328,6 @@ class GraphCtrl extends MetricsPanelCtrl { fileExport.exportSeriesListToCsvColumns(this.seriesList); } - addThreshold() { - this.panel.thresholds.push({value: undefined, colorMode: "critical", op: 'gt', fill: true, line: true}); - } - - removeThreshold(index) { - this.panel.thresholds.splice(index, 1); - this.render(); - } } export {GraphCtrl, GraphCtrl as PanelCtrl} diff --git a/public/app/plugins/panel/graph/tab_display.html b/public/app/plugins/panel/graph/tab_display.html index 20973d3d56b..14c8c4cf6fc 100644 --- a/public/app/plugins/panel/graph/tab_display.html +++ b/public/app/plugins/panel/graph/tab_display.html @@ -10,7 +10,9 @@
  • - Thresholds + + Thresholds ({{ctrl.panel.thresholds.length}}) +
  • @@ -131,56 +133,7 @@
    -
    -
    Thresholds
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    - -
    - -
    -
    - - -
    - - - - -
    - - -
    - - - - -
    - -
    - -
    -
    - -
    - -
    -
    +
    diff --git a/public/app/plugins/panel/graph/thresholds_form.ts b/public/app/plugins/panel/graph/thresholds_form.ts new file mode 100644 index 00000000000..086d278f0c0 --- /dev/null +++ b/public/app/plugins/panel/graph/thresholds_form.ts @@ -0,0 +1,124 @@ +/// + + +import _ from 'lodash'; +import coreModule from 'app/core/core_module'; + +export class ThresholdFormCtrl { + panelCtrl: any; + panel: any; + disabled: boolean; + + /** @ngInject */ + constructor($scope) { + this.panel = this.panelCtrl.panel; + + if (this.panel.alert && this.panel.alert.enabled) { + this.disabled = true; + } + + $scope.$on("$destroy", () => { + this.panelCtrl.editingThresholds = false; + this.panelCtrl.render(); + }); + + this.panelCtrl.editingThresholds = true; + } + + addThreshold() { + this.panel.thresholds.push({value: undefined, colorMode: "critical", op: 'gt', fill: true, line: true}); + this.panelCtrl.render(); + } + + removeThreshold(index) { + this.panel.thresholds.splice(index, 1); + this.panelCtrl.render(); + } + + render() { + this.panelCtrl.render(); + } +} + +var template = ` +
    +
    Thresholds
    +

    + Visual thresholds options disabled. + Visit the Alert tab update your thresholds.
    + To re-enable thresholds, the alert rule must be deleted from this panel. +

    +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    + +
    + +
    +
    + + + +
    + + + + +
    + + + +
    + + + + +
    + +
    + +
    +
    + +
    + +
    +
    +
    +`; + +coreModule.directive('graphThresholdForm', function() { + return { + restrict: 'E', + template: template, + controller: ThresholdFormCtrl, + bindToController: true, + controllerAs: 'ctrl', + scope: { + panelCtrl: "=" + } + }; +}); diff --git a/public/sass/base/_type.scss b/public/sass/base/_type.scss index 7770be25a68..f165d40e2eb 100644 --- a/public/sass/base/_type.scss +++ b/public/sass/base/_type.scss @@ -48,6 +48,11 @@ a.text-success:hover, a.text-success:focus { color: darken($successText, 10%); } a { cursor: pointer; } +a[disabled] { + cursor: default; + pointer-events: none !important; +} + .text-left { text-align: left; } .text-right { text-align: right; } .text-center { text-align: center; } diff --git a/public/sass/components/_panel_graph.scss b/public/sass/components/_panel_graph.scss index 32afd26f91d..f6d564c8264 100644 --- a/public/sass/components/_panel_graph.scss +++ b/public/sass/components/_panel_graph.scss @@ -400,3 +400,7 @@ } } } + +.thresholds-form-disabled { + filter: blur(3px); +} diff --git a/public/sass/components/_switch.scss b/public/sass/components/_switch.scss index 131a971fb2f..00b50c6da9a 100644 --- a/public/sass/components/_switch.scss +++ b/public/sass/components/_switch.scss @@ -88,4 +88,13 @@ $switch-height: 1.5rem; input:checked + label::after { transform: rotateY(0); } + +} + +gf-form-switch[disabled] { + .gf-form-label, + .gf-form-switch input + label { + cursor: default; + pointer-events: none !important; + } }