diff --git a/public/directives/wz-table/wz-table-rows.js b/public/directives/wz-table/wz-table-rows.js new file mode 100644 index 000000000..b4b2e7dfd --- /dev/null +++ b/public/directives/wz-table/wz-table-rows.js @@ -0,0 +1,17 @@ +/* + * Wazuh app - Wazuh table directive helper + * Copyright (C) 2018 Wazuh, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Find more information about this on the LICENSE file. + */ +export default (windowHeight, sizes) => { + if(windowHeight >= 950) return sizes[0]; + if(windowHeight >= 850 && windowHeight < 950) return sizes[1]; + if(windowHeight >= 750 && windowHeight < 850) return sizes[2]; + return 8; +} \ No newline at end of file diff --git a/public/directives/wz-table/wz-table.js b/public/directives/wz-table/wz-table.js index 1c4c94085..efc9b3e4d 100644 --- a/public/directives/wz-table/wz-table.js +++ b/public/directives/wz-table/wz-table.js @@ -14,10 +14,11 @@ import template from './wz-table.html'; import { uiModules } from 'ui/modules'; import DataFactory from '../../services/data-factory'; import KeyEquivalenece from '../../../util/csv-key-equivalence'; +import CheckRows from './wz-table-rows' const app = uiModules.get('app/wazuh', []); -app.directive('wazuhTable', function() { +app.directive('wzTable', function() { return { restrict: 'E', scope: { @@ -25,10 +26,25 @@ app.directive('wazuhTable', function() { keys: '=keys', allowClick: '=allowClick', implicitFilter: '=implicitFilter', - rowsPerPage: '=rowsPerPage', + rowSizes: '=rowSizes', extraLimit: '=extraLimit' }, - controller: function($scope, apiReq, $timeout, shareAgent, $location, errorHandler, wzTableFilter) { + controller: function($scope, apiReq, $timeout, shareAgent, $location, errorHandler, wzTableFilter, $window) { + /** + * Calculate number of table rows depending on the screen height + */ + const rowSizes = $scope.rowSizes || [15,13,11] + let doit; + $window.onresize = () => { + clearTimeout(doit); + doit = setTimeout(() => { + $scope.rowsPerPage = CheckRows($window.innerHeight,rowSizes); + $scope.itemsPerPage = $scope.rowsPerPage; + init() + }, 150); + }; + $scope.rowsPerPage = CheckRows($window.innerHeight,rowSizes); + $scope.keyEquivalence = KeyEquivalenece; $scope.totalItems = 0; @@ -285,6 +301,7 @@ app.directive('wazuhTable', function() { item; $scope.$on('$destroy',() => { + $window.onresize = null; realTime = null; wzTableFilter.set([]); }); @@ -304,7 +321,6 @@ app.directive('wazuhTable', function() { (item.details && item.details.order ? item.details.order : false) || '---' : checkIfArray(item[key.value || key]) || '---'; }; - }, template: template } diff --git a/public/templates/agents-prev/agents-prev.html b/public/templates/agents-prev/agents-prev.html index 1c65b48a1..9ce0e9080 100644 --- a/public/templates/agents-prev/agents-prev.html +++ b/public/templates/agents-prev/agents-prev.html @@ -101,13 +101,13 @@
- - + row-sizes="[17,15,13]"> +
diff --git a/public/templates/agents/agents-syscollector.html b/public/templates/agents/agents-syscollector.html index ec144a974..f03f1a40e 100644 --- a/public/templates/agents/agents-syscollector.html +++ b/public/templates/agents/agents-syscollector.html @@ -76,13 +76,13 @@
- - +
@@ -94,12 +94,12 @@
- - +
-->
- - + +
@@ -88,9 +88,9 @@
- - + +
@@ -105,9 +105,9 @@
- - + +
diff --git a/public/templates/manager/manager-osseclog.html b/public/templates/manager/manager-osseclog.html index a791d8413..84075a1d6 100644 --- a/public/templates/manager/manager-osseclog.html +++ b/public/templates/manager/manager-osseclog.html @@ -58,13 +58,13 @@
- - + row-sizes="[15,13,11]"> +
diff --git a/public/templates/manager/monitoring/nodes-list.html b/public/templates/manager/monitoring/nodes-list.html index 6fdd384ee..4172aea07 100644 --- a/public/templates/manager/monitoring/nodes-list.html +++ b/public/templates/manager/monitoring/nodes-list.html @@ -7,8 +7,8 @@
- - + +
diff --git a/public/templates/manager/ruleset/decoders/decoders-detail.html b/public/templates/manager/ruleset/decoders/decoders-detail.html index 25339bb23..2f84c182a 100644 --- a/public/templates/manager/ruleset/decoders/decoders-detail.html +++ b/public/templates/manager/ruleset/decoders/decoders-detail.html @@ -164,13 +164,13 @@

Related decoders

- - +
diff --git a/public/templates/manager/ruleset/decoders/decoders-list.html b/public/templates/manager/ruleset/decoders/decoders-list.html index 72b37c5c9..9d4aa377e 100644 --- a/public/templates/manager/ruleset/decoders/decoders-list.html +++ b/public/templates/manager/ruleset/decoders/decoders-list.html @@ -38,14 +38,14 @@
- - + row-sizes="[15,13,11]"> +
diff --git a/public/templates/manager/ruleset/rules/rules-detail.html b/public/templates/manager/ruleset/rules/rules-detail.html index 890875a76..398846bd8 100644 --- a/public/templates/manager/ruleset/rules/rules-detail.html +++ b/public/templates/manager/ruleset/rules/rules-detail.html @@ -205,13 +205,13 @@

Related rules

- - +
diff --git a/public/templates/manager/ruleset/rules/rules-list.html b/public/templates/manager/ruleset/rules/rules-list.html index 15edd1813..037c265e2 100644 --- a/public/templates/manager/ruleset/rules/rules-list.html +++ b/public/templates/manager/ruleset/rules/rules-list.html @@ -51,14 +51,14 @@
- - + row-sizes="[15,13,11]"> +