Commit 6f9c3062 by Torkel Ödegaard

fix(singlestat): fixed usage of template variable in drilldown link for singlestat, fixes #2787

parent c369350c
...@@ -15,7 +15,7 @@ function (angular, app, _, $) { ...@@ -15,7 +15,7 @@ function (angular, app, _, $) {
return { return {
link: function(scope, elem) { link: function(scope, elem) {
var data, panel; var data, panel, linkInfo;
var $panelContainer = elem.parents('.panel-container'); var $panelContainer = elem.parents('.panel-container');
scope.$on('render', function() { scope.$on('render', function() {
...@@ -170,10 +170,16 @@ function (angular, app, _, $) { ...@@ -170,10 +170,16 @@ function (angular, app, _, $) {
} }
elem.toggleClass('pointer', panel.links.length > 0); elem.toggleClass('pointer', panel.links.length > 0);
if (panel.links.length > 0) {
linkInfo = linkSrv.getPanelLinkAnchorInfo(panel.links[0], scope.panel.scopedVars);
} else {
linkInfo = null;
}
} }
// drilldown link tooltip // drilldown link tooltip
var drilldownTooltip = $('<div id="tooltip" class="">gello</div>"'); var drilldownTooltip = $('<div id="tooltip" class="">hello</div>"');
elem.mouseleave(function() { elem.mouseleave(function() {
if (panel.links.length === 0) { return;} if (panel.links.length === 0) { return;}
...@@ -181,10 +187,9 @@ function (angular, app, _, $) { ...@@ -181,10 +187,9 @@ function (angular, app, _, $) {
}); });
elem.click(function() { elem.click(function() {
if (panel.links.length === 0) { return; } if (!linkInfo) { return; }
var link = panel.links[0];
var linkInfo = linkSrv.getPanelLinkAnchorInfo(link, scope.panel.scopedVars); if (linkInfo.target === '_blank') {
if (panel.links[0].targetBlank) {
var redirectWindow = window.open(linkInfo.href, '_blank'); var redirectWindow = window.open(linkInfo.href, '_blank');
redirectWindow.location; redirectWindow.location;
return; return;
...@@ -202,9 +207,9 @@ function (angular, app, _, $) { ...@@ -202,9 +207,9 @@ function (angular, app, _, $) {
}); });
elem.mousemove(function(e) { elem.mousemove(function(e) {
if (panel.links.length === 0) { return;} if (!linkInfo) { return;}
drilldownTooltip.text('click to go to: ' + panel.links[0].title); drilldownTooltip.text('click to go to: ' + linkInfo.title);
drilldownTooltip.place_tt(e.pageX+20, e.pageY-15); drilldownTooltip.place_tt(e.pageX+20, e.pageY-15);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment