diff --git a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html index bb2f25a1c32..dc73ebc4706 100644 --- a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html +++ b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html @@ -230,7 +230,7 @@
| {{typestat.hostname}} diff --git a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js index eca79852e43..0d2e9000c5b 100644 --- a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js +++ b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js @@ -29,6 +29,7 @@ $scope.reverse = false; $scope.columnName = "hostname"; let nodeStatusCopy = []; + $scope.filteredNodes = []; $scope.RecordsToDisplay = "10"; $scope.currentPage = 1; $scope.lastIndex = 0; @@ -135,10 +136,12 @@ } }); - nodeStatusCopy = [...$scope.nodeStatus]; - $scope.totalItems = nodeStatusCopy.length; - $scope.lastIndex = Math.ceil(nodeStatusCopy.length / $scope.RecordsToDisplay); - $scope.nodeStatus = nodeStatusCopy.slice(0, $scope.RecordsToDisplay); + nodeStatusCopy = [...$scope.nodeStatus]; + $scope.filteredNodes = [...nodeStatusCopy]; + $scope.totalItems = $scope.filteredNodes.length; + let initialLimit = parseInt($scope.RecordsToDisplay); + $scope.lastIndex = Math.ceil($scope.filteredNodes.length / initialLimit); + $scope.nodeStatus = $scope.filteredNodes.slice(0, initialLimit); $scope.formatValue = function(value) { if (value && value.includes(';')) { @@ -218,28 +221,48 @@ $scope.statistics.containers.health.open_without_pipeline = ctrl.scmcontainermanager.OpenContainersWithoutPipeline; }); - /*if option is 'All' display all records else display specified record on page*/ - $scope.UpdateRecordsToShow = () => { - if($scope.RecordsToDisplay == 'All') { - $scope.lastIndex = 1; - $scope.nodeStatus = nodeStatusCopy; + /* Global Search Logic */ + $scope.applyGlobalSearch = function() { + if (!$scope.search || $scope.search.trim() === "") { + // Reset to full list if search is empty + $scope.filteredNodes = [...nodeStatusCopy]; } else { - $scope.lastIndex = Math.ceil(nodeStatusCopy.length / $scope.RecordsToDisplay); - $scope.nodeStatus = nodeStatusCopy.slice(0, $scope.RecordsToDisplay); - } - $scope.currentPage = 1; - } - /* Page Slicing logic */ - $scope.handlePagination = (pageIndex, isDisabled) => { - if(!isDisabled && $scope.RecordsToDisplay != 'All') { - pageIndex = parseInt(pageIndex); - let startIndex = 0, endIndex = 0; - $scope.currentPage = pageIndex; - startIndex = ($scope.currentPage - 1) * parseInt($scope.RecordsToDisplay); - endIndex = startIndex + parseInt($scope.RecordsToDisplay); - $scope.nodeStatus = nodeStatusCopy.slice(startIndex, endIndex); + let query = $scope.search.toLowerCase(); + // Filter the master list + $scope.filteredNodes = nodeStatusCopy.filter(function(node) { + return (node.hostname && node.hostname.toLowerCase().includes(query)) || + (node.opstate && node.opstate.toLowerCase().includes(query)) || + (node.comstate && node.comstate.toLowerCase().includes(query)) || + (node.uuid && node.uuid.toLowerCase().includes(query)); + }); } - } + $scope.totalItems = $scope.filteredNodes.length; + $scope.UpdateRecordsToShow(); // Re-calculate pagination + }; + /* If option is 'All' display all records, else display specified records on page */ + $scope.UpdateRecordsToShow = () => { + if ($scope.RecordsToDisplay === 'All') { + $scope.lastIndex = 1; + $scope.nodeStatus = $scope.filteredNodes; + } else { + let limit = parseInt($scope.RecordsToDisplay); + $scope.lastIndex = Math.ceil($scope.filteredNodes.length / limit); + $scope.nodeStatus = $scope.filteredNodes.slice(0, limit); + } + $scope.currentPage = 1; + }; + /* Page Slicing logic */ + $scope.handlePagination = (pageIndex, isDisabled) => { + if (!isDisabled && $scope.RecordsToDisplay !== 'All') { + // Force strict math with parseInt + pageIndex = parseInt(pageIndex); + let limit = parseInt($scope.RecordsToDisplay); + $scope.currentPage = pageIndex; + let startIndex = ($scope.currentPage - 1) * limit; + let endIndex = startIndex + limit; + $scope.nodeStatus = $scope.filteredNodes.slice(startIndex, endIndex); + } + } /*column sort logic*/ $scope.columnSort = (colName) => { $scope.columnName = colName; |