From 4945e088c135f4d5f36c971d442f39a764b0c32c Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 23 Nov 2016 11:57:22 -0700 Subject: [PATCH 1/4] [docTable/row] delay first render until watchers initialize --- src/ui/public/doc_table/components/table_row.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/ui/public/doc_table/components/table_row.js b/src/ui/public/doc_table/components/table_row.js index 530ddb996c3a9..3e91c0e65d553 100644 --- a/src/ui/public/doc_table/components/table_row.js +++ b/src/ui/public/doc_table/components/table_row.js @@ -40,10 +40,6 @@ module.directive('kbnTableRow', function ($compile) { $el.after(''); $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); }); @@ -161,8 +157,6 @@ module.directive('kbnTableRow', function ($compile) { return text; } - - init(); } }; }); From 641f9af0e342f4c40b5ab9f46ae11182ff7b70d4 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 23 Nov 2016 11:58:21 -0700 Subject: [PATCH 2/4] [docTable/row] emit a renderComplete event, count in table directive --- src/ui/public/doc_table/components/table_row.js | 1 + src/ui/public/doc_table/doc_table.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ui/public/doc_table/components/table_row.js b/src/ui/public/doc_table/components/table_row.js index 3e91c0e65d553..c8cab43acb329 100644 --- a/src/ui/public/doc_table/components/table_row.js +++ b/src/ui/public/doc_table/components/table_row.js @@ -140,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'); } /** diff --git a/src/ui/public/doc_table/doc_table.js b/src/ui/public/doc_table/doc_table.js index db3148a831525..6d0bb79c43712 100644 --- a/src/ui/public/doc_table/doc_table.js +++ b/src/ui/public/doc_table/doc_table.js @@ -24,7 +24,7 @@ uiModules.get('kibana') infiniteScroll: '=?', filter: '=?', }, - link: function ($scope) { + link: function ($scope, $el) { let notify = new Notifier(); $scope.limit = 50; $scope.persist = { @@ -55,6 +55,12 @@ uiModules.get('kibana') $scope.limit += 50; }; + $el.attr('has-render-count', 'true'); + $el.attr('render-count', '0'); + $el.on('renderComplete', () => { + $el.attr('render-count', parseInt($el.attr('render-count'), 10) + 1); + }); + // This exists to fix the problem of an empty initial column list not playing nice with watchCollection. $scope.$watch('columns', function (columns) { if (columns.length !== 0) return; From 0c084acc9715ec6712922727476c4f369a1ab0c7 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 23 Nov 2016 14:26:44 -0700 Subject: [PATCH 3/4] [renderCounter] unify render counting login into directive --- .../dashboard/components/panel/panel.html | 5 ++- .../kibana/public/discover/index.html | 3 +- .../public/visualize/editor/editor.html | 1 + src/ui/public/directives/render_counter.js | 31 +++++++++++++++++++ src/ui/public/doc_table/doc_table.html | 2 +- src/ui/public/doc_table/doc_table.js | 6 ---- src/ui/public/visualize/visualize.js | 13 +++----- 7 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 src/ui/public/directives/render_counter.js diff --git a/src/core_plugins/kibana/public/dashboard/components/panel/panel.html b/src/core_plugins/kibana/public/dashboard/components/panel/panel.html index 6665034471980..874a62b75522a 100644 --- a/src/core_plugins/kibana/public/dashboard/components/panel/panel.html +++ b/src/core_plugins/kibana/public/dashboard/components/panel/panel.html @@ -28,13 +28,16 @@ search-source="savedObj.searchSource" show-spy-panel="chrome.getVisible()" ui-state="uiState" + render-counter class="panel-content"> - diff --git a/src/core_plugins/kibana/public/discover/index.html b/src/core_plugins/kibana/public/discover/index.html index 1a60d56b6b641..0f2faa466bc67 100644 --- a/src/core_plugins/kibana/public/discover/index.html +++ b/src/core_plugins/kibana/public/discover/index.html @@ -125,7 +125,8 @@

Searching

sorting="state.sort" columns="state.columns" infinite-scroll="true" - filter="filterQuery"> + filter="filterQuery" + render-counter>