Update xtermjs to latest v4.8.1
This commit is contained in:
+17
-10
@@ -1,9 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
/* global angular */
|
||||
/* global $ */
|
||||
/* global Terminal */
|
||||
/* global ISTATES */
|
||||
/* global angular, $, Terminal, AttachAddon, FitAddon, ISTATES */
|
||||
|
||||
// create main application module
|
||||
angular.module('Application', ['angular-md5', 'ui-notification']);
|
||||
@@ -18,6 +15,7 @@ angular.module('Application').controller('TerminalController', ['$scope', '$time
|
||||
$scope.selected = '';
|
||||
$scope.terminal = null;
|
||||
$scope.terminalSocket = null;
|
||||
$scope.fitAddon = null;
|
||||
$scope.restartAppBusy = false;
|
||||
$scope.appBusy = false;
|
||||
$scope.selectedAppInfo = null;
|
||||
@@ -110,7 +108,7 @@ angular.module('Application').controller('TerminalController', ['$scope', '$time
|
||||
|
||||
function reset() {
|
||||
if ($scope.terminal) {
|
||||
$scope.terminal.destroy();
|
||||
$scope.terminal.dispose();
|
||||
$scope.terminal = null;
|
||||
}
|
||||
|
||||
@@ -153,7 +151,7 @@ angular.module('Application').controller('TerminalController', ['$scope', '$time
|
||||
// websocket cannot use relative urls
|
||||
var url = Client.apiOrigin.replace('https', 'wss') + '/api/v1/apps/' + $scope.selected.value + '/execws?tty=true&rows=' + $scope.terminal.rows + '&columns=' + $scope.terminal.cols + '&access_token=' + Client.getToken();
|
||||
$scope.terminalSocket = new WebSocket(url);
|
||||
$scope.terminal.attach($scope.terminalSocket);
|
||||
$scope.terminal.loadAddon(new AttachAddon.AttachAddon($scope.terminalSocket));
|
||||
|
||||
$scope.terminalSocket.onclose = function () {
|
||||
// retry in one second
|
||||
@@ -192,7 +190,11 @@ angular.module('Application').controller('TerminalController', ['$scope', '$time
|
||||
$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'), true);
|
||||
|
||||
$scope.fitAddon = new FitAddon.FitAddon();
|
||||
$scope.terminal.loadAddon($scope.fitAddon);
|
||||
|
||||
$scope.terminal.open(document.querySelector('#terminalContainer'));
|
||||
|
||||
window.terminal = $scope.terminal;
|
||||
|
||||
@@ -207,14 +209,19 @@ angular.module('Application').controller('TerminalController', ['$scope', '$time
|
||||
// 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) return;
|
||||
$scope.terminal.fit();
|
||||
|
||||
// this is here so that the text wraps correctly after the fit!
|
||||
var YELLOW = '\u001b[33m'; // https://gist.github.com/dainkaplan/4651352
|
||||
var NC = '\u001b[0m';
|
||||
$scope.terminal.writeln(YELLOW + 'If you resize the browser window, press Ctrl+D to start a new session with the current size.' + NC);
|
||||
|
||||
createTerminalSocket(); // create exec container after we fit() since we cannot resize exec container post-creation
|
||||
// we have to first write something on reconnect after app restart..not sure why
|
||||
$scope.fitAddon.fit();
|
||||
|
||||
// create exec container after we fit() since we cannot resize exec container post-creation
|
||||
createTerminalSocket();
|
||||
|
||||
$scope.terminal.focus();
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
@@ -299,7 +306,7 @@ angular.module('Application').controller('TerminalController', ['$scope', '$time
|
||||
});
|
||||
|
||||
window.addEventListener('resize', function () {
|
||||
if ($scope.terminal) $scope.terminal.fit();
|
||||
if ($scope.fitAddon) $scope.fitAddon.fit();
|
||||
});
|
||||
|
||||
Client.getStatus(function (error, status) {
|
||||
|
||||
Reference in New Issue
Block a user