From a0332d279bb90e9849d52315f1c57562bfce5058 Mon Sep 17 00:00:00 2001 From: Alexandre Vazquez Date: Sun, 27 Mar 2016 16:03:11 +0200 Subject: [PATCH] Updating the branch to the latest master and making it work with the new docker daemon evolutions --- .../ContainerSettingsPorts.react.js | 45 ++++++++++--------- src/utils/DockerUtil.js | 1 + 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/components/ContainerSettingsPorts.react.js b/src/components/ContainerSettingsPorts.react.js index b3c75e1d92..2e5a086433 100644 --- a/src/components/ContainerSettingsPorts.react.js +++ b/src/components/ContainerSettingsPorts.react.js @@ -45,22 +45,24 @@ var ContainerSettingsPorts = React.createClass({ document.getElementById('portValue').value = ''; }, addPort: function () { - var portKey = document.getElementById('portKey').value; - var portValue = document.getElementById('portValue').value; - var portTypeValue = document.getElementById('portType').textContent; - var ports = this.state.ports; - if (portKey !== '') { - ports[portKey] = { - ip: docker.host, - url: docker.host + ':' + portValue, - port: portValue, - portType: portTypeValue.trim(), - error: null - }; + if (document.getElementById('portKey') != null){ + var portKey = document.getElementById('portKey').value; + var portValue = document.getElementById('portValue').value; + var portTypeValue = document.getElementById('portType').textContent; + var ports = this.state.ports; + if (portKey !== '') { + ports[portKey] = { + ip: docker.host, + url: docker.host + ':' + portValue, + port: portValue, + portType: portTypeValue.trim(), + error: null + }; - this.checkPort(ports, portKey, portKey); - if (ports[portKey].error === null) { - this.createEmptyPort(ports); + this.checkPort(ports, portKey, portKey); + if (ports[portKey].error === null) { + this.createEmptyPort(ports); + } } } return ports; @@ -169,20 +171,19 @@ var ContainerSettingsPorts = React.createClass({ let ports = this.state.ports; ports = this.addPort(); this.setState({ports: ports}); - let bindings = _.reduce(ports, (res, value, key) => { + let exposedPorts = {}; + let portBindings = _.reduce(ports, (res, value, key) => { if (key !== '') { res[key + '/' + value.portType] = [{ HostPort: value.port }]; + exposedPorts[key + '/' + value.portType] = {}; } return res; }, {}); - containerActions.update(this.props.container.Name, { - NetworkSettings: { - Ports: bindings - } - }); + let hostConfig = _.extend(this.props.container.HostConfig, {PortBindings: portBindings}); + containerActions.update(this.props.container.Name, {ExposedPorts: exposedPorts, HostConfig: hostConfig}); }, render: function () { @@ -201,7 +202,7 @@ var ContainerSettingsPorts = React.createClass({ var portKey = ''; var portValue = ''; if (key === '') { - icon = ; + icon = ; portKey = ; portValue = ; }else { diff --git a/src/utils/DockerUtil.js b/src/utils/DockerUtil.js index 1a469facfc..1d8e8bcb50 100644 --- a/src/utils/DockerUtil.js +++ b/src/utils/DockerUtil.js @@ -296,6 +296,7 @@ export default { data.Mounts = data.Mounts || existingData.Mounts; var fullData = _.extend(existingData, data); + console.log(fullData); this.createContainer(name, fullData); }); },