Commit 4c948e0b by Rashid Khan

Added loader animation, framework for adjustable interval time stamped indices

parent ffbddb4f
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
z-index: 1000; z-index: 1000;
} }
.panel-loading {
position:absolute;
z-index: 800;
}
.panel i.editlink { .panel i.editlink {
position: absolute; position: absolute;
right: 5px; right: 5px;
......
...@@ -13,7 +13,7 @@ If you need to configure the default dashboard, please see dashboard.js ...@@ -13,7 +13,7 @@ If you need to configure the default dashboard, please see dashboard.js
*/ */
var config = new Settings( var config = new Settings(
{ {
elasticsearch: 'http://localhost:9200', elasticsearch: 'http://demo.logstash.net:9200',
timeformat: 'mm/dd HH:MM:ss', timeformat: 'mm/dd HH:MM:ss',
modules: ['histogram','map','pie','table','stringquery','sort', modules: ['histogram','map','pie','table','stringquery','sort',
'timepicker','text','fields','hits','dashcontrol'], 'timepicker','text','fields','hits','dashcontrol'],
......
...@@ -100,7 +100,7 @@ angular.module('kibana.controllers', []) ...@@ -100,7 +100,7 @@ angular.module('kibana.controllers', [])
row.collapse = row.collapse ? false : true; row.collapse = row.collapse ? false : true;
if (!row.collapse) { if (!row.collapse) {
$timeout(function() { $timeout(function() {
$scope.$broadcast('render') $scope.send_render();
}); });
} }
} }
...@@ -115,6 +115,8 @@ angular.module('kibana.controllers', []) ...@@ -115,6 +115,8 @@ angular.module('kibana.controllers', [])
$scope.reset_panel = function() { $scope.reset_panel = function() {
$scope.panel = { $scope.panel = {
loading: false,
error: false,
span: 3, span: 3,
editable: true, editable: true,
group: ['default'], group: ['default'],
......
...@@ -7,7 +7,7 @@ angular.module('kibana.directives', []) ...@@ -7,7 +7,7 @@ angular.module('kibana.directives', [])
return { return {
restrict: 'E', restrict: 'E',
link: function(scope, elem, attrs) { link: function(scope, elem, attrs) {
var template = '<i class="icon-edit pointer editlink" bs-modal="\'partials/paneleditor.html\'" ng-show="panel.editable != false"></i>'+ var template = '<img src="common/img/load.gif" class="panel-loading" ng-show="panel.loading == true"> <i class="icon-edit pointer editlink" bs-modal="\'partials/paneleditor.html\'" ng-show="panel.editable != false"></i>'+
'<h4>{{panel.title}}</h4>'; '<h4>{{panel.title}}</h4>';
elem.prepend($compile(angular.element(template))(scope)); elem.prepend($compile(angular.element(template))(scope));
} }
......
<div class="row-fluid" ng-controller="hits"> <div class="row-fluid">
<div class="span3"><h6>Popup Position</h6> <div class="span3"><h6>Popup Position</h6>
<select class="input-small" ng-model="panel.micropanel_position" ng-options="f for f in ['top','right','bottom','left']" ng-change="reload_list();"></select></span> <select class="input-small" ng-model="panel.micropanel_position" ng-options="f for f in ['top','right','bottom','left']" ng-change="reload_list();"></select></span>
</div> </div>
......
...@@ -52,7 +52,6 @@ angular.module('kibana.fields', []) ...@@ -52,7 +52,6 @@ angular.module('kibana.fields', [])
$scope.active = _.without($scope.active,field) $scope.active = _.without($scope.active,field)
else else
$scope.active.push(field) $scope.active.push(field)
eventBus.broadcast($scope.$id,$scope.panel.group,"selected_fields",$scope.active) eventBus.broadcast($scope.$id,$scope.panel.group,"selected_fields",$scope.active)
} }
......
...@@ -50,6 +50,7 @@ angular.module('kibana.histogram', []) ...@@ -50,6 +50,7 @@ angular.module('kibana.histogram', [])
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time)) if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return return
$scope.panel.loading = true;
var request = $scope.ejs.Request().indices($scope.panel.index); var request = $scope.ejs.Request().indices($scope.panel.index);
// Build the question part of the query // Build the question part of the query
...@@ -78,6 +79,7 @@ angular.module('kibana.histogram', []) ...@@ -78,6 +79,7 @@ angular.module('kibana.histogram', [])
// Populate scope when we have results // Populate scope when we have results
results.then(function(results) { results.then(function(results) {
$scope.panel.loading = false;
$scope.hits = results.hits.total; $scope.hits = results.hits.total;
$scope.data = []; $scope.data = [];
_.each(results.facets, function(v, k) { _.each(results.facets, function(v, k) {
......
...@@ -24,6 +24,7 @@ angular.module('kibana.hits', []) ...@@ -24,6 +24,7 @@ angular.module('kibana.hits', [])
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time)) if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return return
$scope.panel.loading = true;
var request = $scope.ejs.Request().indices($scope.panel.index); var request = $scope.ejs.Request().indices($scope.panel.index);
var results = request var results = request
...@@ -39,6 +40,7 @@ angular.module('kibana.hits', []) ...@@ -39,6 +40,7 @@ angular.module('kibana.hits', [])
// Populate scope when we have results // Populate scope when we have results
results.then(function(results) { results.then(function(results) {
$scope.panel.loading = false;
if(_.isUndefined(results)) { if(_.isUndefined(results)) {
$scope.panel.error = 'Your query was unsuccessful'; $scope.panel.error = 'Your query was unsuccessful';
return; return;
......
...@@ -27,6 +27,7 @@ angular.module('kibana.map', []) ...@@ -27,6 +27,7 @@ angular.module('kibana.map', [])
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time)) if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return return
$scope.panel.loading = true;
var request = $scope.ejs.Request().indices($scope.panel.index); var request = $scope.ejs.Request().indices($scope.panel.index);
// Then the insert into facet and make the request // Then the insert into facet and make the request
...@@ -46,6 +47,7 @@ angular.module('kibana.map', []) ...@@ -46,6 +47,7 @@ angular.module('kibana.map', [])
// Populate scope when we have results // Populate scope when we have results
results.then(function(results) { results.then(function(results) {
$scope.panel.loading = false;
$scope.hits = results.hits.total; $scope.hits = results.hits.total;
$scope.data = {}; $scope.data = {};
_.each(results.facets.map.terms, function(v) { _.each(results.facets.map.terms, function(v) {
......
...@@ -73,6 +73,7 @@ angular.module('kibana.pie', []) ...@@ -73,6 +73,7 @@ angular.module('kibana.pie', [])
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time)) if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return return
$scope.panel.loading = true;
var request = $scope.ejs.Request().indices($scope.panel.index); var request = $scope.ejs.Request().indices($scope.panel.index);
// If we have an array, use query facet // If we have an array, use query facet
...@@ -101,6 +102,7 @@ angular.module('kibana.pie', []) ...@@ -101,6 +102,7 @@ angular.module('kibana.pie', [])
// Populate scope when we have results // Populate scope when we have results
results.then(function(results) { results.then(function(results) {
$scope.panel.loading = false;
$scope.hits = results.hits.total; $scope.hits = results.hits.total;
$scope.data = []; $scope.data = [];
_.each(results.facets, function(v, k) { _.each(results.facets, function(v, k) {
...@@ -133,6 +135,7 @@ angular.module('kibana.pie', []) ...@@ -133,6 +135,7 @@ angular.module('kibana.pie', [])
// Populate scope when we have results // Populate scope when we have results
results.then(function(results) { results.then(function(results) {
$scope.panel.loading = false;
$scope.hits = results.hits.total; $scope.hits = results.hits.total;
$scope.data = []; $scope.data = [];
var k = 0; var k = 0;
...@@ -159,6 +162,7 @@ angular.module('kibana.pie', []) ...@@ -159,6 +162,7 @@ angular.module('kibana.pie', [])
.size(0) .size(0)
.doSearch(); .doSearch();
results.then(function(results) { results.then(function(results) {
$scope.panel.loading = false;
var complete = results.hits.total; var complete = results.hits.total;
var remaining = $scope.panel.query.goal - complete; var remaining = $scope.panel.query.goal - complete;
$scope.data = [ $scope.data = [
......
...@@ -76,7 +76,8 @@ angular.module('kibana.table', []) ...@@ -76,7 +76,8 @@ angular.module('kibana.table', [])
// Make sure we have everything for the request to complete // Make sure we have everything for the request to complete
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time)) if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return return
$scope.panel.loading = true;
var request = $scope.ejs.Request().indices($scope.panel.index); var request = $scope.ejs.Request().indices($scope.panel.index);
var results = request var results = request
...@@ -94,6 +95,8 @@ angular.module('kibana.table', []) ...@@ -94,6 +95,8 @@ angular.module('kibana.table', [])
// Populate scope when we have results // Populate scope when we have results
results.then(function(results) { results.then(function(results) {
$scope.panel.loading = false;
if(_.isUndefined(results)) { if(_.isUndefined(results)) {
$scope.panel.error = 'Your query was unsuccessful'; $scope.panel.error = 'Your query was unsuccessful';
return; return;
......
...@@ -34,6 +34,8 @@ angular.module('kibana.timepicker', []) ...@@ -34,6 +34,8 @@ angular.module('kibana.timepicker', [])
timefield : '@timestamp', timefield : '@timestamp',
index : '"logstash-"yyyy.mm.dd', index : '"logstash-"yyyy.mm.dd',
defaultindex : "NOINDEX", defaultindex : "NOINDEX",
index_interval: "day",
timed_indices : true,
group : "default", group : "default",
refresh : { refresh : {
enable : false, enable : false,
...@@ -178,11 +180,15 @@ angular.module('kibana.timepicker', []) ...@@ -178,11 +180,15 @@ angular.module('kibana.timepicker', [])
// Get indices for the time period, then broadcast time range and index list // Get indices for the time period, then broadcast time range and index list
// in a single object. Not sure if I like this. // in a single object. Not sure if I like this.
indices($scope.time.from,$scope.time.to).then(function (p) { if($scope.panel.timed_indices) {
$scope.time.index = p.join(); indices($scope.time.from,$scope.time.to).then(function (p) {
// Broadcast time $scope.time.index = p.join();
eventBus.broadcast($scope.$id,$scope.panel.group,'time',$scope.time)
});
} else {
$scope.time.index = $scope.panel.index;
eventBus.broadcast($scope.$id,$scope.panel.group,'time',$scope.time) eventBus.broadcast($scope.$id,$scope.panel.group,'time',$scope.time)
}); }
// Update panel's string representation of the time object // Update panel's string representation of the time object
$scope.panel.time = { $scope.panel.time = {
...@@ -196,7 +202,7 @@ angular.module('kibana.timepicker', []) ...@@ -196,7 +202,7 @@ angular.module('kibana.timepicker', [])
// pattern that exist in a given range // pattern that exist in a given range
function indices(from,to) { function indices(from,to) {
var possible = []; var possible = [];
_.each(date_range(from,to.add_days(1)),function(d){ _.each(expand_range(fake_utc(from),fake_utc(to),$scope.panel.index_interval),function(d){
possible.push(d.format($scope.panel.index)); possible.push(d.format($scope.panel.index));
}); });
...@@ -226,6 +232,46 @@ angular.module('kibana.timepicker', []) ...@@ -226,6 +232,46 @@ angular.module('kibana.timepicker', [])
}); });
} }
// this is stupid, but there is otherwise no good way to ensure that when
// I extract the date from an object that I'm get the UTC date. Stupid js.
// I die a little inside every time I call this function.
function fake_utc(date) {
return new Date(date.getTime() + date.getTimezoneOffset() * 60000);
}
// Create an array of date objects by a given interval
function expand_range(start, end, interval) {
if(_.contains(['hour','day','week','month','year'],interval)) {
var range;
start = start.clone();
range = [];
while (start.isBefore(end)) {
range.push(start.clone());
switch (interval) {
case 'hour':
start.addHours(1)
break
case 'day':
start.addDays(1)
break
case 'week':
start.addWeeks(1)
break
case 'month':
start.addMonths(1)
break
case 'year':
start.addYears(1)
break
}
}
range.push(end.clone());
return range;
} else {
return false;
}
}
// Great, every function is ready, init. // Great, every function is ready, init.
$scope.init(); $scope.init();
......
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