Initial ui for email relay configuration

This commit is contained in:
Johannes Zellner
2017-06-27 13:39:08 +02:00
parent 82b5c11374
commit 140e9fdd94
2 changed files with 104 additions and 0 deletions

View File

@@ -34,6 +34,79 @@
</div>
</div>
<div class="section-header">
<div class="text-left">
<h3>SMTP Settings</h3>
</div>
</div>
<div class="card" style="margin-bottom: 15px;">
<div class="row">
<div class="col-md-12">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="mailRelay.used"> Relay email using another mail server
</label>
</div>
</div>
</div>
<div class="row" ng-show="mailRelay.used">
<div class="col-md-12">
<div>
<div class="form-group">
<label class="control-label">Presets</label>
<select class="form-control" ng-model="mailRelay.preset" ng-options="a.name for a in mailRelayPresets track by a.id" ng-change="mailRelay.presetChanged()"></select>
</div>
<form name="mailRelayForm" role="form" ng-submit="mailRelay.submit()" autocomplete="off" novalidate>
<!-- Prevent autofill -->
<input type="password" style="display: none;">
<div class="form-group" ng-class="{ 'has-error': (mailRelayForm.smtpHost.$dirty && mailRelayForm.smtpHost.$invalid) }">
<label class="control-label">SMTP Host</label>
<div class="control-label" ng-show="(!mailRelayForm.smtpHost.$dirty && mailRelay.error.smtpHost) || (mailRelayForm.smtpHost.$dirty && mailRelayForm.smtpHost.$invalid)">
<small ng-show="!mailRelayForm.smtpHost.$dirty && mailRelay.error.smtpHost">{{ mailRelay.error.smtpHost }}</small>
</div>
<input type="text" class="form-control" ng-model="mailRelay.smtpHost" name="smtpHost" required>
</div>
<div class="form-group" ng-class="{ 'has-error': (mailRelayForm.smtpPort.$dirty && mailRelayForm.smtpPort.$invalid) }">
<label class="control-label">SMTP Port</label>
<div class="control-label" ng-show="(!mailRelayForm.smtpPort.$dirty && mailRelay.error.smtpPort) || (mailRelayForm.smtpPort.$dirty && mailRelayForm.smtpPort.$invalid)">
<small ng-show="!mailRelayForm.smtpPort.$dirty && mailRelay.error.smtpPort">{{ mailRelay.error.smtpPort }}</small>
</div>
<input type="number" class="form-control" ng-model="mailRelay.smtpPort" name="smtpPort" required>
</div>
<div class="form-group" ng-class="{ 'has-error': (mailRelayForm.username.$dirty && mailRelayForm.username.$invalid) }">
<label class="control-label">Username</label>
<div class="control-label" ng-show="(!mailRelayForm.username.$dirty && mailRelay.error.username) || (mailRelayForm.username.$dirty && mailRelayForm.username.$invalid)">
<small ng-show="!mailRelayForm.username.$dirty && mailRelay.error.username">{{ mailRelay.error.username }}</small>
</div>
<input type="text" class="form-control" ng-model="mailRelay.username" name="username" required>
</div>
<div class="form-group" ng-class="{ 'has-error': (mailRelayForm.password.$dirty && mailRelayForm.password.$invalid) }">
<label class="control-label">Password</label>
<div class="control-label" ng-show="(!mailRelayForm.password.$dirty && mailRelay.error.password) || (mailRelayForm.password.$dirty && mailRelayForm.password.$invalid)">
<small ng-show="!mailRelayForm.password.$dirty && mailRelay.error.password">{{ mailRelay.error.password }}</small>
</div>
<input type="password" class="form-control" ng-model="mailRelay.password" name="password" required>
</div>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="mailRelay.tls"> Use TLS
</label>
</div>
<input class="ng-hide" type="submit" ng-disabled="mailRelayForm.$invalid"/>
</form>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<button class="btn btn-primary pull-right" ng-click="mailRelay.submit()" ng-disabled="!mailRelayForm.$dirty || mailRelayForm.$invalid || mailRelay.busy"><i class="fa fa-circle-o-notch fa-spin" ng-show="mailRelay.busy"></i> Save</button>
</div>
</div>
</div>
<div class="section-header">
<div class="text-left">
<h3>IMAP and SMTP Server</h3>

View File

@@ -84,6 +84,37 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
}
};
$scope.mailRelayPresets = [
{ id: 'custom', name: 'Custom', smtpHost: '', smtpPort: 25, tls: false },
{ id: 'google', name: 'Google', smtpHost: 'smtp.gmail.com', smtpPort: 587, tls: true },
{ id: 'sendgrid', name: 'SendGrid', smtpHost: 'smtp.sendgrid.net', smtpPort: 587, tls: true },
{ id: 'ses', name: 'Amazon SES', smtpHost: 'email-smtp.us-east-1.amazonaws.com', smtpPort: 25, tls: true }
];
$scope.mailRelay = {
error: {},
busy: false,
preset: $scope.mailRelayPresets[0],
presetChanged: function () {
$scope.mailRelay.smtpHost = $scope.mailRelay.preset.smtpHost;
$scope.mailRelay.smtpPort = $scope.mailRelay.preset.smtpPort;
$scope.mailRelay.tls = $scope.mailRelay.preset.tls;
},
// form data to be set on load
used: false,
smtpHost: '',
smtpPort: 25,
username: '',
password: '',
tls: true,
submit: function () {
console.error('Not implemented');
}
};
function getMailConfig() {
Client.getMailConfig(function (error, mailConfig) {
if (error) return console.error(error);