module.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. define([
  2. 'angular',
  3. 'lodash',
  4. './linkSrv',
  5. ],
  6. function (angular, _) {
  7. 'use strict';
  8. angular
  9. .module('grafana.directives')
  10. .directive('panelLinksEditor', function() {
  11. return {
  12. scope: {
  13. panel: "="
  14. },
  15. restrict: 'E',
  16. controller: 'PanelLinksEditorCtrl',
  17. templateUrl: 'app/features/panellinks/module.html',
  18. link: function() {
  19. }
  20. };
  21. }).controller('PanelLinksEditorCtrl', function($scope, backendSrv) {
  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(queryStr, callback) {
  30. var query = {query: queryStr};
  31. backendSrv.search(query).then(function(result) {
  32. var dashboards = _.map(result.dashboards, function(dash) {
  33. return dash.title;
  34. });
  35. callback(dashboards);
  36. });
  37. };
  38. $scope.deleteLink = function(link) {
  39. $scope.panel.links = _.without($scope.panel.links, link);
  40. };
  41. });
  42. });