Compare commits
1 Commits
78aaf83d6e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b692a58ee2 |
40
build.bat
Normal file
40
build.bat
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
echo ==============================
|
||||||
|
echo Building Go binaries...
|
||||||
|
echo ==============================
|
||||||
|
|
||||||
|
set APP_NAME=dbPrompt
|
||||||
|
|
||||||
|
REM Create output folder
|
||||||
|
if not exist dist mkdir dist
|
||||||
|
|
||||||
|
REM Windows build
|
||||||
|
echo Building Windows...
|
||||||
|
set GOOS=windows
|
||||||
|
set GOARCH=amd64
|
||||||
|
go build -o dist\%APP_NAME%-windows-amd64.exe
|
||||||
|
|
||||||
|
if errorlevel 1 goto error
|
||||||
|
|
||||||
|
REM Linux build
|
||||||
|
echo Building Linux...
|
||||||
|
set GOOS=linux
|
||||||
|
set GOARCH=amd64
|
||||||
|
go build -o dist\%APP_NAME%-linux-amd64
|
||||||
|
|
||||||
|
if errorlevel 1 goto error
|
||||||
|
|
||||||
|
echo ==============================
|
||||||
|
echo Build completed successfully!
|
||||||
|
echo Output in dist\
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:error
|
||||||
|
echo.
|
||||||
|
echo BUILD FAILED!
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:end
|
||||||
|
endlocal
|
||||||
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"embed"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -17,6 +18,9 @@ import (
|
|||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed index.html static/*
|
||||||
|
var embeddedFiles embed.FS
|
||||||
|
|
||||||
// Config struct for database connection
|
// Config struct for database connection
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
@ -81,8 +85,11 @@ func main() {
|
|||||||
os.Mkdir(historyDir, 0755)
|
os.Mkdir(historyDir, 0755)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Serve static files
|
||||||
|
fs := http.FS(embeddedFiles)
|
||||||
|
|
||||||
// HTTP Handlers
|
// HTTP Handlers
|
||||||
http.HandleFunc("/", serveIndex)
|
http.Handle("/", http.FileServer(fs))
|
||||||
http.HandleFunc("/query", handleQuery)
|
http.HandleFunc("/query", handleQuery)
|
||||||
http.HandleFunc("/history/", handleHistory)
|
http.HandleFunc("/history/", handleHistory)
|
||||||
|
|
||||||
|
|||||||
27
index.html
27
index.html
@ -6,10 +6,19 @@
|
|||||||
<title>dbPrompt</title>
|
<title>dbPrompt</title>
|
||||||
<style>
|
<style>
|
||||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; margin: 0; background-color: #f0f2f5; color: #1c1e21; }
|
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; margin: 0; background-color: #f0f2f5; color: #1c1e21; }
|
||||||
header {
|
header {
|
||||||
background-color: #ffffff; padding: 10px 20px; border-bottom: 1px solid #dddfe2; font-size: 24px; font-weight: bold; color: #4b4f56;
|
background-color: #ffffff; padding: 10px 20px; border-bottom: 1px solid #dddfe2; font-size: 24px; font-weight: bold; color: #4b4f56;
|
||||||
display: flex; justify-content: space-between; align-items: center;
|
display: flex; justify-content: space-between; align-items: center;
|
||||||
}
|
}
|
||||||
|
.header-logo {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.header-logo a,
|
||||||
|
.header-logo a:visited {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #4b4f56;
|
||||||
|
}
|
||||||
.header-buttons button {
|
.header-buttons button {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@ -79,13 +88,16 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
dbPrompt
|
<div class="header-logo">
|
||||||
|
<a href="https://www.tpsoft.org" target="_blank"><img src="static/tpsoft-logo.png" alt="TPsoft.org" height="59"></a>
|
||||||
|
<a href="index.html">dbPrompt</a>
|
||||||
|
</div>
|
||||||
<div class="header-buttons">
|
<div class="header-buttons">
|
||||||
<button id="collapse-all-btn">Collapse All</button>
|
<button id="collapse-all-btn">Collapse All</button>
|
||||||
<button id="expand-all-btn">Expand All</button>
|
<button id="expand-all-btn">Expand All</button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main id="main-container">
|
<main id="main-container">
|
||||||
<!-- Query blocks will be inserted here -->
|
<!-- Query blocks will be inserted here -->
|
||||||
</main>
|
</main>
|
||||||
@ -144,7 +156,7 @@
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const isNewQueryBlock = block.classList.contains('new-query-block');
|
const isNewQueryBlock = block.classList.contains('new-query-block');
|
||||||
|
|
||||||
block.dataset.id = data.id;
|
block.dataset.id = data.id;
|
||||||
renderResult(resultContainer, data);
|
renderResult(resultContainer, data);
|
||||||
|
|
||||||
@ -179,7 +191,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Toggle Collapse
|
// Handle Toggle Collapse
|
||||||
const header = target.closest('.collapsible-header');
|
const header = target.closest('.collapsible-header');
|
||||||
if (header) {
|
if (header) {
|
||||||
@ -227,12 +239,12 @@
|
|||||||
if (data.timestamp) {
|
if (data.timestamp) {
|
||||||
metaHtml = `
|
metaHtml = `
|
||||||
<div class="result-meta">
|
<div class="result-meta">
|
||||||
<span>Executed: ${new Date(data.timestamp / 1000000).toLocaleString()}</span> |
|
<span>Executed: ${new Date(data.timestamp / 1000000).toLocaleString()}</span> |
|
||||||
<span>Duration: ${data.duration ?? 'N/A'} ms</span>
|
<span>Duration: ${data.duration ?? 'N/A'} ms</span>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let finalHtml;
|
let finalHtml;
|
||||||
if (isCollapsible) {
|
if (isCollapsible) {
|
||||||
finalHtml = `
|
finalHtml = `
|
||||||
@ -314,4 +326,3 @@
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
BIN
static/tpsoft-logo.png
Normal file
BIN
static/tpsoft-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.8 KiB |
Reference in New Issue
Block a user