From 0d3d24445e57ab88cc89dc382dde0d0930f947b8 Mon Sep 17 00:00:00 2001 From: bergware Date: Mon, 16 May 2016 13:42:55 +0200 Subject: [PATCH] Enhanced docker edit box [4] Some corrections and added display of "deployed ports" --- .../include/CreateDocker.php | 108 +++++++++++++----- 1 file changed, 77 insertions(+), 31 deletions(-) diff --git a/plugins/dynamix.docker.manager/include/CreateDocker.php b/plugins/dynamix.docker.manager/include/CreateDocker.php index 24013b3b8..65643aaff 100644 --- a/plugins/dynamix.docker.manager/include/CreateDocker.php +++ b/plugins/dynamix.docker.manager/include/CreateDocker.php @@ -2,6 +2,8 @@ /* Copyright 2015, Lime Technology * Copyright 2015, Guilherme Jardim, Eric Schultz, Jon Panozzo. * + * Adaptations by Bergware International (May 2016) + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. @@ -423,6 +425,22 @@ function setXmlVal(&$xml, $value, $el, $attr = null, $pos = 0) { $xml = $dom->saveXML(); } +function getUsedPorts() { + global $dockerManPaths; + $docker = new DockerClient(); + $docker = $docker->getDockerContainers(); + $names = $ports = []; + foreach ($docker as $ct) $names[] = strtolower($ct['Name']); + foreach (glob($dockerManPaths['templates-user'].'/*.xml',GLOB_NOSORT) as $file) { + $name = strtolower(getXmlVal($file,'Name')); + if (!in_array($name,$names)) continue; + $list = []; $p = 0; + $list['Name'] = $name; + while ($port = getXmlVal($file,'HostPort',null,$p++)) $list['Port'] .= $port.' '; + $ports[] = $list; + } + return $ports; +} # ██████╗ ██████╗ ██████╗ ███████╗ # ██╔════╝██╔═══██╗██╔══██╗██╔════╝ @@ -635,10 +653,10 @@ if ($_GET['xmlTemplate']) { echo ""; } } +echo ""; $authoringMode = ($dockercfg["DOCKER_AUTHORING_MODE"] == "yes") ? true : false; $authoring = $authoringMode ? 'advanced' : 'noshow'; $showAdditionalInfo = ''; - ?> @@ -706,7 +724,7 @@ $showAdditionalInfo = ''; } $('#tab'+this_tab).bind({click:function(){$('#'+elementId).show();}}); for (var x=1; x<=last; x++) if(x != this_tab) $('#tab'+x).bind({click:function(){$('#'+elementId).hide();}}); - + $('.advanced-switch').switchButton({ labels_placement: "left", on_label: 'Advanced View', off_label: 'Basic View'}); $('.advanced-switch').change(function () { var status = $(this).is(':checked'); @@ -743,7 +761,7 @@ $showAdditionalInfo = ''; // Create config nodes using templateDisplayConfig function makeConfig(opts) { confNum += 1; - newConfig = $("#templateDisplayConfig").html(); + var newConfig = $("#templateDisplayConfig").html(); newConfig = newConfig.format(opts.Name, opts.Target, opts.Default, @@ -783,6 +801,15 @@ $showAdditionalInfo = ''; return newConfig.prop('outerHTML'); } + function makeUsedPorts(container,current) { + var html = []; + for (var i=0; i < container.length; i++) { + var highlight = container[i].Name.toLowerCase()==current.toLowerCase() ? "color:#F0000C" : ""; + html.push($("#templateUsedPorts").html().format(highlight,container[i].Name,container[i].Port)); + } + return html.join(''); + } + function getVal(el, name) { var el = $(el).find("*[name="+name+"]"); if (el.length) { @@ -841,8 +868,7 @@ $showAdditionalInfo = ''; newConf = makeConfig(Opts); $("#configLocation").append(newConf); reloadTriggers(); - // simulate change - $('input[name="contName"]').trigger('change'); + $('input[name="contName"]').trigger('change'); // signal change }, Cancel: function() { $(this).dialog("close"); @@ -923,9 +949,8 @@ $showAdditionalInfo = ''; $("#configLocation").append(newConf); } } - reloadTriggers(); - // simulate change - $('input[name="contName"]').trigger('change'); + reloadTriggers(); + $('input[name="contName"]').trigger('change'); // signal change }, Cancel: function() { $(this).dialog("close"); @@ -941,8 +966,7 @@ $showAdditionalInfo = ''; function removeConfig(num) { $('#ConfigNum' + num).fadeOut("fast", function() { $(this).remove(); }); - //simulate change - $('input[name="contName"]').trigger('change'); + $('input[name="contName"]').trigger('change'); // signal change } function prepareConfig(form) { @@ -1289,7 +1313,7 @@ $showAdditionalInfo = '';

When you click on an application icon from the Docker Containers page, the WebUI option will link to the path in this field. - Use [IP} to identify the IP of your host and [PORT:####] replacing the #'s for your port.

+ Use [IP] to identify the IP of your host and [PORT:####] replacing the #'s for your port.

@@ -1343,25 +1367,32 @@ $showAdditionalInfo = '';

- - + +
  Show advanced settings ... Show advanced settings ...

- - + + + +
  Add another Path, Port or Variable Show deployed host ports ...
+
+ + + +
Add another Path, Port or Variable

- + @@ -1379,7 +1410,7 @@ $showAdditionalInfo = ''; # ╚█████╔╝███████║ ██║ ███████╗██║ ╚═╝ ██║██║ ███████╗██║ ██║ ██║ ███████╗███████║ # ╚════╝ ╚══════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝ ?> - - -
  - + - +
- - - - + + + +
{13}: -  {10} -
{12}
-
{13}: {10}
{12}