mail from validation: add busy indicator

This commit is contained in:
Girish Ramakrishnan
2020-02-27 10:47:14 -08:00
parent 3c7e28c768
commit 0515b650ca
2 changed files with 23 additions and 6 deletions

View File

@@ -520,7 +520,10 @@
Masquerading allows users and apps to send emails with an arbitrary username in the FROM address
</div>
<div class="col-md-2">
<button ng-class="domain.mailConfig.mailFromValidation ? 'btn btn-danger' : 'btn btn-primary'" ng-click="toggleMailFromValidation()">{{ domain.mailConfig.mailFromValidation ? "Enable" : "Disable" }}</button>
<button ng-class="domain.mailConfig.mailFromValidation ? 'btn btn-danger' : 'btn btn-primary'" ng-disabled="mailFromValidation.busy" ng-click="mailFromValidation.submit()">
<i class="fa fa-circle-notch fa-spin" ng-show="mailFromValidation.busy"></i>
{{ domain.mailConfig.mailFromValidation ? "Enable" : "Disable" }}
</button>
</div>
</div>
</div>

View File

@@ -184,11 +184,25 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
}
};
$scope.toggleMailFromValidation = function () {
Client.setMailFromValidation($scope.domain.domain, !$scope.domain.mailConfig.mailFromValidation, function (error) {
if (error) return console.error(error);
$scope.refreshDomain();
});
$scope.mailFromValidation = {
busy: false,
submit: function () {
$scope.mailFromValidation.busy = true;
Client.setMailFromValidation($scope.domain.domain, !$scope.domain.mailConfig.mailFromValidation, function (error) {
if (error) {
$scope.mailFromValidation.busy = false;
return console.error(error);
}
// give sometime for the mail container to restart
$timeout(function () {
$scope.mailFromValidation.busy = false;
$scope.refreshDomain();
}, 5000);
});
}
};
$scope.incomingEmail = {