diff --git a/src/js/client.js b/src/js/client.js
index 0ffde954e..5f8176dc4 100644
--- a/src/js/client.js
+++ b/src/js/client.js
@@ -2111,11 +2111,12 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
};
// Mailboxes
- Client.prototype.getMailboxes = function (domain, callback) {
+ Client.prototype.getMailboxes = function (domain, search, page, perPage, callback) {
var config = {
params: {
- page: 1,
- per_page: 1000
+ search: search,
+ page: page,
+ per_page: perPage
}
};
diff --git a/src/views/email.html b/src/views/email.html
index 2a2a61876..2faabf7cf 100644
--- a/src/views/email.html
+++ b/src/views/email.html
@@ -324,9 +324,14 @@
diff --git a/src/views/email.js b/src/views/email.js
index 429dc2da8..791e55246 100644
--- a/src/views/email.js
+++ b/src/views/email.js
@@ -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();
});