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 ~ Stacked log #543

Merged
merged 2 commits into from
Feb 22, 2024
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
8 changes: 8 additions & 0 deletions frontend/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ button {
overflow: auto;
}

.log-message {
padding: 10px;
border: 1px solid #000;
border-radius: 5px;
margin-top: 5px;
overflow: auto;
}

/* Close connection button*/
.close-button {
background-color: #c0392b; /* Red color */
Expand Down
14 changes: 9 additions & 5 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

function handleOpenWebSocket(){
const message = `WebSocket connection for Port ${port} established.`
setLoggedMessages(prevMessages => [...prevMessages, message]);
addLoggedMessage(message);
console.log(message);

// Clear error messages
Expand Down Expand Up @@ -109,6 +109,10 @@
console.log(`WebSocket connection for Port ${port} closed.`);
}

const addLoggedMessage = (newMessage) => {
setLoggedMessages(prevMessages => [newMessage, ...prevMessages]);
}

const decomposeJSON = (message) => {
// Note: This decompose function is closely tied to the composition in websocketwriter.go.
// We expect the following structure:
Expand All @@ -135,7 +139,7 @@
console.log("new message accepted on port: ", port);

// Accept ORIGINAL Log (without modifications)
setLoggedMessages(prevMessages => [...prevMessages, incomingMessage]);
addLoggedMessage(incomingMessage);

// Send the response on the WebSocket
let webSocketResponse = {
Expand All @@ -153,7 +157,7 @@
console.log("new message async accepted on port: ", port);

// Accept ORIGINAL Log (without modifications and automatically)
setLoggedMessages(prevMessages => [...prevMessages, message]);
addLoggedMessage(message);

// Send the response on the WebSocket
let webSocketResponse = {
Expand All @@ -174,7 +178,7 @@

// Accept REPLACED Log
const acceptingModifiedMessage = JSON.stringify(incomingMessageJSON.current, null, 2)
setLoggedMessages(prevMessages => [...prevMessages, acceptingModifiedMessage]);
addLoggedMessage(acceptingModifiedMessage);

// Send the response on the WebSocket

Expand Down Expand Up @@ -423,7 +427,7 @@
Accepted Logs:
<div id="log-placeholder" className="log-screen json-message">
{loggedMessages.map((log, index) => (
<p key={index}>{log}</p>
<p key={index} className="log-message">{log}</p>
))}
</div>
</div>
Expand Down
Loading