Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from spenceralger/TimefilterAutoRefresh
Browse files Browse the repository at this point in the history
Timefilter auto refresh
  • Loading branch information
grouma committed Dec 20, 2014
2 parents 591a3a3 + fd7f75c commit e432638
Show file tree
Hide file tree
Showing 29 changed files with 414 additions and 320 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"angular-ui-select": "~0.9.3",
"async": "~0.2.10",
"bluebird": "~2.1.3",
"bootstrap": "~3.1.1",
"bootstrap": "~3.3.1",
"d3": "~3.4.8",
"elasticsearch": "elasticsearch/bower-elasticsearch-js#prerelease",
"Faker": "~1.1.0",
Expand Down
8 changes: 6 additions & 2 deletions src/kibana/components/agg_table/agg_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
per-page="perPage">

<div class="agg-table-controls">
<a class="small" ng-click="aggTable.exportAsCsv()">
Export <i class="fa fa-download"></i>
<small>Export:</small>&nbsp;&nbsp;
<a class="small" ng-click="aggTable.exportAsCsv(false)">
Raw <i class="fa fa-download"></i>
</a>&nbsp;&nbsp;&nbsp;
<a class="small" ng-click="aggTable.exportAsCsv(true)">
Formatted <i class="fa fa-download"></i>
</a>
<paginate-controls></paginate-controls>
</div>
Expand Down
11 changes: 5 additions & 6 deletions src/kibana/components/agg_table/agg_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ define(function (require) {
quoteValues: config.get('csv:quoteValues')
};

self.exportAsCsv = function () {
var csv = new Blob([self.toCsv()], { type: 'text/plain' });
self.exportAsCsv = function (formatted) {
var csv = new Blob([self.toCsv(formatted)], { type: 'text/plain' });
self._saveAs(csv, self.csv.filename);
};


self.toCsv = function () {
var rows = $scope.table.rows;
var columns = $scope.table.columns;
self.toCsv = function (formatted) {
var rows = formatted ? $scope.formattedRows : $scope.table.rows;
var columns = formatted ? $scope.formattedColumns : $scope.table.columns;
var nonAlphaNumRE = /[^a-zA-Z0-9]/;
var allDoubleQuoteRE = /"/g;

Expand Down
13 changes: 7 additions & 6 deletions src/kibana/components/courier/courier.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ define(function (require) {
require('components/index_patterns/index_patterns');

require('modules').get('kibana/courier')
.service('courier', function ($rootScope, Private, Promise, indexPatterns) {
.service('courier', function ($rootScope, Private, Promise, indexPatterns, Notifier) {
function Courier() {
var self = this;

Expand All @@ -32,7 +32,6 @@ define(function (require) {
self.SearchSource = SearchSource;

var HastyRefresh = errors.HastyRefresh;
var Abort = errors.Abort;

/**
* update the time between automatic search requests
Expand All @@ -50,6 +49,7 @@ define(function (require) {
*/
self.start = function () {
searchLooper.start();
docLooper.start();
return this;
};

Expand Down Expand Up @@ -108,10 +108,7 @@ define(function (require) {
searchLooper.stop();
docLooper.stop();

[].concat(requestQueue.splice(0), errorHandlers.splice(0))
.forEach(function (req) {
req.defer.reject(new Abort());
});
_.invoke(requestQueue, 'abort');

if (requestQueue.length) {
throw new Error('Aborting all pending requests failed.');
Expand All @@ -128,6 +125,10 @@ define(function (require) {
self.fetchInterval(0);
}
});

var onFatalDefer = Promise.defer();
onFatalDefer.promise.then(self.close);
Notifier.fatalCallbacks.push(onFatalDefer.resolve);
}

return new Courier();
Expand Down
1 change: 1 addition & 0 deletions src/kibana/components/courier/fetch/_call_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ define(function (require) {

return (esPromise = es[strategy.clientMethod]({
timeout: configFile.shard_timeout,
ignore_unavailable: true,
preference: sessionId,
body: body
}));
Expand Down
24 changes: 15 additions & 9 deletions src/kibana/components/courier/fetch/_call_response_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,21 @@ define(function (require) {
notify.warning(new SearchTimeout());
}

function progress() {
if (req.isIncomplete()) {
return INCOMPLETE;
}

req.complete();
return resp;
}

if (resp.error) {
return req.handleFailure(new RequestFailure(null, resp));
if (req.filterError(resp)) {
return progress();
} else {
return req.handleFailure(new RequestFailure(null, resp));
}
}

return Promise.try(function () {
Expand All @@ -30,14 +43,7 @@ define(function (require) {
resp = arguments[0];
return req.handleResponse(resp);
})
.then(function () {
if (req.isIncomplete()) {
return INCOMPLETE;
}

req.complete();
return resp;
});
.then(progress);
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/kibana/components/courier/fetch/request/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ define(function (require) {
return function DocRequestProvider(Private) {
var _ = require('lodash');

var strategy = Private(require('components/courier/fetch/strategy/doc'));
var docStrategy = Private(require('components/courier/fetch/strategy/doc'));
var AbstractRequest = Private(require('components/courier/fetch/request/request'));

_(DocRequest).inherits(AbstractRequest);
function DocRequest(source, defer) {
DocRequest.Super.call(this, source, defer);
}

DocRequest.prototype.type = 'doc';
DocRequest.prototype.strategy = strategy;
this.type = 'doc';
this.strategy = docStrategy;
}

DocRequest.prototype.canStart = function () {
var parent = DocRequest.Super.prototype.canStart.call(this);
Expand Down
4 changes: 4 additions & 0 deletions src/kibana/components/courier/fetch/request/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ define(function (require) {
return resp;
};

AbstractReq.prototype.filterError = function (resp) {
return false;
};

AbstractReq.prototype.handleResponse = function (resp) {
this.success = true;
this.resp = resp;
Expand Down
35 changes: 21 additions & 14 deletions src/kibana/components/courier/fetch/request/segmented.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ define(function (require) {
this._remainingSize = false;
this._direction = 'desc';
this._handle = new SegmentedHandle(this);
// prevent the source from changing between requests
this._getFlattenedSource = _.once(this._getFlattenedSource);

// give the request consumer a chance to receive each segment and set
// parameters via the handle
if (_.isFunction(initFn)) initFn(this._handle);
}

/*********
** SearchReq overrides
*********/

SegmentedReq.prototype.start = function () {
this._createQueue();
this._all = this._queue.slice(0);
this._complete = [];
Expand All @@ -41,20 +49,9 @@ define(function (require) {
}
};

// prevent the source from changing between requests
this._getFlattenedSource = _.once(this._getFlattenedSource);

// send out the initial status
// Send the initial fetch status
this._reportStatus();
}

/*********
** SearchReq overrides
*********/

SegmentedReq.prototype.start = function () {
// update the status on every iteration
this._reportStatus();
return SearchReq.prototype.start.call(this);
};

Expand Down Expand Up @@ -84,6 +81,13 @@ define(function (require) {
return this._consumeSegment(resp);
};

SegmentedReq.prototype.filterError = function (resp) {
if (/ClusterBlockException.*index\sclosed/.test(resp.error)) {
this._consumeSegment(false);
return true;
}
};

SegmentedReq.prototype.isIncomplete = function () {
return this._queue.length > 0;
};
Expand Down Expand Up @@ -136,13 +140,16 @@ define(function (require) {
};

SegmentedReq.prototype._consumeSegment = function (seg) {
this._segments.push(seg);

var index = this._active;
var first = this._segments.length === 1;
var first = this._segments.length === 0;

this._complete.push(index);

if (!seg) return; // segment was ignored/filtered, don't store it

this._segments.push(seg);

if (this._remainingSize !== false) {
this._remainingSize -= seg.hits.hits.length;
}
Expand Down
3 changes: 3 additions & 0 deletions src/kibana/components/courier/looper/_looper.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ define(function (require) {
*/
looper.ms = function (ms) {
_ms = ms;

if (!_started) return;

if (_ms) {
looper.restart();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/kibana/components/courier/looper/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define(function (require) {
*/
var docLooper = new Looper(1500, function () {
fetch.docs();
}).start();
});

return docLooper;
};
Expand Down
2 changes: 1 addition & 1 deletion src/kibana/components/index_patterns/_get_ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define(function (require) {
fields: [],
body: {
query: { match_all: {} },
size: 10000
size: 2147483647
}
})
.then(function (resp) {
Expand Down
9 changes: 1 addition & 8 deletions src/kibana/components/notify/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,9 @@ define(function (require) {
return Notifier;
});

module.run(function ($timeout, Promise, courier) {
module.run(function ($timeout) {
// provide alternate methods for setting timeouts, which will properly trigger digest cycles
Notifier.setTimerFns($timeout, $timeout.cancel);

var onFatalDefer = Promise.defer();
onFatalDefer.promise.then(function () {
courier.close();
});

Notifier.fatalCallbacks.push(onFatalDefer.resolve);
});

/**
Expand Down
3 changes: 2 additions & 1 deletion src/kibana/components/vis/_agg_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ define(function (require) {
* @return {object} the new params object
*/
AggConfig.prototype.resetParams = function () {
return this.fillDefaults({});
// We need to ensure that row doesn't get overriden.
return this.fillDefaults(_.pick(this.params, 'row'));
};

AggConfig.prototype.write = function () {
Expand Down
2 changes: 1 addition & 1 deletion src/kibana/plugins/dashboard/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div dashboard-app class="app-container dashboard-container">
<nav ng-show="!appEmbedded" class="navbar navbar-default navbar-static-top">
<navbar>
<span class="name" ng-if="dash.id" bindonce bo-bind="dash.title"></span>
<span class="name" ng-if="dash.id" bindonce bo-bind="dash.title" tooltip="{{dash.title}}"></span>

<form name="queryInput"
class="fill inline-form"
Expand Down
14 changes: 4 additions & 10 deletions src/kibana/plugins/discover/directives/table_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@ define(function (require) {
if (!sortableField(column)) return;

var sorting = $scope.sorting;
var defaultClass = ['fa', 'fa-sort', 'table-header-sortchange'];
var defaultClass = ['fa', 'fa-sort-up', 'table-header-sortchange'];

if (!sorting) return defaultClass;

if (column === sorting[0]) {
return ['fa', sorting[1] === 'asc' ? 'fa-sort-up' : 'fa-sort-down'];
} else {
return defaultClass;
}
if (!sorting || column !== sorting[0]) return defaultClass;
return ['fa', sorting[1] === 'asc' ? 'fa-sort-up' : 'fa-sort-down'];
};

$scope.moveLeft = function (column) {
Expand All @@ -53,9 +48,8 @@ define(function (require) {
if (!sortableField(column)) return;

var sorting = $scope.sorting || [];
$scope.sorting = [column, sorting[1] === 'asc' ? 'desc' : 'asc'];
$scope.sorting = [column, (sorting[0] === column && sorting[1] === 'asc') ? 'desc' : 'asc'];
};

}
};
});
Expand Down
Loading

0 comments on commit e432638

Please sign in to comment.