mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
render-counter
directive (#9210)
Backports PR #9206 **Commit 1:** [docTable/row] delay first render until watchers initialize * Original sha:4945e088c1
* Authored by spalger <email@spalger.com> on 2016-11-23T18:57:22Z **Commit 2:** [docTable/row] emit a renderComplete event, count in table directive * Original sha:641f9af0e3
* Authored by spalger <email@spalger.com> on 2016-11-23T18:58:21Z **Commit 3:** [renderCounter] unify render counting login into directive * Original sha:0c084acc97
* Authored by spalger <email@spalger.com> on 2016-11-23T21:26:44Z **Commit 4:** [docTable] remove unused var * Original sha:275bf70a95
* Authored by spalger <email@spalger.com> on 2016-11-23T22:00:52Z
This commit is contained in:
parent
4f225957f4
commit
4617e092ae
7 changed files with 49 additions and 23 deletions
|
@ -28,13 +28,16 @@
|
|||
search-source="savedObj.searchSource"
|
||||
show-spy-panel="chrome.getVisible()"
|
||||
ui-state="uiState"
|
||||
render-counter
|
||||
class="panel-content">
|
||||
</visualize>
|
||||
|
||||
<doc-table ng-switch-when="search"
|
||||
<doc-table
|
||||
ng-switch-when="search"
|
||||
search-source="savedObj.searchSource"
|
||||
sorting="panel.sort"
|
||||
columns="panel.columns"
|
||||
render-counter
|
||||
class="panel-content"
|
||||
filter="filter">
|
||||
</doc-table>
|
||||
|
|
|
@ -125,7 +125,8 @@
|
|||
sorting="state.sort"
|
||||
columns="state.columns"
|
||||
infinite-scroll="true"
|
||||
filter="filterQuery">
|
||||
filter="filterQuery"
|
||||
render-counter>
|
||||
</doc-table>
|
||||
|
||||
<div ng-if="rows.length == opts.sampleSize" class="discover-table-footer">
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
<div class="vis-editor-canvas" ng-class="{ embedded: !chrome.getVisible() }">
|
||||
<visualize
|
||||
vis="vis"
|
||||
render-counter
|
||||
ui-state="uiState"
|
||||
show-spy-panel="chrome.getVisible()"
|
||||
editable-vis="editableVis"
|
||||
|
|
31
src/ui/public/directives/render_counter.js
Normal file
31
src/ui/public/directives/render_counter.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
import uiModules from 'ui/modules';
|
||||
|
||||
uiModules
|
||||
.get('kibana')
|
||||
.directive('renderCounter', () => ({
|
||||
controller($scope, $element) {
|
||||
let counter = 0;
|
||||
|
||||
const increment = () => {
|
||||
counter += 1;
|
||||
$element.attr('render-counter', counter);
|
||||
};
|
||||
|
||||
const teardown = () => {
|
||||
$element.off('renderComplete', increment);
|
||||
};
|
||||
|
||||
const setup = () => {
|
||||
$element.attr('render-counter', counter);
|
||||
$element.on('renderComplete', increment);
|
||||
$scope.$on('$destroy', teardown);
|
||||
};
|
||||
|
||||
this.disable = () => {
|
||||
$element.attr('render-counter', 'disabled');
|
||||
teardown();
|
||||
};
|
||||
|
||||
setup();
|
||||
}
|
||||
}));
|
|
@ -40,10 +40,6 @@ module.directive('kbnTableRow', function ($compile) {
|
|||
$el.after('<tr>');
|
||||
$el.empty();
|
||||
|
||||
let init = function () {
|
||||
createSummaryRow($scope.row, $scope.row._id);
|
||||
};
|
||||
|
||||
// when we compile the details, we use this $scope
|
||||
let $detailsScope;
|
||||
|
||||
|
@ -79,11 +75,11 @@ module.directive('kbnTableRow', function ($compile) {
|
|||
$compile($detailsTr)($detailsScope);
|
||||
};
|
||||
|
||||
$scope.$watchCollection('columns', function () {
|
||||
createSummaryRow($scope.row, $scope.row._id);
|
||||
});
|
||||
|
||||
$scope.$watchMulti(['indexPattern.timeFieldName', 'row.highlight'], function () {
|
||||
$scope.$watchMulti([
|
||||
'indexPattern.timeFieldName',
|
||||
'row.highlight',
|
||||
'[]columns'
|
||||
], function () {
|
||||
createSummaryRow($scope.row, $scope.row._id);
|
||||
});
|
||||
|
||||
|
@ -144,6 +140,7 @@ module.directive('kbnTableRow', function ($compile) {
|
|||
|
||||
// trim off cells that were not used rest of the cells
|
||||
$cells.filter(':gt(' + (newHtmls.length - 1) + ')').remove();
|
||||
$el.trigger('renderComplete');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,8 +158,6 @@ module.directive('kbnTableRow', function ($compile) {
|
|||
|
||||
return text;
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -43,4 +43,4 @@
|
|||
<div ng-if="hits != null && !hits.length" class="table-vis-error">
|
||||
<h2><i class="fa fa-meh-o"></i></h2>
|
||||
<h4>No results found</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -25,6 +25,7 @@ uiModules
|
|||
|
||||
return {
|
||||
restrict: 'E',
|
||||
require: '?renderCounter',
|
||||
scope : {
|
||||
showSpyPanel: '=?',
|
||||
vis: '=',
|
||||
|
@ -34,7 +35,7 @@ uiModules
|
|||
esResp: '=?',
|
||||
},
|
||||
template: visualizeTemplate,
|
||||
link: function ($scope, $el, attr) {
|
||||
link: function ($scope, $el, attr, renderCounter) {
|
||||
const minVisChartHeight = 180;
|
||||
|
||||
if (_.isUndefined($scope.showSpyPanel)) {
|
||||
|
@ -72,14 +73,8 @@ uiModules
|
|||
return legendPositionToVisContainerClassMap[$scope.vis.params.legendPosition];
|
||||
};
|
||||
|
||||
if ($scope.vis.implementsRenderComplete()) {
|
||||
$el.attr('has-render-count', 'true');
|
||||
let renderCount = 0;
|
||||
$el.on('renderComplete', () => {
|
||||
$el.attr('render-count', ++renderCount);
|
||||
});
|
||||
} else {
|
||||
$el.attr('has-render-count', 'false');
|
||||
if (renderCounter && !$scope.vis.implementsRenderComplete()) {
|
||||
renderCounter.disable();
|
||||
}
|
||||
|
||||
$scope.spy = {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue