From a49a9b3b6462d8c3b0d73ca417016c944e86e212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 11 Nov 2014 12:51:57 +0100 Subject: [PATCH] Panel: more work on panel links, #1041 --- src/app/components/panellinkeditor/linkSrv.js | 8 +++---- src/app/directives/panelMenu.js | 24 +++++++++++++------ src/css/less/panel.less | 9 +++++++ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/app/components/panellinkeditor/linkSrv.js b/src/app/components/panellinkeditor/linkSrv.js index 8737814556d..eacdf1d2c35 100644 --- a/src/app/components/panellinkeditor/linkSrv.js +++ b/src/app/components/panellinkeditor/linkSrv.js @@ -13,14 +13,14 @@ function (angular, kbn) { var info = {}; if (link.type === 'absolute') { info.target = '_blank'; - info.href = templateSrv.replace(link.url); - info.title = templateSrv.replace(link.title); + info.href = templateSrv.replace(link.url || ''); + info.title = templateSrv.replace(link.title || ''); info.href += '?'; } else { - info.title = templateSrv.replace(link.title); - var slug = kbn.slugifyForUrl(link.dashboard); + info.title = templateSrv.replace(link.title || ''); + var slug = kbn.slugifyForUrl(link.dashboard || ''); info.href = '#dashboard/db/' + slug + '?'; } diff --git a/src/app/directives/panelMenu.js b/src/app/directives/panelMenu.js index 13aed5f6f3e..1a340b19bfa 100644 --- a/src/app/directives/panelMenu.js +++ b/src/app/directives/panelMenu.js @@ -9,7 +9,11 @@ function (angular, $, _) { angular .module('grafana.directives') .directive('panelMenu', function($compile, linkSrv) { - var linkTemplate = '{{panel.title | interpolateTemplateVars}}'; + var linkTemplate = + '' + + '{{panel.title | interpolateTemplateVars}}' + + '' + + ''; function createMenuTemplate($scope) { var template = '
'; @@ -39,13 +43,15 @@ function (angular, $, _) { } function getExtendedMenu($scope) { - var menu =angular.copy($scope.panelMeta.extendedMenu); - if (!$scope.panel.links) { return; } + var menu = angular.copy($scope.panelMeta.extendedMenu); + + if ($scope.panel.links) { + _.each($scope.panel.links, function(link) { + var info = linkSrv.getPanelLinkAnchorInfo(link); + menu.push({text: info.title, href: info.href, target: info.target }); + }); + } - _.each($scope.panel.links, function(link) { - var info = linkSrv.getPanelLinkAnchorInfo(link); - menu.push({text: info.title, href: info.href, target: info.target }); - }); return menu; } @@ -61,6 +67,10 @@ function (angular, $, _) { elem.append($link); + $scope.$watchCollection('panel.links', function(newValue) { + $link.toggleClass('has-panel-links', newValue ? newValue.length > 0 : false); + }); + function dismiss(time) { clearTimeout(timeout); timeout = null; diff --git a/src/css/less/panel.less b/src/css/less/panel.less index 8dd1dccdd45..5c3dd93c6cf 100644 --- a/src/css/less/panel.less +++ b/src/css/less/panel.less @@ -27,6 +27,15 @@ font-weight: bold; position: relative; cursor: context-menu; + + &.has-panel-links { + .panel-title-text:after { + content: "\f0c1"; + font-family:'FontAwesome'; + font-size: 80%; + padding-left: 10px; + } + } } .panel-loading {