From 3e980a66172a036729051fbf6c8df37fcb15e054 Mon Sep 17 00:00:00 2001 From: Piotr Date: Wed, 1 May 2024 09:55:48 +0200 Subject: [PATCH] Add error and success alert partials and update code execution handling 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. --- web/main.go | 1 + web/public/views/edytor.html | 14 ++++++++++++-- web/public/views/partials/error.html | 3 +++ web/public/views/partials/success.html | 3 +++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 web/public/views/partials/error.html create mode 100644 web/public/views/partials/success.html diff --git a/web/main.go b/web/main.go index 6af9045..adba07c 100644 --- a/web/main.go +++ b/web/main.go @@ -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() diff --git a/web/public/views/edytor.html b/web/public/views/edytor.html index 032dcba..76fbfff 100644 --- a/web/public/views/edytor.html +++ b/web/public/views/edytor.html @@ -15,6 +15,7 @@ +
@@ -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); + }); }); diff --git a/web/public/views/partials/error.html b/web/public/views/partials/error.html new file mode 100644 index 0000000..42b6aec --- /dev/null +++ b/web/public/views/partials/error.html @@ -0,0 +1,3 @@ + diff --git a/web/public/views/partials/success.html b/web/public/views/partials/success.html new file mode 100644 index 0000000..64b821e --- /dev/null +++ b/web/public/views/partials/success.html @@ -0,0 +1,3 @@ + \ No newline at end of file