mail: add pagination to mailboxes UI
This commit is contained in:
@@ -20,6 +20,7 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
$scope.incomingDomains = [];
|
||||
$scope.domain = null;
|
||||
$scope.adminDomain = null;
|
||||
$scope.diskUsage = {};
|
||||
|
||||
$scope.expectedDnsRecords = {
|
||||
mx: { },
|
||||
@@ -53,9 +54,13 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
},
|
||||
|
||||
refresh: function () {
|
||||
$scope.catchall.mailboxes = $scope.domain.mailConfig.catchAll.map(function (name) {
|
||||
return $scope.mailboxes.mailboxes.find(function (m) { return m.name === name; });
|
||||
}).filter(function (m) { return !!m; });
|
||||
Client.getMailboxes($scope.domain.domain, '', 1, 1000, function (error, mailboxes) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
$scope.catchall.mailboxes = $scope.domain.mailConfig.catchAll.map(function (name) {
|
||||
return mailboxes.find(function (m) { return m.name === name; });
|
||||
}).filter(function (m) { return !!m; });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -297,6 +302,8 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
$scope.mailboxes = {
|
||||
mailboxes: [],
|
||||
search: '',
|
||||
currentPage: 1,
|
||||
perPage: 10,
|
||||
|
||||
add: {
|
||||
error: null,
|
||||
@@ -427,7 +434,7 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
refresh: function (callback) {
|
||||
callback = typeof callback === 'function' ? callback : function (error) { if (error) return console.error(error); };
|
||||
|
||||
Client.getMailboxes($scope.domain.domain, function (error, mailboxes) {
|
||||
Client.getMailboxes($scope.domain.domain, $scope.mailboxes.search, $scope.mailboxes.currentPage, $scope.mailboxes.perPage, function (error, mailboxes) {
|
||||
if (error) return callback(error);
|
||||
|
||||
$scope.mailboxes.mailboxes = mailboxes;
|
||||
@@ -444,18 +451,30 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
}, function iteratorDone(error) {
|
||||
if (error) return callback(error);
|
||||
|
||||
Client.getMailUsage($scope.domain.domain, function (error, usage) {
|
||||
if (error) return callback(error);
|
||||
|
||||
$scope.mailboxes.mailboxes.forEach(function (m) {
|
||||
var u = usage[m.name + '@' + m.domain]; // this is unset when no emails have been received yet
|
||||
m.usage = (u && u.size) || 0;
|
||||
});
|
||||
|
||||
callback();
|
||||
$scope.mailboxes.mailboxes.forEach(function (m) {
|
||||
var u = $scope.diskUsage[m.name + '@' + m.domain]; // this is unset when no emails have been received yet
|
||||
m.usage = (u && u.size) || 0;
|
||||
});
|
||||
|
||||
callback();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
showNextPage: function () {
|
||||
$scope.mailboxes.currentPage++;
|
||||
$scope.mailboxes.refresh();
|
||||
},
|
||||
|
||||
showPrevPage: function () {
|
||||
if ($scope.mailboxes.currentPage > 1) $scope.mailboxes.currentPage--;
|
||||
else $scope.mailboxes.currentPage = 1;
|
||||
$scope.mailboxes.refresh();
|
||||
},
|
||||
|
||||
updateFilter: function (fresh) {
|
||||
if (fresh) $scope.mailboxes.currentPage = 1;
|
||||
$scope.mailboxes.refresh();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -659,9 +678,12 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
$scope.domain.mailConfig = mailConfig;
|
||||
$scope.domain.mailStatus = {};
|
||||
|
||||
$scope.mailboxes.refresh(function (error) {
|
||||
Client.getMailUsage($scope.domain.domain, function (error, usage) {
|
||||
if (error) console.error(error);
|
||||
|
||||
$scope.diskUsage = usage || {}; // if mail server is down, don't stop the listing
|
||||
|
||||
$scope.mailboxes.refresh(); // relies on disk usage
|
||||
$scope.mailinglists.refresh();
|
||||
$scope.catchall.refresh();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user