Skip to content

Commit

Permalink
backport official 'Data Table' last changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fbaligand committed Feb 25, 2018
1 parent 7c7e362 commit d51a9b5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions public/enhanced-table-vis-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,21 @@ module.controller('EnhancedTableVisController', function ($scope, Private, confi

/**
* Recreate the entire table when:
* - the underlying data changes (esResponse)
* - table 'renderComplete' event (renderComplete)
* - user submits a new filter to apply on results (activeFilter)
*/
$scope.$watchMulti(['esResponse', 'activeFilter'], function ([resp]) {
$scope.$watchMulti(['renderComplete', 'activeFilter'], function () {

let tableGroups = $scope.tableGroups = null;
let hasSomeRows = $scope.hasSomeRows = null;
let esResponse = $scope.esResponse;

if (resp) {
if (esResponse) {
const vis = $scope.vis;
const params = vis.params;

// create tableGroups
tableGroups = tabifyAggResponse(vis, resp, {
tableGroups = tabifyAggResponse(vis, esResponse, {
partialRows: params.showPartialRows,
minimalColumns: vis.isHierarchical() && !params.showMeticsAtAllLevels,
asAggConfigResults: true
Expand All @@ -230,7 +231,7 @@ module.controller('EnhancedTableVisController', function ($scope, Private, confi
if (computedColumn.enabled) {
let parser = createParser(computedColumn);
let newColumn = createColumn(computedColumn, index);
createTables(tableGroups.tables, computedColumn, index, parser, newColumn, resp.hits.total);
createTables(tableGroups.tables, computedColumn, index, parser, newColumn, esResponse.hits.total);
}
});

Expand Down Expand Up @@ -262,13 +263,12 @@ module.controller('EnhancedTableVisController', function ($scope, Private, confi
'hide-pagination': !showPagination,
'hide-export-links': params.hideExportLinks
};

$scope.renderComplete();
}

$scope.hasSomeRows = hasSomeRows;
if (hasSomeRows) {
$scope.tableGroups = tableGroups;
}
$scope.renderComplete();
});
});
8 changes: 4 additions & 4 deletions public/enhanced-table-vis.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ <h4>No results found</h4>
<div ng-if="tableGroups" class="table-vis-container" ng-class="tableVisContainerClass">
<kbn-agg-table-group
group="tableGroups"
export-title="vis.title"
per-page="vis.params.perPage"
export-title="visState.title"
per-page="visState.params.perPage"
sort="sort"
show-total="vis.params.showTotal"
total-func="vis.params.totalFunc">
show-total="visState.params.showTotal"
total-func="visState.params.totalFunc">
</kbn-agg-table-group>
</div>
</div>
4 changes: 2 additions & 2 deletions public/enhanced-table-vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ function EnhancedTableVisProvider(Private) {
image,
description: 'Same functionality than Data Table, but with enhanced features like computed columns and filter bar.',
category: CATEGORY.DATA,
template: tableVisTemplate,
params: {
visConfig: {
defaults: {
perPage: 10,
showPartialRows: false,
Expand All @@ -56,6 +55,7 @@ function EnhancedTableVisProvider(Private) {
filterBarHideable: false,
filterBarWidth: '25%'
},
template: tableVisTemplate
},
editorConfig: {
optionsTemplate: '<enhanced-table-vis-params></enhanced-table-vis-params>',
Expand Down

0 comments on commit d51a9b5

Please sign in to comment.