From c0da52aac8b47501535ab5740305a73510d5d2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 10 Oct 2015 14:38:22 -0400 Subject: [PATCH] fix(share): fixed share panel image url, did not generate correct url when domain name contained word dashboards, fixes #2916 --- public/app/features/dashboard/shareModalCtrl.js | 2 +- public/test/specs/helpers.js | 3 ++- public/test/specs/shareModalCtrl-specs.js | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/public/app/features/dashboard/shareModalCtrl.js b/public/app/features/dashboard/shareModalCtrl.js index 5afee9d39cd..9c0d14ee601 100644 --- a/public/app/features/dashboard/shareModalCtrl.js +++ b/public/app/features/dashboard/shareModalCtrl.js @@ -75,7 +75,7 @@ function (angular, _, require, config) { $scope.iframeHtml = ''; - $scope.imageUrl = soloUrl.replace('/dashboard', '/render/dashboard'); + $scope.imageUrl = soloUrl.replace('/dashboard-solo/', '/render/dashboard-solo/'); $scope.imageUrl += '&width=1000'; $scope.imageUrl += '&height=500'; }; diff --git a/public/test/specs/helpers.js b/public/test/specs/helpers.js index 011c0cc70d6..9fa5aeee209 100644 --- a/public/test/specs/helpers.js +++ b/public/test/specs/helpers.js @@ -38,9 +38,10 @@ define([ }; this.createControllerPhase = function(controllerName) { - return inject(function($controller, $rootScope, $q, $location) { + return inject(function($controller, $rootScope, $q, $location, $browser) { self.scope = $rootScope.$new(); self.$location = $location; + self.$browser = $browser; self.scope.contextSrv = {}; self.scope.panel = {}; self.scope.row = { panels:[] }; diff --git a/public/test/specs/shareModalCtrl-specs.js b/public/test/specs/shareModalCtrl-specs.js index 6aea645d557..f3ff4aeb719 100644 --- a/public/test/specs/shareModalCtrl-specs.js +++ b/public/test/specs/shareModalCtrl-specs.js @@ -7,6 +7,7 @@ define([ describe('ShareModalCtrl', function() { var ctx = new helpers.ControllerTestContext(); + var browser; function setTime(range) { ctx.timeSrv.timeRange = sinon.stub().returns(range); @@ -31,6 +32,17 @@ define([ expect(ctx.scope.shareUrl).to.be('http://server/#/test?from=1000&to=2000&panelId=22&fullscreen'); }); + it('should generate render url', function() { + ctx.$location.$$absUrl = 'http://dashboards.grafana.com/dashboard/db/my-dash'; + + ctx.scope.panel = { id: 22 }; + + ctx.scope.init(); + var base = 'http://dashboards.grafana.com/render/dashboard-solo/db/my-dash'; + var params = '?from=1000&to=2000&panelId=22&fullscreen&width=1000&height=500'; + expect(ctx.scope.imageUrl).to.be(base + params); + }); + it('should remove panel id when no panel in scope', function() { ctx.$location.path('/test'); ctx.scope.options.forCurrent = true;