Fix terminal resize on window resize

This still does not update the terminal COLUMNS and ROWS
This commit is contained in:
Johannes Zellner
2018-05-15 18:31:52 +02:00
parent 26087e1580
commit f05967d871
3 changed files with 12 additions and 4 deletions

View File

@@ -244,8 +244,9 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
$scope.schedulerTasks = result.manifest.addons.scheduler ? Object.keys(result.manifest.addons.scheduler).map(function (k) { return { name: k, command: result.manifest.addons.scheduler[k].command }; }) : [];
$scope.terminal = new Terminal();
$scope.terminal.open(document.querySelector('#terminalContainer'));
$scope.terminal.fit();
$scope.terminal.open(document.querySelector('#terminalContainer'), true);
window.terminal = $scope.terminal;
try {
// websocket cannot use relative urls
@@ -270,6 +271,9 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
if (retry) $scope.terminal.writeln('Reconnecting...');
else $scope.terminal.writeln('Connecting...');
// we have to give it some time to setup the terminal to make it fit, there is no event unfortunately
setTimeout(function () { if ($scope.terminal) $scope.terminal.fit(); }, 1000);
});
}
@@ -353,6 +357,10 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
return false;
});
window.addEventListener('resize', function (e) {
if ($scope.terminal) $scope.terminal.fit();
});
Client.getStatus(function (error, status) {
if (error) return $scope.error(error);