Skip to content

Commit

Permalink
Add error and success alert partials and update code execution handling
Browse files Browse the repository at this point in the history
The commit introduces error and success alert partials in the web application for displaying user notifications. It also updates the main.go file to load these partials and modifies the code execution handling in edytor.html for more user-friendly output. Now, the execution results or errors are displayed in an HTML element instead of the console, enhancing the user interface experience.
  • Loading branch information
PiotrFerenc committed May 1, 2024
1 parent 904cc56 commit 3e980a6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions web/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func main() {
t := LoadTemplates([]string{
"web/public/views/*.html",
"web/public/views/dashboard/*.html",
"web/public/views/partials/*.html",
})
parameters := executor.CreateActionMap(&configuration.Config{})
e := echo.New()
Expand Down
14 changes: 12 additions & 2 deletions web/public/views/edytor.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<button class="btn btn-primary" id="execute-btn">
<i class="bi bi-play-fill"></i>
</button>
<div id="execute-result"></div>
</nav>
</div>
</div>
Expand Down Expand Up @@ -115,13 +116,22 @@
contentType: 'application/json',
dataType: 'json',
success: function(response) {
console.log(response);
$('#execute-result').html(response)
},
error: function(error) {
console.error(error.responseText);
$('#execute-result').html(error.responseText)
}
});
})

$.post('/execute', window.code)
.done(function(response) {
console.log(response);
$('#execute-result').html(response.responseText);
})
.fail(function(xhr, status, error) {
$('#execute-result').html(error);
});
});
</script>
</body>
Expand Down
3 changes: 3 additions & 0 deletions web/public/views/partials/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="alert alert-danger" role="alert">
{{.error}}
</div>
3 changes: 3 additions & 0 deletions web/public/views/partials/success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="alert alert-success" role="alert">
A simple success alert—check it out!
</div>

0 comments on commit 3e980a6

Please sign in to comment.