Skip to content

Commit

Permalink
- do not set a default value for the aggregate with property since it is
Browse files Browse the repository at this point in the history
  dependent on the field
- added tooltips for "aggregate with" and "size" parameters
  • Loading branch information
scampi committed Dec 21, 2016
1 parent d19ba56 commit 66d3b31
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ describe('metric vis', function () {
$scope.processTableGroups({
tables: [{
columns: [{ title: 'Count' }],
rows: [[ { toString: () => formatter(4301021) } ]],
aggConfig: function () {
return {
fieldFormatter: function () {
return formatter;
}
};
}
rows: [[ { toString: () => formatter(4301021) } ]]
}]
});

Expand All @@ -44,14 +37,7 @@ describe('metric vis', function () {
{ title: '1st percentile of bytes' },
{ title: '99th percentile of bytes' }
],
rows: [[ { toString: () => formatter(182) }, { toString: () => formatter(445842.4634666484) } ]],
aggConfig: function () {
return {
fieldFormatter: function () {
return formatter;
}
};
}
rows: [[ { toString: () => formatter(182) }, { toString: () => formatter(445842.4634666484) } ]]
}]
});

Expand Down
14 changes: 12 additions & 2 deletions src/ui/public/agg_types/controls/top_aggregate_and_size.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@
<div class="form-group">
<label>
Aggregate With
<kbn-info
info="Choose a strategy for combining multiple hits or a multi-valued field into a single metric."
placement="right">
</kbn-info>
</label>

<select
required
name="aggregate"
ng-model="agg.params.aggregate"
ng-options="opt as opt.display disable when opt.disabled for opt in options| orderBy: 'display'"
ng-options="opt as opt.display disable when opt.disabled for opt in options| orderBy: 'display' track by opt.val"
class="form-control"
></select>
</div>
<div class="form-group">
<label>Size</label>
<label>
Size
<kbn-info
info="Request top-K hits. Multiple hits will be combined via 'aggregate with'."
placement="right">
</kbn-info>
</label>

<input
required
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/controls/top_sort.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
name="sortOrder"
ng-model="agg.params.sortOrder"
required
ng-options="opt as opt.display for opt in aggParam.options"
ng-options="opt as opt.display for opt in aggParam.options track by opt.val"
class="form-control">
</select>
</div>
16 changes: 6 additions & 10 deletions src/ui/public/agg_types/metrics/top_hit.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export default function AggTypeMetricTopProvider(Private) {
{
name: 'aggregate',
type: 'optioned',
default: 'concat',
editor: aggregateAndSizeEditor,
options: [
{
Expand Down Expand Up @@ -169,16 +168,13 @@ export default function AggTypeMetricTopProvider(Private) {
return null;
}
const path = agg.params.field.name;
let values = [];

for (const hit of hits) {
const hitValues = path === '_source' ? hit._source : agg.vis.indexPattern.flattenHit(hit, true)[path];
if (_.isArray(hitValues)) {
values.push(...hitValues);
} else {
values.push(hitValues);
}
}
let values = _(hits).map(hit => {
return path === '_source' ? hit._source : agg.vis.indexPattern.flattenHit(hit, true)[path];
})
.flatten()
.value();

if (values.length === 1) {
values = values[0];
}
Expand Down

0 comments on commit 66d3b31

Please sign in to comment.