Merge pull request #654 from TeckniX/add-tty-stdin

Added support for docker tty stdin options
This commit is contained in:
Jeffrey Morgan 2015-06-18 10:19:17 -07:00
commit 11739f0eac
3 changed files with 39 additions and 3 deletions

View File

@ -22,10 +22,14 @@ var ContainerSettingsGeneral = React.createClass({
return [util.randomId(), e[0], e[1]];
});
let [tty, openStdin] = ContainerUtil.mode(this.props.container) || [true, true];
return {
slugName: null,
nameError: null,
env: env
env: env,
tty: tty,
openStdin: openStdin
};
},
@ -90,7 +94,9 @@ var ContainerSettingsGeneral = React.createClass({
list.push(key + '=' + value);
}
});
containerActions.update(this.props.container.Name, {Env: list});
let tty = this.state.tty;
let openStdin = this.state.openStdin;
containerActions.update(this.props.container.Name, {Env: list, Tty: tty, OpenStdin: openStdin});
},
handleChangeEnvKey: function (index, event) {
@ -133,6 +139,18 @@ var ContainerSettingsGeneral = React.createClass({
metrics.track('Removed Environment Variable');
},
handleChangeTty: function () {
this.setState({
tty: !this.state.tty
});
},
handleChangeOpenStdin: function () {
this.setState({
openStdin: !this.state.openStdin
});
},
handleDeleteContainer: function () {
dialog.showMessageBox({
message: 'Are you sure you want to delete this container?',
@ -211,6 +229,13 @@ var ContainerSettingsGeneral = React.createClass({
<div className="env-vars">
{vars}
</div>
</div>
<div className="settings-section">
<div className="env-vars">
<h4>Advanced Options</h4>
<p><input type="checkbox" checked={this.state.tty} onChange={this.handleChangeTty}/> Attach standard streams to a tty, including stdin if it is not closed</p>
<p><input type="checkbox" checked={this.state.openStdin} onChange={this.handleChangeOpenStdin}/> Keep STDIN open even if not attached</p>
</div>
<a className="btn btn-action" disabled={this.props.container.State.Updating} onClick={this.handleSaveEnvVars}>Save</a>
</div>
<div className="settings-section">

View File

@ -13,6 +13,14 @@ var ContainerUtil = {
});
},
// Provide Foreground options
mode: function (container) {
if (!container || !container.Config) {
return [true, true];
}
return [container.Config.Tty, container.Config.OpenStdin];
},
// TODO: inject host here instead of requiring Docker
ports: function (container) {
if (!container || !container.NetworkSettings) {

View File

@ -101,6 +101,7 @@ export default {
containerData.Env = containerData.Config.Env;
}
containerData.Volumes = _.mapObject(containerData.Volumes, () => {return {};});
let existing = this.client.getContainer(name);
@ -160,6 +161,8 @@ export default {
Config: {
Image: imageName,
},
Tty: true,
OpenStdin: true,
State: {
Downloading: true
}
@ -181,7 +184,7 @@ export default {
delete this.placeholders[name];
localStorage.setItem('placeholders', JSON.stringify(this.placeholders));
this.createContainer(name, {Image: imageName});
this.createContainer(name, {Image: imageName, Tty: true, OpenStdin: true});
},
// progress is actually the progression PER LAYER (combined in columns)