mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
fix(console): use writeUtf8 instead of environment variables EE-6593 (#11019)
This commit is contained in:
parent
249b6bc628
commit
b640b58371
3 changed files with 19 additions and 30 deletions
|
@ -183,9 +183,6 @@ angular.module('portainer.docker').controller('ContainerConsoleController', [
|
||||||
socket.onopen = function () {
|
socket.onopen = function () {
|
||||||
$scope.state = states.connected;
|
$scope.state = states.connected;
|
||||||
term = new Terminal();
|
term = new Terminal();
|
||||||
socket.send('export LANG=C.UTF-8\n');
|
|
||||||
socket.send('export LC_ALL=C.UTF-8\n');
|
|
||||||
socket.send('clear\n');
|
|
||||||
|
|
||||||
term.onData(function (data) {
|
term.onData(function (data) {
|
||||||
socket.send(data);
|
socket.send(data);
|
||||||
|
@ -205,7 +202,8 @@ angular.module('portainer.docker').controller('ContainerConsoleController', [
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.onmessage = function (e) {
|
socket.onmessage = function (e) {
|
||||||
term.write(e.data);
|
var encoded = new TextEncoder().encode(e.data);
|
||||||
|
term.writeUtf8(encoded);
|
||||||
};
|
};
|
||||||
socket.onerror = function (err) {
|
socket.onerror = function (err) {
|
||||||
$scope.disconnect();
|
$scope.disconnect();
|
||||||
|
|
|
@ -75,14 +75,12 @@ export function ConsoleView() {
|
||||||
terminal?.setOption('cursorBlink', true);
|
terminal?.setOption('cursorBlink', true);
|
||||||
terminal?.focus();
|
terminal?.focus();
|
||||||
setConnectionStatus('open');
|
setConnectionStatus('open');
|
||||||
socket.send('export LANG=C.UTF-8\n');
|
|
||||||
socket.send('export LC_ALL=C.UTF-8\n');
|
|
||||||
socket.send('clear\n');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onmessage = (msg) => {
|
socket.onmessage = (msg) => {
|
||||||
terminal?.write(msg.data);
|
const encoded = new TextEncoder().encode(msg.data);
|
||||||
|
terminal?.writeUtf8(encoded);
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onerror = () => {
|
socket.onerror = () => {
|
||||||
|
|
|
@ -46,27 +46,19 @@ export function KubeCtlShell({ environmentId, onClose }: Props) {
|
||||||
onClose();
|
onClose();
|
||||||
}, [onClose, terminal, socket]);
|
}, [onClose, terminal, socket]);
|
||||||
|
|
||||||
const openTerminal = useCallback(
|
const openTerminal = useCallback(() => {
|
||||||
(socket: WebSocket | null) => {
|
if (!terminalElem.current) {
|
||||||
if (!terminalElem.current) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
terminal.open(terminalElem.current);
|
terminal.open(terminalElem.current);
|
||||||
terminal.setOption('cursorBlink', true);
|
terminal.setOption('cursorBlink', true);
|
||||||
terminal.focus();
|
terminal.focus();
|
||||||
fit(terminal);
|
fit(terminal);
|
||||||
if (socket) {
|
terminal.writeln('#Run kubectl commands inside here');
|
||||||
socket.send('export LANG=C.UTF-8\n');
|
terminal.writeln('#e.g. kubectl get all');
|
||||||
socket.send('export LC_ALL=C.UTF-8\n');
|
terminal.writeln('');
|
||||||
socket.send('clear\n');
|
}, [terminal]);
|
||||||
}
|
|
||||||
terminal.writeln('#Run kubectl commands inside here');
|
|
||||||
terminal.writeln('#e.g. kubectl get all');
|
|
||||||
terminal.writeln('');
|
|
||||||
},
|
|
||||||
[terminal]
|
|
||||||
);
|
|
||||||
|
|
||||||
// refresh socket listeners on socket updates
|
// refresh socket listeners on socket updates
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -74,10 +66,11 @@ export function KubeCtlShell({ environmentId, onClose }: Props) {
|
||||||
return () => {};
|
return () => {};
|
||||||
}
|
}
|
||||||
function onOpen() {
|
function onOpen() {
|
||||||
openTerminal(socket);
|
openTerminal();
|
||||||
}
|
}
|
||||||
function onMessage(e: MessageEvent) {
|
function onMessage(e: MessageEvent) {
|
||||||
terminal.write(e.data);
|
const encoded = new TextEncoder().encode(e.data);
|
||||||
|
terminal.writeUtf8(encoded);
|
||||||
}
|
}
|
||||||
function onClose() {
|
function onClose() {
|
||||||
handleClose();
|
handleClose();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue