From 86872319475d324902185f91fe9312b2aed85ba9 Mon Sep 17 00:00:00 2001 From: Jacek Migdal Date: Thu, 2 May 2024 20:57:36 +0200 Subject: [PATCH] More work --- quesma/quesma/ui/console_routes.go | 7 ++++++- quesma/quesma/ui/html_pages.go | 9 +++++---- quesma/quesma/ui/unsupported_queries.go | 15 ++++++++------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/quesma/quesma/ui/console_routes.go b/quesma/quesma/ui/console_routes.go index 45ed36203..3c6e910ed 100644 --- a/quesma/quesma/ui/console_routes.go +++ b/quesma/quesma/ui/console_routes.go @@ -126,10 +126,15 @@ func (qmc *QuesmaManagementConsole) createRouting() *mux.Router { buf := qmc.generateErrorForReason(vars["reason"]) _, _ = writer.Write(buf) }) - router.PathPrefix("/unsupported-requests").HandlerFunc(func(writer http.ResponseWriter, r *http.Request) { + router.Path("/unsupported-requests").HandlerFunc(func(writer http.ResponseWriter, r *http.Request) { buf := qmc.generateReportForUnsupportedRequests() _, _ = writer.Write(buf) }) + router.PathPrefix("/unsupported-requests/{reason}").HandlerFunc(func(writer http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + buf := qmc.generateReportForUnsupportedType(vars["reason"]) + _, _ = writer.Write(buf) + }) router.PathPrefix("/requests-by-str/{queryString}").HandlerFunc(func(writer http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) buf := qmc.generateReportForRequestsWithStr(vars["queryString"]) diff --git a/quesma/quesma/ui/html_pages.go b/quesma/quesma/ui/html_pages.go index a4a715dd5..350c8543c 100644 --- a/quesma/quesma/ui/html_pages.go +++ b/quesma/quesma/ui/html_pages.go @@ -858,7 +858,7 @@ func (qmc *QuesmaManagementConsole) generateReportForRequestsWithStr(requestStr qmc.mutex.Unlock() title := fmt.Sprintf("Report for str '%s' with %d results", requestStr, len(debugKeyValueSlice)) - return qmc.generateReportForRequests(title, debugKeyValueSlice) + return qmc.generateReportForRequests(title, debugKeyValueSlice, []byte{}) } func (qmc *QuesmaManagementConsole) generateReportForRequestsWithError() []byte { @@ -874,7 +874,7 @@ func (qmc *QuesmaManagementConsole) generateReportForRequestsWithError() []byte } qmc.mutex.Unlock() - return qmc.generateReportForRequests("Report for requests with errors", debugKeyValueSlice) + return qmc.generateReportForRequests("Report for requests with errors", debugKeyValueSlice, []byte{}) } func (qmc *QuesmaManagementConsole) generateReportForRequestsWithWarning() []byte { @@ -890,10 +890,10 @@ func (qmc *QuesmaManagementConsole) generateReportForRequestsWithWarning() []byt } qmc.mutex.Unlock() - return qmc.generateReportForRequests("Report for requests with warnings", debugKeyValueSlice) + return qmc.generateReportForRequests("Report for requests with warnings", debugKeyValueSlice, []byte{}) } -func (qmc *QuesmaManagementConsole) generateReportForRequests(title string, requests []DebugKeyValue) []byte { +func (qmc *QuesmaManagementConsole) generateReportForRequests(title string, requests []DebugKeyValue, sidebar []byte) []byte { buffer := newBufferWithHead() buffer.Write(generateSimpleTop(title)) @@ -909,6 +909,7 @@ func (qmc *QuesmaManagementConsole) generateReportForRequests(title string, requ buffer.Html("\n

Menu

") buffer.Html(`
 
`) + buffer.Write(sidebar) buffer.Html("\n") buffer.Html("\n") diff --git a/quesma/quesma/ui/unsupported_queries.go b/quesma/quesma/ui/unsupported_queries.go index bff1ff356..f75f2e876 100644 --- a/quesma/quesma/ui/unsupported_queries.go +++ b/quesma/quesma/ui/unsupported_queries.go @@ -59,7 +59,7 @@ func (qmc *QuesmaManagementConsole) generateReportForUnsupportedRequests() []byt } qmc.mutex.Unlock() - return qmc.generateReportForRequests("Report for unsupported requests", debugKeyValueSlice) + return qmc.generateReportForRequests("Unsupported requests", debugKeyValueSlice, []byte{}) } func (qmc *QuesmaManagementConsole) generateUnsupportedQuerySidePanel() []byte { @@ -73,9 +73,9 @@ func (qmc *QuesmaManagementConsole) generateUnsupportedQuerySidePanel() []byte { savedErrorsCount += count } typesSeenCount := len(typesCount) - unkownTypeCount := 0 + unknownTypeCount := 0 if value, ok := typesCount[UnrecognizedQueryType]; ok { - unkownTypeCount = value + unknownTypeCount = value } var buffer HtmlBuffer @@ -88,8 +88,9 @@ func (qmc *QuesmaManagementConsole) generateUnsupportedQuerySidePanel() []byte { plural = "" } buffer.Html(fmt.Sprintf(`%s class="debug-warn-log"">%d different type%s`, linkToMainView, typesSeenCount, plural)) - if unkownTypeCount > 0 { - buffer.Html(fmt.Sprintf(`%s class="debug-error-log"">%d of unrecognized type`, linkToMainView, unkownTypeCount)) + if unknownTypeCount > 0 { + buffer.Html(fmt.Sprintf(`
  • `, UnrecognizedQueryType)) + buffer.Html(fmt.Sprintf(`%d of unrecognized type
  • `, unknownTypeCount)) } } else { buffer.Html(`
  • None!
  • `) @@ -158,6 +159,6 @@ func (qmc *QuesmaManagementConsole) QueriesWithUnsupportedType(typeName string) } func (qmc *QuesmaManagementConsole) generateReportForUnsupportedType(typeName string) []byte { - debugKeyValueSlice := qmc.QueriesWithUnsupportedType(typeName) - return qmc.generateReportForRequests("Report for unsupported request '"+typeName+"'", debugKeyValueSlice) + requests := qmc.QueriesWithUnsupportedType(typeName) + return qmc.generateReportForRequests("Report for unsupported request '"+typeName+"'", requests, []byte{}) }