Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend ~ close button #534

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions frontend/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ button {
overflow: auto;
}

/* Close connection button*/
.close-button {
background-color: #c0392b; /* Red color */
color: #fff; /* White text color */
border: none;
padding: 8px 12px;
font-size: 14px;
cursor: pointer;
border-radius: 4px;
float: right; /* Float the button to the right */
margin: 5px;
}

/* EditableText*/
/* Style for spans with text content */
.editable-text-span {
Expand Down
17 changes: 17 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,25 @@
}
};

const closeConnection = () => {
console.log('Closing connection from button');
if (ws) {
declineIncomingLog();
ws.close();

// Send the response on the WebSocket
let webSocketResponse = {
"Type": "close",
"Value": ""
};
const webSocketResponseJSON = JSON.stringify(webSocketResponse);
ws.send(webSocketResponseJSON);
}
}

return (
<div id="sub-screen" className="sub-screen">
<button onClick={closeConnection} className="close-button">Close Connection</button>
<p className="websocket-console-title">
WebSocket Console for Port {port}:
</p>
Expand Down
Loading