templates/index.html aktualisiert
This commit is contained in:
@@ -275,6 +275,7 @@
|
|||||||
<script>
|
<script>
|
||||||
let currentSettings = {};
|
let currentSettings = {};
|
||||||
let termDataDisposable = null;
|
let termDataDisposable = null;
|
||||||
|
let term, fitAddon;
|
||||||
|
|
||||||
// 1. CHAT LOGIK
|
// 1. CHAT LOGIK
|
||||||
function initChat(chatWs) {
|
function initChat(chatWs) {
|
||||||
@@ -454,10 +455,29 @@
|
|||||||
localStorage.setItem('pi-orch-layout-v2', JSON.stringify(grid.save(false)));
|
localStorage.setItem('pi-orch-layout-v2', JSON.stringify(grid.save(false)));
|
||||||
});
|
});
|
||||||
|
|
||||||
const term = new Terminal({ theme: { background: '#000' }, fontSize: 13, convertEol: true });
|
// Terminal Setup
|
||||||
const fitAddon = new FitAddon.FitAddon();
|
term = new Terminal({ theme: { background: '#000' }, fontSize: 13, convertEol: true });
|
||||||
|
fitAddon = new FitAddon.FitAddon();
|
||||||
term.loadAddon(fitAddon);
|
term.loadAddon(fitAddon);
|
||||||
term.open(document.getElementById('terminal'));
|
term.open(document.getElementById('terminal'));
|
||||||
|
fitAddon.fit();
|
||||||
|
|
||||||
|
// WICHTIG: Wenn das Widget in GridStack vergrößert wird
|
||||||
|
grid.on('resizestop', function(event, el) {
|
||||||
|
if (el.getAttribute('gs-id') === 'term-widget') {
|
||||||
|
setTimeout(() => {
|
||||||
|
fitAddon.fit();
|
||||||
|
// Sende neue Größe an das Backend
|
||||||
|
if (window.termWs && window.termWs.readyState === WebSocket.OPEN) {
|
||||||
|
window.termWs.send(JSON.stringify({
|
||||||
|
type: "resize",
|
||||||
|
cols: term.cols,
|
||||||
|
rows: term.rows
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const logWs = new WebSocket(`ws://${location.host}/ws/install_logs`);
|
const logWs = new WebSocket(`ws://${location.host}/ws/install_logs`);
|
||||||
logWs.onmessage = (ev) => {
|
logWs.onmessage = (ev) => {
|
||||||
@@ -482,10 +502,26 @@
|
|||||||
if (window.termWs) window.termWs.close();
|
if (window.termWs) window.termWs.close();
|
||||||
if (termDataDisposable) termDataDisposable.dispose();
|
if (termDataDisposable) termDataDisposable.dispose();
|
||||||
term.clear();
|
term.clear();
|
||||||
|
fitAddon.fit(); // Einmal anpassen beim Öffnen
|
||||||
|
|
||||||
window.termWs = new WebSocket(`ws://${location.host}/ws/terminal/${ip}`);
|
window.termWs = new WebSocket(`ws://${location.host}/ws/terminal/${ip}`);
|
||||||
|
|
||||||
|
window.termWs.onopen = () => {
|
||||||
|
// Initiale Größe nach dem Verbinden senden
|
||||||
|
window.termWs.send(JSON.stringify({
|
||||||
|
type: "resize",
|
||||||
|
cols: term.cols,
|
||||||
|
rows: term.rows
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
window.termWs.onmessage = (ev) => term.write(ev.data);
|
window.termWs.onmessage = (ev) => term.write(ev.data);
|
||||||
|
|
||||||
termDataDisposable = term.onData(data => {
|
termDataDisposable = term.onData(data => {
|
||||||
if (window.termWs?.readyState === WebSocket.OPEN) window.termWs.send(data);
|
if (window.termWs?.readyState === WebSocket.OPEN) {
|
||||||
|
// Normale Tastatureingaben senden wir direkt
|
||||||
|
window.termWs.send(data);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user