FIX: Close DB connection and htmx spinner
This commit is contained in:
parent
6dc9c19749
commit
0da4821724
@ -30,6 +30,7 @@ func queryConnection(query, url string) ([]string, []map[string]interface{}, err
|
||||
if err != nil {
|
||||
return []string{}, []map[string]interface{}{}, err
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
rows, err := db.Query(query)
|
||||
if err != nil {
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Database Query Tool</title>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
|
||||
<script src="https://unpkg.com/htmx.org@2.0.1"></script>
|
||||
<link rel="icon" type="image/png" href="/v1/web/assets/favicon.ico">
|
||||
</head>
|
||||
</head>
|
||||
|
||||
<body class="bg-gray-100">
|
||||
<body class="bg-gray-100">
|
||||
|
||||
<div class="flex flex-col h-screen">
|
||||
<!-- Top Bar -->
|
||||
@ -112,9 +112,17 @@
|
||||
<div class="w-full md:w-3/4 p-4">
|
||||
<main>
|
||||
<!-- Query Input -->
|
||||
<form class="mb-4" hx-post="/v1/api/query" hx-trigger="input delay:1000ms" hx-swap="outerHTML" hx-target="#query-result">
|
||||
<form
|
||||
class="mb-4"
|
||||
hx-post="/v1/api/query"
|
||||
hx-trigger="input delay:500ms"
|
||||
hx-swap="outerHTML"
|
||||
hx-target="#query-result"
|
||||
hx-indicator="#spinner"
|
||||
>
|
||||
<label for="sql" class="block text-sm font-medium text-gray-700">SQL Query</label>
|
||||
<textarea id="sql" name="sql" rows="4" class="mt-1 block w-full p-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm"></textarea>
|
||||
<p id="spinner" class="text-gray-700 text-sm px-1 py-2 htmx-indicator"> Query running... </p>
|
||||
<p id="query-error" hx-swap-oob="outerHTML" class="text-red-500 py-2 text-sm hidden"></p>
|
||||
</form>
|
||||
|
||||
@ -231,6 +239,6 @@
|
||||
<!-- Scripts -->
|
||||
<script src="/v1/web/static/scripts/password.js"></script>
|
||||
<script src="/v1/web/static/scripts/modal.js"></script>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user