Browse Source

fix(share): fixed share panel image url, did not generate correct url when domain name contained word dashboards, fixes #2916

Torkel Ödegaard 10 years ago
parent
commit
c0da52aac8

+ 1 - 1
public/app/features/dashboard/shareModalCtrl.js

@@ -75,7 +75,7 @@ function (angular, _, require, config) {
 
       $scope.iframeHtml = '<iframe src="' + soloUrl + '" width="450" height="200" frameborder="0"></iframe>';
 
-      $scope.imageUrl = soloUrl.replace('/dashboard', '/render/dashboard');
+      $scope.imageUrl = soloUrl.replace('/dashboard-solo/', '/render/dashboard-solo/');
       $scope.imageUrl += '&width=1000';
       $scope.imageUrl += '&height=500';
     };

+ 2 - 1
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:[] };

+ 12 - 0
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;