portainer/app/docker/views/containers/console/containerConsoleController.js

242 lines
6.6 KiB
JavaScript
Raw Normal View History

import { Terminal } from 'xterm';
angular.module('portainer.docker').controller('ContainerConsoleController', [
'$scope',
'$transition$',
'ContainerService',
'ImageService',
'EndpointProvider',
'Notifications',
'ContainerHelper',
'ExecService',
'HttpRequestHelper',
'LocalStorage',
'CONSOLE_COMMANDS_LABEL_PREFIX',
function (
$scope,
$transition$,
ContainerService,
ImageService,
EndpointProvider,
Notifications,
ContainerHelper,
ExecService,
HttpRequestHelper,
LocalStorage,
CONSOLE_COMMANDS_LABEL_PREFIX
) {
var socket, term;
let states = Object.freeze({
disconnected: 0,
connecting: 1,
connected: 2,
});
$scope.loaded = false;
$scope.states = states;
$scope.state = states.disconnected;
$scope.formValues = {};
$scope.containerCommands = [];
// Ensure the socket is closed before leaving the view
$scope.$on('$stateChangeStart', function () {
$scope.disconnect();
});
$scope.connectAttach = function () {
if ($scope.state > states.disconnected) {
return;
}
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
$scope.state = states.connecting;
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
let attachId = $transition$.params().id;
ContainerService.container(attachId)
.then((details) => {
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
if (!details.State.Running) {
Notifications.error('Failure', details, 'Container ' + attachId + ' is not running!');
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
$scope.disconnect();
return;
}
const params = {
token: LocalStorage.getJWT(),
endpointId: EndpointProvider.endpointID(),
id: attachId,
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
};
var url =
window.location.href.split('#')[0] +
'api/websocket/attach?' +
Object.keys(params)
.map((k) => k + '=' + params[k])
.join('&');
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
initTerm(url, ContainerService.resizeTTY.bind(this, attachId));
})
.catch(function error(err) {
Notifications.error('Error', err, 'Unable to retrieve container details');
$scope.disconnect();
});
};
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
$scope.connectExec = function () {
if ($scope.state > states.disconnected) {
return;
}
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
$scope.state = states.connecting;
var command = $scope.formValues.isCustomCommand ? $scope.formValues.customCommand : $scope.formValues.command;
var execConfig = {
id: $transition$.params().id,
AttachStdin: true,
AttachStdout: true,
AttachStderr: true,
Tty: true,
User: $scope.formValues.user,
Cmd: ContainerHelper.commandStringToArray(command),
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
};
ContainerService.createExec(execConfig)
.then(function success(data) {
const params = {
token: LocalStorage.getJWT(),
endpointId: EndpointProvider.endpointID(),
id: data.Id,
};
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
var url =
window.location.href.split('#')[0] +
'api/websocket/exec?' +
Object.keys(params)
.map((k) => k + '=' + params[k])
.join('&');
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
initTerm(url, ExecService.resizeTTY.bind(this, params.id));
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to exec into container');
$scope.disconnect();
});
};
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
$scope.disconnect = function () {
if (socket) {
socket.close();
}
if ($scope.state > states.disconnected) {
$scope.state = states.disconnected;
if (term) {
term.write('\n\r(connection closed)');
term.dispose();
}
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
}
};
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
$scope.autoconnectAttachView = function () {
return $scope.initView().then(function success() {
if ($scope.container.State.Running) {
$scope.connectAttach();
}
});
};
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
function resize(restcall, add) {
add = add || 0;
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
term.fit();
var termWidth = term.cols;
var termHeight = 30;
term.resize(termWidth, termHeight);
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
restcall(termWidth + add, termHeight + add, 1);
}
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
function initTerm(url, resizeRestCall) {
let resizefun = resize.bind(this, resizeRestCall);
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
if ($transition$.params().nodeName) {
url += '&nodeName=' + $transition$.params().nodeName;
}
if (url.indexOf('https') > -1) {
url = url.replace('https://', 'wss://');
} else {
url = url.replace('http://', 'ws://');
}
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
socket = new WebSocket(url);
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
socket.onopen = function () {
$scope.state = states.connected;
term = new Terminal();
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
term.on('data', function (data) {
socket.send(data);
});
var terminal_container = document.getElementById('terminal-container');
term.open(terminal_container);
term.focus();
term.setOption('cursorBlink', true);
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
window.onresize = function () {
resizefun();
$scope.$apply();
};
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
$scope.$watch('toggle', function () {
setTimeout(resizefun, 400);
});
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
socket.onmessage = function (e) {
term.write(e.data);
};
socket.onerror = function (err) {
$scope.disconnect();
$scope.$apply();
Notifications.error('Failure', err, 'Connection error');
};
socket.onclose = function () {
$scope.disconnect();
feat(containers): add support docker attach (#2842) * #592 feat(container-details): split websocket backend code into more files and add attach handler * #592 feat(container-details): rename console to exec and add attach console * Revert "#592 feat(container-details): rename console to exec and add attach console" This reverts commit f2deaee1 * #592 feat(container-details): add attach to containerconsole * #592 feat(container-details): catch more errors * #592 feat(container-details): use less vars * #592 feat(container-details): error message is more verbose * #592 feat(container-details): go fmt * #592 feat(container-details): unpack netdial * #592 feat(container-details): reformat service * #592 feat(container-details): fix go compiler bugs * #592 feat(container-details): refactor services * #592 feat(container-details): fix windows dial * #592 feat(container-details): gofmt dial_windows.go * #592 feat(container-details): split console into two views and fix breadcrumbs * #592 feat(container-details): swap exec and attach action * #592 feat(container-details): add some warnings * #592 feat(container-details): refresh view more * #592 feat(container-details): use less functions for connecting/disconnecting * #592 feat(container-details): move link replacements into initTerm * #592 feat(container-details): disable attach/exec button if container is not running * #592 feat(container-details): fix typo * #592 feat(container-details): autoconnect attach view * #592 feat(container-details): fix first draw after attach + reformat code * #592 feat(container-details): remove init-helper-div * #592 feat(container-details): console resize code and remove padding * #592 feat(container-details): swap height and width arguments in container tty resize restcall * #592 feat(container-details): swap height and width arguments in exec tty resize restcall * #592 feat(container-details): remove css unit * #592 feat(container-details): remove loaded state from states object * #592 feat(container-details): reword Disattach to Detach * #592 feat(container-details): remove unloaded state from states object * #592 feat(container-details): remove useless code * #592 feat(container-details): clearer state-check * #592 feat(container-details): fixed resize bugs by using xterms col attribute
2019-05-09 02:04:40 +00:00
$scope.$apply();
};
resizefun(1);
$scope.$apply();
};
}
$scope.initView = function () {
HttpRequestHelper.setPortainerAgentTargetHeader($transition$.params().nodeName);
return ContainerService.container($transition$.params().id)
.then(function success(data) {
var container = data;
$scope.container = container;
return ImageService.image(container.Image);
})
.then(function success(data) {
var image = data;
var containerLabels = $scope.container.Config.Labels;
$scope.imageOS = image.Os;
$scope.formValues.command = image.Os === 'windows' ? 'powershell' : 'bash';
$scope.containerCommands = Object.keys(containerLabels)
.filter(function (label) {
return label.indexOf(CONSOLE_COMMANDS_LABEL_PREFIX) === 0;
})
.map(function (label) {
return {
title: label.replace(CONSOLE_COMMANDS_LABEL_PREFIX, ''),
command: containerLabels[label],
};
});
$scope.loaded = true;
})
.catch(function error(err) {
Notifications.error('Error', err, 'Unable to retrieve container details');
});
};
},
]);