wazuh-dashboard-plugins icon indicating copy to clipboard operation
wazuh-dashboard-plugins copied to clipboard

Custom branding: PDF reports

Open AlexRuiz7 opened this issue 2 years ago • 5 comments

Description

As described in #4392, we need to add the ability to white-label the reports generated by the App.

Screenshot from 2022-08-31 12-08-17

Pre-conditions

  • [x] #4434

Tasks

  • [x] (1) Use of custom logo in reports
  • [x] (2) #3892
  • [x] (3) Use of custom copyright mark in reports

Custom logo

Definitions

  • wazuh_logo: Wazuh's original logo, as seen in the image.
  • custom_logo: user chosen logo. By default, this logo will be a copy of wazuh_logo.

Strategy

These 2 logos will live in the app's space simultaneously (the paths are yet to be defined). The app will always use the custom_logo. The following states and mutations are allowed:

  • (S) initial: custom_logo = wazuh_logo
  • (M) update: custom_logo overwritten with uploaded logo
  • (M) delete: custom_logo overwritten with wazuh_logo

Depends on: #4443

AlexRuiz7 avatar Aug 31 '22 10:08 AlexRuiz7

Proposal

Goal

The user should be able to customize the data displayed in the PDF reports related to:

  • the header (in the example, the company's site and email)
  • the footer (in the example, the Copyright)

Implementation

Add the new plugin's settings and use them if the custom branding is enabled.

We want to offer the users the possibility to add whatever they like in the header and the footer of the PDF reports, not only the website, the email and the copyright, as seen in the example.

New settings

Setting Description Configurable in file Configurable in UI Validation
customization.reports.header Header text for PDF reports Yes Yes Max: 3 lines. Max characters by line: 20
customization.reports.footer Footer text for PDF reports Yes Yes Max: 2 lines. Max characters by line: 30

Tasks

  • [x] Create the new plugin's settings.
  • [x] Adapt the PDF report generation to use these new settings.
  • [x] Test

Desvelao avatar Sep 05 '22 11:09 Desvelao

I added the new settings and adapted the generation of PDF reports.

I think it will be interesting to support multiple lines. This requires changing the input type (and the input form in the Settings/Configuration view) and see how the data is stored in the configuration file. I found some problems when the values contain new lines.

Tasks

  • [x] Fix the current problems when new lines are used in the footer and header values.

Desvelao avatar Sep 05 '22 11:09 Desvelao

Should we allow the users to use empty strings in these values?

In that case, anything will be displayed in the related sections of the PDF.

Desvelao avatar Sep 05 '22 11:09 Desvelao

  • Fixed a problem when using multiple lines in the value of the settings cutomization.reports.footer and customization.reports.header and saving the configuration from UI.

Desvelao avatar Sep 09 '22 11:09 Desvelao

Enhancement suggestion

I was investigating the possibility to resize the custom logo in the PDF reports.

It is possible to use the fit property to fit the image to the defined size in the property. More information in https://pdfmake.github.io/docs/0.1/document-definition-object/images.

We could use it to avoid the custom image overlay the text of the report.

Desvelao avatar Sep 09 '22 11:09 Desvelao

Update

  • Added a character count limitation

Desvelao avatar Oct 31 '22 10:10 Desvelao