Commit 278c069b by Rashid Khan

Fixed double loading indices issue

parent b96277c0
...@@ -23,7 +23,6 @@ angular.module('kibana.services', []) ...@@ -23,7 +23,6 @@ angular.module('kibana.services', [])
if(_.contains(_types,'$kibana_debug')) if(_.contains(_types,'$kibana_debug'))
$rootScope.$broadcast('$kibana_debug',packet); $rootScope.$broadcast('$kibana_debug',packet);
//console.log('Sent: '+type + ' to ' + to + ' from ' + from + ': ' + angular.toJson(data))
$rootScope.$broadcast(type,{ $rootScope.$broadcast(type,{
from: from, from: from,
to: to, to: to,
...@@ -46,7 +45,6 @@ angular.module('kibana.services', []) ...@@ -46,7 +45,6 @@ angular.module('kibana.services', [])
var _time = packet.time var _time = packet.time
var _group = (!(_.isUndefined(scope.panel))) ? scope.panel.group : ["NONE"] var _group = (!(_.isUndefined(scope.panel))) ? scope.panel.group : ["NONE"]
//console.log('registered:' + type + " for " + scope.panel.title + " " + scope.$id)
if(!(_.isArray(_to))) if(!(_.isArray(_to)))
_to = [_to]; _to = [_to];
if(!(_.isArray(_group))) if(!(_.isArray(_group)))
...@@ -61,7 +59,6 @@ angular.module('kibana.services', []) ...@@ -61,7 +59,6 @@ angular.module('kibana.services', [])
_.indexOf(_to,'ALL') > -1) && _.indexOf(_to,'ALL') > -1) &&
_from !== _id _from !== _id
) { ) {
//console.log('Got: '+type + ' from ' + _from + ' to ' + _to + ': ' + angular.toJson(packet.data))
fn(event,packet.data,{time:_time,to:_to,from:_from,type:_type}); fn(event,packet.data,{time:_time,to:_to,from:_from,type:_type});
} }
}); });
...@@ -208,13 +205,15 @@ angular.module('kibana.services', []) ...@@ -208,13 +205,15 @@ angular.module('kibana.services', [])
"#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7" //7 "#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7" //7
]; ];
// Save a reference to this
this.list = dashboard.current.services.query.list;
this.ids = dashboard.current.services.query.ids;
// Save a reference to this
var self = this; var self = this;
var init = function() { this.init = function() {
_q = dashboard.current.services.query;
self.list = dashboard.current.services.query.list;
self.ids = dashboard.current.services.query.ids;
if (self.ids.length == 0) { if (self.ids.length == 0) {
self.set({}); self.set({});
} }
...@@ -273,7 +272,7 @@ angular.module('kibana.services', []) ...@@ -273,7 +272,7 @@ angular.module('kibana.services', [])
return self.colors[id % self.colors.length] return self.colors[id % self.colors.length]
} }
init(); self.init();
}) })
.service('filterSrv', function(dashboard, ejsResource) { .service('filterSrv', function(dashboard, ejsResource) {
...@@ -292,9 +291,19 @@ angular.module('kibana.services', []) ...@@ -292,9 +291,19 @@ angular.module('kibana.services', [])
// Save a reference to this // Save a reference to this
var self = this; var self = this;
// Accessors // Call this whenever we need to reload the important stuff
this.list = dashboard.current.services.filter.list; this.init = function() {
this.ids = dashboard.current.services.filter.ids; // Accessors
self.list = dashboard.current.services.filter.list;
self.ids = dashboard.current.services.filter.ids;
_f = dashboard.current.services.filter;
_.each(self.getByType('time',true),function(time) {
self.list[time.id].from = new Date(time.from)
self.list[time.id].to = new Date(time.to)
})
}
// This is used both for adding filters and modifying them. // This is used both for adding filters and modifying them.
// If an id is passed, the filter at that id is updated // If an id is passed, the filter at that id is updated
...@@ -396,7 +405,8 @@ angular.module('kibana.services', []) ...@@ -396,7 +405,8 @@ angular.module('kibana.services', [])
} }
this.idsByType = function(type,inactive) { this.idsByType = function(type,inactive) {
return _.pluck(_.where(self.list,{type:type,active:(inactive ? false:true)}),'id') var _require = inactive ? {type:type} : {type:type,active:true}
return _.pluck(_.where(self.list,_require),'id')
} }
// This special function looks for all time filters, and returns a time range according to the mode // This special function looks for all time filters, and returns a time range according to the mode
...@@ -446,6 +456,9 @@ angular.module('kibana.services', []) ...@@ -446,6 +456,9 @@ angular.module('kibana.services', [])
} }
} }
// Now init
self.init();
}) })
.service('dashboard', function($routeParams, $http, $rootScope, $injector, ejsResource, timer, kbnIndex) { .service('dashboard', function($routeParams, $http, $rootScope, $injector, ejsResource, timer, kbnIndex) {
// A hash of defaults to use when loading a dashboard // A hash of defaults to use when loading a dashboard
...@@ -466,16 +479,17 @@ angular.module('kibana.services', []) ...@@ -466,16 +479,17 @@ angular.module('kibana.services', [])
var ejs = ejsResource(config.elasticsearch); var ejs = ejsResource(config.elasticsearch);
var gist_pattern = /(^\d{5,}$)|(^[a-z0-9]{10,}$)|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/; var gist_pattern = /(^\d{5,}$)|(^[a-z0-9]{10,}$)|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/;
// Empty dashboard object
this.current = {};
this.last = {};
this.indices = [];
// Store a reference to this // Store a reference to this
var self = this; var self = this;
var filterSrv,query; var filterSrv,query;
this.current = {};
this.last = {};
$rootScope.$on('$routeChangeSuccess',function(){ $rootScope.$on('$routeChangeSuccess',function(){
// Clear the current dashboard to prevent reloading
self.current = {};
self.indices = [];
route(); route();
}) })
...@@ -538,19 +552,26 @@ angular.module('kibana.services', []) ...@@ -538,19 +552,26 @@ angular.module('kibana.services', [])
} }
this.dash_load = function(dashboard) { this.dash_load = function(dashboard) {
// Cancel all timers
timer.cancel_all(); timer.cancel_all();
// If not using time based indices, use the default index
if(dashboard.index.interval === 'none') { if(dashboard.index.interval === 'none') {
self.indices = [dashboard.index.default] self.indices = [dashboard.index.default]
} }
self.current = dashboard; self.current = _.clone(dashboard);
// Ok, now that we've setup the current dashboard, we can inject our services // Ok, now that we've setup the current dashboard, we can inject our services
query = $injector.get('query'); query = $injector.get('query');
filterSrv = $injector.get('filterSrv') filterSrv = $injector.get('filterSrv')
// Make sure these re-init
query.init();
filterSrv.init();
if(dashboard.index.interval !== 'none' && filterSrv.idsByType('time').length == 0) { if(dashboard.index.interval !== 'none' && filterSrv.idsByType('time').length == 0) {
//if(dashboard.index.interval !== 'none') {
self.refresh(); self.refresh();
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
*/ */
angular.module('kibana.dashcontrol', []) angular.module('kibana.dashcontrol', [])
.controller('dashcontrol', function($scope, $routeParams, $http, timer, dashboard) { .controller('dashcontrol', function($scope, $http, timer, dashboard) {
$scope.panel = $scope.panel || {}; $scope.panel = $scope.panel || {};
// Set and populate defaults // Set and populate defaults
......
...@@ -49,7 +49,7 @@ angular.module('kibana.histogram', []) ...@@ -49,7 +49,7 @@ angular.module('kibana.histogram', [])
auto_int : true, auto_int : true,
resolution : 100, resolution : 100,
interval : '5m', interval : '5m',
fill : 3, fill : 0,
linewidth : 3, linewidth : 3,
timezone : 'browser', // browser, utc or a standard timezone timezone : 'browser', // browser, utc or a standard timezone
spyable : true, spyable : true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment