Spaces:
Configuration error
Configuration error
File size: 760 Bytes
da79dee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import React, { useEffect, useRef } from 'react';
import { Terminal } from 'xterm';
import 'xterm/css/xterm.css';
import socket from './socket';
const ProxmoxVM = ({ vmAddress }) => {
const terminalRef = useRef(null);
const terminal = useRef(new Terminal());
useEffect(() => {
terminal.current.open(terminalRef.current);
terminal.current.writeln('Connecting to VM...');
socket.emit('fetchVmData', { vm_address: vmAddress });
socket.on('vmData', (data) => {
terminal.current.writeln(data);
});
return () => {
socket.off('vmData');
terminal.current.dispose();
};
}, [vmAddress]);
return <div ref={terminalRef} />;
};
export default ProxmoxVM;
|