module.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. status: "Stable",
  17. panels : [
  18. ]
  19. }
  20. _.defaults($scope.panel,_d);
  21. $scope.init = function(){
  22. $scope.reset_panel();
  23. }
  24. $scope.toggle_row = function(panel) {
  25. panel.collapse = panel.collapse ? false : true;
  26. if (!panel.collapse) {
  27. $timeout(function() {
  28. $scope.send_render();
  29. });
  30. }
  31. }
  32. $scope.send_render = function() {
  33. $scope.$broadcast('render');
  34. }
  35. $scope.add_panel = function(panel) {
  36. $scope.panel.panels.push(panel);
  37. }
  38. $scope.reset_panel = function(type) {
  39. $scope.new_panel = {
  40. loading: false,
  41. error: false,
  42. sizeable: false,
  43. span: 12,
  44. height: "150px",
  45. editable: true,
  46. group: ['default'],
  47. type: type,
  48. };
  49. };
  50. })
  51. .directive('columnEdit', function($compile,$timeout) {
  52. return {
  53. scope : {
  54. new_panel:"=panel",
  55. row:"=",
  56. config:"=",
  57. dashboards:"=",
  58. type:"=type"
  59. },
  60. link: function(scope, elem, attrs, ctrl) {
  61. scope.$on('render', function () {
  62. // Make sure the digest has completed and populated the attributes
  63. $timeout(function() {
  64. // Create a reference to the new_panel as panel so that the existing
  65. // editors work with our isolate scope
  66. scope.panel = scope.new_panel
  67. var template = '<div ng-include src="\'panels/column/panelgeneral.html\'"></div>'
  68. if(!(_.isUndefined(scope.type)) && scope.type != "")
  69. template = template+'<div ng-include src="\'panels/'+scope.type+'/editor.html\'"></div>';
  70. //var new_elem = $compile(angular.element(template))(scope))
  71. elem.html($compile(angular.element(template))(scope));
  72. })
  73. })
  74. }
  75. }
  76. }).filter('withoutColumn', function() {
  77. return function() {
  78. return _.without(config.modules,'column');
  79. };
  80. });