From 73fc659011da3e52e75d946af9c8cf029e75417f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 11 Oct 2016 13:22:46 +0200 Subject: [PATCH] fix(graph): fixed issue with old threshold to new threshold model migration, fixes #6236 --- public/app/features/dashboard/dashboard_srv.ts | 14 +++++++++----- .../dashboard/specs/dashboard_srv_specs.ts | 10 +++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/public/app/features/dashboard/dashboard_srv.ts b/public/app/features/dashboard/dashboard_srv.ts index 92cfa4dc925..94026233134 100644 --- a/public/app/features/dashboard/dashboard_srv.ts +++ b/public/app/features/dashboard/dashboard_srv.ts @@ -514,9 +514,11 @@ export class DashboardModel { if (panel.grid.thresholdLine) { t1.line = true; t1.lineColor = panel.grid.threshold1Color; + t1.colorMode = 'custom'; } else { t1.fill = true; t1.fillColor = panel.grid.threshold1Color; + t1.colorMode = 'custom'; } } @@ -525,25 +527,27 @@ export class DashboardModel { if (panel.grid.thresholdLine) { t2.line = true; t2.lineColor = panel.grid.threshold2Color; + t2.colorMode = 'custom'; } else { t2.fill = true; t2.fillColor = panel.grid.threshold2Color; + t2.colorMode = 'custom'; } } if (_.isNumber(t1.value)) { if (_.isNumber(t2.value)) { if (t1.value > t2.value) { - t1.op = t2.op = '<'; - panel.thresholds.push(t2); + t1.op = t2.op = 'lt'; panel.thresholds.push(t1); + panel.thresholds.push(t2); } else { - t1.op = t2.op = '>'; - panel.thresholds.push(t2); + t1.op = t2.op = 'gt'; panel.thresholds.push(t1); + panel.thresholds.push(t2); } } else { - t1.op = '>'; + t1.op = 'gt'; panel.thresholds.push(t1); } } diff --git a/public/app/features/dashboard/specs/dashboard_srv_specs.ts b/public/app/features/dashboard/specs/dashboard_srv_specs.ts index 56ce355881a..7dded76e079 100644 --- a/public/app/features/dashboard/specs/dashboard_srv_specs.ts +++ b/public/app/features/dashboard/specs/dashboard_srv_specs.ts @@ -221,11 +221,11 @@ describe('dashboardSrv', function() { it('graph thresholds should be migrated', function() { expect(graph.thresholds.length).to.be(2); - expect(graph.thresholds[0].op).to.be('>'); - expect(graph.thresholds[0].value).to.be(400); - expect(graph.thresholds[0].fillColor).to.be('red'); - expect(graph.thresholds[1].value).to.be(200); - expect(graph.thresholds[1].fillColor).to.be('yellow'); + expect(graph.thresholds[0].op).to.be('gt'); + expect(graph.thresholds[0].value).to.be(200); + expect(graph.thresholds[0].fillColor).to.be('yellow'); + expect(graph.thresholds[1].value).to.be(400); + expect(graph.thresholds[1].fillColor).to.be('red'); }); });