navinko commented on code in PR #10076:
URL: https://github.com/apache/ozone/pull/10076#discussion_r3221782899


##########
hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js:
##########
@@ -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));
+                    });

Review Comment:
   Thanks @smengcl for reviewing , Definitely suggested approach would be 
maintenance free and no need to update the search criteria if any columns are 
being added/removed. 
   
   Instead of manually listing out each and every single column name (like 
hostname, capacity, uuid, etc.), I just updated the search to use 
Object.values(node). This tells the code to automatically grab every piece of 
data inside that specific row, convert it to text, and check if it matches the 
search query. 
   This also matches the original search behavior and it automatically 
future-proofs the page so we never have to update this code if new columns are 
added/removed later!
   
   -> search by any colume for example , i used lastHeartbeat for dn sits on 
2nd page 
   <img width="1104" height="671" alt="1" 
src="https://github.com/user-attachments/assets/2e84b7be-bdab-43eb-bb7c-c076029c04b8";
 />
   
   -> global serach by lastHeartbeat
   <img width="1112" height="278" alt="2" 
src="https://github.com/user-attachments/assets/64dfbcea-853d-4fa3-9d4a-4716f41cff17";
 />
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to