diff --git a/emhttp/plugins/dynamix.docker.manager/AddContainer.page b/emhttp/plugins/dynamix.docker.manager/AddContainer.page index 6a4b65895d..91b869c3ec 100755 --- a/emhttp/plugins/dynamix.docker.manager/AddContainer.page +++ b/emhttp/plugins/dynamix.docker.manager/AddContainer.page @@ -22,5 +22,10 @@ if (substr($_SERVER['REQUEST_URI'],0,7) != '/Docker') { $docker = "$docroot/languages/$locale/docker.dot"; if (file_exists($docker)) $language = array_merge($language,unserialize(file_get_contents($docker))); } +// Avoid blocking other browser tabs by releasing the PHP session lock +// before running long-running container creation logic. +if (session_status() === PHP_SESSION_ACTIVE) { + session_write_close(); +} eval('?>'.parse_file("$docroot/plugins/dynamix.docker.manager/include/CreateDocker.php")); ?> \ No newline at end of file diff --git a/emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php b/emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php index 739c7cce58..cb32fc1923 100755 --- a/emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php +++ b/emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php @@ -68,6 +68,63 @@ function cpu_pinning() { ## CREATE CONTAINER ## ########################## +// Simple UI blocker used by create/update operations so the user can't keep clicking around mid-install. +function dockerUIBlockerScript($enable) { + if ($enable) { + echo << +(function () { + try { + var d = (window.parent && window.parent.document) ? window.parent.document : document; + if (!d || !d.body) return; + + // Define helpers once. + if (!window.parent) window.parent = window; + if (!window.parent.dockerUIBlock) { + window.parent.dockerUIBlock = function (on) { + try { + var doc = (window.parent && window.parent.document) ? window.parent.document : document; + if (!doc || !doc.body) return; + + var blockerId = 'dockerInstallBlocker'; + var blockerClass = 'docker-install-blocker'; + + if (!on) { + var o = doc.getElementById(blockerId); + if (o) o.remove(); + return; + } + + var o2 = doc.getElementById(blockerId); + if (!o2) { + o2 = doc.createElement('div'); + o2.id = blockerId; + o2.className = blockerClass; + doc.body.appendChild(o2); + } + } catch (e) {} + }; + } + + window.parent.dockerUIBlock(true); + } catch (e) {} +})(); + +HTML; + } else { + echo << +(function () { + try { + var w = window.parent || window; + if (w && w.dockerUIBlock) w.dockerUIBlock(false); + } catch (e) {} +})(); + +HTML; + } +} + if (isset($_POST['contName'])) { $postXML = postToXML($_POST, true); $dry_run = isset($_POST['dryRun']) && $_POST['dryRun']=='true'; @@ -76,6 +133,8 @@ function cpu_pinning() { // Get the command line [$cmd, $Name, $Repository] = xmlToCommand($postXML, $create_paths); readfile("$docroot/plugins/dynamix.docker.manager/log.htm"); + echo ''; + if (!$dry_run) dockerUIBlockerScript(true); @flush(); // Saving the generated configuration file. $userTmplDir = $dockerManPaths['templates-user']; @@ -114,6 +173,7 @@ function cpu_pinning() { if (!$DockerClient->doesImageExist($Repository)) { // Pull image if (!pullImage($Name, $Repository)) { + dockerUIBlockerScript(false); echo '