module.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. ## Column
  3. The column panel is sort of a hack to allow you to put multiple, veritcal,
  4. panels next to a bigger panel. Note that it has no group, and setting a group
  5. for the panel itself will do nothing
  6. ### Parameters
  7. * panels :: an array of panel objects. All of their spans should be set to 12
  8. ### Group Events
  9. #### Sends
  10. * time :: Object Includes from, to and index
  11. */
  12. angular.module('kibana.column', [])
  13. .controller('column', function($scope, $rootScope) {
  14. // Set and populate defaults
  15. var _d = {
  16. panels : [
  17. ]
  18. }
  19. _.defaults($scope.panel,_d);
  20. $scope.init = function(){
  21. $scope.reset_panel();
  22. }
  23. $scope.toggle_row = function(panel) {
  24. panel.collapse = panel.collapse ? false : true;
  25. if (!panel.collapse) {
  26. $timeout(function() {
  27. $scope.send_render();
  28. });
  29. }
  30. }
  31. $scope.send_render = function() {
  32. $scope.$broadcast('render');
  33. }
  34. $scope.add_panel = function(panel) {
  35. $scope.panel.panels.push(panel);
  36. }
  37. $scope.reset_panel = function(type) {
  38. $scope.new_panel = {
  39. loading: false,
  40. error: false,
  41. sizeable: false,
  42. span: 12,
  43. height: "150px",
  44. editable: true,
  45. group: ['default'],
  46. type: type,
  47. };
  48. };
  49. })
  50. .directive('columnEdit', function($compile,$timeout) {
  51. return {
  52. scope : {
  53. new_panel:"=panel",
  54. row:"=",
  55. config:"=",
  56. dashboards:"=",
  57. type:"=type"
  58. },
  59. link: function(scope, elem, attrs, ctrl) {
  60. scope.$on('render', function () {
  61. // Make sure the digest has completed and populated the attributes
  62. $timeout(function() {
  63. // Create a reference to the new_panel as panel so that the existing
  64. // editors work with our isolate scope
  65. scope.panel = scope.new_panel
  66. var template = '<div ng-include src="\'panels/column/panelgeneral.html\'"></div>'
  67. if(!(_.isUndefined(scope.type)) && scope.type != "")
  68. template = template+'<div ng-include src="\'panels/'+scope.type+'/editor.html\'"></div>';
  69. //var new_elem = $compile(angular.element(template))(scope))
  70. elem.html($compile(angular.element(template))(scope));
  71. })
  72. })
  73. }
  74. }
  75. }).filter('withoutColumn', function() {
  76. return function() {
  77. return _.without(config.modules,'column');
  78. };
  79. });