From 199a9e52fc0ccaabee5e4204d18509ce4e77a015 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Tue, 2 Jun 2015 17:31:51 -0700 Subject: [PATCH 01/14] [discover] respect the sample size settings when not sorting --- .../fetch/request/_segmented_handle.js | 22 ++----- .../courier/fetch/request/segmented.js | 64 +++++++++++-------- .../plugins/discover/controllers/discover.js | 1 + 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/src/kibana/components/courier/fetch/request/_segmented_handle.js b/src/kibana/components/courier/fetch/request/_segmented_handle.js index 3af37cba8e088..58d407f8bd026 100644 --- a/src/kibana/components/courier/fetch/request/_segmented_handle.js +++ b/src/kibana/components/courier/fetch/request/_segmented_handle.js @@ -17,24 +17,12 @@ define(function (require) { _(SegmentedHandle).inherits(Events); function SegmentedHandle(req) { SegmentedHandle.Super.call(this); - this._req = req; - } - /** - * Set the sort direction for the request. - * - * @param {string} dir - one of 'asc' or 'desc' - */ - SegmentedHandle.prototype.setDirection = function (dir) { - switch (dir) { - case 'asc': - case 'desc': - return (this._req._direction = dir); - default: - throw new TypeError('unkown sort direction "' + dir + '"'); - } - }; + // export a couple methods from the request + this.setDirection = _.bindKey(req, 'setDirection'); + this.setSize = _.bindKey(req, 'setSize'); + } return SegmentedHandle; }; -}); \ No newline at end of file +}); diff --git a/src/kibana/components/courier/fetch/request/segmented.js b/src/kibana/components/courier/fetch/request/segmented.js index 540e26bd12c33..9377c98e527f4 100644 --- a/src/kibana/components/courier/fetch/request/segmented.js +++ b/src/kibana/components/courier/fetch/request/segmented.js @@ -17,8 +17,8 @@ define(function (require) { // segmented request specific state this._initFn = initFn; - this._totalSize = false; - this._remainingSize = false; + this._desiredSize = false; + this._hitsReceived = 0; this._direction = 'desc'; this._handle = new SegmentedHandle(this); @@ -70,15 +70,8 @@ define(function (require) { var index = self._active = self._queue.shift(); params.index = index; - - // Only subtract from remaining size if dealing with the indexPattern's timefield - var timefield = self.source.get('index').timeFieldName; - if (_.keys(params.body.sort)[0] !== timefield) { - self._remainingSize = false; - } - - if (self._remainingSize !== false) { - params.body.size = self._remainingSize; + if (self._desiredSize !== false) { + params.body.size = Math.max(self._desiredSize - self._hitsReceived, 0); } return params; @@ -115,6 +108,35 @@ define(function (require) { ** SegmentedReq specific methods *********/ + /** + * Set the sort direction for the request. + * + * @param {string} dir - one of 'asc' or 'desc' + */ + SegmentedReq.prototype.setDirection = function (dir) { + switch (dir) { + case 'asc': + case 'desc': + return (this._direction = dir); + default: + throw new TypeError('unkown sort direction "' + dir + '"'); + } + }; + + /** + * Set the sort total number of documents to + * emit + * + * Setting to false will not limit the documents, + * if a number is set the size of the request to es + * will be updated on each new request + * + * @param {number|false} + */ + SegmentedReq.prototype.setSize = function (totalSize) { + this._desiredSize = _.parseInt(totalSize) || false; + }; + SegmentedReq.prototype._createQueue = function () { var timeBounds = timefilter.getBounds(); var indexPattern = this.source.get('index'); @@ -135,18 +157,9 @@ define(function (require) { hitCount: this._mergedResp.hits.hits.length }); }; - SegmentedReq.prototype._getFlattenedSource = function () { - var self = this; - - return self.source._flatten() - .then(function (flatSource) { - var size = _.parseInt(_.deepGet(flatSource, 'body.size')); - if (_.isNumber(size)) { - self._totalSize = self._remainingSize = size; - } - return flatSource; - }); + SegmentedReq.prototype._getFlattenedSource = function () { + return this.source._flatten(); }; SegmentedReq.prototype._consumeSegment = function (seg) { @@ -161,10 +174,7 @@ define(function (require) { this._mergeSegment(seg); this.resp = _.omit(this._mergedResp, '_bucketIndex'); - - if (this._remainingSize !== false) { - this._remainingSize -= seg.hits.hits.length; - } + this._hitsReceived += seg.hits.hits.length; if (firstHits) this._handle.emit('first', seg); if (gotHits) this._handle.emit('segment', seg); @@ -212,4 +222,4 @@ define(function (require) { return SegmentedReq; }; -}); \ No newline at end of file +}); diff --git a/src/kibana/plugins/discover/controllers/discover.js b/src/kibana/plugins/discover/controllers/discover.js index e02a8d9cac915..cf9c510a6f1d1 100644 --- a/src/kibana/plugins/discover/controllers/discover.js +++ b/src/kibana/plugins/discover/controllers/discover.js @@ -333,6 +333,7 @@ define(function (require) { $scope.updateTime(); segmented.setDirection(sortBy === 'time' ? (sort[1] || 'desc') : 'desc'); + segmented.setSize(sortBy === 'time' ? $scope.opts.sampleSize : false); // triggered when the status updated segmented.on('status', function (status) { From fa65695241dc5bdc99b6436e62d5d8b604462a6f Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Wed, 3 Jun 2015 13:48:52 -0400 Subject: [PATCH 02/14] Closes #3965. Throw an error to canvas when wiggle is selected when not using time or a linear scale --- src/kibana/components/errors.js | 8 ++++++++ src/kibana/components/vislib/vis.js | 1 + src/kibana/components/vislib/visualizations/area_chart.js | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/src/kibana/components/errors.js b/src/kibana/components/errors.js index e69cb7e93cabf..524d470cfffaa 100644 --- a/src/kibana/components/errors.js +++ b/src/kibana/components/errors.js @@ -257,5 +257,13 @@ define(function (require) { }; inherits(errors.InvalidLogScaleValues, KbnError); + /** error thrown when wiggle chart is selected for non linear data */ + errors.InvalidWiggleSelection = function InvalidWiggleSelection() { + KbnError.call(this, + 'The wiggle option can only be used with the Date Histogram or Histogram aggregation.', + errors.InvalidWiggleSelection); + }; + inherits(errors.InvalidWiggleSelection, KbnError); + return errors; }); diff --git a/src/kibana/components/vislib/vis.js b/src/kibana/components/vislib/vis.js index 0fecf0ac7b282..dc3aaea11c63a 100644 --- a/src/kibana/components/vislib/vis.js +++ b/src/kibana/components/vislib/vis.js @@ -82,6 +82,7 @@ define(function (require) { // Because we have to wait for the DOM element to initialize, we do not // want to throw an error when the DOM `el` is zero if (error instanceof errors.ContainerTooSmall || + error instanceof errors.InvalidWiggleSelection || error instanceof errors.InvalidLogScaleValues || error instanceof errors.PieContainsAllZeros || error instanceof errors.NotEnoughData || diff --git a/src/kibana/components/vislib/visualizations/area_chart.js b/src/kibana/components/vislib/visualizations/area_chart.js index 722be6b6fc7fd..8fbab7df26c4c 100644 --- a/src/kibana/components/vislib/visualizations/area_chart.js +++ b/src/kibana/components/vislib/visualizations/area_chart.js @@ -249,6 +249,13 @@ define(function (require) { } }; + AreaChart.prototype.validateWiggleSelection = function () { + var isWiggle = this._attr.mode === 'wiggle'; + var ordered = this.handler.data.get('ordered'); + + if (isWiggle && !ordered) throw new errors.InvalidWiggleSelection(); + }; + /** * Renders d3 visualization * @@ -294,6 +301,7 @@ define(function (require) { if (width < minWidth || height < minHeight) { throw new errors.ContainerTooSmall(); } + self.validateWiggleSelection(); // Select the current DOM element div = d3.select(this); From 4ddcc4f20a34c8799cd6aaaee7d889be7c26006f Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Wed, 3 Jun 2015 16:02:43 -0400 Subject: [PATCH 03/14] updating error message --- src/kibana/components/errors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kibana/components/errors.js b/src/kibana/components/errors.js index 524d470cfffaa..6cec8bf1af74f 100644 --- a/src/kibana/components/errors.js +++ b/src/kibana/components/errors.js @@ -260,7 +260,7 @@ define(function (require) { /** error thrown when wiggle chart is selected for non linear data */ errors.InvalidWiggleSelection = function InvalidWiggleSelection() { KbnError.call(this, - 'The wiggle option can only be used with the Date Histogram or Histogram aggregation.', + 'In wiggle mode the area chart requires ordered values on the x-axis. Try using a Histogram or Date Histogram aggregation.', errors.InvalidWiggleSelection); }; inherits(errors.InvalidWiggleSelection, KbnError); From 9ccfa1c3aae53f03fb33f21345937a99f4ac7d62 Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Wed, 3 Jun 2015 14:05:18 -0700 Subject: [PATCH 04/14] Closes #4096 - Swap this.innerText to $(this).text() --- test/unit/specs/components/paginated_table/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/specs/components/paginated_table/index.js b/test/unit/specs/components/paginated_table/index.js index 5d6fb6c4fe2e3..45fd90472b19d 100644 --- a/test/unit/specs/components/paginated_table/index.js +++ b/test/unit/specs/components/paginated_table/index.js @@ -1,6 +1,7 @@ define(function (require) { require('components/paginated_table/paginated_table'); var _ = require('lodash'); + var $ = require('jquery'); var sinon = require('sinon/sinon'); describe('paginated table', function () { @@ -240,7 +241,7 @@ define(function (require) { it('should should have duplicate column titles', function () { var columns = $el.find('thead th span'); columns.each(function () { - expect(this.innerText).to.be(colText); + expect($(this).text()).to.be(colText); }); }); From 2c5fae89c87297e2ab3d16d6ed9e63437b5a3ed2 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Wed, 3 Jun 2015 14:17:55 -0700 Subject: [PATCH 05/14] [inputFocus/tests] fix test compatibility in IE --- test/unit/specs/directives/input_focus.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/unit/specs/directives/input_focus.js b/test/unit/specs/directives/input_focus.js index 4efb776b808d5..77c2d7be39cdd 100644 --- a/test/unit/specs/directives/input_focus.js +++ b/test/unit/specs/directives/input_focus.js @@ -9,7 +9,6 @@ define(function (require) { var inputValue = 'Input Text Value'; beforeEach(module('kibana')); - beforeEach(inject(function (_$compile_, _$rootScope_, _$timeout_) { $compile = _$compile_; $rootScope = _$rootScope_; @@ -31,7 +30,10 @@ define(function (require) { $rootScope.$digest(); $timeout.flush(); selectedEl = document.activeElement; - selectedText = window.getSelection().toString(); + selectedText = selectedEl.value.slice( + selectedEl.selectionStart, + selectedEl.selectionEnd + ); } @@ -48,4 +50,4 @@ define(function (require) { expect(selectedText).to.equal(inputValue); }); }); -}); \ No newline at end of file +}); From 646f9e7783282f2f6e82ed466451693f93cd065c Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 3 Jun 2015 14:56:29 -0700 Subject: [PATCH 06/14] Preserve whitespace in discover table cells for added fields --- .../components/doc_table/components/table_row/cell.html | 4 +--- src/kibana/components/doc_table/doc_table.less | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/kibana/components/doc_table/components/table_row/cell.html b/src/kibana/components/doc_table/components/table_row/cell.html index 69964385f72fa..312dca4a12663 100644 --- a/src/kibana/components/doc_table/components/table_row/cell.html +++ b/src/kibana/components/doc_table/components/table_row/cell.html @@ -1,3 +1 @@ -> - <%= formatted %> - \ No newline at end of file +><%= formatted %> diff --git a/src/kibana/components/doc_table/doc_table.less b/src/kibana/components/doc_table/doc_table.less index 6954b401b0901..86b9982c7014e 100644 --- a/src/kibana/components/doc_table/doc_table.less +++ b/src/kibana/components/doc_table/doc_table.less @@ -7,6 +7,12 @@ doc-table { margin: 5px; .flex(1, 1, 100%); + tr.discover-table-row { + td:not(.discover-table-timefield):not(.ng-scope) { + white-space: pre; + } + } + .loading { opacity: @loading-opacity; } From 8fc4900cd3064a13dda84385eac0b017025992fc Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Wed, 3 Jun 2015 15:02:57 -0700 Subject: [PATCH 07/14] Update angular-elastic and fix IE bug --- bower.json | 2 +- src/kibana/plugins/settings/sections/objects/_view.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 8161b48b0ff78..aa6b5d35cf058 100644 --- a/bower.json +++ b/bower.json @@ -23,7 +23,7 @@ "angular": "1.2.28", "angular-bindonce": "~0.3.1", "angular-bootstrap": "~0.10.0", - "angular-elastic": "~2.3.3", + "angular-elastic": "~2.4.2", "angular-mocks": "~1.2.14", "angular-route": "~1.2.14", "angular-ui-ace": "~0.2.3", diff --git a/src/kibana/plugins/settings/sections/objects/_view.html b/src/kibana/plugins/settings/sections/objects/_view.html index 2ae81e43228a2..aa87ad62d954d 100644 --- a/src/kibana/plugins/settings/sections/objects/_view.html +++ b/src/kibana/plugins/settings/sections/objects/_view.html @@ -21,7 +21,7 @@

Proceed with caution

-