INIT: First commit, having session issues
Shocker! These sessions are stupid as hell. Going to try using gorilla instead.
This commit is contained in:
parent
adfafc9943
commit
111a6aead3
BIN
assets/favicon.ico
Normal file
BIN
assets/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 433 KiB |
7
cmd/web_server.go
Normal file
7
cmd/web_server.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/Azpect3120/Web-Database-Viewer/internal/http"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
http.New("3001").Setup().Start()
|
||||||
|
}
|
||||||
43
go.mod
Normal file
43
go.mod
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
module github.com/Azpect3120/Web-Database-Viewer
|
||||||
|
|
||||||
|
go 1.22.5
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gin-contrib/cors v1.7.2
|
||||||
|
github.com/gin-contrib/sessions v1.0.1
|
||||||
|
github.com/gin-gonic/gin v1.10.0
|
||||||
|
github.com/lib/pq v1.10.9
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/bytedance/sonic v1.11.6 // indirect
|
||||||
|
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||||
|
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||||
|
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||||
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
|
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||||
|
github.com/goccy/go-json v0.10.2 // indirect
|
||||||
|
github.com/gorilla/context v1.1.2 // indirect
|
||||||
|
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||||
|
github.com/gorilla/sessions v1.2.2 // indirect
|
||||||
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||||
|
github.com/kr/text v0.2.0 // indirect
|
||||||
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||||
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
|
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||||
|
golang.org/x/arch v0.8.0 // indirect
|
||||||
|
golang.org/x/crypto v0.23.0 // indirect
|
||||||
|
golang.org/x/net v0.25.0 // indirect
|
||||||
|
golang.org/x/sys v0.20.0 // indirect
|
||||||
|
golang.org/x/text v0.15.0 // indirect
|
||||||
|
google.golang.org/protobuf v1.34.1 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
)
|
||||||
111
go.sum
Normal file
111
go.sum
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||||
|
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||||
|
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
||||||
|
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||||
|
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
||||||
|
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||||
|
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||||
|
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||||
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||||
|
github.com/gin-contrib/cors v1.7.2 h1:oLDHxdg8W/XDoN/8zamqk/Drgt4oVZDvaV0YmvVICQw=
|
||||||
|
github.com/gin-contrib/cors v1.7.2/go.mod h1:SUJVARKgQ40dmrzgXEVxj2m7Ig1v1qIboQkPDTQ9t2E=
|
||||||
|
github.com/gin-contrib/sessions v1.0.1 h1:3hsJyNs7v7N8OtelFmYXFrulAf6zSR7nW/putcPEHxI=
|
||||||
|
github.com/gin-contrib/sessions v1.0.1/go.mod h1:ouxSFM24/OgIud5MJYQJLpy6AwxQ5EYO9yLhbtObGkM=
|
||||||
|
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||||
|
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||||
|
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||||
|
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||||
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
|
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
|
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||||
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
|
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
|
||||||
|
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||||
|
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||||
|
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||||
|
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||||
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||||
|
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o=
|
||||||
|
github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM=
|
||||||
|
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
||||||
|
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
|
||||||
|
github.com/gorilla/sessions v1.2.2 h1:lqzMYz6bOfvn2WriPUjNByzeXIlVzURcPmgMczkmTjY=
|
||||||
|
github.com/gorilla/sessions v1.2.2/go.mod h1:ePLdVu+jbEgHH+KWw8I1z2wqd0BAdAQh/8LRvBeoNcQ=
|
||||||
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||||
|
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||||
|
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||||
|
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||||
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
|
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||||
|
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||||
|
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||||
|
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
|
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||||
|
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||||
|
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||||
|
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
||||||
|
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||||
|
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||||
|
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||||
|
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||||
|
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||||
|
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||||
|
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
||||||
|
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||||
|
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||||
31
internal/database/create.go
Normal file
31
internal/database/create.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package database
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/gin-contrib/sessions"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CreateConnection(c *gin.Context) {
|
||||||
|
session := sessions.Default(c)
|
||||||
|
var (
|
||||||
|
url string = c.PostForm("db-url")
|
||||||
|
database string = c.PostForm("db-database")
|
||||||
|
)
|
||||||
|
|
||||||
|
connections, ok := session.Get("connections").(map[string]string)
|
||||||
|
if !ok {
|
||||||
|
fmt.Println("Creating new connections map /internal/database/create.go:19")
|
||||||
|
connections = make(map[string]string)
|
||||||
|
}
|
||||||
|
|
||||||
|
connections[database] = url
|
||||||
|
|
||||||
|
session.Set("connections", connections)
|
||||||
|
err := session.Save()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Failed to save session /internal/database/create.go:29")
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
48
internal/database/test.go
Normal file
48
internal/database/test.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package database
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
_ "github.com/lib/pq"
|
||||||
|
)
|
||||||
|
|
||||||
|
const CONNECTION_SUCCESS string = `
|
||||||
|
<span id="connection-status" class="w-3 h-3 bg-green-500 rounded-full"></span>
|
||||||
|
<span hx-swap-oob="outerHTML" id="connection-message" class="text-green-500"> Connection successful! </span>
|
||||||
|
<span hx-swap-oob="outerHTML" id="db-url-invalid" class="text-xs text-red-500 hidden"></span>
|
||||||
|
`
|
||||||
|
|
||||||
|
const CONNECTION_FAILURE string = `
|
||||||
|
<span id="connection-status" class="w-3 h-3 bg-red-500 rounded-full"></span>
|
||||||
|
<span hx-swap-oob="outerHTML" id="connection-message" class="text-red-500"> Connection failed! </span>
|
||||||
|
<span hx-swap-oob="outerHTML" id="db-url-invalid" class="text-xs text-red-500">%s</span>
|
||||||
|
`
|
||||||
|
|
||||||
|
// Test a connection to a database
|
||||||
|
func TestConnectionURL(c *gin.Context) {
|
||||||
|
var driver string
|
||||||
|
switch c.PostForm("db-driver") {
|
||||||
|
case "postgresql":
|
||||||
|
driver = "postgres"
|
||||||
|
default:
|
||||||
|
c.String(200, fmt.Sprintf(CONNECTION_FAILURE, "Unsupported driver"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open connection
|
||||||
|
conn, err := sql.Open(driver, c.PostForm("db-url"))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
c.String(200, CONNECTION_FAILURE)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ping/test connection
|
||||||
|
if err := conn.Ping(); err != nil {
|
||||||
|
c.String(200, fmt.Sprintf(CONNECTION_FAILURE, err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.String(200, CONNECTION_SUCCESS)
|
||||||
|
}
|
||||||
38
internal/http/router.go
Normal file
38
internal/http/router.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package http
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Azpect3120/Web-Database-Viewer/internal/database"
|
||||||
|
"github.com/gin-contrib/sessions"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Populate the server with routes
|
||||||
|
func populate(web, api *gin.RouterGroup) {
|
||||||
|
web.GET("/view", func(c *gin.Context) {
|
||||||
|
c.HTML(200, "index.html", gin.H{})
|
||||||
|
})
|
||||||
|
|
||||||
|
api.GET("/status", func(c *gin.Context) {
|
||||||
|
c.JSON(200, gin.H{
|
||||||
|
"status": "ok",
|
||||||
|
"time": time.Now().String(),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
api.POST("/query", func(c *gin.Context) {
|
||||||
|
sql := c.PostForm("sql")
|
||||||
|
c.JSON(200, gin.H{"sql": sql})
|
||||||
|
})
|
||||||
|
|
||||||
|
api.POST("/connections/test", database.TestConnectionURL)
|
||||||
|
api.POST("/connections", database.CreateConnection)
|
||||||
|
api.GET("/connections", func(c *gin.Context) {
|
||||||
|
session := sessions.Default(c)
|
||||||
|
connections, ok := session.Get("connections").(map[string]string)
|
||||||
|
|
||||||
|
c.JSON(200, gin.H{"okay": ok, "connections": connections})
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
54
internal/http/server.go
Normal file
54
internal/http/server.go
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package http
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/gin-contrib/cors"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Server struct {
|
||||||
|
port string
|
||||||
|
Router *gin.Engine
|
||||||
|
config cors.Config
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new instance of the http.Server struct
|
||||||
|
func New(port string) *Server {
|
||||||
|
gin.SetMode(gin.DebugMode)
|
||||||
|
|
||||||
|
var server *Server = &Server{
|
||||||
|
port: port,
|
||||||
|
Router: gin.Default(),
|
||||||
|
config: cors.DefaultConfig(),
|
||||||
|
}
|
||||||
|
|
||||||
|
server.config.AllowOrigins = []string{"*"}
|
||||||
|
server.Router.Use(cors.New(server.config))
|
||||||
|
|
||||||
|
return server
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup the server with the necessary configurations
|
||||||
|
func (s *Server) Setup() *Server {
|
||||||
|
// This has to be first ALWAYS for some stupid reason :|
|
||||||
|
s.initSession()
|
||||||
|
|
||||||
|
v1 := s.Router.Group("/v1")
|
||||||
|
web_g := v1.Group("/web")
|
||||||
|
api_g := v1.Group("/api")
|
||||||
|
|
||||||
|
web_g.Static("/static", "./web/static")
|
||||||
|
web_g.Static("/assets", "./assets")
|
||||||
|
|
||||||
|
s.Router.LoadHTMLGlob("./web/templates/*.html")
|
||||||
|
|
||||||
|
populate(web_g, api_g)
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run the server with the port defined on instantiation
|
||||||
|
func (s *Server) Start() {
|
||||||
|
s.Router.Run(fmt.Sprintf(":%s", s.port))
|
||||||
|
}
|
||||||
18
internal/http/session.go
Normal file
18
internal/http/session.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package http
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/gob"
|
||||||
|
|
||||||
|
"github.com/gin-contrib/sessions"
|
||||||
|
"github.com/gin-contrib/sessions/cookie"
|
||||||
|
)
|
||||||
|
|
||||||
|
const SESSION_SECRET string = "lqMVy04h8KWll6lCU9XCDbfUsBIjD1eG"
|
||||||
|
|
||||||
|
// Initialize the session
|
||||||
|
// Session is a map of "db name": "connection url"
|
||||||
|
func (s *Server) initSession() {
|
||||||
|
gob.Register(&map[string]string{})
|
||||||
|
store := cookie.NewStore([]byte(SESSION_SECRET))
|
||||||
|
s.Router.Use(sessions.Sessions("mysession", store))
|
||||||
|
}
|
||||||
25
tailwind.config.js
Normal file
25
tailwind.config.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
module.exports = {
|
||||||
|
content: [
|
||||||
|
"./web/templates/*.html",
|
||||||
|
"./web/templates/**/*.html"
|
||||||
|
],
|
||||||
|
darkMode: "class",
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
colors: {
|
||||||
|
primary: {
|
||||||
|
100: "#EF8275",
|
||||||
|
200: "#98023E",
|
||||||
|
},
|
||||||
|
secondary: {
|
||||||
|
100: "#E6E6E6",
|
||||||
|
200: "#808D8E",
|
||||||
|
300: "#1E2019",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
|
|
||||||
3
tools/styles/compile.sh
Executable file
3
tools/styles/compile.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
./tools/tailwind -i ./public/assets/styles/config.css -o ./public/assets/styles/main.css --minify
|
||||||
3
tools/styles/watch.sh
Executable file
3
tools/styles/watch.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
./tools/tailwind -i ./web/static/styles/config.css -o ./web/static/styles/main.css --watch
|
||||||
BIN
tools/tailwind
Executable file
BIN
tools/tailwind
Executable file
Binary file not shown.
77
web/static/scripts/modal.js
Normal file
77
web/static/scripts/modal.js
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* This file is used to generate the connection URL for the database connection
|
||||||
|
* when the user changes inputs in the connection modal.
|
||||||
|
*
|
||||||
|
* This file is also used to show and hide the connection modal.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// New connection modal
|
||||||
|
const modal = document.getElementById("connection-modal");
|
||||||
|
|
||||||
|
function ShowModal() {
|
||||||
|
modal.classList.remove("hidden");
|
||||||
|
modal.classList.remove("opacity-0");
|
||||||
|
}
|
||||||
|
|
||||||
|
function HideModal() {
|
||||||
|
modal.classList.add("hidden");
|
||||||
|
modal.classList.add("opacity-0");
|
||||||
|
}
|
||||||
|
|
||||||
|
const input = {
|
||||||
|
host: document.getElementById("db-host"),
|
||||||
|
port: document.getElementById("db-port"),
|
||||||
|
driver: document.getElementById("db-driver"),
|
||||||
|
username: document.getElementById("db-username"),
|
||||||
|
password: document.getElementById("db-password"),
|
||||||
|
database: document.getElementById("db-database"),
|
||||||
|
connectionURL: document.getElementById("db-url")
|
||||||
|
}
|
||||||
|
|
||||||
|
// State for hiding the password in the connection URL
|
||||||
|
// let hidden = true;
|
||||||
|
// const togglePassword = () => {
|
||||||
|
// hidden = !hidden;
|
||||||
|
// GenerateURL(input);
|
||||||
|
// }
|
||||||
|
|
||||||
|
function GenerateURL(data) {
|
||||||
|
// let password = hidden ? "●".repeat(data.password.value.length) : data.password.value;
|
||||||
|
data.connectionURL.value = `${data.driver.value}://${data.username.value || "<username>"}:${data.password.value || "<password>"}@${data.host.value || "<host>"}:${data.port.value || "<port>"}/${data.database.value || "<database>"}?sslmode=disable`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ParseURL (data) {
|
||||||
|
const regex = /^(?<protocol>[a-z]+):\/\/(?<username>[^:]+):(?<password>[^@]+)@(?<host>[^:]+):(?<port>[0-9]+)\/(?<database>[^\?]+)(\?(?<params>.*))?$/;
|
||||||
|
const match = data.connectionURL.value.match(regex);
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
const { protocol, username, password, host, port, database } = match.groups;
|
||||||
|
|
||||||
|
data.host.value = host;
|
||||||
|
data.port.value = port;
|
||||||
|
data.password.value = password;
|
||||||
|
data.username.value = username;
|
||||||
|
data.driver.value = protocol;
|
||||||
|
data.database.value = database;
|
||||||
|
|
||||||
|
data.connectionURL.classList.remove("text-red-500");
|
||||||
|
document.getElementById("db-url-invalid").classList.add("hidden");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
data.connectionURL.classList.add("text-red-500");
|
||||||
|
document.getElementById("db-url-invalid").classList.remove("hidden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the event listeners for the input fields
|
||||||
|
for (const key in input) {
|
||||||
|
if (key == "connectionURL") {
|
||||||
|
input[key].addEventListener("input", () => {
|
||||||
|
ParseURL(input);
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
input[key].addEventListener("input", () => {
|
||||||
|
GenerateURL(input);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
20
web/static/scripts/password.js
Normal file
20
web/static/scripts/password.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* This file is used to toggle the password visibility in the password input field
|
||||||
|
* of the new connection modal.
|
||||||
|
*/
|
||||||
|
const passwordInput = document.getElementById("db-password");
|
||||||
|
const toggleButton = document.getElementById("togglePassword");
|
||||||
|
const eyeIcon = document.getElementById("eyeIcon");
|
||||||
|
const urlInput = document.getElementById("db-url");
|
||||||
|
|
||||||
|
toggleButton.addEventListener("click", () => {
|
||||||
|
if (passwordInput.type === "password") {
|
||||||
|
passwordInput.type = "text";
|
||||||
|
urlInput.type = "text";
|
||||||
|
eyeIcon.setAttribute("stroke", "blue");
|
||||||
|
} else {
|
||||||
|
passwordInput.type = "password";
|
||||||
|
urlInput.type = "password";
|
||||||
|
eyeIcon.setAttribute("stroke", "currentColor");
|
||||||
|
}
|
||||||
|
});
|
||||||
3
web/static/styles/config.css
Normal file
3
web/static/styles/config.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind utilities;
|
||||||
|
@tailwind components;
|
||||||
1043
web/static/styles/main.css
Normal file
1043
web/static/styles/main.css
Normal file
File diff suppressed because it is too large
Load Diff
244
web/templates/index.html
Normal file
244
web/templates/index.html
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<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>
|
||||||
|
<body class="bg-gray-100">
|
||||||
|
|
||||||
|
<div class="flex flex-col h-screen">
|
||||||
|
<!-- Top Bar -->
|
||||||
|
<div class="bg-white shadow-md p-4 flex items-center justify-between border-b">
|
||||||
|
<div>
|
||||||
|
<h1 class="text-2xl font-bold">Database Query Tool</h1>
|
||||||
|
<p class="text-sm text-gray-600">Connect and query your databases effortlessly.</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-end space-x-4 flex-wrap">
|
||||||
|
<label for="database" class="block text-sm font-medium text-gray-700">Connected Database:</label>
|
||||||
|
<select id="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">
|
||||||
|
<option value="database1">Database 1</option>
|
||||||
|
<option value="database2">Database 2</option>
|
||||||
|
</select>
|
||||||
|
<button onclick="ShowModal();" class="bg-blue-500 text-white px-4 py-2 my-2 rounded-md text-sm md:text-base">
|
||||||
|
Add Connection
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col md:flex-row flex-grow">
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<div class="w-full md:w-1/4 bg-white shadow-md">
|
||||||
|
<div class="p-4 border-b">
|
||||||
|
<h2 class="text-lg font-bold"><em>Database 1</em> Tables</h2>
|
||||||
|
</div>
|
||||||
|
<div class="p-4 max-h-full">
|
||||||
|
<ul class="space-y-2">
|
||||||
|
<li>
|
||||||
|
<button class="w-full text-left text-gray-700 font-medium hover:bg-gray-100 p-2 rounded flex items-center" title="Select this table">
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 9l6 6 6-6"></path>
|
||||||
|
</svg>
|
||||||
|
Table 1
|
||||||
|
</button>
|
||||||
|
<ul class="ml-6 mt-1 space-y-1 text-gray-600">
|
||||||
|
<li>
|
||||||
|
<button class="flex items-center" title="Select this field">
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-7 6h7"></path>
|
||||||
|
</svg>
|
||||||
|
<span>Column 1</span>
|
||||||
|
<span class="h-1.5 w-1.5 bg-yellow-500 rounded-full mx-2" title="Primary Key"></span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button class="flex items-center" title="Select this field">
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-7 6h7"></path>
|
||||||
|
</svg>
|
||||||
|
<span>Column 2</span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button class="w-full text-left text-gray-700 font-medium hover:bg-gray-100 p-2 rounded flex items-center" title="Select this table">
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 9l6 6 6-6"></path>
|
||||||
|
</svg>
|
||||||
|
Table 2
|
||||||
|
</button>
|
||||||
|
<ul class="ml-6 mt-1 space-y-1 text-gray-600">
|
||||||
|
<li>
|
||||||
|
<button class="flex items-center" title="Select this field">
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-7 6h7"></path>
|
||||||
|
</svg>
|
||||||
|
<span>Column A</span>
|
||||||
|
<span class="h-1.5 w-1.5 bg-yellow-500 rounded-full mx-2" title="Primary Key"></span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button class="flex items-center" title="Select this field">
|
||||||
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-7 6h7"></path>
|
||||||
|
</svg>
|
||||||
|
<span>Column B</span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Main Content -->
|
||||||
|
<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="none"
|
||||||
|
hx-target=""
|
||||||
|
>
|
||||||
|
<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>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- Query Results -->
|
||||||
|
<div class="overflow-x-auto overflow-y-hidden bg-white shadow-md rounded-lg">
|
||||||
|
<table class="min-w-full divide-y divide-gray-200">
|
||||||
|
<thead class="bg-gray-50">
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Column 1</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Column 2</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="bg-white divide-y divide-gray-200">
|
||||||
|
<tr>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">Data 1</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">Data 2</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">Data A</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">Data B</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Create Connection Modal -->
|
||||||
|
<div id="connection-modal" class="fixed inset-0 bg-gray-600 bg-opacity-50 hidden opacity-0">
|
||||||
|
<div class="flex items-center justify-center min-h-screen">
|
||||||
|
<div class="bg-white p-6 rounded-lg shadow-lg w-2/3">
|
||||||
|
<div class="flex justify-between items-center border-b pb-2">
|
||||||
|
<h2 class="text-xl font-bold">Add New Connection</h2>
|
||||||
|
<button onclick="HideModal();" class="text-gray-500 hover:text-gray-700">
|
||||||
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="mt-4">
|
||||||
|
<form id="connection-form" class="grid grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label for="db-host" class="block text-sm font-medium text-gray-700">Host</label>
|
||||||
|
<input id="db-host" name="db-host" type="text" placeholder="127.0.0.1" value="127.0.0.1" 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">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="db-port" class="block text-sm font-medium text-gray-700">Port</label>
|
||||||
|
<input id="db-port" name="db-port" type="text" placeholder="5432" value="5432" 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">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="db-username" class="block text-sm font-medium text-gray-700">Username</label>
|
||||||
|
<input id="db-username" name="db-username" type="text" placeholder="admin" value="azpect" 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">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="db-password" class="block text-sm font-medium text-gray-700">Password</label>
|
||||||
|
<div class="relative mt-1">
|
||||||
|
<input
|
||||||
|
id="db-password"
|
||||||
|
name="db-password"
|
||||||
|
type="password"
|
||||||
|
placeholder="●●●●●●●●●"
|
||||||
|
value="Panther4487!!!!"
|
||||||
|
class="block w-full p-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
|
||||||
|
>
|
||||||
|
<button type="button" id="togglePassword" class="absolute inset-y-0 right-0 px-3 py-2 text-gray-500 bg-gray-200 rounded-r-md border border-gray-300" title="Display secret details">
|
||||||
|
<svg id="eyeIcon" xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M1 12s3.5-7 11-7 11 7 11 7-3.5 7-11 7S1 12 1 12z"></path>
|
||||||
|
<circle cx="12" cy="12" r="3"></circle>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="db-driver" class="block text-sm font-medium text-gray-700">Driver/Type of Database</label>
|
||||||
|
<select id="db-driver" name="db-driver" 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">
|
||||||
|
<option value="postgresql">PostgreSQL</option>
|
||||||
|
<option value="mysql">MySQL</option>
|
||||||
|
<option value="sqlite">SQLite</option>
|
||||||
|
<option value="sqlserver">SQL Server</option>
|
||||||
|
<option value="oracle">Oracle</option>
|
||||||
|
<option value="mariadb">MariaDB</option>
|
||||||
|
<option value="db2">DB2</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="db-database" class="block text-sm font-medium text-gray-700">Database Name</label>
|
||||||
|
<input id="db-database" name="db-database" type="text" placeholder="master_database" value="azpect" 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">
|
||||||
|
</div>
|
||||||
|
<div class="col-span-2">
|
||||||
|
<label for="db-url" class="block text-sm font-medium text-gray-700">
|
||||||
|
Connection URL
|
||||||
|
<br>
|
||||||
|
<span class="text-xs font-light">
|
||||||
|
The connection URL will be automatically generated based on the above fields. To view the URL generated,
|
||||||
|
push the "display secret details" button in the password section.
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
<input id="db-url" name="db-url" type="password" placeholder="postgresql://admin:password@127.0.0.1:5432/master_database" value="postgresql://azpect:Panther4487!!!!@127.0.0.1:5432/azpect?sslmode=disable" 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">
|
||||||
|
<span id="db-url-invalid" class="text-xs text-red-500 hidden">Connection URL is incomplete or invalid.</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="flex items-center space-x-4 mt-4">
|
||||||
|
<button
|
||||||
|
hx-post="/v1/api/connections"
|
||||||
|
hx-trigger="click"
|
||||||
|
hx-swap="none"
|
||||||
|
hx-include="#connection-form"
|
||||||
|
onclick="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" hx-target="#connection-status" hx-include="#connection-form" hx-encoding="multipart/form-data" class="bg-gray-200 text-gray-700 px-4 py-2 rounded-md flex items-center space-x-2">
|
||||||
|
<span>Test Connection</span>
|
||||||
|
<span id="connection-status" class="w-3 h-3 rounded-full bg-gray-400"></span>
|
||||||
|
</button>
|
||||||
|
<span id="connection-message"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Scripts -->
|
||||||
|
<script src="/v1/web/static/scripts/password.js"></script>
|
||||||
|
<script src="/v1/web/static/scripts/modal.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user