mirror of https://github.com/portainer/portainer
pull/1012/head
parent
fe5a993fc9
commit
8dc6d05ed6
|
@ -22,28 +22,35 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="command" class="col-lg-1 text-left col-sm-2 control-label">Command</label>
|
<label for="command" class="col-lg-1 text-left col-sm-2 control-label">Command</label>
|
||||||
<div class="col-lg-11 col-sm-10">
|
<div class="col-lg-11 col-sm-10">
|
||||||
<div class="input-group">
|
<div class="input-group" ng-if="!formValues.isCustomCommand">
|
||||||
<span class="input-group-addon">
|
<span class="input-group-addon">
|
||||||
<i class="fa fa-linux" aria-hidden="true" ng-if="imageOS == 'linux'"></i>
|
<i class="fa fa-linux" aria-hidden="true" ng-if="imageOS == 'linux'"></i>
|
||||||
<i class="fa fa-windows" aria-hidden="true" ng-if="imageOS == 'windows'"></i>
|
<i class="fa fa-windows" aria-hidden="true" ng-if="imageOS == 'windows'"></i>
|
||||||
</span>
|
</span>
|
||||||
<select class="form-control" ng-model="state.command" id="command">
|
<select class="form-control" ng-model="formValues.command" id="command">
|
||||||
<option value="bash" ng-if="imageOS == 'linux'">/bin/bash</option>
|
<option value="bash" ng-if="imageOS == 'linux'">/bin/bash</option>
|
||||||
<option value="sh" ng-if="imageOS == 'linux'">/bin/sh</option>
|
<option value="sh" ng-if="imageOS == 'linux'">/bin/sh</option>
|
||||||
<option value="powershell" ng-if="imageOS == 'windows'">powershell</option>
|
<option value="powershell" ng-if="imageOS == 'windows'">powershell</option>
|
||||||
<option value="cmd.exe" ng-if="imageOS == 'windows'">cmd.exe</option>
|
<option value="cmd.exe" ng-if="imageOS == 'windows'">cmd.exe</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<input class="form-control" ng-if="formValues.isCustomCommand" type="text" name="custom-command" ng-model="formValues.customCommand" placeholder="e.g. ps aux">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- !command-list -->
|
<!-- !command-list -->
|
||||||
|
<div class="form-group col-lg-12">
|
||||||
|
<label for="command" class="text-left control-label">Use custom command</label>
|
||||||
|
<label class="switch" style="margin-left: 20px;">
|
||||||
|
<input type="checkbox" ng-model="formValues.isCustomCommand"><i></i>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username" class="col-lg-1 text-left col-sm-2 control-label">
|
<label for="username" class="col-lg-1 text-left col-sm-2 control-label">
|
||||||
User
|
User
|
||||||
<portainer-tooltip position="bottom" message="Format is one of: user, user:group, uid or uid:gid"></portainer-tooltip>
|
<portainer-tooltip position="bottom" message="Format is one of: user, user:group, uid or uid:gid"></portainer-tooltip>
|
||||||
</label>
|
</label>
|
||||||
<div class="col-lg-11 col-sm-10">
|
<div class="col-lg-11 col-sm-10">
|
||||||
<input class="form-control" type="text" name="username" ng-model="state.user" placeholder="root">
|
<input class="form-control" type="text" name="username" ng-model="formValues.user" placeholder="root">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
angular.module('containerConsole', [])
|
angular.module('containerConsole', [])
|
||||||
.controller('ContainerConsoleController', ['$scope', '$stateParams', 'Container', 'Image', 'Exec', '$timeout', 'EndpointProvider', 'Notifications',
|
.controller('ContainerConsoleController', ['$scope', '$stateParams', 'Container', 'Image', 'Exec', '$timeout', 'EndpointProvider', 'Notifications', 'ContainerHelper',
|
||||||
function ($scope, $stateParams, Container, Image, Exec, $timeout, EndpointProvider, Notifications) {
|
function ($scope, $stateParams, Container, Image, Exec, $timeout, EndpointProvider, Notifications, ContainerHelper) {
|
||||||
$scope.state = {};
|
$scope.state = {};
|
||||||
$scope.state.loaded = false;
|
$scope.state.loaded = false;
|
||||||
$scope.state.connected = false;
|
$scope.state.connected = false;
|
||||||
|
$scope.formValues = {};
|
||||||
|
|
||||||
var socket, term;
|
var socket, term;
|
||||||
|
|
||||||
// Ensure the socket is closed before leaving the view
|
// Ensure the socket is closed before leaving the view
|
||||||
|
@ -22,7 +23,7 @@ function ($scope, $stateParams, Container, Image, Exec, $timeout, EndpointProvid
|
||||||
} else {
|
} else {
|
||||||
Image.get({id: d.Image}, function(imgData) {
|
Image.get({id: d.Image}, function(imgData) {
|
||||||
$scope.imageOS = imgData.Os;
|
$scope.imageOS = imgData.Os;
|
||||||
$scope.state.command = imgData.Os === 'windows' ? 'powershell' : 'bash';
|
$scope.formValues.command = imgData.Os === 'windows' ? 'powershell' : 'bash';
|
||||||
$scope.state.loaded = true;
|
$scope.state.loaded = true;
|
||||||
$('#loadingViewSpinner').hide();
|
$('#loadingViewSpinner').hide();
|
||||||
}, function (e) {
|
}, function (e) {
|
||||||
|
@ -39,14 +40,16 @@ function ($scope, $stateParams, Container, Image, Exec, $timeout, EndpointProvid
|
||||||
$('#loadConsoleSpinner').show();
|
$('#loadConsoleSpinner').show();
|
||||||
var termWidth = Math.round($('#terminal-container').width() / 8.2);
|
var termWidth = Math.round($('#terminal-container').width() / 8.2);
|
||||||
var termHeight = 30;
|
var termHeight = 30;
|
||||||
|
var command = $scope.formValues.isCustomCommand ?
|
||||||
|
$scope.formValues.customCommand : $scope.formValues.command;
|
||||||
var execConfig = {
|
var execConfig = {
|
||||||
id: $stateParams.id,
|
id: $stateParams.id,
|
||||||
AttachStdin: true,
|
AttachStdin: true,
|
||||||
AttachStdout: true,
|
AttachStdout: true,
|
||||||
AttachStderr: true,
|
AttachStderr: true,
|
||||||
Tty: true,
|
Tty: true,
|
||||||
User: $scope.state.user,
|
User: $scope.formValues.user,
|
||||||
Cmd: $scope.state.command.replace(' ', ',').split(',')
|
Cmd: ContainerHelper.commandStringToArray(command)
|
||||||
};
|
};
|
||||||
|
|
||||||
Container.exec(execConfig, function(d) {
|
Container.exec(execConfig, function(d) {
|
||||||
|
|
Loading…
Reference in New Issue