Skip to content

Commit

Permalink
Display source dashboard and count in the default label of relational…
Browse files Browse the repository at this point in the history
… filters
  • Loading branch information
szydan authored and fabiocorneti committed Sep 16, 2015
1 parent ad45ee1 commit 31f1aa7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ define(function (require) {
});

button.joinFilter = existingJoin;
button.joinFilter.meta.value = button.filterLabel ? button.filterLabel : 'button: ' + button.label;

fulfill(button);
});
};
Expand Down Expand Up @@ -166,7 +164,6 @@ define(function (require) {
});

button.joinFilter = existingJoin;
button.joinFilter.meta.value = button.filterLabel ? button.filterLabel : 'button: ' + button.label;

indexPatterns.get(button.sourceIndexPatternId).then(function (indexPattern) {
var timeFilter = timefilter.get(indexPattern);
Expand Down Expand Up @@ -293,7 +290,6 @@ define(function (require) {
indexToDashboardMap
).then(function (joinFilter) {
button.joinFilter = joinFilter;
button.joinFilter.meta.value = button.filterLabel ? button.filterLabel : 'button: ' + button.label;
fulfill(button);
});

Expand Down Expand Up @@ -411,6 +407,11 @@ define(function (require) {
kibiStateHelper.saveFiltersForDashboardId(urlHelper.getCurrentDashboardId(), urlHelper.getCurrentDashboardFilters());
kibiStateHelper.saveQueryForDashboardId(urlHelper.getCurrentDashboardId(), urlHelper.getCurrentDashboardQuery());

this.joinFilter.meta.value =
button.filterLabel ? button.filterLabel :
'... related to (' + this.sourceCount + ') from ' + urlHelper.getCurrentDashboardId();


if (this.joinFilter) {
// get filters from dashboard we would like to switch to
var targetDashboardQuery = kibiStateHelper.getQueryForDashboardId(this.redirectToDashboard);
Expand Down Expand Up @@ -469,12 +470,21 @@ define(function (require) {
});
$scope.$on('$destroy', off);

$scope.$watchMulti([ 'buttons', 'esResponse' ], function () {
$scope.$watch('buttons', function () {
if ($scope.buttons) {
_updateCounts();
}
});

$scope.$watch('esResponse', function (resp) {
if ($scope.buttons) {
_updateCounts();
_.each($scope.buttons, function (button) {
button.sourceCount = resp.hits.total;
});
}
});

$scope.$watch('vis.params.buttons', function () {
_constructButtons();
}, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ <h2>Relational filter {{$index + 1}}</h2>
<input required="true" type="text" ng-model="button.label" class="form-control"/>
</div>
<div class="form-group">
<label>Filter label</label></br>
<label>Custom filter label</label> <span>(optional)</span>
<i class="fa fa-info-circle"
tooltip="A custom label for the filter created by pressing the button. The default label is: '... related to (COUNT) from DASHBOARD_ID'"
tooltip-placement="right"
tooltip-animation="false"
tooltip-popup-delay="0"
tooltip-append-to-body="true"></i></br>
<input type="text" ng-model="button.filterLabel" class="form-control"/>
</div>

Expand Down

0 comments on commit 31f1aa7

Please sign in to comment.