diff --git a/quesma/quesma/ui/console_routes.go b/quesma/quesma/ui/console_routes.go index 6a5d0ace4..aaf190964 100644 --- a/quesma/quesma/ui/console_routes.go +++ b/quesma/quesma/ui/console_routes.go @@ -61,7 +61,7 @@ func (qmc *QuesmaManagementConsole) createRouting() *mux.Router { }) router.HandleFunc("/data-sources", func(writer http.ResponseWriter, req *http.Request) { - buf := qmc.generateDatasources() + buf := qmc.generateDatasourcesPage() _, _ = writer.Write(buf) }) @@ -107,6 +107,11 @@ func (qmc *QuesmaManagementConsole) createRouting() *mux.Router { _, _ = writer.Write(buf) }) + router.HandleFunc("/panel/data-sources", func(writer http.ResponseWriter, req *http.Request) { + buf := qmc.generateDatasources() + _, _ = writer.Write(buf) + }) + router.PathPrefix("/request-Id/{requestId}").HandlerFunc(func(writer http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) buf := qmc.generateReportForRequestId(vars["requestId"]) diff --git a/quesma/quesma/ui/dashboard.go b/quesma/quesma/ui/dashboard.go index 5b7d1d66a..caf7d60ec 100644 --- a/quesma/quesma/ui/dashboard.go +++ b/quesma/quesma/ui/dashboard.go @@ -6,7 +6,7 @@ import ( "github.com/shirou/gopsutil/v3/host" "github.com/shirou/gopsutil/v3/mem" "mitmproxy/quesma/buildinfo" - "mitmproxy/quesma/quesma/ui/internal/buffer" + "mitmproxy/quesma/quesma/ui/internal/builder" "mitmproxy/quesma/stats/errorstats" "net/url" "runtime" @@ -90,7 +90,7 @@ func (qmc *QuesmaManagementConsole) generateDashboardTrafficElement(typeName str } func (qmc *QuesmaManagementConsole) generateDashboardTrafficPanel() []byte { - var buffer buffer.HtmlBuffer + var buffer builder.HtmlBuffer // Clickhouse -> Kibana if qmc.config.ReadsFromClickhouse() { @@ -124,7 +124,7 @@ func statusToDiv(s healthCheckStatus) string { } func (qmc *QuesmaManagementConsole) generateDashboardPanel() []byte { - var buffer buffer.HtmlBuffer + var buffer builder.HtmlBuffer dashboardName := "

Kibana

" storeName := "

Elasticsearch

" diff --git a/quesma/quesma/ui/data_sources.go b/quesma/quesma/ui/data_sources.go index fd80798b2..f0cc6251e 100644 --- a/quesma/quesma/ui/data_sources.go +++ b/quesma/quesma/ui/data_sources.go @@ -2,15 +2,34 @@ package ui import ( "fmt" + "mitmproxy/quesma/quesma/ui/internal/builder" "slices" "strings" ) -func (qmc *QuesmaManagementConsole) generateDatasources() []byte { +func (qmc *QuesmaManagementConsole) generateDatasourcesPage() []byte { buffer := newBufferWithHead() - buffer.Write(generateTopNavigation("datasources")) + buffer.Write(generateTopNavigation("data-sources")) + + buffer.Html(`
`) + buffer.Write(qmc.generateDatasources()) + + buffer.Html("\n
\n\n") - buffer.Html(`
`) + buffer.Html(`") + + buffer.Html("\n") + buffer.Html("\n") + return buffer.Bytes() +} + +func (qmc *QuesmaManagementConsole) generateDatasources() []byte { + var buffer builder.HtmlBuffer buffer.Html(`

Data sources

`) buffer.Html(`

Clickhouse

`) @@ -64,17 +83,5 @@ func (qmc *QuesmaManagementConsole) generateDatasources() []byte { } buffer.Html(``) - - buffer.Html("\n
\n\n") - - buffer.Html(`") - - buffer.Html("\n") - buffer.Html("\n") return buffer.Bytes() } diff --git a/quesma/quesma/ui/html_utils.go b/quesma/quesma/ui/html_utils.go index 328b55a31..89143eec2 100644 --- a/quesma/quesma/ui/html_utils.go +++ b/quesma/quesma/ui/html_utils.go @@ -2,12 +2,12 @@ package ui import ( "fmt" - "mitmproxy/quesma/quesma/ui/internal/buffer" + "mitmproxy/quesma/quesma/ui/internal/builder" "net/url" ) func generateSimpleTop(title string) []byte { - var buffer buffer.HtmlBuffer + var buffer builder.HtmlBuffer buffer.Html(`
` + "\n") buffer.Html(`
` + "\n") buffer.Html(`` + "\n") @@ -17,7 +17,7 @@ func generateSimpleTop(title string) []byte { } func generateTopNavigation(target string) []byte { - var buffer buffer.HtmlBuffer + var buffer builder.HtmlBuffer buffer.Html(`
` + "\n") buffer.Html(`
` + "\n") buffer.Html(`` + "\n") @@ -58,7 +58,7 @@ func generateTopNavigation(target string) []byte { buffer.Html(`>Telemetry`) buffer.Html("Data sources`) @@ -81,9 +81,9 @@ func generateTopNavigation(target string) []byte { return buffer.Bytes() } -func newBufferWithHead() buffer.HtmlBuffer { +func newBufferWithHead() builder.HtmlBuffer { const bufferSize = 4 * 1024 // size of ui/head.html - var buffer buffer.HtmlBuffer + var buffer builder.HtmlBuffer buffer.Grow(bufferSize) head, err := uiFs.ReadFile("asset/head.html") buffer.Write(head) diff --git a/quesma/quesma/ui/ingest.go b/quesma/quesma/ui/ingest.go index ff659ed42..80321e032 100644 --- a/quesma/quesma/ui/ingest.go +++ b/quesma/quesma/ui/ingest.go @@ -2,7 +2,7 @@ package ui import ( "fmt" - "mitmproxy/quesma/quesma/ui/internal/buffer" + "mitmproxy/quesma/quesma/ui/internal/builder" "mitmproxy/quesma/stats" "strings" ) @@ -28,7 +28,7 @@ func (qmc *QuesmaManagementConsole) generateIngestStatistics() []byte { } func (qmc *QuesmaManagementConsole) generateStatistics() []byte { - var buffer buffer.HtmlBuffer + var buffer builder.HtmlBuffer const maxTopValues = 5 if !qmc.config.IngestStatistics { diff --git a/quesma/quesma/ui/internal/buffer/html_buffer.go b/quesma/quesma/ui/internal/builder/html_buffer.go similarity index 97% rename from quesma/quesma/ui/internal/buffer/html_buffer.go rename to quesma/quesma/ui/internal/builder/html_buffer.go index fee3d02ca..8e122308a 100644 --- a/quesma/quesma/ui/internal/buffer/html_buffer.go +++ b/quesma/quesma/ui/internal/builder/html_buffer.go @@ -1,4 +1,4 @@ -package buffer +package builder import ( "bytes" diff --git a/quesma/quesma/ui/internal/buffer/html_buffer_test.go b/quesma/quesma/ui/internal/builder/html_buffer_test.go similarity index 96% rename from quesma/quesma/ui/internal/buffer/html_buffer_test.go rename to quesma/quesma/ui/internal/builder/html_buffer_test.go index 42b9678af..82568660b 100644 --- a/quesma/quesma/ui/internal/buffer/html_buffer_test.go +++ b/quesma/quesma/ui/internal/builder/html_buffer_test.go @@ -1,4 +1,4 @@ -package buffer +package builder import ( "github.com/stretchr/testify/assert" diff --git a/quesma/quesma/ui/live_tail.go b/quesma/quesma/ui/live_tail.go index 26415a8ea..4927a4056 100644 --- a/quesma/quesma/ui/live_tail.go +++ b/quesma/quesma/ui/live_tail.go @@ -3,7 +3,7 @@ package ui import ( "fmt" "mitmproxy/quesma/buildinfo" - "mitmproxy/quesma/quesma/ui/internal/buffer" + "mitmproxy/quesma/quesma/ui/internal/builder" "mitmproxy/quesma/quesma/ui/internal/sqlfmt" ) @@ -126,7 +126,7 @@ func (qmc *QuesmaManagementConsole) generateUnsupportedQuerySidePanel() []byte { unknownTypeCount = value } - var buffer buffer.HtmlBuffer + var buffer builder.HtmlBuffer linkToMainView := `
  • `) if totalErrorsCount > 0 { @@ -162,7 +162,7 @@ func (qmc *QuesmaManagementConsole) generateQueriesStatsPanel() []byte { } qmc.mutex.Unlock() - var buffer buffer.HtmlBuffer + var buffer builder.HtmlBuffer buffer.Html(`