|
@@ -18,7 +18,7 @@ function (angular, _) {
|
|
|
link: function() {
|
|
link: function() {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
- }).directive('dashLink', function(linkSrv) {
|
|
|
|
|
|
|
+ }).directive('dashLink', function(linkSrv, $rootScope) {
|
|
|
return {
|
|
return {
|
|
|
scope: {
|
|
scope: {
|
|
|
link: "="
|
|
link: "="
|
|
@@ -27,29 +27,52 @@ function (angular, _) {
|
|
|
controller: 'DashLinkCtrl',
|
|
controller: 'DashLinkCtrl',
|
|
|
templateUrl: 'app/features/dashlinks/module.html',
|
|
templateUrl: 'app/features/dashlinks/module.html',
|
|
|
link: function(scope, elem) {
|
|
link: function(scope, elem) {
|
|
|
|
|
+ var linkInfo;
|
|
|
|
|
+ var anchor = elem.find('a');
|
|
|
|
|
+ var icon = elem.find('i');
|
|
|
|
|
+ var span = elem.find('span');
|
|
|
|
|
|
|
|
function update() {
|
|
function update() {
|
|
|
- var linkInfo = linkSrv.getPanelLinkAnchorInfo(scope.link);
|
|
|
|
|
- elem.find("span").text(linkInfo.title);
|
|
|
|
|
- elem.find("a").attr("href", linkInfo.href);
|
|
|
|
|
|
|
+ linkInfo = linkSrv.getPanelLinkAnchorInfo(scope.link);
|
|
|
|
|
+ span.text(linkInfo.title);
|
|
|
|
|
+ anchor.attr("href", linkInfo.href);
|
|
|
|
|
|
|
|
- if (scope.link.type === 'dashboard') {
|
|
|
|
|
- scope.tooltip = 'Go to dashboard';
|
|
|
|
|
|
|
+ if (scope.link.type === 'absolute') {
|
|
|
|
|
+ icon.attr('class', 'fa fw fa-external-link');
|
|
|
|
|
+ anchor.attr('target', '_blank');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ icon.attr('class', 'fa fw fa-th-large');
|
|
|
|
|
+ anchor.attr('target', '');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // tooltip
|
|
|
|
|
+ elem.find('a').tooltip({
|
|
|
|
|
+ title: function () {
|
|
|
|
|
+ if (scope.link.tooltip) {
|
|
|
|
|
+ return scope.link.tooltip;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (scope.link.type === 'dashboard') {
|
|
|
|
|
+ return 'Open dashboard';
|
|
|
|
|
+ } else if (scope.link.type === 'absolute') {
|
|
|
|
|
+ return 'Open external page';
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ html: true,
|
|
|
|
|
+ container: 'body', // Grafana change
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
update();
|
|
update();
|
|
|
scope.$on('refresh', update);
|
|
scope.$on('refresh', update);
|
|
|
|
|
+ $rootScope.onAppEvent('dash-links-updated', update);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
})
|
|
})
|
|
|
- .controller("DashLinkCtrl", function($scope) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ .controller("DashLinkCtrl", function() {
|
|
|
})
|
|
})
|
|
|
- .controller('DashLinkEditorCtrl', function($scope, backendSrv) {
|
|
|
|
|
|
|
+ .controller('DashLinkEditorCtrl', function($scope, backendSrv, $rootScope) {
|
|
|
|
|
|
|
|
$scope.dashboard.links = $scope.dashboard.links || [];
|
|
$scope.dashboard.links = $scope.dashboard.links || [];
|
|
|
-
|
|
|
|
|
$scope.addLink = function() {
|
|
$scope.addLink = function() {
|
|
|
$scope.dashboard.links.push({
|
|
$scope.dashboard.links.push({
|
|
|
type: 'dashboard',
|
|
type: 'dashboard',
|
|
@@ -57,6 +80,10 @@ function (angular, _) {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ $scope.updated = function() {
|
|
|
|
|
+ $rootScope.appEvent('dash-links-updated');
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
$scope.searchDashboards = function(queryStr, callback) {
|
|
$scope.searchDashboards = function(queryStr, callback) {
|
|
|
var query = {query: queryStr};
|
|
var query = {query: queryStr};
|
|
|
|
|
|