Add button to send test email

Fixes #419
This commit is contained in:
Johannes Zellner
2017-09-15 14:21:52 +02:00
parent 09fe957cc7
commit e8a93dcb1b
7 changed files with 85 additions and 5 deletions

View File

@@ -1157,6 +1157,17 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
}).error(defaultErrorHandler(callback));
};
Client.prototype.sentTestMail = function (email, callback) {
var data = {
email: email
};
post('/api/v1/cloudron/send_test_mail', data).success(function(data, status) {
if (status !== 202) return callback(new ClientError(status, data));
callback(null);
}).error(defaultErrorHandler(callback));
};
client = new Client();
return client;
}]);

View File

@@ -26,6 +26,23 @@
</div>
</div>
<!-- Test email sent -->
<div class="modal fade" id="testEmailSent" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Test Email Sent</h4>
</div>
<div class="modal-body">
A test Email was sent to {{ user.email }}. Please check the inbox of this account and verify the Email was delivered.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Ok</button>
</div>
</div>
</div>
</div>
<div class="content">
<div class="text-left">
<h1>Email</h1>
@@ -39,6 +56,7 @@
<div class="row">
<div class="col-md-12">
Cloudron has a built-in <a ng-href="{{ config.webServerOrigin + '/documentation/email/' }}" target="_blank">email server</a> that allows users to send and receive email for your domain.
Apps can send Emails regardless of this setting.
</div>
</div>
<div class="row" ng-show="mailConfig.enabled">
@@ -57,7 +75,7 @@
<br/>
<div class="row">
<div class="col-md-12" ng-show="dnsConfig.provider !== 'caas'">
<button ng-class="mailConfig.enabled ? 'btn btn-danger' : 'btn btn-primary'" ng-click="email.toggle()" ng-enabled="mailConfig">{{ mailConfig.enabled ? "Disable Email" : "Enable Email" }}</button>
<button class="pull-right" ng-class="mailConfig.enabled ? 'btn btn-danger' : 'btn btn-primary'" ng-click="email.toggle()" ng-enabled="mailConfig">{{ mailConfig.enabled ? "Disable Email" : "Enable Email" }}</button>
</div>
<div class="col-md-12" ng-show="dnsConfig.provider === 'caas'">
<span class="text-danger text-bold">This feature requires the Cloudron to be on <a ng-href="{{ config.webServerOrigin + '/documentation/managed-hosting/#using-a-custom-domain' }}" target="_blank">custom domain</a>.</span>
@@ -242,6 +260,11 @@
</div>
</div>
<div class="row">
<div class="col-xs-12">
<button class="btn btn-primary pull-right" ng-click="sendTestEmail()">Send Test Email</button>
</div>
</div>
</div>
</div>
</div>

View File

@@ -158,6 +158,14 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
}
};
$scope.sendTestEmail = function () {
Client.sentTestMail($scope.user.email, function (error) {
if (error) return console.error(error);
$('#testEmailSent').modal('show');
});
};
function getMailConfig() {
Client.getMailConfig(function (error, mailConfig) {
if (error) return console.error(error);