ArafatKhan2198 commented on code in PR #5983:
URL: https://github.com/apache/ozone/pull/5983#discussion_r1577370497
##########
hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js:
##########
@@ -82,12 +82,16 @@
});
/*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;
- } else {
- $scope.lastIndex = Math.ceil(nodeStatusCopy.length /
$scope.RecordsToDisplay);
- $scope.nodeStatus = nodeStatusCopy.slice(0,
$scope.RecordsToDisplay);
+ if($scope.search){
+ $scope.nodeStatus = nodeStatusCopy.filter(item =>
item.hostname.includes($scope.search));
+ }else {
+ if ($scope.RecordsToDisplay == 'All') {
Review Comment:
It's a good practice to use strict equality (===) instead of loose equality
(==) in JavaScript to avoid unexpected type coercion.
##########
hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js:
##########
@@ -82,12 +82,16 @@
});
/*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;
- } else {
- $scope.lastIndex = Math.ceil(nodeStatusCopy.length /
$scope.RecordsToDisplay);
- $scope.nodeStatus = nodeStatusCopy.slice(0,
$scope.RecordsToDisplay);
+ if($scope.search){
+ $scope.nodeStatus = nodeStatusCopy.filter(item =>
item.hostname.includes($scope.search));
+ }else {
+ if ($scope.RecordsToDisplay == 'All') {
Review Comment:
Here’s a suggested refactor to make the function more readable, with a few
changed comments.
```
$scope.UpdateRecordsToShow = () => {
// First, handle search filtering
if ($scope.search) {
$scope.nodeStatus = nodeStatusCopy.filter(item =>
item.hostname.includes($scope.search));
} else {
// Then handle record display based on 'All' or a specific number
if ($scope.RecordsToDisplay === 'All') {
$scope.nodeStatus = nodeStatusCopy;
} else {
$scope.nodeStatus = nodeStatusCopy.slice(0,
$scope.RecordsToDisplay);
}
$scope.lastIndex = $scope.RecordsToDisplay === 'All' ? 1 :
Math.ceil(nodeStatusCopy.length / $scope.RecordsToDisplay);
}
$scope.currentPage = 1;
}
```
--
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]