FEAT: Displays database name in tree view
This commit is contained in:
parent
0da4821724
commit
fb548e4207
@ -2,10 +2,13 @@ package templates
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
|
// List item templates
|
||||||
const LIST_OPEN string = `<select id="connected-database" name="connected-database" class="mt-1 block p-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 text-sm md:text-base">`
|
const LIST_OPEN string = `<select id="connected-database" name="connected-database" class="mt-1 block p-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 text-sm md:text-base">`
|
||||||
const LIST_ITEM string = `<option value="%s"%s>%s</option>`
|
const LIST_ITEM string = `<option value="%s"%s>%s</option>`
|
||||||
const LIST_CLOSE string = `</select>`
|
const LIST_CLOSE string = `</select>`
|
||||||
|
|
||||||
|
const TREE_VIEW_NAME string = `<span hx-swap-oob="outerHTML" id="database-name-tree">%s</span>`
|
||||||
|
|
||||||
// Generate a list of connections to display in the drop-down.
|
// Generate a list of connections to display in the drop-down.
|
||||||
// Current connection will be toggled as selected
|
// Current connection will be toggled as selected
|
||||||
func ConnectionsList(connections map[string]string, current string) string {
|
func ConnectionsList(connections map[string]string, current string) string {
|
||||||
@ -24,6 +27,8 @@ func ConnectionsList(connections map[string]string, current string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
treeName := fmt.Sprintf(TREE_VIEW_NAME, current)
|
||||||
|
|
||||||
html += LIST_CLOSE
|
html += LIST_CLOSE
|
||||||
return html
|
return html + treeName
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
<!-- Sidebar -->
|
<!-- Sidebar -->
|
||||||
<div class="w-full md:w-1/4 bg-white shadow-md">
|
<div class="w-full md:w-1/4 bg-white shadow-md">
|
||||||
<div class="p-4 border-b">
|
<div class="p-4 border-b">
|
||||||
<h2 class="text-lg font-bold"><em>Database 1</em> Tables</h2>
|
<h2 class="text-lg font-bold"><span id="database-name-tree">database</span> Tables</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-4 max-h-full">
|
<div class="p-4 max-h-full">
|
||||||
<ul class="space-y-2">
|
<ul class="space-y-2">
|
||||||
@ -112,14 +112,7 @@
|
|||||||
<div class="w-full md:w-3/4 p-4">
|
<div class="w-full md:w-3/4 p-4">
|
||||||
<main>
|
<main>
|
||||||
<!-- Query Input -->
|
<!-- Query Input -->
|
||||||
<form
|
<form class="mb-4" hx-post="/v1/api/query" hx-trigger="input delay:500ms" hx-swap="outerHTML" hx-target="#query-result" hx-indicator="#spinner">
|
||||||
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>
|
<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>
|
<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="spinner" class="text-gray-700 text-sm px-1 py-2 htmx-indicator"> Query running... </p>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user