Fix mail server location UI

This commit is contained in:
Girish Ramakrishnan
2020-08-20 23:06:22 -07:00
parent f6fef21bf7
commit eb69c365fc
3 changed files with 94 additions and 22 deletions
+37 -11
View File
@@ -3,7 +3,7 @@
/* global angular:false */
/* global $:false */
angular.module('Application').controller('EmailsController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
angular.module('Application').controller('EmailsController', ['$scope', '$location', '$timeout', 'Client', function ($scope, $location, $timeout, Client) {
Client.onReady(function () { if (!Client.getUserInfo().isAtLeastAdmin) $location.path('/'); });
$scope.ready = false;
@@ -72,24 +72,43 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati
}
};
$scope.mailDomainChange = {
$scope.mailLocation = {
busy: false,
error: null,
mailDomain: '',
currentLocation: { domain: null, subdomain: '' },
domain: null,
subdomain: '',
show: function () {
$scope.mailDomainChange.busy = false;
$scope.mailDomainChange.error = null;
$scope.mailDomainChange.mailDomain = $scope.config.mailFqdn;
$scope.mailLocation.busy = false;
$scope.mailLocation.error = null;
$scope.mailDomainChangeForm.$setUntouched();
$scope.mailDomainChangeForm.$setPristine();
$scope.mailLocation.domain = $scope.mailLocation.currentLocation.domain;
$scope.mailLocation.subdomain = $scope.mailLocation.currentLocation.subdomain;
console.log($scope.mailLocation.location);
$('#mailDomainChangeModal').modal('show');
$scope.mailLocationForm.$setUntouched();
$scope.mailLocationForm.$setPristine();
$('#mailLocationModal').modal('show');
},
submit: function () {
console.log('tbd');
$scope.mailLocation.busy = true;
Client.setMailLocation($scope.mailLocation.subdomain, $scope.mailLocation.domain.domain, function (error) {
if (error) {
$scope.mailLocation.busy = false;
$scope.mailLocation.error = error;
return;
}
$timeout(function () {
$scope.mailLocation.currentLocation = { subdomain: $scope.mailLocation.subdomain, domain: $scope.mailLocation.domain };
$scope.mailLocation.busy = false;
$('#mailLocationModal').modal('hide');
}, 3000);
});
}
};
@@ -147,7 +166,7 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati
submit: function () {
console.log('tbd');
}
}
},
$scope.testEmail = {
busy: false,
@@ -244,6 +263,13 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati
if ($scope.user.role === 'owner') $scope.activity.refresh();
Client.getMailLocation(function (error, location) {
if (error) return console.error('Failed to get max email location', error);
$scope.mailLocation.currentLocation.subdomain = location.subdomain;
$scope.mailLocation.currentLocation.domain = $scope.domains.find(function (d) { return location.domain === d.domain; });
});
refreshDomainStatuses();
});
});