Fixup spam configuration UI
This commit is contained in:
+15
-12
@@ -77,29 +77,32 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal change block/allow lists -->
|
||||
<div class="modal fade" id="blockAllowListsChangeModal" tabindex="-1" role="dialog">
|
||||
<!-- Modal change spam config -->
|
||||
<div class="modal fade" id="spamConfigChangeModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Change Lists</h4>
|
||||
<h4 class="modal-title">Spam Filtering</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form name="blockAllowListsChangeForm" role="form" novalidate ng-submit="maxEmailSize.submit()" autocomplete="off">
|
||||
<form name="spamConfigChangeForm" role="form" novalidate ng-submit="spamConfig.submit()" autocomplete="off">
|
||||
<div class="form-group">
|
||||
<label class="control-label">Always allowed origins</label>
|
||||
<textarea ng-model="blockAllowLists.allowList" placeholder="Line separated allowed origins" class="form-control" rows="4"></textarea>
|
||||
<label class="control-label">Blacklisted addresses</label>
|
||||
<p class="small">Matched addresses will end up in the user's Spam folder. '*' and '?' glob patterns are supported.</p>
|
||||
<div class="has-error" ng-show="spamConfig.error.blacklist">{{ spamConfig.error.blacklist }}</div>
|
||||
<textarea ng-model="spamConfig.blacklist" placeholder="Line separated email address patterns" name="blacklist" class="form-control" ng-class="{ 'has-error': !spamConfigChangeForm.blacklist.$dirty && spamConfig.error.blacklist }" rows="4"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">Blocked Origins</label>
|
||||
<textarea ng-model="blockAllowLists.blockList" placeholder="Line separated blocked origins" class="form-control" rows="4"></textarea>
|
||||
<label class="control-label">Custom Spamassassin Config <sup><a ng-href="https://cwiki.apache.org/confluence/display/SPAMASSASSIN/WritingRules" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup></label>
|
||||
<div class="has-error" ng-show="spamConfig.error.config">{{ spamConfig.error.config }}</div>
|
||||
<textarea ng-model="spamConfig.config" placeholder="Custom Spamassassin Rules" class="form-control" name="config" ng-class="{ 'has-error': !spamConfigChangeForm.config.$dirty && spamConfig.error.config }" rows="4"></textarea>
|
||||
</div>
|
||||
<input class="ng-hide" type="submit"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-success" ng-click="blockAllowLists.submit()"><i class="fa fa-circle-notch fa-spin" ng-show="blockAllowLists.busy"></i> Change</button>
|
||||
<button type="button" class="btn btn-success" ng-click="spamConfig.submit()"><i class="fa fa-circle-notch fa-spin" ng-show="spamConfig.busy"></i> Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -220,10 +223,10 @@
|
||||
<span>{{ maxEmailSize.currentSize | prettyDiskSize }} <a href="" ng-click="maxEmailSize.show()"><i class="fa fa-edit text-small"></i></a></span>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<span class="text-muted">Always allowed origins</span>
|
||||
<span class="text-muted">Spam filtering</span>
|
||||
</div>
|
||||
<div class="col-xs-6 text-right">
|
||||
<span>0</span>
|
||||
<span>{{ spamConfig.acl.blacklist.length }} address(es) blacklisted {{ spamConfig.customConfig ? ' + Custom Config' : '' }} <a href="" ng-click="spamConfig.show()"><i class="fa fa-edit text-small"></i></a></span>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<span class="text-muted">Blocked origins</span>
|
||||
@@ -237,7 +240,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button class="btn btn-outline btn-primary pull-right" ng-click="blockAllowLists.show()">Change Block/Allowlists</button>
|
||||
<button class="btn btn-outline btn-primary pull-right" ng-click="spamConfig.show()">Change Block/Allowlists</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+59
-12
@@ -145,26 +145,71 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati
|
||||
}
|
||||
};
|
||||
|
||||
$scope.blockAllowLists = {
|
||||
$scope.spamConfig = {
|
||||
busy: false,
|
||||
error: null,
|
||||
allowList: '',
|
||||
blockList: '',
|
||||
error: {},
|
||||
acl: { whitelist: [], blacklist: [] },
|
||||
customConfig: '',
|
||||
|
||||
config: '',
|
||||
blacklist: '', // currently, we don't support whitelist because it requires user to understand a bit more of what he is doing
|
||||
|
||||
refresh: function () {
|
||||
Client.getSpamCustomConfig(function (error, config) {
|
||||
if (error) return console.error('Failed to get custom spam config', error);
|
||||
|
||||
$scope.spamConfig.customConfig = config;
|
||||
});
|
||||
|
||||
Client.getSpamAcl(function (error, acl) {
|
||||
if (error) return console.error('Failed to get spam acl', error);
|
||||
|
||||
$scope.spamConfig.acl = acl;
|
||||
});
|
||||
},
|
||||
|
||||
show: function() {
|
||||
$scope.blockAllowLists.busy = false;
|
||||
$scope.blockAllowLists.error = null;
|
||||
$scope.blockAllowLists.allowList = '';
|
||||
$scope.blockAllowLists.blockList = '';
|
||||
$scope.spamConfig.busy = false;
|
||||
$scope.spamConfig.error = {};
|
||||
|
||||
$scope.blockAllowListsChangeForm.$setUntouched();
|
||||
$scope.blockAllowListsChangeForm.$setPristine();
|
||||
$scope.spamConfig.blacklist = $scope.spamConfig.acl.blacklist.join('\n');
|
||||
$scope.spamConfig.config = $scope.spamConfig.customConfig;
|
||||
|
||||
$('#blockAllowListsChangeModal').modal('show');
|
||||
$scope.spamConfigChangeForm.$setUntouched();
|
||||
$scope.spamConfigChangeForm.$setPristine();
|
||||
|
||||
$('#spamConfigChangeModal').modal('show');
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
console.log('tbd');
|
||||
$scope.spamConfig.busy = true;
|
||||
$scope.spamConfig.error = {};
|
||||
|
||||
var blacklist = $scope.spamConfig.blacklist.split('\n').filter(function (l) { return l !== ''; });
|
||||
|
||||
Client.setSpamAcl({ blacklist: blacklist, whitelist: [] }, function (error) {
|
||||
if (error) {
|
||||
$scope.spamConfig.busy = false;
|
||||
$scope.spamConfig.error.blacklist = error.message;
|
||||
$scope.spamConfigChangeForm.blacklist.$setPristine();
|
||||
return;
|
||||
}
|
||||
|
||||
Client.setSpamCustomConfig($scope.spamConfig.config, function (error) {
|
||||
if (error) {
|
||||
$scope.spamConfig.busy = false;
|
||||
$scope.spamConfig.error.config = error.message;
|
||||
$scope.spamConfigChangeForm.config.$setPristine();
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.spamConfig.busy = false;
|
||||
|
||||
$scope.spamConfig.refresh();
|
||||
|
||||
$('#spamConfigChangeModal').modal('hide');
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -251,6 +296,8 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati
|
||||
|
||||
$scope.maxEmailSize.currentSize = size;
|
||||
});
|
||||
|
||||
$scope.spamConfig.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user