dash.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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, $route, ejsResource, fields, dashboard, alertSrv, panelMove, esVersion) {
  30. $scope.requiredElasticSearchVersion = ">=0.20.5";
  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. // Provide a global list of all seen fields
  50. $scope.fields = fields;
  51. $scope.reset_row();
  52. $scope.ejs = ejsResource(config.elasticsearch);
  53. };
  54. $scope.isPanel = function(obj) {
  55. if(!_.isNull(obj) && !_.isUndefined(obj) && !_.isUndefined(obj.type)) {
  56. return true;
  57. } else {
  58. return false;
  59. }
  60. };
  61. $scope.add_row = function(dash,row) {
  62. dash.rows.push(row);
  63. };
  64. $scope.reset_row = function() {
  65. $scope.row = {
  66. title: '',
  67. height: '150px',
  68. editable: true,
  69. };
  70. };
  71. $scope.row_style = function(row) {
  72. return { 'min-height': row.collapse ? '5px' : row.height };
  73. };
  74. $scope.panel_path =function(type) {
  75. if(type) {
  76. return 'app/panels/'+type.replace(".","/");
  77. } else {
  78. return false;
  79. }
  80. };
  81. $scope.edit_path = function(type) {
  82. var p = $scope.panel_path(type);
  83. if(p) {
  84. return p+'/editor.html';
  85. } else {
  86. return false;
  87. }
  88. };
  89. $scope.setEditorTabs = function(panelMeta) {
  90. $scope.editorTabs = ['General','Panel'];
  91. if(!_.isUndefined(panelMeta.editorTabs)) {
  92. $scope.editorTabs = _.union($scope.editorTabs,_.pluck(panelMeta.editorTabs,'title'));
  93. }
  94. return $scope.editorTabs;
  95. };
  96. // This is whoafully incomplete, but will do for now
  97. $scope.parse_error = function(data) {
  98. var _error = data.match("nested: (.*?);");
  99. return _.isNull(_error) ? data : _error[1];
  100. };
  101. $scope.init();
  102. });
  103. });