From 3cfa00eb2cf1b3c56c9904cf7fc76cb3c5384086 Mon Sep 17 00:00:00 2001 From: Alessandro Bellina Date: Thu, 1 Sep 2016 08:10:45 -0500 Subject: [PATCH 1/2] STORM-2078: enable paging in worker datatable --- storm-core/src/ui/public/js/script.js | 37 +++++++++++++++++---------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/storm-core/src/ui/public/js/script.js b/storm-core/src/ui/public/js/script.js index ad739a5e8ca..5f312d009cd 100644 --- a/storm-core/src/ui/public/js/script.js +++ b/storm-core/src/ui/public/js/script.js @@ -54,8 +54,9 @@ $.extend( $.fn.dataTableExt.oSort, { } }); +var minEntriesToShowPagination = 20; function dtAutoPage(selector, conf) { - if ($(selector.concat(" tr")).length <= 20) { + if ($(selector.concat(" tr")).length <= minEntriesToShowPagination) { $.extend(conf, {paging: false}); } return $(selector).DataTable(conf); @@ -389,25 +390,28 @@ var makeWorkerStatsTable = function (response, elId, parentId, type) { break; } - var workerStatsTable = dtAutoPage(elId, { + var initializeComponents = function (){ + var show = $.cookies.get("showComponents") || false; + + // toggle all components visibile/invisible + $(elId + ' tr').each(function (){ + var dt = $(elId).dataTable(); + showComponents(dt.api().row(this), show); + }); + }; + + var pagingEnabled = response && response.workers && + response.workers.length > minEntriesToShowPagination; + + var workerStatsTable = $(elId).DataTable({ + paging: pagingEnabled, data: response.workers, autoWidth: false, columns: columns, initComplete: function (){ // add a "Toggle Components" button renderToggleComponents ($(elId + '_filter'), elId); - var show = $.cookies.get("showComponents") || false; - - // if the cookie is false, then we are done - if (!show) { - return; - } - - // toggle all components visibile - $(elId + ' tr').each(function (){ - var dt = $(elId).dataTable(); - showComponents(dt.api().row(this), true); - }); + initializeComponents(); } }); @@ -419,6 +423,11 @@ var makeWorkerStatsTable = function (response, elId, parentId, type) { showComponents(row, !row.child.isShown()); }); + $(elId + '_paginate').on('click', function(){ + // when we change pages, re-initialize components + initializeComponents(); + }); + $(parentId + ' #toggle-on-components-btn').on('click', 'input', function (){ toggleComponents(elId); }); From 0b861c19152cb3d400bc9f216d9aaa84b8fa60ee Mon Sep 17 00:00:00 2001 From: Alessandro Bellina Date: Sat, 3 Sep 2016 15:01:47 -0500 Subject: [PATCH 2/2] STORM-2078: fix bug where worker rows were not redrawing on filter. Now it happens on drawCallback (every drw --- storm-core/src/ui/public/js/script.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/storm-core/src/ui/public/js/script.js b/storm-core/src/ui/public/js/script.js index 5f312d009cd..886c34b1347 100644 --- a/storm-core/src/ui/public/js/script.js +++ b/storm-core/src/ui/public/js/script.js @@ -411,6 +411,8 @@ var makeWorkerStatsTable = function (response, elId, parentId, type) { initComplete: function (){ // add a "Toggle Components" button renderToggleComponents ($(elId + '_filter'), elId); + }, + drawCallback: function (){ initializeComponents(); } }); @@ -423,11 +425,6 @@ var makeWorkerStatsTable = function (response, elId, parentId, type) { showComponents(row, !row.child.isShown()); }); - $(elId + '_paginate').on('click', function(){ - // when we change pages, re-initialize components - initializeComponents(); - }); - $(parentId + ' #toggle-on-components-btn').on('click', 'input', function (){ toggleComponents(elId); });