Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ <h2>Node Status</h2>
</select>
</div>
<div class="col-md-6 text-right">
<label>Search: </label> <input type="text" ng-model="search">
<label>Search: </label> <input type="text" ng-model="search" ng-change="applyGlobalSearch()" ng-model-options="{ debounce: 300 }">
</div>
</div>
<table class="table table-bordered table-striped col-md-6">
Expand All @@ -255,7 +255,7 @@ <h2>Node Status</h2>
</tr>
</thead>
<tbody>
<tr ng-repeat="typestat in nodeStatus|filter:search|orderBy:columnName:reverse">
<tr ng-repeat="typestat in nodeStatus|orderBy:columnName:reverse">
<td ng-switch="typestat.port > 0">
<span ng-switch-when="true">
<a href="{{typestat.protocol}}://{{typestat.hostname}}:{{typestat.port}}" target="_blank">{{typestat.hostname}}</a>
Expand Down
71 changes: 47 additions & 24 deletions hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
$scope.reverse = false;
$scope.columnName = "hostname";
let nodeStatusCopy = [];
$scope.filteredNodes = [];
$scope.RecordsToDisplay = "10";
$scope.currentPage = 1;
$scope.lastIndex = 0;
Expand Down Expand Up @@ -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(';')) {
Expand Down Expand Up @@ -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;
Expand Down