module.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. define([
  2. 'angular',
  3. 'lodash',
  4. './linkSrv',
  5. ],
  6. function (angular, _) {
  7. 'use strict';
  8. angular
  9. .module('grafana.directives')
  10. .directive('panelLinkEditor', function() {
  11. return {
  12. scope: {
  13. panel: "="
  14. },
  15. restrict: 'E',
  16. controller: 'PanelLinkEditorCtrl',
  17. templateUrl: 'app/features/panellinkeditor/module.html',
  18. link: function() {
  19. }
  20. };
  21. }).controller('PanelLinkEditorCtrl', function($scope, datasourceSrv) {
  22. $scope.panel.links = $scope.panel.links || [];
  23. $scope.addLink = function() {
  24. $scope.panel.links.push({
  25. type: 'dashboard',
  26. name: 'Drilldown dashboard'
  27. });
  28. };
  29. $scope.searchDashboards = function(query, callback) {
  30. var ds = datasourceSrv.getGrafanaDB();
  31. if (ds === null) { return; }
  32. ds.searchDashboards(query).then(function(result) {
  33. var dashboards = _.map(result.dashboards, function(dash) {
  34. return dash.title;
  35. });
  36. callback(dashboards);
  37. });
  38. };
  39. $scope.deleteLink = function(link) {
  40. $scope.panel.links = _.without($scope.panel.links, link);
  41. };
  42. });
  43. });