2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-31 14:25:30 +00:00

Added pagination in zone history tab

This commit is contained in:
Jay07GIT
2022-07-22 16:58:26 +05:30
parent 94c16361b1
commit 877d4fe76d
4 changed files with 83 additions and 28 deletions

View File

@@ -432,8 +432,16 @@ class VinylDNS @Inject() (
}
def getZoneChange(id: String): Action[AnyContent] = userAction.async { implicit request =>
val queryParameters = new HashMap[String, java.util.List[String]]()
for {
(name, values) <- request.queryString
} queryParameters.put(name, values.asJava)
val vinyldnsRequest =
new VinylDNSRequest("GET", s"$vinyldnsServiceBackend", s"zones/$id/changes")
new VinylDNSRequest(
"GET",
s"$vinyldnsServiceBackend",
s"zones/$id/changes",
parameters = queryParameters)
executeRequest(vinyldnsRequest, request.user).map(response => {
Status(response.status)(response.body)
.withHeaders(cacheHeaders: _*)

View File

@@ -40,26 +40,27 @@
data-toggle="modal"> ACL Rules
</a>
</td>
<td><a>{{zoneChange.zone.adminGroupName}}</a></td>
<td><a ng-bind="zoneChange.zone.adminGroupName" href="/groups/{{zoneChange.zone.adminGroupId}}"></a>
</td>
</tr>
</tbody>
</table>
</div>
<!-- PAGINATION -->
<div class="dataTables_paginate">
<div class="dataTables_paginate vinyldns_zones_paginate">
<span class="vinyldns_zones_page_number">{{ getZoneHistoryPageNumber() }}</span>
<ul class="pagination">
<li class="paginate_button previous">
<a ng-if="changePrevPageEnabled()" ng-click="changePrevPage()" class="paginate_button">Previous</a>
<a ng-if="prevPageEnabled()" ng-click="prevPageZoneHistory()" class="paginate_button">Previous</a>
</li>
<li class="paginate_button next">
<a ng-if="changeNextPageEnabled()" ng-click="changeNextPage()" class="paginate_button">Next</a>
<a ng-if="nextPageEnabled()" ng-click="nextPageAllZoneHistory()" class="paginate_button">Next</a>
</li>
</ul>
</div>
<!-- END PAGINATION -->
</div>
</div>
<div class="panel-footer"></div>
<!-- END SIMPLE DATATABLE -->
@@ -76,12 +77,6 @@
<!-- Modal body -->
<div class="modal-body">
<div class="btn-group">
<button id="refresh-acl-rules-button" class="btn btn-default" ng-click="refreshAclRule()">
<span class="fa fa-refresh"></span> Refresh
</button>
</div>
<table id="aclRuleTable" class="table table-hover table-striped">
<thead>
<tr>
@@ -130,7 +125,7 @@
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>

View File

@@ -16,7 +16,7 @@
angular.module('controller.manageZones', [])
.controller('ManageZonesController', function ($scope, $timeout, $log, recordsService, zonesService, groupsService,
profileService, utilityService) {
profileService, utilityService, pagingService) {
groupsService.getGroupsStored()
.then(function (results) {
@@ -39,7 +39,6 @@ angular.module('controller.manageZones', [])
$scope.alerts = [];
$scope.zoneInfo = {};
$scope.zoneChanges={};
$scope.allAclRules = [];
$scope.updateZoneInfo = {};
$scope.manageZoneState = {
UPDATE: 0,
@@ -76,6 +75,9 @@ angular.module('controller.manageZones', [])
};
$scope.aclRecordTypes = ['A', 'AAAA', 'CNAME', 'DS', 'MX', 'NS', 'PTR', 'SRV', 'NAPTR', 'SSHFP', 'TXT'];
var zoneHistoryPaging = pagingService.getNewPagingParams(100);
/**
* Zone modal control functions
*/
@@ -288,12 +290,14 @@ angular.module('controller.manageZones', [])
};
$scope.refreshZoneChange = function() {
zoneHistoryPaging = pagingService.resetPaging(zoneHistoryPaging);
function success(response) {
$log.log('zonesService::getZoneChanges-success');
zoneHistoryPaging.next = response.data.nextId;
updateZoneChangeDisplay(response.data.zoneChanges);
}
return zonesService
.getZoneChanges($scope.zoneId)
.getZoneChanges(zoneHistoryPaging.maxItems, undefined, $scope.zoneId)
.then(success)
.catch(function (error) {
handleError(error, 'zonesService::getZoneChanges-failure');
@@ -301,12 +305,14 @@ angular.module('controller.manageZones', [])
};
$scope.refreshAclRule = function (index) {
$scope.allAclRules = [];
for (var length = 0; length < $scope.allZonesChange[index].zone.acl.rules.length; length++) {
$scope.allAclRules.push($scope.allZonesChange[index].zone.acl.rules[length]);
getAclUser($scope.allZonesChange[index].zone.acl.rules[length].userId, length, index);
getAclGroup($scope.allZonesChange[index].zone.acl.rules[length].groupId, length, index);
}
if ($scope.allAclRules[length].hasOwnProperty('userId')){
getAclUser($scope.allAclRules[length].userId, length); }
else{ getAclGroup($scope.allAclRules[length].groupId, length);}
}
};
function updateZoneChangeDisplay (zoneChange) {
$scope.allZonesChange = zoneChange;
@@ -314,6 +320,7 @@ angular.module('controller.manageZones', [])
getZoneGroup(zoneChange[length].zone.adminGroupId, length);
getZoneUser(zoneChange[length].userId, length);
}
};
function getZoneGroup(groupId, length) {
@@ -342,10 +349,10 @@ angular.module('controller.manageZones', [])
});
};
function getAclGroup(groupId, length, index) {
function getAclGroup(groupId, length) {
function success(response) {
$log.log('groupsService::getAclGroup-success',length);
$scope.allZonesChange[index].zone.acl.rules[length].groupName = response.data.name;
$log.log('groupsService::getAclGroup-success');
$scope.allAclRules[length].groupName = response.data.name;
}
return groupsService
.getGroup(groupId)
@@ -355,10 +362,10 @@ angular.module('controller.manageZones', [])
});
}
function getAclUser(userId, length, index) {
function getAclUser(userId, length) {
function success(response) {
$log.log('profileService::getAclUserDataById-success',userId, length, index);
$scope.allZonesChange[index].zone.acl.rules[length].userName = response.data.userName;
$log.log('profileService::getAclUserDataById-success');
$scope.allAclRules[length].userName = response.data.userName;
}
return profileService
.getUserDataById(userId)
@@ -368,6 +375,47 @@ angular.module('controller.manageZones', [])
});
};
$scope.getZoneHistoryPageNumber = function() {
return pagingService.getPanelTitle(zoneHistoryPaging);
};
$scope.prevPageEnabled = function() {
return pagingService.prevPageEnabled(zoneHistoryPaging);
};
$scope.nextPageEnabled = function(tab) {
return pagingService.nextPageEnabled(zoneHistoryPaging);
};
$scope.nextPageAllZoneHistory = function () {
return zonesService
.getZoneChanges(zoneHistoryPaging.maxItems, zoneHistoryPaging.next, $scope.zoneId )
.then(function(response) {
var zoneChanges = response.data.zoneChanges;
zoneHistoryPaging = pagingService.nextPageUpdate(zoneChanges, response.data.nextId, zoneHistoryPaging);
if (zoneChanges.length > 0) {
updateZoneChangeDisplay(response.data.zoneChanges);
}
})
.catch(function (error) {
handleError(error,'zonesService::nextPage-failure')
});
};
$scope.prevPageZoneHistory = function() {
var startFrom = pagingService.getPrevStartFrom(zoneHistoryPaging);
return zonesService
.getZoneChanges(zoneHistoryPaging.maxItems, startFrom, $scope.zoneId )
.then(function(response) {
zoneHistoryPaging = pagingService.prevPageUpdate(response.data.nextId, zoneHistoryPaging);
updateZoneChangeDisplay(response.data.zoneChanges);
})
.catch(function (error) {
handleError(error,'zonesService::prevPage-failure');
});
};
$scope.refreshAclRuleDisplay = function() {
$scope.aclRules = [];
angular.forEach($scope.zoneInfo.acl.rules, function (rule) {

View File

@@ -33,8 +33,12 @@ angular.module('service.zones', [])
return $http.get(url);
};
this.getZoneChanges = function (zoneId) {
var url = '/api/zones/' + zoneId + '/changes';
this.getZoneChanges = function (limit, startFrom, zoneId) {
var params = {
"maxItems": limit,
"startFrom": startFrom
}
var url = utilityService.urlBuilder ( "/api/zones/" + zoneId + "/changes", params);
return $http.get(url);
};