dash.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /** @scratch /index/0
  2. * = Kibana
  3. *
  4. * // Why can't I have a preamble here?
  5. *
  6. * == Introduction
  7. *
  8. * Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for
  9. * ElasticSearch. Kibana is a snap to setup and start using. Written entirely in HTML and Javascript
  10. * it requires only a plain webserver, Kibana requires no fancy server side components.
  11. * Kibana strives to be easy to get started with, while also being flexible and powerful, just like
  12. * Elasticsearch.
  13. *
  14. * include::configuration/config.js.asciidoc[]
  15. *
  16. * include::panels.asciidoc[]
  17. *
  18. */
  19. define([
  20. 'angular',
  21. 'config',
  22. 'underscore',
  23. 'services/all'
  24. ],
  25. function (angular, config, _) {
  26. "use strict";
  27. var module = angular.module('kibana.controllers');
  28. module.controller('DashCtrl', function(
  29. $scope, $rootScope, $route, ejsResource, dashboard, alertSrv, panelMove, esVersion, keyboardManager) {
  30. $scope.requiredElasticSearchVersion = ">=0.90.3";
  31. $scope.editor = {
  32. index: 0
  33. };
  34. // For moving stuff around the dashboard.
  35. $scope.panelMoveDrop = panelMove.onDrop;
  36. $scope.panelMoveStart = panelMove.onStart;
  37. $scope.panelMoveStop = panelMove.onStop;
  38. $scope.panelMoveOver = panelMove.onOver;
  39. $scope.panelMoveOut = panelMove.onOut;
  40. $scope.init = function() {
  41. $scope.config = config;
  42. // Make stuff, including underscore.js available to views
  43. $scope._ = _;
  44. $scope.dashboard = dashboard;
  45. $scope.dashAlerts = alertSrv;
  46. $scope.esVersion = esVersion;
  47. // Clear existing alerts
  48. alertSrv.clearAll();
  49. $scope.reset_row();
  50. $scope.ejs = ejsResource(config.elasticsearch);
  51. $rootScope.$on('fullEditMode', function(evt, enabled) {
  52. $scope.fullEditMode = enabled;
  53. });
  54. keyboardManager.bind('esc', function() {
  55. $rootScope.$emit('fullEditMode', false);
  56. });
  57. };
  58. $scope.isPanel = function(obj) {
  59. if(!_.isNull(obj) && !_.isUndefined(obj) && !_.isUndefined(obj.type)) {
  60. return true;
  61. } else {
  62. return false;
  63. }
  64. };
  65. $scope.add_row = function(dash,row) {
  66. dash.rows.push(row);
  67. };
  68. $scope.reset_row = function() {
  69. $scope.row = {
  70. title: '',
  71. height: '150px',
  72. editable: true,
  73. };
  74. };
  75. $scope.row_style = function(row) {
  76. return { 'min-height': row.collapse ? '5px' : row.height };
  77. };
  78. $scope.panel_path =function(type) {
  79. if(type) {
  80. return 'app/panels/'+type.replace(".","/");
  81. } else {
  82. return false;
  83. }
  84. };
  85. $scope.edit_path = function(type) {
  86. var p = $scope.panel_path(type);
  87. if(p) {
  88. return p+'/editor.html';
  89. } else {
  90. return false;
  91. }
  92. };
  93. $scope.setEditorTabs = function(panelMeta) {
  94. $scope.editorTabs = ['General','Panel'];
  95. if(!_.isUndefined(panelMeta.editorTabs)) {
  96. $scope.editorTabs = _.union($scope.editorTabs,_.pluck(panelMeta.editorTabs,'title'));
  97. }
  98. return $scope.editorTabs;
  99. };
  100. // This is whoafully incomplete, but will do for now
  101. $scope.parse_error = function(data) {
  102. var _error = data.match("nested: (.*?);");
  103. return _.isNull(_error) ? data : _error[1];
  104. };
  105. $scope.init();
  106. });
  107. });