mail: Add pagination to lists UI

This commit is contained in:
Girish Ramakrishnan
2020-07-05 11:55:17 -07:00
parent a9a9af9ef7
commit f51eccdef7
3 changed files with 30 additions and 6 deletions
+7 -2
View File
@@ -373,8 +373,13 @@
<div class="text-left">
<h3 style="margin-bottom: 15px;">Mailing Lists
<button class="btn btn-primary btn-outline pull-right" ng-click="mailinglists.add.show()" ng-disabled="!domain.mailConfig.enabled" tooltip-enable="!domain.mailConfig.enabled" uib-tooltip="Email is disabled for this domain"><i class="fa fa-list"></i> New Mailing list</button>
<input class="form-control pull-right" style="width: 200px;" placeholder="Search" type="text" ng-model="mailinglists.search"/>
<button class="btn btn-primary btn-outline pull-right" ng-click="mailinglists.add.show()" ng-disabled="!domain.mailConfig.enabled" tooltip-enable="!domain.mailConfig.enabled" uib-tooltip="Email is disabled for this domain"><i class="fa fa-list"></i> Add</button>
<div class="pull-right">
<button class="btn btn-default btn-outline" ng-click="mailinglists.showPrevPage()" ng-disabled="mailinglists.busy || mailinglists.currentPage <= 1"><i class="fa fa-angle-double-left"></i> prev</button>
<button class="btn btn-default btn-outline" ng-click="mailinglists.showNextPage()" ng-disabled="mailinglists.busy || mailinglists.perPage > mailinglists.mailinglists.length">next <i class="fa fa-angle-double-right"></i></button>
</div>
<input class="form-control pull-right" style="width: 200px;" placeholder="Search" type="text" ng-model="mailinglists.search" ng-model-options="{ debounce: 1000 }" ng-change="mailinglists.updateFilter()" />
</h3>
</div>
+19 -1
View File
@@ -63,6 +63,8 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
busy: false,
mailinglists: [],
search: '',
currentPage: 1,
perPage: 10,
add: {
busy: false,
@@ -179,13 +181,29 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
refresh: function (callback) {
callback = typeof callback === 'function' ? callback : function (error) { if (error) return console.error(error); };
Client.listMailingLists($scope.domain.domain, function (error, result) {
Client.listMailingLists($scope.domain.domain, $scope.mailinglists.search, $scope.mailinglists.currentPage, $scope.mailinglists.perPage, function (error, result) {
if (error) return callback(error);
$scope.mailinglists.mailinglists = result;
callback();
});
},
showNextPage: function () {
$scope.mailinglists.currentPage++;
$scope.mailinglists.refresh();
},
showPrevPage: function () {
if ($scope.mailinglists.currentPage > 1) $scope.mailinglists.currentPage--;
else $scope.mailinglists.currentPage = 1;
$scope.mailinglists.refresh();
},
updateFilter: function (fresh) {
if (fresh) $scope.mailinglists.currentPage = 1;
$scope.mailinglists.refresh();
}
};