module.js 1.9 KB

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