[Web] Restart SOGo after adding a new domain, fixes #864

master
andre.peters 2018-01-11 22:40:43 +01:00
parent 0d8c7e446a
commit 278f1c2a37
6 changed files with 37 additions and 6 deletions

View File

@ -13,6 +13,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/modals/footer.php';
<script src="/js/u2f-api.js"></script>
<script src="/js/api.js"></script>
<script>
var loading_text = '<?= $lang['footer']['loading']; ?>'
$(window).scroll(function() {
sessionStorage.scrollTop = $(this).scrollTop();
});
@ -157,7 +158,7 @@ $(document).ready(function() {
}
})();
// Disable submit after submitting form
// Disable submit after submitting form (not API driven buttons)
$('form').submit(function() {
if ($('form button[type="submit"]').data('submitted') == '1') {
return false;

View File

@ -333,6 +333,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
$aliases = $_data['aliases'];
$mailboxes = $_data['mailboxes'];
$maxquota = $_data['maxquota'];
$restart_sogo = $_data['restart_sogo'];
$quota = $_data['quota'];
if ($maxquota > $quota) {
$_SESSION['return'] = array(
@ -416,11 +417,22 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
);
return false;
}
if (!empty($restart_sogo)) {
$restart_reponse = json_decode(docker('sogo-mailcow', 'post', 'restart'), true);
if ($restart_reponse['type'] == "success") {
$_SESSION['return'] = array(
'type' => 'success',
'msg' => sprintf($lang['success']['domain_added'], htmlspecialchars($domain))
);
}
else {
$_SESSION['return'] = array(
'type' => 'warning',
'msg' => 'Added domain but failed to restart SOGo, please check your server logs.'
);
}
}
}
catch (PDOException $e) {
mailbox('delete', 'domain', array('domain' => $domain));
$_SESSION['return'] = array(

View File

@ -1,4 +1,15 @@
$(document).ready(function() {
function is_active(elem) {
if ($(elem).data('submitted') == '1') {
return true;
} else {
$(elem).text(loading_text);
$(elem).attr('data-submitted', '1');
function disableF5(e) { if ((e.which || e.keyCode) == 116 || (e.which || e.keyCode) == 82) e.preventDefault(); };
$(document).on("keydown", disableF5);
return false;
}
}
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
@ -115,6 +126,7 @@ $(document).ready(function() {
api_items = multi_data[id];
// alert(JSON.stringify(api_attr));
if (Object.keys(api_items).length !== 0) {
if (is_active($(this))) { return false; }
$.ajax({
type: "POST",
dataType: "json",
@ -185,6 +197,7 @@ $(document).ready(function() {
return false;
}
}
if (is_active($(this))) { return false; }
// alert(JSON.stringify(api_attr));
$.ajax({
type: "POST",

View File

@ -493,6 +493,8 @@ $lang['admin']['dkim_key_unused'] = 'Key ohne Zuweisung';
$lang['admin']['dkim_key_missing'] = 'Key fehlt';
$lang['admin']['dkim_key_hint'] = 'Der Selector für DKIM-Keys lautet immer <code>dkim</code>.';
$lang['admin']['add'] = 'Hinzufügen';
$lang['add']['add_domain_restart'] = 'Domain hinzufügen und SOGo neustarten';
$lang['add']['add_domain_only'] = 'Nur Domain hinzufügen';
$lang['admin']['configuration'] = 'Konfiguration';
$lang['admin']['password'] = 'Passwort';
$lang['admin']['password_repeat'] = 'Passwort (Wiederholung)';

View File

@ -499,6 +499,8 @@ $lang['admin']['sys_info'] = 'System information';
$lang['admin']['dkim_add_key'] = 'Add ARC/DKIM key';
$lang['admin']['dkim_keys'] = 'ARC/DKIM keys';
$lang['admin']['add'] = 'Add';
$lang['add']['add_domain_restart'] = 'Add domain and restart SOGo';
$lang['add']['add_domain_only'] = 'Add domain only';
$lang['admin']['configuration'] = 'Configuration';
$lang['admin']['password'] = 'Password';
$lang['admin']['password_repeat'] = 'Confirmation password (repeat)';

View File

@ -143,7 +143,8 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button class="btn btn-default" id="add_item" data-id="add_domain" data-api-url='add/domain' data-api-attr='{}' href="#"><?=$lang['admin']['add'];?></button>
<button class="btn btn-default" id="add_item" data-id="add_domain" data-api-url='add/domain' data-api-attr='{}' href="#"><?=$lang['add']['add_domain_only'];?></button>
<button class="btn btn-default" id="add_item" data-id="add_domain" data-api-url='add/domain' data-api-attr='{"restart_sogo":"1"}' href="#"><?=$lang['add']['add_domain_restart'];?></button>
</div>
</div>
<p><span class="glyphicon glyphicon-exclamation-sign text-danger"></span> <?=$lang['add']['restart_sogo_hint'];?></p>