diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 00000000..3cf3e3cd
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,137 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "lastFilter": {}
+}
+ {
+ "selectedUrlAndAccountId": {
+ "url": "https://github.com/LukeGus/ssh-project.git",
+ "accountId": "f04977d4-c3b2-400a-9c9b-d5b445f8a970"
+ }
+}
+ {
+ "associatedIndex": 8
+}
+
+
+
+
+
+
+
+
+ {
+ "keyToString": {
+ "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "Shell Script.Node Server.js Start.executor": "Run",
+ "Shell Script.Run backend and frontend.executor": "Run",
+ "Shell Script.run_backend_frontend.executor": "Run",
+ "git-widget-placeholder": "alpha-1.0",
+ "ignore.virus.scanning.warn.message": "true",
+ "last_opened_file_path": "D:/Programming Projects/SSH-Project-JB",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "npm.run_start.executor": "Run",
+ "npm.run_start_frontend.executor": "Run",
+ "npm.run_start_node_backend.executor": "Run",
+ "npm.run_start_vite.executor": "Run",
+ "npm.start.executor": "Run",
+ "vue.rearranger.settings.migration": "true"
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1733439468142
+
+
+ 1733439468142
+
+
+
+
+
+ 1733447944692
+
+
+
+ 1733447944692
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/package.json b/frontend/package.json
index cbe8f407..45136381 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -24,7 +24,7 @@
},
"scripts": {
"start-vite": "cross-env BROWSER=none WDS_SOCKET_PORT=0 vite --port 8080",
- "start-server": "node 'D:/Programming Projects/SSH-Project/ssh-project/backend/server.js'",
+ "start-server": "node ./start.js",
"start": "npm run start-vite && npm run start-server",
"build": "vite build",
"preview": "vite preview",
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index cb77b26d..642f3d15 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -14,24 +14,26 @@ const App = () => {
const [password, setPassword] = useState('');
const [isConnected, setIsConnected] = useState(false);
const [isSideBarHidden, setIsSideBarHidden] = useState(false);
- const [zoomFactor, setZoomFactor] = useState(1); // This will control zoom
useEffect(() => {
- // Initialize the terminal and the fit addon
+ console.log('Initializing terminal...');
terminal.current = new Terminal({
cursorBlink: true,
- theme: {
- background: '#1e1e1e',
- foreground: '#ffffff',
- },
+ theme: { background: '#1e1e1e', foreground: '#ffffff' },
macOptionIsMeta: true,
allowProposedApi: true,
- fontSize: 14, // Start with a default font size
+ fontSize: 14, // Set the default font size initially
});
fitAddon.current = new FitAddon();
terminal.current.loadAddon(fitAddon.current);
- terminal.current.open(terminalRef.current);
+
+ if (terminalRef.current) {
+ terminal.current.open(terminalRef.current);
+ console.log('Terminal opened successfully.');
+ } else {
+ console.error('Terminal reference is not valid!');
+ }
terminal.current.onData((data) => {
if (socket.current && socket.current.readyState === WebSocket.OPEN) {
@@ -39,40 +41,24 @@ const App = () => {
}
});
- // Resize terminal to fit the container initially
const resizeTerminal = () => {
if (terminalRef.current) {
fitAddon.current.fit();
- adjustZoom(); // Adjust zoom whenever the terminal resizes
notifyServerOfResize();
}
};
- // Adjust the zoom factor based on the terminal container size
- const adjustZoom = () => {
- const containerHeight = terminalRef.current.offsetHeight;
- const containerWidth = terminalRef.current.offsetWidth;
-
- // Adjust zoom based on container size
- const newZoomFactor = Math.max(0.5, Math.min(2, containerHeight / 300)); // Adjust this logic as needed
- if (zoomFactor !== newZoomFactor) {
- setZoomFactor(newZoomFactor);
- terminal.current.setOption('fontSize', 14 * newZoomFactor); // Use setOption instead of setFontSize
- }
- };
-
- // Notify the server of terminal resize
const notifyServerOfResize = () => {
if (socket.current && socket.current.readyState === WebSocket.OPEN) {
const { rows, cols } = terminal.current;
socket.current.send(
- JSON.stringify({
- type: 'resize',
- rows,
- cols,
- height: terminalRef.current.offsetHeight,
- width: terminalRef.current.offsetWidth,
- })
+ JSON.stringify({
+ type: 'resize',
+ rows,
+ cols,
+ height: terminalRef.current.offsetHeight,
+ width: terminalRef.current.offsetWidth,
+ })
);
}
};
@@ -87,29 +73,35 @@ const App = () => {
}
window.removeEventListener('resize', resizeTerminal);
};
- }, [zoomFactor]); // Re-run when zoomFactor changes
+ }, []);
const handleConnect = () => {
+ console.log('Connecting...');
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsUrl = `${protocol}//${window.location.host}/ws/`;
+ console.log(`WebSocket URL: ${wsUrl}`);
socket.current = new WebSocket(wsUrl);
socket.current.onopen = () => {
+ console.log('WebSocket connection opened');
terminal.current.writeln(`Connected to WebSocket server at ${wsUrl}`);
socket.current.send(JSON.stringify({ host, username, password }));
setIsConnected(true);
};
socket.current.onmessage = (event) => {
+ console.log('Received message:', event.data);
terminal.current.write(event.data);
};
socket.current.onerror = (error) => {
+ console.error('WebSocket error:', error);
terminal.current.writeln(`WebSocket error: ${error.message}`);
};
socket.current.onclose = () => {
+ console.log('WebSocket connection closed');
terminal.current.writeln('Disconnected from WebSocket server.');
setIsConnected(false);
};
@@ -125,46 +117,46 @@ const App = () => {
setTimeout(() => {
fitAddon.current.fit();
notifyServerOfResize();
- }, 100); // Delay to ensure layout updates before resize
+ }, 100);
}
};
return (
-
-
-
-
Connection Details
-
handleInputChange(e, setHost)}
- />
-
handleInputChange(e, setUsername)}
- />
-
handleInputChange(e, setPassword)}
- />
-
+
+
-
+
-
-
-
);
};
-export default App;
\ No newline at end of file
+export default App;
diff --git a/frontend/start.js b/frontend/start.js
new file mode 100644
index 00000000..c491af14
--- /dev/null
+++ b/frontend/start.js
@@ -0,0 +1,12 @@
+// start.js
+const { spawn } = require('child_process');
+
+const child = spawn('node', ["\"D:/Programming Projects/SSH-Project-JB/backend/server.js\""], {
+ stdio: 'inherit', // this is key for interactivity
+ shell: true, // use system shell
+});
+
+child.on('exit', function (code, signal) {
+ console.log('child process exited with ' +
+ `code ${code} and signal ${signal}`);
+});
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 047d800b..6632fe50 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "ssh-project",
+ "name": "SSH-Project-JB",
"lockfileVersion": 2,
"requires": true,
"packages": {