Merge branch 'master' into bucketOnExpression

Conflicts:
	src/kibana/components/agg_types/buckets/terms.js
This commit is contained in:
Spencer Alger 2015-02-03 10:33:31 -07:00
commit fc1a10e00b
23 changed files with 106 additions and 69 deletions

View file

@ -1 +0,0 @@
1.9.3-p547

View file

@ -27,7 +27,7 @@ define(function (require) {
depth: depth,
field: field,
bucket: bucket,
metric: item.value
metric: item.size
});
// If the item has a parent and it's also a child then continue walking

View file

@ -25,7 +25,7 @@ define(function (require) {
// Map those values to what the tooltipSource.rows format.
$tooltipScope.rows = _.map(rows, function (row) {
row.spacer = $sce.trustAsHtml(_.repeat(' ', row.depth));
row.metric = row.metric + ' (' + Math.round((row.metric / sum) * 100) + '%)';
row.metric = row.metric + ' (' + Math.round((Math.abs(row.metric) / sum) * 100) + '%)';
return row;
});

View file

@ -16,10 +16,10 @@ define(function (require) {
}
])).all[0];
function isType(type) {
function isNotType(type) {
return function (agg) {
var field = agg.params.field;
return !field || field.type !== 'string';
return !field || field.type !== type;
};
}
@ -41,13 +41,13 @@ define(function (require) {
name: 'exclude',
type: 'regex',
advanced: true,
disabled: isType('string')
disabled: isNotType('string')
},
{
name: 'include',
type: 'regex',
advanced: true,
disabled: isType('string')
disabled: isNotType('string')
},
{
name: 'size',

View file

@ -9,14 +9,29 @@ define(function (require) {
*/
return function (sort, indexPattern) {
var sortObj = {};
if (_.isArray(sort) && sort.length === 2) {
var field, direction;
function isSortable(field) {
return (indexPattern.fields.byName[field] && indexPattern.fields.byName[field].sortable);
}
if (_.isArray(sort) && sort.length === 2 && isSortable(sort[0])) {
// At some point we need to refact the sorting logic, this array sucks.
sortObj[sort[0]] = sort[1];
} else if (indexPattern.timeFieldName) {
sortObj[indexPattern.timeFieldName] = 'desc';
field = sort[0];
direction = sort[1];
} else if (indexPattern.timeFieldName && isSortable(indexPattern.timeFieldName)) {
field = indexPattern.timeFieldName;
direction = 'desc';
}
if (field) {
sortObj[field] = direction;
} else {
sortObj._score = 'desc';
}
return sortObj;
};
});

View file

@ -18,11 +18,12 @@ define(function (require) {
charts = obj.rows ? obj.rows : obj.columns;
}
return _.chain(charts ? charts : [obj])
return _(charts ? charts : [obj])
.pluck('series')
.flatten()
.pluck('values')
.flatten()
.filter(Boolean)
.value();
};
};

View file

@ -65,7 +65,7 @@ define(function (require) {
return;
}
if (_.isFunction(this.handler.resize)) {
if (this.handler && _.isFunction(this.handler.resize)) {
this._runOnHandler('resize');
} else {
this.render(this.data);

View file

@ -61,7 +61,7 @@ define(function (require) {
var partition = d3.layout.partition()
.sort(null)
.value(function (d) {
return d.size;
return Math.abs(d.size);
});
var x = d3.scale.linear()
.range([0, 2 * Math.PI]);

View file

@ -27,7 +27,8 @@ define(function (require) {
$scope.table = tabifyAggResponse($scope.vis, $scope.esResp, {
canSplit: false,
asAggConfigResults: true
asAggConfigResults: true,
partialRows: true
});
}
});

View file

@ -424,15 +424,8 @@ define(function (require) {
$scope.searchSource
.size($scope.opts.sampleSize)
.sort(function () {
var sort = {};
if (_.isArray($state.sort) && $state.sort.length === 2) {
sort[$state.sort[0]] = $state.sort[1];
} else if ($scope.indexPattern.timeFieldName) {
// Use the watcher to set sort in this case, the above `if` will now be true
$state.sort = [$scope.indexPattern.timeFieldName, 'desc'];
} else {
sort._score = 'desc';
}
var sort = getSort($state.sort, $scope.indexPattern);
$state.sort = _.pairs(sort)[0];
return sort;
})
.query(!$state.query ? null : $state.query)

View file

@ -30,7 +30,6 @@ define(function (require) {
name: 'metric',
title: 'Metric',
min: 1,
max: 1,
defaults: [
{ type: 'count', schema: 'metric' }
]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -11,11 +11,17 @@ define(function (require) {
return aggResponse.hierarchical(vis, esResponse);
}
var tableGroup = aggResponse.tabify(this.vis, esResponse, {
var tableGroup = aggResponse.tabify(vis, esResponse, {
canSplit: true,
asAggConfigResults: true
});
var converted = convertTableGroup(vis, tableGroup);
if (!converted) {
// mimic a row of tables that doesn't have any tables
// https://github.com/elasticsearch/kibana/blob/7bfb68cd24ed42b1b257682f93c50cd8d73e2520/src/kibana/components/vislib/components/zero_injection/inject_zeros.js#L32
converted = { rows: [] };
}
converted.hits = esResponse.hits.total;
@ -35,6 +41,7 @@ define(function (require) {
return chart;
}
if (!tables.length) return;
var out = {};
var outList;
@ -45,15 +52,12 @@ define(function (require) {
outList = out[direction] = [];
}
outList.push(convertTableGroup(vis, table));
var output;
if (output = convertTableGroup(vis, table)) {
outList.push(output);
}
});
if (!tables.length) {
// mimic a row of tables that doesn't have any tables
// https://github.com/elasticsearch/kibana/blob/7bfb68cd24ed42b1b257682f93c50cd8d73e2520/src/kibana/components/vislib/components/zero_injection/inject_zeros.js#L32
out.rows = [];
}
return out;
}

View file

@ -41,6 +41,7 @@
margin: 10px 0;
word-break: normal;
word-wrap: normal;
white-space: pre-wrap;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -13,7 +13,7 @@ var client = new elasticsearch.Client({
module.exports = function () {
var options = {
index: '.kibana',
index: config.kibana.kibana_index,
type: 'config',
body: {
size: 1000,
@ -33,7 +33,7 @@ module.exports = function () {
return client.search(options)
.then(upgrade)
.catch(function (err) {
if (!/^IndexMissingException/.test(err.message)) throw err;
if (!/SearchParseException.+mapping.+\[buildNum\]|^IndexMissingException/.test(err.message)) throw err;
});
};

View file

@ -16,10 +16,10 @@ module.exports = function (response) {
// Look for upgradeable configs. If none of them are upgradeable
// then resolve with null.
var body = _.find(response.hits.hits, isUpgradeable);
if (body) return Promise.resolve();
if (!body) return Promise.resolve();
return client.create({
index: '.kibana',
index: config.kibana.kibana_index,
type: 'config',
id: config.package.version,
body: body

View file

@ -37,7 +37,7 @@ router.use(function (req, res, next) {
function getPort(req) {
var matches = req.headers.host.match(/:(\d+)/);
if (matches[1]) return matches[1];
if (matches) return matches[1];
return req.connection.pair ? '443' : '80';
}

View file

@ -1,20 +1,21 @@
define(function (require) {
function stubbedLogstashFields() {
var sourceData = [
{ name: 'bytes', type: 'number', indexed: true, analyzed: true, count: 10 },
{ name: 'ssl', type: 'boolean', indexed: true, analyzed: true, count: 20 },
{ name: '@timestamp', type: 'date', indexed: true, analyzed: true, count: 30 },
{ name: 'time', type: 'date', indexed: true, analyzed: true, count: 30 },
{ name: 'utc_time', type: 'date', indexed: true, analyzed: true },
{ name: 'phpmemory', type: 'number', indexed: true, analyzed: true },
{ name: 'ip', type: 'ip', indexed: true, analyzed: true },
{ name: 'request_body', type: 'attachment', indexed: true, analyzed: true },
{ name: 'point', type: 'geo_point', indexed: true, analyzed: true },
{ name: 'area', type: 'geo_shape', indexed: true, analyzed: true },
{ name: 'extension', type: 'string', indexed: true, analyzed: true },
{ name: 'machine.os', type: 'string', indexed: true, analyzed: true },
{ name: 'geo.src', type: 'string', indexed: true, analyzed: true },
{ name: '_type', type: 'string', indexed: true, analyzed: true },
{ name: 'bytes', type: 'number', indexed: true, analyzed: true, sortable: true, filterable: true, count: 10 },
{ name: 'ssl', type: 'boolean', indexed: true, analyzed: true, sortable: true, filterable: true, count: 20 },
{ name: '@timestamp', type: 'date', indexed: true, analyzed: true, sortable: true, filterable: true, count: 30 },
{ name: 'time', type: 'date', indexed: true, analyzed: true, sortable: true, filterable: true, count: 30 },
{ name: 'utc_time', type: 'date', indexed: true, analyzed: true, sortable: true, filterable: true },
{ name: 'phpmemory', type: 'number', indexed: true, analyzed: true, sortable: true, filterable: true },
{ name: 'ip', type: 'ip', indexed: true, analyzed: true, sortable: true, filterable: true },
{ name: 'request_body', type: 'attachment', indexed: true, analyzed: true, sortable: false, filterable: true },
{ name: 'point', type: 'geo_point', indexed: true, analyzed: true, sortable: false, filterable: false },
{ name: 'area', type: 'geo_shape', indexed: true, analyzed: true, sortable: true, filterable: false },
{ name: 'extension', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
{ name: 'machine.os', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
{ name: 'geo.src', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
{ name: '_type', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
{ name: '_id', type: 'string', indexed: false, analyzed: false, sortable: false, filterable: true},
{ name: 'custom_user_field', type: 'conflict', indexed: false, analyzed: false },
{ name: 'script string', type: 'string', scripted: true, script: '\'i am a string\''},
{ name: 'script number', type: 'number', scripted: true, script: '1234'},

View file

@ -11,18 +11,18 @@ define(function (require) {
results = collectBranch({
name: 'bucket3',
depth: 3,
value: 6,
size: 6,
field: { format: { convert: convert } },
aggConfig: { params: { field: { displayName: 'field3' } }, fieldFormatter: _.constant(String) },
parent: {
name: 'bucket2',
depth: 2,
value: 12,
size: 12,
aggConfig: { label: 'field2', fieldFormatter: _.constant(String) },
parent: {
name: 'bucket1',
depth: 1,
value: 24,
size: 24,
parent: {}
}
}

View file

@ -4,30 +4,43 @@ define(function (require) {
describe('docTable', function () {
describe('getSort function', function () {
var timePattern = {
timeFieldName: 'time'
};
var noTimePattern = {};
beforeEach(module('kibana'));
beforeEach(inject(function (Private, _$rootScope_, Promise) {
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
}));
it('should be a function', function () {
expect(getSort).to.be.a(Function);
});
it('should return an object if passed a 2 item array', function () {
expect(getSort(['foo', 'bar'], timePattern)).to.eql({foo: 'bar'});
expect(getSort(['foo', 'bar'], noTimePattern)).to.eql({foo: 'bar'});
expect(getSort(['bytes', 'desc'], indexPattern)).to.eql({bytes: 'desc'});
delete indexPattern.timeFieldName;
expect(getSort(['bytes', 'desc'], indexPattern)).to.eql({bytes: 'desc'});
});
it('should sort by the default when passed an unsortable field', function () {
expect(getSort(['_id', 'asc'], indexPattern)).to.eql({time: 'desc'});
expect(getSort(['lol_nope', 'asc'], indexPattern)).to.eql({time: 'desc'});
delete indexPattern.timeFieldName;
expect(getSort(['_id', 'asc'], indexPattern)).to.eql({_score: 'desc'});
});
it('should sort in reverse chrono order otherwise on time based patterns', function () {
expect(getSort([], timePattern)).to.eql({time: 'desc'});
expect(getSort(['foo'], timePattern)).to.eql({time: 'desc'});
expect(getSort({foo: 'bar'}, timePattern)).to.eql({time: 'desc'});
expect(getSort([], indexPattern)).to.eql({time: 'desc'});
expect(getSort(['foo'], indexPattern)).to.eql({time: 'desc'});
expect(getSort({foo: 'bar'}, indexPattern)).to.eql({time: 'desc'});
});
it('should sort by score on non-time patterns', function () {
expect(getSort([], noTimePattern)).to.eql({_score: 'desc'});
expect(getSort(['foo'], noTimePattern)).to.eql({_score: 'desc'});
expect(getSort({foo: 'bar'}, noTimePattern)).to.eql({_score: 'desc'});
delete indexPattern.timeFieldName;
expect(getSort([], indexPattern)).to.eql({_score: 'desc'});
expect(getSort(['foo'], indexPattern)).to.eql({_score: 'desc'});
expect(getSort({foo: 'bar'}, indexPattern)).to.eql({_score: 'desc'});
});
});

View file

@ -101,8 +101,10 @@ define(function (require) {
describe('getFields', function () {
it('should return all non-scripted fields', function () {
var indexed = _.where(mockLogstashFields, { scripted: false });
expect(indexPattern.getFields()).to.eql(indexed);
var expected = _.pluck(_.where(mockLogstashFields, { scripted: false }), name).sort();
var result = _.pluck(indexPattern.getFields(), name).sort();
expect(result).to.eql(expected);
});
it('should return all scripted fields', function () {

View file

@ -4,6 +4,10 @@ define(function (require) {
var sinon = require('sinon/sinon');
var IndexedArray = require('utils/indexed_array/index');
var fieldFormats = Private(require('components/index_patterns/_field_formats'));
var flattenSearchResponse = require('components/index_patterns/_flatten_search_response');
var flattenHit = require('components/index_patterns/_flatten_hit');
var getComputedFields = require('components/index_patterns/_get_computed_fields');
function StubIndexPattern(pattern, timeField, fields) {
this.popularizeField = sinon.spy();
@ -27,6 +31,10 @@ define(function (require) {
});
this.getFields = sinon.spy();
this.toIndexList = _.constant([pattern]);
this.getComputedFields = getComputedFields;
this.flattenSearchResponse = flattenSearchResponse;
this.flattenHit = flattenHit;
this.metaFields = ['_id', '_type', '_source'];
}
return StubIndexPattern;