Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom legends can be specified for filter aggregates #3621

Merged
merged 6 commits into from
Jun 19, 2015
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/kibana/components/agg_types/buckets/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define(function (require) {
{
name: 'filters',
editor: require('text!components/agg_types/controls/filters.html'),
default: [ {input: {}} ],
default: [ {input: {}, label: ''} ],
write: function (aggConfig, output) {
var inFilters = aggConfig.params.filters;
if (!_.size(inFilters)) return;
Expand All @@ -29,7 +29,11 @@ define(function (require) {

decorateQuery(query);

var label = _.deepGet(query, 'query_string.query') || angular.toJson(query);
var label = filter.label;
if (!label) {
label = _.deepGet(query, 'query_string.query') || angular.toJson(query);
}

filters[label] = input;
}, {});

Expand Down
40 changes: 32 additions & 8 deletions src/kibana/components/agg_types/controls/filters.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
<div class="form-group">
<div ng-repeat="filter in agg.params.filters">
<label>Filter {{$index + 1}}</label>
<div class="form-group vis-editor-agg-form-row">
<div class="vis-editor-agg-header">
<label class="vis-editor-agg-header-growing">
Filter {{$index + 1}}
<span ng-if="filter.label">- {{ filter.label }}</span>
</label>

<div class="btn-group">
<button
ng-click="showConfig = !showConfig"
type="button"
class="btn btn-default btn-xs">
<i class="fa fa-cog"></i>
</button>
<button
type="button"
ng-click="agg.params.filters.splice($index, 1)"
class="btn btn-danger btn-xs">
<i class="fa fa-times"></i>
</button>
</div>
</div>

<div class="form-group">
<input validate-query
ng-model="filter.input.query"
type="text"
class="form-control"
name="filter{{$index}}">
</div>

<button
type="button"
ng-click="agg.params.filters.splice($index, 1)"
class="btn btn-danger btn-xs">
<i class="fa fa-times"></i>
</button>
<div class="form-group" ng-show="showConfig">
<label>Filter {{$index + 1}} label</label>
<input
ng-model="filter.label"
placeholder="Label"
type="text"
class="form-control"
name="label{{$index}}">
</div>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions src/kibana/plugins/visualize/editor/styles/editor.less
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@
font-weight: bold;
}

&-growing {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure on this class naming? Also, this really isn't any kind of vis-editor-agg-header

.flex(2 0 0);
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
margin-bottom: 0;
}

&-description {
font-weight: normal;
padding-right: @vis-editor-agg-editor-spacing;
Expand Down