diff --git a/websiteFunctions/templates/websiteFunctions/WPsitesList.html b/websiteFunctions/templates/websiteFunctions/WPsitesList.html index b6771c0fd..93c1ec210 100644 --- a/websiteFunctions/templates/websiteFunctions/WPsitesList.html +++ b/websiteFunctions/templates/websiteFunctions/WPsitesList.html @@ -19,6 +19,32 @@ $scope.userId = $scope.debug.user_id; $scope.isAdmin = $scope.debug.is_admin; $scope.wpSitesCount = $scope.debug.wp_sites_count; + $scope.currentPage = 1; + $scope.recordsToShow = 10; + + $scope.updatePagination = function() { + var filteredSites = $scope.wpSites; + if ($scope.searchText) { + filteredSites = $scope.wpSites.filter(function(site) { + return site.title.toLowerCase().includes($scope.searchText.toLowerCase()) || + site.url.toLowerCase().includes($scope.searchText.toLowerCase()); + }); + } + $scope.totalPages = Math.ceil(filteredSites.length / $scope.recordsToShow); + if ($scope.currentPage > $scope.totalPages) { + $scope.currentPage = 1; + } + }; + + $scope.$watch('searchText', function() { + $scope.updatePagination(); + }); + + $scope.$watch('recordsToShow', function() { + $scope.updatePagination(); + }); + + $scope.updatePagination(); $scope.getFullUrl = function(url) { if (!url) return ''; @@ -139,6 +165,21 @@ $scope.wpSites.forEach(fetchSiteData); } }); + + // Add a range filter for pagination + angular.module('CyberCP').filter('range', function() { + return function(input, start, end) { + start = parseInt(start); + end = parseInt(end); + var direction = (start <= end) ? 1 : -1; + while (start != end) { + input.push(start); + start += direction; + } + input.push(end); + return input; + }; + }); {% endblock %} @@ -158,7 +199,20 @@
-
+
+
+ +
+
+ +
+
+ +
@@ -245,6 +299,22 @@
+ +
+
+
+
+ Showing {$ ((currentPage-1)*recordsToShow) + 1 $} to {$ ((currentPage-1)*recordsToShow) + filteredSites.length $} of {$ (wpSites | filter:searchText).length $} sites +
+
+
+ +
+
+
+
+