From f673c84ba4675b9fad38ecb353f1985593b7f5d7 Mon Sep 17 00:00:00 2001 From: Markus Blaschke Date: Wed, 21 Aug 2024 19:33:57 +0200 Subject: [PATCH] add configurable paging size Signed-off-by: Markus Blaschke --- config/opts.go | 3 ++- main.go | 30 ++++++++++++++++-------------- templates/report.js | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/config/opts.go b/config/opts.go index 5a95a0e..cb4d20a 100644 --- a/config/opts.go +++ b/config/opts.go @@ -24,7 +24,8 @@ type ( // report Report struct { - Title string `long:"report.title" env:"REPORT_TITLE" description:"Report title"` + Title string `long:"report.title" env:"REPORT_TITLE" description:"Report title"` + PaginationSize int `long:"report.pagination.size" env:"REPORT_PAGINATION_SIZE" description:"Report pagination size" default:"50" choice:"5" choice:"10" choice:"25" choice:"50" choice:"100" choice:"250"` } // scrape times diff --git a/main.go b/main.go index 0067547..81f505b 100644 --- a/main.go +++ b/main.go @@ -175,21 +175,23 @@ func startHttpServer() { selectedReport := r.URL.Query().Get("report") templatePayload := struct { - Nonce string - Config auditor.AuditConfig - ReportTitle string - ReportConfig *validator.AuditConfigValidation - Reports map[string]*auditor.AzureAuditorReport - ServerPathReport string - RequestReport string + Nonce string + Config auditor.AuditConfig + ReportTitle string + ReportConfig *validator.AuditConfigValidation + Reports map[string]*auditor.AzureAuditorReport + ServerPathReport string + RequestReport string + ReportPaginationSize int }{ - Nonce: cspNonce, - Config: azureAuditor.GetConfig(), - ReportTitle: Opts.Report.Title, - ReportConfig: nil, - Reports: azureAuditor.GetReport(), - ServerPathReport: Opts.Server.PathReport, - RequestReport: "", + Nonce: cspNonce, + Config: azureAuditor.GetConfig(), + ReportTitle: Opts.Report.Title, + ReportConfig: nil, + Reports: azureAuditor.GetReport(), + ServerPathReport: Opts.Server.PathReport, + RequestReport: "", + ReportPaginationSize: Opts.Report.PaginationSize, } reportInfo := strings.SplitN(selectedReport, ":", 2) diff --git a/templates/report.js b/templates/report.js index d6bb4e9..a89841b 100644 --- a/templates/report.js +++ b/templates/report.js @@ -200,7 +200,7 @@ let table = new Tabulator("#report-table", { renderHorizontal: "virtual", pagination: true, - paginationSize: 10, + paginationSize: {{ $root.ReportPaginationSize | default "10" }}, paginationSizeSelector: [5, 10, 25, 50, 100, 250, true], printHeader: $("#report-title").html(),