[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

@@ -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;