Skip to content

Commit

Permalink
feat: Setup logo in footer of report
Browse files Browse the repository at this point in the history
Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri committed May 2, 2024
1 parent 756b9ba commit b44d6a9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
6 changes: 6 additions & 0 deletions pkg/plugin/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Config struct {
orientation string
layout string
dashboardMode string
encodedLogo string
maxRenderWorkers int
persistData bool
vfs *afero.BasePathFs
Expand Down Expand Up @@ -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 {
Expand All @@ -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))
}
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions pkg/plugin/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type ReportConfig struct {
layout string
orientation string
persistData bool
encodedLogo string
header string
footer string
chromeOpts []func(*chromedp.ExecAllocator)
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/plugin/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)
Expand Down
33 changes: 21 additions & 12 deletions pkg/plugin/templates/footer.gohtml
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
<html>
<style type="text/css">
#footer {
padding: 0;
padding: 0;
}

.content-footer {
width: 100%;
background-color: white;
color: black;
padding: 5px;
-webkit-print-color-adjust: exact;
vertical-align: middle;
font-style: italic;
font-size: 10px;
margin-top: 0;
display: inline-block;
text-align: center;
width: 100%;
background-color: white;
color: black;
padding: 5px;
-webkit-print-color-adjust: exact;
vertical-align: middle;
font-style: italic;
font-size: 10px;
margin-top: 0;
display: inline-block;
text-align: center;
}

.content-footer-right {
float: right;
}
</style>
<body>
<div class="content-footer">
Page <span class="pageNumber"></span> of <span class="totalPages"></span>
{{- if .Logo}}
<div class="content-footer-right">
<img src="data:image/png;base64,{{.Logo}}" width="25" height="25" alt="Logo" />
</div>
{{- end}}
</div>
</body>
</html>

0 comments on commit b44d6a9

Please sign in to comment.