FIX: Bug with clearing modal before sending

The creation modal was sending data after being wiped, this was fixed
and the data does not get cleared from the modal until AFTER the request
is sent.
This commit is contained in:
Azpect3120 2024-08-15 09:22:39 -07:00
parent c35ab0d0b1
commit 8ab00b20d4
3 changed files with 16 additions and 4 deletions

View File

@ -17,6 +17,8 @@ func CreateConnection(c *gin.Context) {
name string = c.PostForm("db-conn-name")
)
fmt.Println(name, ": ", url)
session := sessions.Default(c)
var connections map[string]string

View File

@ -17,10 +17,11 @@ function HideModal() {
modal.classList.add("hidden");
modal.classList.add("opacity-0");
// Clear the inputs
for (const key in input) {
if (key != "driver") {
input[key].value = "";
}
}
}
const input = {
@ -75,6 +76,8 @@ for (const key in input) {
input[key].addEventListener("input", () => {
ParseURL(input);
})
} else if (key == "name") {
continue;
} else {
// If the input changed is the database name, update the connection name as well.
// This will create a default connection name based on the database name.

View File

@ -201,8 +201,15 @@
</div>
</form>
<div class="flex items-center space-x-4 mt-4">
<button hx-post="/v1/api/connections" hx-trigger="click" hx-target="#connected-database" hx-swap="outerHTML"
hx-include="#connection-form" onclick="HideModal();" class="bg-blue-500 text-white px-4 py-2 rounded-md">
<button
hx-post="/v1/api/connections"
hx-trigger="click"
hx-target="#connected-database"
hx-swap="outerHTML"
hx-include="#connection-form"
hx-on::after-request="HideModal();"
class="bg-blue-500 text-white px-4 py-2 rounded-md"
>
Create Connection
</button>
<button hx-post="/v1/api/connections/test" hx-trigger="click" hx-swap="outerHTML"