From b44d6a96806b0b93c04ab7daa3e579a3777e295b Mon Sep 17 00:00:00 2001 From: Mahendra Paipuri Date: Thu, 2 May 2024 16:48:07 +0200 Subject: [PATCH] feat: Setup logo in footer of report Signed-off-by: Mahendra Paipuri --- pkg/plugin/app.go | 6 ++++++ pkg/plugin/report.go | 6 ++++++ pkg/plugin/resources.go | 1 + pkg/plugin/templates/footer.gohtml | 33 +++++++++++++++++++----------- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/pkg/plugin/app.go b/pkg/plugin/app.go index 002a8fe..0a648c9 100755 --- a/pkg/plugin/app.go +++ b/pkg/plugin/app.go @@ -37,6 +37,7 @@ type Config struct { orientation string layout string dashboardMode string + encodedLogo string maxRenderWorkers int persistData bool vfs *afero.BasePathFs @@ -82,6 +83,7 @@ func NewApp(ctx context.Context, settings backend.AppInstanceSettings) (instance var orientation string var layout string var dashboardMode string + var encodedLogo string var maxRenderWorkers int = 2 var persistData bool = false if settings.JSONData != nil { @@ -104,6 +106,9 @@ func NewApp(ctx context.Context, settings backend.AppInstanceSettings) (instance if v, exists := data["dashboardMode"]; exists { dashboardMode = v.(string) } + if v, exists := data["logo"]; exists { + encodedLogo = v.(string) + } if v, exists := data["maxRenderWorkers"]; exists { maxRenderWorkers = int(v.(float64)) } @@ -243,6 +248,7 @@ func NewApp(ctx context.Context, settings backend.AppInstanceSettings) (instance orientation: orientation, layout: layout, dashboardMode: dashboardMode, + encodedLogo: encodedLogo, maxRenderWorkers: maxRenderWorkers, persistData: persistData, vfs: vfs, diff --git a/pkg/plugin/report.go b/pkg/plugin/report.go index 027a2db..150e146 100644 --- a/pkg/plugin/report.go +++ b/pkg/plugin/report.go @@ -52,6 +52,7 @@ type ReportConfig struct { layout string orientation string persistData bool + encodedLogo string header string footer string chromeOpts []func(*chromedp.ExecAllocator) @@ -77,6 +78,11 @@ func (c ReportConfig) To() string { return c.timeRange.ToFormatted() } +// Get logo +func (c ReportConfig) Logo() string { + return c.encodedLogo +} + // report struct type report struct { logger log.Logger diff --git a/pkg/plugin/resources.go b/pkg/plugin/resources.go index faaa7b0..2e6527c 100755 --- a/pkg/plugin/resources.go +++ b/pkg/plugin/resources.go @@ -189,6 +189,7 @@ func (a *App) handleReport(w http.ResponseWriter, req *http.Request) { layout: layout, orientation: orientation, persistData: persistData, + encodedLogo: a.config.encodedLogo, chromeOpts: a.config.chromeOpts, }, ) diff --git a/pkg/plugin/templates/footer.gohtml b/pkg/plugin/templates/footer.gohtml index 1c89989..7f92fe4 100644 --- a/pkg/plugin/templates/footer.gohtml +++ b/pkg/plugin/templates/footer.gohtml @@ -1,26 +1,35 @@