[Web] Add search fields to some select forms

[Web] Better container restart js, but still a wip
[Web] Allow to set a DOCKER_TIMEOUT in vars.inc.php, default is 60 (seconds)
This commit is contained in:
André 2018-07-23 20:01:01 +02:00
parent 7de2607594
commit cedc38fbaa
10 changed files with 74 additions and 32 deletions

View File

@ -135,4 +135,7 @@ nav .glyphicon {
}
#top {
padding-top: 70px;
}
.bootstrap-select.btn-group .no-results {
display: none;
}

View File

@ -80,7 +80,7 @@ if (isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group">
<label class="control-label col-sm-2" for="domains"><?=$lang['edit']['domains'];?></label>
<div class="col-sm-10">
<select id="domains" name="domains" multiple required>
<select data-live-search="true" id="domains" name="domains" multiple required>
<?php
foreach ($result['selected_domains'] as $domain):
?>
@ -186,7 +186,7 @@ if (isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group">
<label class="control-label col-sm-2" for="quota">Relayhost</label>
<div class="col-sm-10">
<select name="relayhost" id="relayhost" class="form-control">
<select data-live-search="true" name="relayhost" id="relayhost" class="form-control">
<?php
foreach ($rlyhosts as $rlyhost) {
?>
@ -408,7 +408,7 @@ if (isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group">
<label class="control-label col-sm-2" for="sender_acl"><?=$lang['edit']['sender_acl'];?>:</label>
<div class="col-sm-10">
<select data-width="100%" style="width:100%" id="sender_acl" name="sender_acl" size="10" multiple>
<select data-live-search="true" data-width="100%" style="width:100%" id="sender_acl" name="sender_acl" size="10" multiple>
<?php
$sender_acl_handles = mailbox('get', 'sender_acl_handles', $mailbox);

View File

@ -203,27 +203,29 @@ $(document).ready(function() {
$('#triggerRestartContainer').click(function(){
$(this).prop("disabled",true);
$(this).html('<span class="glyphicon glyphicon-refresh glyphicon-spin"></span> ');
$('#statusTriggerRestartContainer').text('Restarting container, this may take a while... ');
$('#statusTriggerRestartContainer2').text('Reloading webpage... ');
$('#statusTriggerRestartContainer').html('<?= $lang['footer']['restarting_container']; ?>');
$.ajax({
method: 'get',
url: '/inc/ajax/container_ctrl.php',
timeout: 10000,
timeout: <?= $DOCKER_TIMEOUT * 1000; ?>,
data: {
'service': container,
'action': 'restart'
},
error: function() {
window.location = window.location.href.split("#")[0];
},
success: function(data) {
$('#statusTriggerRestartContainer').append(data);
$('#triggerRestartContainer').html('<span class="glyphicon glyphicon-ok"></span> ');
$('#statusTriggerRestartContainer2').append(data);
$('#triggerRestartContainer').html('<span class="glyphicon glyphicon-ok"></span> ');
window.location = window.location.href.split("#")[0];
'service': container,
'action': 'restart'
}
});
})
.always( function (data, status) {
$('#statusTriggerRestartContainer').append(data);
var htmlResponse = $.parseHTML(data)
if ($(htmlResponse).find('span').hasClass('text-success')) {
$('#triggerRestartContainer').html('<span class="glyphicon glyphicon-ok"></span> ');
setTimeout(function(){
$('#RestartContainer').modal('toggle');
window.location = window.location.href.split("#")[0];
}, 1200);
} else {
$('#triggerRestartContainer').html('<span class="glyphicon glyphicon-remove"></span> ');
}
})
});
})

View File

@ -1,5 +1,6 @@
<?php
function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_headers = null) {
global $DOCKER_TIMEOUT;
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER,array( 'Content-Type: application/json' ));
switch($action) {
@ -7,7 +8,7 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_TIMEOUT, $DOCKER_TIMEOUT);
$response = curl_exec($curl);
if ($response === false) {
$err = curl_error($curl);
@ -30,7 +31,7 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_TIMEOUT, $DOCKER_TIMEOUT);
$response = curl_exec($curl);
if ($response === false) {
$err = curl_error($curl);
@ -55,7 +56,7 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_TIMEOUT, $DOCKER_TIMEOUT);
$response = curl_exec($curl);
if ($response === false) {
$err = curl_error($curl);
@ -82,7 +83,7 @@ function docker($service_name, $action, $attr1 = null, $attr2 = null, $extra_hea
if (ctype_xdigit($container_id) && ctype_alnum($attr1)) {
curl_setopt($curl, CURLOPT_URL, 'http://dockerapi:8080/containers/' . $container_id . '/' . $attr1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_TIMEOUT, $DOCKER_TIMEOUT);
if (!empty($attr2)) {
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($attr2));
}

View File

@ -0,0 +1,32 @@
<?xml version='1.0' standalone='yes'?>
<extension name="vacation-seconds">
<command name="vacation">
<parameter type="tag" name="seconds" occurrence="optional" regex="seconds">
<parameter type="number" name="period" />
</parameter>
<parameter type="tag" name="addresses" occurrence="optional" regex="addresses">
<parameter type="stringlist" name="address strings" />
</parameter>
<parameter type="tag" name="subject" occurrence="optional" regex="subject">
<parameter type="string" name="subject string" />
</parameter>
<parameter type="tag" name="from" occurrence="optional" regex="from">
<parameter type="string" name="from string" />
</parameter>
<parameter type="tag" name="handle" occurrence="optional" regex="handle">
<parameter type="string" name="handle string" />
</parameter>
<parameter type="tag" name="mime" occurrence="optional" regex="mime" />
<parameter type="string" name="reason" />
</command>
</extension>

View File

@ -116,3 +116,6 @@ $OTP_LABEL = "mailcow UI";
// Default "to" address in relay test tool
$RELAY_TO = "null@hosted.mailcow.de";
// How long to wait (in s) for cURL Docker requests
$DOCKER_TIMEOUT = 60;

View File

@ -8,7 +8,8 @@ $lang['header']['restart_sogo'] = 'SOGo neustarten';
$lang['header']['restart_netfilter'] = 'Netfilter neustarten';
$lang['footer']['restart_container'] = 'Container neustarten';
$lang['footer']['restart_now'] = 'Jetzt neustarten';
$lang['footer']['restart_container_info'] = '<b>Wichtig:</b> Ein korrekter Neustart eines Containers kann eine Weile in Anspruch nehmen, bitte warten Sie, bis der Prozess vollständig beendet wurde.';
$lang['footer']['restarting_container'] = 'Container wird neugestartet, bitte warten...';
$lang['footer']['restart_container_info'] = '<b>Wichtig:</b> Der Neustart eines Containers kann eine Weile in Anspruch nehmen, bitte warten Sie, bis der Prozess vollständig beendet wurde.<br>Die Website wird neugeladen, wenn der Vorgang erfolgreich ist.';
$lang['footer']['confirm_delete'] = 'Löschen bestätigen';
$lang['footer']['delete_these_items'] = 'Sind Sie sicher, dass die Änderungen an Elementen mit folgender ID durchgeführt werden sollen?';

View File

@ -8,7 +8,8 @@ $lang['header']['restart_sogo'] = 'Restart SOGo';
$lang['header']['restart_netfilter'] = 'Restart netfilter';
$lang['footer']['restart_container'] = 'Restart container';
$lang['footer']['restart_now'] = 'Restart now';
$lang['footer']['restart_container_info'] = '<b>Important:</b> A graceful restart may take a while to complete, please wait for it to finish.';
$lang['footer']['restarting_container'] = 'Restarting container, this may take a while...';
$lang['footer']['restart_container_info'] = '<b>Important:</b> A graceful restart may take a while to complete, please wait for it to finish.<br>This website will reload if the process succeeded.';
$lang['footer']['confirm_delete'] = 'Confirm deletion';
$lang['footer']['delete_these_items'] = 'Please confirm your changes to the following object id:';

View File

@ -196,7 +196,6 @@ if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'admi
<button class="btn btn-md btn-primary" id="triggerRestartContainer"><?= $lang['footer']['restart_now']; ?></button>
<br><br>
<div id="statusTriggerRestartContainer"></div>
<div id="statusTriggerRestartContainer2"></div>
</div>
</div>
</div>

View File

@ -23,7 +23,7 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group">
<label class="control-label col-sm-2" for="domain"><?=$lang['add']['domain'];?>:</label>
<div class="col-sm-10">
<select id="addSelectDomain" name="domain" id="domain" required>
<select data-live-search="true" id="addSelectDomain" name="domain" id="domain" required>
<?php
foreach (mailbox('get', 'domains') as $domain) {
echo "<option>".htmlspecialchars($domain)."</option>";
@ -172,7 +172,7 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group">
<label class="control-label col-sm-2" for="domain"><?=$lang['add']['domain'];?>:</label>
<div class="col-sm-10">
<select name="domain" id="domain" title="<?=$lang['add']['select'];?>" required>
<select data-live-search="true" name="domain" id="domain" title="<?=$lang['add']['select'];?>" required>
<?php
foreach (mailbox('get', 'domains') as $domain) {
echo "<option>".htmlspecialchars($domain)."</option>";
@ -289,7 +289,7 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group">
<label class="control-label col-sm-2" for="target_domain"><?=$lang['add']['target_domain'];?></label>
<div class="col-sm-10">
<select name="target_domain" id="target_domain" title="<?=$lang['add']['select'];?>" required>
<select data-live-search="true" name="target_domain" id="target_domain" title="<?=$lang['add']['select'];?>" required>
<?php
foreach (mailbox('get', 'domains') as $domain) {
echo "<option>".htmlspecialchars($domain)."</option>";
@ -329,7 +329,7 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group">
<label class="control-label col-sm-2" for="username"><?=$lang['add']['username'];?>:</label>
<div class="col-sm-10">
<select id="addSelectUsername" name="username" id="username" required>
<select data-live-search="true" id="addSelectUsername" name="username" id="username" required>
<?php
$domains = mailbox('get', 'domains');
if (!empty($domains)) {
@ -477,7 +477,7 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group">
<label class="control-label col-sm-2" for="username"><?=$lang['add']['username'];?>:</label>
<div class="col-sm-10">
<select id="addSelectUsername" name="username" id="username" required>
<select data-live-search="true" id="addSelectUsername" name="username" id="username" required>
<?php
$domains = mailbox('get', 'domains');
if (!empty($domains)) {
@ -545,7 +545,7 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group">
<label class="control-label col-sm-2" for="local_dest"><?=$lang['mailbox']['bcc_local_dest'];?>:</label>
<div class="col-sm-10">
<select id="addSelectLocalDest" name="local_dest" id="local_dest" required>
<select data-live-search="true" id="addSelectLocalDest" name="local_dest" id="local_dest" required>
<?php
$domains = mailbox('get', 'domains');
$alias_domains = mailbox('get', 'alias_domains');