diff --git a/src/app/app.js b/src/app/app.js index 132e7f2b994..41905a92955 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -12,9 +12,10 @@ define([ 'angular-strap', 'angular-dragdrop', 'extend-jquery', - 'bindonce' + 'bindonce', ], function (angular, $, _, appLevelRequire) { + "use strict"; var app = angular.module('kibana', []), @@ -25,6 +26,11 @@ function (angular, $, _, appLevelRequire) { // features if we define them after boot time register_fns = {}; + app.constant('version',"3.0.0pre5"); + + // Use this for cache busting partials + app.constant('cacheBust',"cache-bust="+Date.now()); + /** * Tells the application to watch the module, once bootstraping has completed * the modules controller, service, etc. functions will be overwritten to register directly @@ -59,6 +65,7 @@ function (angular, $, _, appLevelRequire) { }; app.config(function ($routeProvider, $controllerProvider, $compileProvider, $filterProvider, $provide) { + $routeProvider .when('/dashboard', { templateUrl: 'app/partials/dashboard.html', @@ -72,6 +79,7 @@ function (angular, $, _, appLevelRequire) { .otherwise({ redirectTo: 'dashboard' }); + // this is how the internet told me to dynamically add modules :/ register_fns.controller = $controllerProvider.register; register_fns.directive = $compileProvider.directive; diff --git a/src/app/components/require.config.js b/src/app/components/require.config.js index 13ab51de567..966ee7f8c01 100644 --- a/src/app/components/require.config.js +++ b/src/app/components/require.config.js @@ -58,7 +58,7 @@ require.config({ }, angular: { - deps: ['jquery'], + deps: ['jquery','config'], exports: 'angular' }, @@ -75,6 +75,7 @@ require.config({ }, // simple dependency declaration + // 'jquery-ui': ['jquery'], 'jquery.flot': ['jquery'], 'jquery.flot.byte': ['jquery', 'jquery.flot'], diff --git a/src/app/components/settings.js b/src/app/components/settings.js index ba787cb7bda..b283dd16aeb 100644 --- a/src/app/components/settings.js +++ b/src/app/components/settings.js @@ -10,10 +10,11 @@ function (_) { * @type {Object} */ var defaults = { - elasticsearch : "http://"+window.location.hostname+":9200", - panel_names : [], - kibana_index : 'kibana-int', - graphiteUrl : null, + elasticsearch : "http://"+window.location.hostname+":9200", + panel_names : [], + kibana_index : 'kibana-int', + graphiteUrl : null, + default_route : '/dashboard/file/default.json' }; // This initializes a new hash on purpose, to avoid adding parameters to diff --git a/src/app/controllers/dash.js b/src/app/controllers/dash.js index 627d2b989d5..3ce25543330 100644 --- a/src/app/controllers/dash.js +++ b/src/app/controllers/dash.js @@ -31,7 +31,7 @@ function (angular, config, _) { module.controller('DashCtrl', function( $scope, $rootScope, $route, ejsResource, fields, dashboard, alertSrv, panelMove, esVersion) { - $scope.requiredElasticSearchVersion = ">=0.20.5"; + $scope.requiredElasticSearchVersion = ">=0.90.3"; $scope.editor = { index: 0 diff --git a/src/app/controllers/dashLoader.js b/src/app/controllers/dashLoader.js index 210b4ae9e98..fbecc69ce72 100644 --- a/src/app/controllers/dashLoader.js +++ b/src/app/controllers/dashLoader.js @@ -7,7 +7,7 @@ function (angular, _) { var module = angular.module('kibana.controllers'); - module.controller('dashLoader', function($scope, $http, timer, dashboard, alertSrv) { + module.controller('dashLoader', function($scope, $http, timer, dashboard, alertSrv, $location) { $scope.loader = dashboard.current.loader; $scope.init = function() { @@ -35,8 +35,8 @@ function (angular, _) { }; $scope.set_default = function() { - if(dashboard.set_default()) { - alertSrv.set('Local Default Set',dashboard.current.title+' has been set as your local default','success',5000); + if(dashboard.set_default($location.path())) { + alertSrv.set('Home Set','This page has been set as your default Kibana dashboard','success',5000); } else { alertSrv.set('Incompatible Browser','Sorry, your browser is too old for this feature','error',5000); } @@ -44,7 +44,8 @@ function (angular, _) { $scope.purge_default = function() { if(dashboard.purge_default()) { - alertSrv.set('Local Default Clear','Your local default dashboard has been cleared','success',5000); + alertSrv.set('Local Default Clear','Your Kibana default dashboard has been reset to the default', + 'success',5000); } else { alertSrv.set('Incompatible Browser','Sorry, your browser is too old for this feature','error',5000); } diff --git a/src/app/directives/kibanaPanel.js b/src/app/directives/kibanaPanel.js index 1a2f00b1982..6c5efef6295 100644 --- a/src/app/directives/kibanaPanel.js +++ b/src/app/directives/kibanaPanel.js @@ -77,7 +77,8 @@ function (angular) { var nameAsPath = name.replace(".", "/"); $scope.require([ 'jquery', - 'text!panels/'+nameAsPath+'/module.html' + 'text!panels/'+nameAsPath+'/module.html', + 'text!panels/'+nameAsPath+'/editor.html' ], function ($, moduleTemplate) { var $module = $(moduleTemplate); // top level controllers diff --git a/src/app/panels/histogram/module.html b/src/app/panels/histogram/module.html index 20ca4732d93..f52b408e4cb 100644 --- a/src/app/panels/histogram/module.html +++ b/src/app/panels/histogram/module.html @@ -43,11 +43,11 @@ Zoom Out |  - - + + - {{series.info.alias || series.info.query}} - {{series.info.alias}} + {{series.alias || series.query}} + {{series.alias}} ({{series.hits}}) diff --git a/src/app/panels/histogram/module.js b/src/app/panels/histogram/module.js index b2876d5bf13..641f85fb68c 100644 --- a/src/app/panels/histogram/module.js +++ b/src/app/panels/histogram/module.js @@ -242,9 +242,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { $scope.init = function() { // Hide view options by default $scope.options = false; - $scope.$on('refresh',function(){ - $scope.get_data(); - }); // Always show the query if an alias isn't set. Users can set an alias if the query is too // long @@ -303,7 +300,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { * @param {number} query_id The id of the query, generated on the first run and passed back when * this call is made recursively for more segments */ - $scope.get_data = function(segment, query_id) { + $scope.get_data = function(data, segment, query_id) { var _range, _interval, @@ -380,12 +377,12 @@ function (angular, app, $, _, kbn, moment, timeSeries) { results = request.doSearch(); // Populate scope when we have results - results.then(function(results) { - + return results.then(function(results) { $scope.panelMeta.loading = false; if(segment === 0) { + $scope.legend = []; $scope.hits = 0; - $scope.data = []; + data = []; $scope.annotations = []; query_id = $scope.query_id = new Date().getTime(); } @@ -407,7 +404,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { var query_results = results.facets[q.id]; // we need to initialize the data variable on the first run, // and when we are working on the first segment of the data. - if(_.isUndefined($scope.data[i]) || segment === 0) { + if(_.isUndefined(data[i]) || segment === 0) { var tsOpts = { interval: _interval, start_date: _range && _range.from, @@ -417,8 +414,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) { time_series = new timeSeries.ZeroFilled(tsOpts); hits = 0; } else { - time_series = $scope.data[i].time_series; - hits = $scope.data[i].hits; + time_series = data[i].time_series; + hits = data[i].hits; } // push each entry into the time series, while incrementing counters @@ -427,7 +424,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) { hits += entry.count; // The series level hits counter $scope.hits += entry.count; // Entire dataset level hits counter }); - $scope.data[i] = { + + $scope.legend[i] = q; + + data[i] = { info: q, time_series: time_series, hits: hits @@ -462,11 +462,11 @@ function (angular, app, $, _, kbn, moment, timeSeries) { } // Tell the histogram directive to render. - $scope.$emit('render'); + $scope.$emit('render', data); // If we still have segments left, get them if(segment < dashboard.indices.length-1) { - $scope.get_data(segment+1,query_id); + $scope.get_data(data,segment+1,query_id); } } }); @@ -528,15 +528,21 @@ function (angular, app, $, _, kbn, moment, timeSeries) { restrict: 'A', template: '
', link: function(scope, elem) { + var data; + + scope.$on('refresh',function(){ + scope.get_data(); + }); // Receive render events - scope.$on('render',function(){ - render_panel(); + scope.$on('render',function(event,d){ + data = d || data; + render_panel(data); }); // Re-render if the window is resized angular.element(window).bind('resize', function(){ - render_panel(); + render_panel(data); }); var scale = function(series,factor) { @@ -564,13 +570,13 @@ function (angular, app, $, _, kbn, moment, timeSeries) { }; // Function for rendering panel - function render_panel() { + function render_panel(data) { // IE doesn't work without this elem.css({height:scope.panel.height || scope.row.height}); // Populate from the query service try { - _.each(scope.data, function(series) { + _.each(data, function(series) { series.label = series.info.alias; series.color = series.info.color; }); @@ -669,8 +675,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) { // when rendering stacked bars, we need to ensure each point that has data is zero-filled // so that the stacking happens in the proper order var required_times = []; - if (scope.data.length > 1) { - required_times = Array.prototype.concat.apply([], _.map(scope.data, function (query) { + if (data.length > 1) { + required_times = Array.prototype.concat.apply([], _.map(data, function (query) { return query.time_series.getOrderedTimes(); })); required_times = _.uniq(required_times.sort(function (a, b) { @@ -680,8 +686,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) { } - for (var i = 0; i < scope.data.length; i++) { - var _d = scope.data[i].time_series.getFlotPairs(required_times); + for (var i = 0; i < data.length; i++) { + var _d = data[i].time_series.getFlotPairs(required_times); if(scope.panel.derivative) { _d = derivative(_d); } @@ -691,10 +697,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) { if(scope.panel.scaleSeconds) { _d = scaleSeconds(_d,scope.panel.interval); } - scope.data[i].data = _d; + data[i].data = _d; } - scope.plot = $.plot(elem, scope.data, options); + scope.plot = $.plot(elem, data, options); } catch(e) { // Nothing to do here diff --git a/src/app/partials/dashLoader.html b/src/app/partials/dashLoader.html index 5e450963329..27c43b37c74 100644 --- a/src/app/partials/dashLoader.html +++ b/src/app/partials/dashLoader.html @@ -14,15 +14,15 @@