Adding terminal button

This commit is contained in:
Jeffrey Morgan 2015-01-27 11:13:48 -05:00
parent d9ec2203e4
commit 03b24bb849
3 changed files with 18 additions and 9 deletions

View File

@ -3,6 +3,7 @@ var $ = require('jquery');
var React = require('react/addons'); var React = require('react/addons');
var Router = require('react-router'); var Router = require('react-router');
var exec = require('exec'); var exec = require('exec');
var path = require('path');
var remote = require('remote'); var remote = require('remote');
var dialog = remote.require('dialog'); var dialog = remote.require('dialog');
var ContainerStore = require('./ContainerStore'); var ContainerStore = require('./ContainerStore');
@ -114,6 +115,16 @@ var ContainerDetails = React.createClass({
}); });
}); });
}, },
handleTerminal: function () {
var container = this.props.container;
var terminal = path.join(process.cwd(), 'resources', 'terminal').replace(/ /g, '\\\\ ');
var cmd = [terminal, boot2docker.command().replace(/ /g, '\\\\ '), 'ssh', '-t', 'sudo', 'docker', 'exec', '-i', '-t', container.Name, 'bash'];
exec(cmd, function (stderr, stdout, code) {
if (code) {
console.log(stderr);
}
});
},
handleSaveEnvVar: function () { handleSaveEnvVar: function () {
var $rows = $('.env-vars .keyval-row'); var $rows = $('.env-vars .keyval-row');
var envVarList = []; var envVarList = [];
@ -303,7 +314,7 @@ var ContainerDetails = React.createClass({
</div> </div>
<div className="details-header-actions"> <div className="details-header-actions">
<div className="action btn-group"> <div className="action btn-group">
<a className={buttonClass} onClick={this.handleView}><span className="icon icon-preview-2"></span><span className="content">View</span></a><a className="btn btn-action with-icon dropdown-toggle"><span className="icon-dropdown icon icon-arrow-37"></span></a> <a className={buttonClass} onClick={this.handleView}><span className="icon icon-preview-2"></span><span className="content">View</span></a><a className={dropdownButtonClass}><span className="icon-dropdown icon icon-arrow-37"></span></a>
</div> </div>
<div className="action"> <div className="action">
<a className={dropdownButtonClass} onClick={this.handleView}><span className="icon icon-folder-1"></span> <span className="content">Volumes</span> <span className="icon-dropdown icon icon-arrow-37"></span></a> <a className={dropdownButtonClass} onClick={this.handleView}><span className="icon icon-folder-1"></span> <span className="content">Volumes</span> <span className="icon-dropdown icon icon-arrow-37"></span></a>
@ -312,7 +323,7 @@ var ContainerDetails = React.createClass({
<a className={buttonClass} onClick={this.handleView}><span className="icon icon-refresh"></span> <span className="content">Restart</span></a> <a className={buttonClass} onClick={this.handleView}><span className="icon icon-refresh"></span> <span className="content">Restart</span></a>
</div> </div>
<div className="action"> <div className="action">
<a className={buttonClass} onClick={this.handleView}><span className="icon icon-window-code-3"></span> <span className="content">Terminal</span></a> <a className={buttonClass} onClick={this.handleTerminal}><span className="icon icon-window-code-3"></span> <span className="content">Terminal</span></a>
</div> </div>
<div className="details-header-actions-rhs tabs btn-group"> <div className="details-header-actions-rhs tabs btn-group">
<a className={textButtonClasses} onClick={this.showLogs}><span className="icon icon-text-wrapping-2"></span></a> <a className={textButtonClasses} onClick={this.showLogs}><span className="icon icon-text-wrapping-2"></span></a>

View File

@ -10,7 +10,7 @@
//box-shadow: 0 3px 15px rgba(0, 0, 0, 0.2); //box-shadow: 0 3px 15px rgba(0, 0, 0, 0.2);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.10); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.10);
border: none; //1px solid #ccc; border: none; //1px solid #ccc;
height: 650px; height: 610px;
display: flex; display: flex;
} }
@ -31,7 +31,7 @@
text-align: center; text-align: center;
.popover-content { .popover-content {
max-height: 300px; max-height: 160px;
padding: 0; padding: 0;
overflow: auto; overflow: auto;
} }

View File

@ -9,8 +9,6 @@ end try
return doesExist return doesExist
EOF` EOF`
echo $ITERM_EXISTS
if [ $ITERM_EXISTS == "true" ]; then if [ $ITERM_EXISTS == "true" ]; then
osascript > /dev/null <<EOF osascript > /dev/null <<EOF
tell application "iTerm" tell application "iTerm"
@ -19,14 +17,14 @@ tell application "iTerm"
tell the first terminal tell the first terminal
launch session "Default Session" launch session "Default Session"
tell the last session tell the last session
write text "clear && $*" write text "bash -c \"clear && $*\""
end tell end tell
end tell end tell
on error on error
tell (make new terminal) tell (make new terminal)
launch session "Default Session" launch session "Default Session"
tell the last session tell the last session
write text "clear && $*" write text "bash -c \"clear && $*\""
end tell end tell
end tell end tell
end try end try
@ -39,7 +37,7 @@ tell application "Terminal" to activate
delay 0.4 delay 0.4
tell application "System Events" to keystroke "t" using command down tell application "System Events" to keystroke "t" using command down
tell application "Terminal" tell application "Terminal"
do script "clear && $*" in window 1 do script "bash -c \"clear && $*\"" in window 1
end tell end tell
EOF EOF