Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add header and footer report customization #4505

Merged
merged 112 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
918418f
feat(settings): centralize the plugin settings
Desvelao Sep 13, 2022
de48a49
feat(settings): add setting services and replaced the references to c…
Desvelao Sep 13, 2022
c25a1a0
feat(settings): refactor the content of the default configuration file
Desvelao Sep 13, 2022
ffdb2d7
feat(inputs): create new inputs components
Desvelao Sep 13, 2022
e7cd9b0
feat(configuration): refactor the form of Settings/Configuration
Desvelao Sep 13, 2022
5999419
feat(settings): support updating multiple setting at the same time
Desvelao Sep 13, 2022
9a2b9ba
feat: add validation to the plugin settings
Desvelao Sep 13, 2022
f530d7a
feat(validation): add validation to the `PUT /utils/configuration`
Desvelao Sep 13, 2022
b6a7220
feat(validation): add validation to the configuration form in
Desvelao Sep 13, 2022
134ffd8
feat(validatio): remove no used import
Desvelao Sep 13, 2022
9b977e6
clean: remove not used code
Desvelao Sep 13, 2022
a984a7c
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Sep 13, 2022
f3fc8c8
Add report header-footer configuration
asteriscos Sep 13, 2022
17ad2e8
fix: fixed category name in `Settings/Configuration`
Desvelao Sep 13, 2022
ce4652e
fix(settings): Fix accessing to `validate` of undefined error
Desvelao Sep 13, 2022
23b925d
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Sep 13, 2022
a454dd8
fix(settings): fixed error due to missing service
Desvelao Sep 13, 2022
a56e9d1
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Sep 13, 2022
c3daf43
Merge branch 'feat/settings-validation' into feat/header-footer-repor…
asteriscos Sep 14, 2022
acb8bf0
Fix custom logo ratio in PDF sheet
asteriscos Sep 14, 2022
5d68615
fix(settings): refactor the form and inputs of `Settings/Configuratio…
Desvelao Sep 16, 2022
ef8d6ad
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Sep 16, 2022
1c076be
Merge branch 'feat/settings-validation' into feat/header-footer-repor…
asteriscos Sep 16, 2022
cf15ef8
fix: add value transformation for the form inputs and output of field…
Desvelao Sep 19, 2022
2597cf6
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Sep 19, 2022
951812e
fix: Fixed some settings validation
Desvelao Sep 19, 2022
e0a057e
fix(settings): fixed validation of literals
Desvelao Sep 19, 2022
9699336
fix(settings): removed unused import
Desvelao Sep 19, 2022
0a1ee1d
fix(settings): renamed properties related to transform the value of t…
Desvelao Sep 19, 2022
0109910
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Sep 19, 2022
b4ef2cd
feat(settings): add description to the plugin setting definition prop…
Desvelao Sep 19, 2022
fac95d5
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Sep 19, 2022
34c8de2
Merge branch 'feat/settings-validation' of https:/wazuh/w…
Desvelao Sep 19, 2022
138db83
fix(settings): fix getConfiguration service when the configuration fi…
Desvelao Sep 20, 2022
710800d
fix(settings): Fixed error when do changes of the `useForm` hook an r…
Desvelao Sep 20, 2022
7d7decc
tests(settings): add test related to the plugin settings and its conf…
Desvelao Sep 20, 2022
5f4d0bd
feat(settings): rename plugin setting options of type select to match…
Desvelao Sep 21, 2022
0cb6be5
feat(settings): add plugin settings services and enhance the descript…
Desvelao Sep 21, 2022
34ddc38
tests(input-form): update tests of InputForm component
Desvelao Sep 21, 2022
f74553b
test(configuration-file): add tests of the default configuration file
Desvelao Sep 21, 2022
4bc1972
feat(settings): remove `extensions.mitre` plugin setting
Desvelao Sep 21, 2022
c4b4c3e
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Sep 21, 2022
28c2266
test(settings): add test to validate the plugin setting when updating…
Desvelao Sep 22, 2022
3d2ca47
feat(settings): add documentation to some setting services and test s…
Desvelao Sep 22, 2022
ef631ff
fix: fixed documentation of setting service
Desvelao Sep 22, 2022
1851f9e
doc(settings): move the documentation of the plugin setting properties
Desvelao Sep 22, 2022
d2a8773
fix(settings): rename some plugin setting properties because of reque…
Desvelao Sep 23, 2022
1d34f6c
tests: fix tests of InputForm component
Desvelao Sep 23, 2022
ac3ebc2
fix: response properties when saving the configuration
Desvelao Sep 23, 2022
70e408d
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Sep 23, 2022
1356c5b
fix(settings): fix validation plugin settings value in the UI
Desvelao Sep 23, 2022
797c9c6
Merge branch 'feat/settings-validation' of https:/wazuh/w…
Desvelao Sep 23, 2022
b0e5864
fix(settings): fix `customization.reports.header` and `customization.…
Desvelao Sep 23, 2022
6e8b657
fix(settings): fix validation of numbers
Desvelao Sep 23, 2022
fdb6bfc
Merge branch 'feat/settings-validation' of https:/wazuh/w…
Desvelao Sep 23, 2022
b0881c6
fix(settings): fix validation of numbers
Desvelao Sep 23, 2022
7f96098
Merge branch 'feat/settings-validation' of https:/wazuh/w…
Desvelao Sep 23, 2022
7855a3f
test(settings): Add tests related to validation for the `useForm` hoo…
Desvelao Sep 26, 2022
e7fd477
Merge branch 'feat/settings-validation' of https:/wazuh/w…
Desvelao Sep 26, 2022
716a582
fix(settings): fix displaying toast to run the healthcheck when savin…
Desvelao Sep 26, 2022
8ae5067
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Sep 26, 2022
b5c4229
Merge branch 'feat/settings-validation' of https:/wazuh/w…
Desvelao Sep 26, 2022
6b3cdd3
test(settings): add tests for the `customization.reports.footer` and …
Desvelao Sep 27, 2022
93157e3
Added category sorting + description + docs link
asteriscos Sep 28, 2022
a007e01
Added settings sorting within their category
asteriscos Sep 28, 2022
0549cb6
Fixed constant types definition
asteriscos Sep 28, 2022
26fa66c
Checks if localCompare exists validation
asteriscos Sep 28, 2022
1f4c01a
fix(settings): fixed plugin setting description doesn't display the m…
Desvelao Oct 3, 2022
33bc999
fix(settings): fix setting type of `wazuh.monitoring.replicas` and li…
Desvelao Oct 3, 2022
ffb1eb9
feat(settins): add plugin settings category description
Desvelao Oct 3, 2022
a935861
fix(settings): fix a problem comparing the initial and current value …
Desvelao Oct 3, 2022
3847992
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Oct 3, 2022
62d1aab
Merge branch 'feat/settings-validation' of https:/wazuh/w…
Desvelao Oct 3, 2022
a962188
fix(settings): fix wrong conflict resolution
Desvelao Oct 3, 2022
b551b00
fix(settings): fix typo in setting description
Desvelao Oct 3, 2022
8adf7b4
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Oct 3, 2022
0e5e8c9
Merge branch 'feat/settings-validation' of https:/wazuh/w…
Desvelao Oct 3, 2022
f5bf16f
Add set custom header footer unit test
asteriscos Oct 3, 2022
a4e202e
feat(settings): enhance the validation of plugin settings related to …
Desvelao Oct 4, 2022
08792c9
feat(settings): add validation of setting values in the inputs
Desvelao Oct 4, 2022
51f96cb
Added unit test to verify the PDF report integrity
asteriscos Oct 4, 2022
624a8f4
fix(tests): format tables of the tests
Desvelao Oct 5, 2022
d6a22a7
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Oct 5, 2022
2e0d6c3
Merge branch 'feat/settings-validation' of https:/wazuh/w…
Desvelao Oct 5, 2022
9456bcf
Merge branch 'feat/header-footer-report-customization-4426' of https:…
Desvelao Oct 5, 2022
95b9020
fix: remove unnecessary import
Desvelao Oct 5, 2022
034bd34
test(endpoints): add test to GET /reports endpoint
Desvelao Oct 5, 2022
91e6749
Improved report unit test with more cases
asteriscos Oct 5, 2022
282b7e9
Fix small typo
asteriscos Oct 5, 2022
12fe59c
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Oct 6, 2022
22f2e70
Merge branch 'feat/settings-validation' of https:/wazuh/w…
Desvelao Oct 6, 2022
04f7457
fix(settings): fix a typo in a toast related to modify the plugin set…
Desvelao Oct 6, 2022
066002e
Merge branch 'feat/centralize-plugin-settings' of https:/…
Desvelao Oct 6, 2022
caf1c98
Merge branch 'feat/settings-validation' of https:/wazuh/w…
Desvelao Oct 6, 2022
312461c
Changed Custom Branding documentation link
asteriscos Oct 11, 2022
6d5afcd
Merge centralize plugin settings PR
asteriscos Oct 11, 2022
cb793d6
Fix white-labeling documentation link
asteriscos Oct 11, 2022
d4c18b1
Code format
asteriscos Oct 20, 2022
19c7cac
Delete unused imports
asteriscos Oct 20, 2022
84472df
Merge branch 'feat/centralize-plugin-settings' into feat/settings-val…
AlexRuiz7 Oct 20, 2022
e6da4c3
fix(settings): fix a problem with the useForm hook
Desvelao Oct 21, 2022
dffeb09
fix(settings): refactor the settings validation function to a class a…
Desvelao Oct 21, 2022
e5a28ea
feat(settings): add check for integer numbers and adapt the affected …
Desvelao Oct 21, 2022
a4e0a86
Merge branch 'feat/settings-validation' into feat/header-footer-repor…
asteriscos Oct 24, 2022
7983721
Merge branch '4.4-7.10' of https:/wazuh/wazuh-kibana-app …
Desvelao Oct 28, 2022
92b9aac
test: fix tests
Desvelao Oct 28, 2022
3973f08
Set textArea size
asteriscos Oct 28, 2022
ad1b260
Add max character length validation
asteriscos Oct 28, 2022
8cd8b8c
test(settings): fix tests
Desvelao Oct 31, 2022
5a40771
changelog: add PR entry
Desvelao Oct 31, 2022
e2e1718
Merge branch '4.4-7.10' of https:/wazuh/wazuh-kibana-app …
Desvelao Oct 31, 2022
cf3b967
test(settings): format tests
Desvelao Oct 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Redesign the SCA table from agent's dashboard [#4512](https:/wazuh/wazuh-kibana-app/pull/4512)
- Enhanced the plugin setting description displayed in the UI and the configuration file. [#4501](https:/wazuh/wazuh-kibana-app/pull/4501)
- Added validation to the plugin settings in the form of `Settings/Configuration` and the endpoint to update the plugin configuration [#4503](https:/wazuh/wazuh-kibana-app/pull/4503)
- Added new plugin settings to customize the header and footer on the PDF reports [#4505](https:/wazuh/wazuh-kibana-app/pull/4505)

### Changed

Expand Down
55 changes: 52 additions & 3 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ export enum SettingCategory {
CUSTOMIZATION,
};

type TPluginSettingOptionsTextArea = {
rowsSize?: number
maxLength?: number
};

type TPluginSettingOptionsSelect = {
select: { text: string, value: any }[]
};
Expand Down Expand Up @@ -442,7 +447,13 @@ export type TPluginSetting = {
// Modify the setting requires restarting the plugin platform to take effect.
requiresRestartingPluginPlatform?: boolean
// Define options related to the `type`.
options?: TPluginSettingOptionsNumber | TPluginSettingOptionsEditor | TPluginSettingOptionsFile | TPluginSettingOptionsSelect | TPluginSettingOptionsSwitch
options?:
TPluginSettingOptionsEditor |
TPluginSettingOptionsFile |
TPluginSettingOptionsNumber |
TPluginSettingOptionsSelect |
TPluginSettingOptionsSwitch |
TPluginSettingOptionsTextArea
// Transform the input value. The result is saved in the form global state of Settings/Configuration
uiFormTransformChangedInputValue?: (value: any) => any
// Transform the configuration value or default as initial value for the input in Settings/Configuration
Expand Down Expand Up @@ -545,7 +556,6 @@ export const PLUGIN_SETTINGS: { [key: string]: TPluginSetting } = {
validateBackend: function(schema){
return schema.boolean();
},

},
"checks.fields": {
title: "Known fields",
Expand Down Expand Up @@ -1072,6 +1082,46 @@ export const PLUGIN_SETTINGS: { [key: string]: TPluginSetting } = {
)(value)
},
},
"customization.reports.footer": {
title: "Reports footer",
description: "Set the footer of the reports.",
category: SettingCategory.CUSTOMIZATION,
type: EpluginSettingType.textarea,
defaultValue: "",
defaultValueIfNotSet: REPORTS_PAGE_FOOTER_TEXT,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: { rowsSize: 2, maxLength: 30 },
validate: function (value) {
return SettingsValidator.multipleLinesString({
max: this.options.rowsSize,
maxLength: this.options.maxLength
})(value)
},
validateBackend: function (schema) {
return schema.string({ validate: this.validate.bind(this) });
},
},
"customization.reports.header": {
title: "Reports header",
description: "Set the header of the reports.",
category: SettingCategory.CUSTOMIZATION,
type: EpluginSettingType.textarea,
defaultValue: "",
defaultValueIfNotSet: REPORTS_PAGE_HEADER_TEXT,
isConfigurableFromFile: true,
isConfigurableFromUI: true,
options: { rowsSize: 3, maxLength: 20 },
validate: function (value) {
return SettingsValidator.multipleLinesString({
max: this.options.rowsSize,
maxLength: this.options?.maxLength
})(value)
},
validateBackend: function(schema){
return schema.string({validate: this.validate?.bind(this)});
},
},
"disabled_roles": {
title: "Disable roles",
description: "Disabled the plugin visibility for users with the roles.",
Expand Down Expand Up @@ -1785,7 +1835,6 @@ export const PLUGIN_SETTINGS: { [key: string]: TPluginSetting } = {

export type TPluginSettingKey = keyof typeof PLUGIN_SETTINGS;


export enum HTTP_STATUS_CODES {
CONTINUE = 100,
SWITCHING_PROTOCOLS = 101,
Expand Down
468 changes: 239 additions & 229 deletions common/plugin-settings.test.ts

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions common/services/settings-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ export class SettingsValidator {
* @param options
* @returns
*/
static multipleLinesString(options: { min?: number, max?: number } = {}) {
static multipleLinesString(options: { min?: number, max?: number, maxLength?: number } = {}) {
return function (value: number) {
const lines = value.split(/\r\n|\r|\n/).length;
if (typeof options.maxLength !== 'undefined' && value.split('\n').some(line => line.length > options.maxLength)) {
return `The maximum length of a line is ${options.maxLength} characters.`;
};
if (typeof options.min !== 'undefined' && lines < options.min) {
return `The string should have more or ${options.min} line/s.`;
};
if (typeof options.max !== 'undefined' && lines > options.max) {
return `The string should have less or ${options.max} line/s.`;
return `The string should have less or equal to ${options.max} line/s.`;
};
}
};
Expand Down
11 changes: 11 additions & 0 deletions public/components/common/form/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,14 @@ exports[`[component] InputForm Renders correctly to match the snapshot: Input: t
</div>
</div>
`;

exports[`[component] InputForm Renders correctly to match the snapshot: Input: textarea 1`] = `
<div>
<textarea
class="euiTextArea euiTextArea--resizeVertical euiTextArea--fullWidth"
rows="6"
>
test
</textarea>
</div>
`;
15 changes: 8 additions & 7 deletions public/components/common/form/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ describe('[component] InputForm', () => {
const optionsSelect = {select: [{text: 'Label1', value: 'value1'}, {text: 'Label2', value: 'value2'}]};
const optionsSwitch = {switch: {values: {enabled: {label: 'Enabled', value: true}, disabled: {label: 'Disabled', value: false}}}};
it.each`
inputType | value | options
${'editor'} | ${'{}'} | ${optionsEditor}
${'filepicker'} | ${'{}'} | ${optionsFilepicker}
${'number'} | ${4} | ${undefined}
${'select'} | ${'value1'} | ${optionsSelect}
${'switch'} | ${true} | ${optionsSwitch}
${'text'} | ${'test'} | ${undefined}
inputType | value | options
${'editor'} | ${'{}'} | ${optionsEditor}
${'filepicker'} | ${'{}'} | ${optionsFilepicker}
${'number'} | ${4} | ${undefined}
${'select'} | ${'value1'} | ${optionsSelect}
${'switch'} | ${true} | ${optionsSwitch}
${'text'} | ${'test'} | ${undefined}
${'textarea'} | ${'test'} | ${undefined}
`('Renders correctly to match the snapshot: Input: $inputType', ({ inputType, value, options }) => {
const wrapper = render(
<InputForm
Expand Down
2 changes: 2 additions & 0 deletions public/components/common/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { InputFormText } from './input_text';
import { InputFormSelect } from './input_select';
import { InputFormSwitch } from './input_switch';
import { InputFormFilePicker } from './input_filepicker';
import { InputFormTextArea } from './input_text_area';
import { EuiFlexGroup, EuiFlexItem, EuiFormRow } from '@elastic/eui';

export const InputForm = ({
Expand Down Expand Up @@ -61,5 +62,6 @@ const Input = {
number: InputFormNumber,
select: InputFormSelect,
text: InputFormText,
textarea: InputFormTextArea,
filepicker: InputFormFilePicker
};
15 changes: 15 additions & 0 deletions public/components/common/form/input_text_area.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { EuiTextArea } from '@elastic/eui';
import { IInputFormType } from './types';

export const InputFormTextArea = ({ value, isInvalid, onChange, options } : IInputFormType) => {
return (
<EuiTextArea
fullWidth
value={value}
isInvalid={isInvalid}
onChange={onChange}
rows={options?.rowsSize}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export const Category: React.FunctionComponent<ICategoryProps> = ({
aria-label={item.key}
content='Invalid' />
)}

{isUpdated && (
<EuiIconTip
anchorClassName="mgtAdvancedSettings__fieldTitleUnsavedIcon"
Expand Down
2 changes: 1 addition & 1 deletion public/components/settings/configuration/configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const WzConfigurationSettingsProvider = (props) => {
// Update the settings that uploads a file
if(Object.keys(settingsToUpdate.fileUpload).length){
requests.push(...Object.entries(settingsToUpdate.fileUpload)
.map(([pluginSettingKey, {file, extension}]) => {
.map(([pluginSettingKey, {file}]) => {
// Create the form data
const formData = new FormData();
formData.append('file', file);
Expand Down
6 changes: 3 additions & 3 deletions server/controllers/wazuh-reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export class WazuhReportingCtrl {
str += `${
type === 'range'
? `${params.gte}-${params.lt}`
: type === 'phrases'
? '(' + params.join(" OR ") + ')'
: type === 'exists'
: type === 'phrases'
? '(' + params.join(" OR ") + ')'
: type === 'exists'
? '*'
: !!value
? value
Expand Down
67 changes: 41 additions & 26 deletions server/lib/reporting/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import {
import { log } from '../logger';
import * as TimSort from 'timsort';
import { getConfiguration } from '../get-configuration';
import { REPORTS_PRIMARY_COLOR, REPORTS_LOGO_IMAGE_ASSETS_RELATIVE_PATH, REPORTS_PAGE_FOOTER_TEXT, REPORTS_PAGE_HEADER_TEXT } from '../../../common/constants';
import { REPORTS_PRIMARY_COLOR} from '../../../common/constants';
import { getSettingDefaultValue } from '../../../common/services/settings';

const COLORS = {
PRIMARY: REPORTS_PRIMARY_COLOR
};

const pageConfiguration = (nameLogo) => ({
const pageConfiguration = ({ pathToLogo, pageHeader, pageFooter }) => ({
styles: {
h1: {
fontSize: 22,
Expand Down Expand Up @@ -54,11 +55,11 @@ const pageConfiguration = (nameLogo) => ({
margin: [40, 20, 0, 0],
columns: [
{
image: path.join(__dirname, `../../../public/assets/${nameLogo}`),
width: 190
image: path.join(__dirname, `../../../public/assets/${pathToLogo}`),
fit: [190, 50]
},
{
text: REPORTS_PAGE_HEADER_TEXT,
text: pageHeader,
alignment: 'right',
margin: [0, 0, 40, 0],
color: COLORS.PRIMARY
Expand All @@ -70,7 +71,7 @@ const pageConfiguration = (nameLogo) => ({
return {
columns: [
{
text: REPORTS_PAGE_FOOTER_TEXT,
text: pageFooter,
color: COLORS.PRIMARY,
margin: [40, 40, 0, 0]
},
Expand Down Expand Up @@ -473,7 +474,7 @@ export class ReportPrinter{
this.addContent(typeof title === 'string' ? { text: title, style: 'h4' } : title)
.addNewLine();
}

if (!items || !items.length) {
this.addContent({
text: 'No results match your search criteria',
Expand All @@ -494,31 +495,31 @@ export class ReportPrinter{
style: 'standard'
}
})
});
});

// 385 is the max initial width per column
let totalLength = columns.length - 1;
const widthColumn = 385/totalLength;
let totalWidth = totalLength * widthColumn;

const widths:(number)[] = [];

for (let step = 0; step < columns.length - 1; step++) {

let columnLength = this.getColumnWidth(columns[step], tableRows, step);

if (columnLength <= Math.round(totalWidth / totalLength)) {
widths.push(columnLength);
totalWidth -= columnLength;
}
}
else {
widths.push(Math.round(totalWidth / totalLength));
totalWidth -= Math.round((totalWidth / totalLength));
}
totalLength--;
}
widths.push('*');

this.addContent({
fontSize: 8,
table: {
Expand Down Expand Up @@ -562,9 +563,9 @@ export class ReportPrinter{
`agents: ${agents}`,
'debug'
);

this.addNewLine();

this.addContent({
text:
'NOTE: This report only includes the authorized agents of the user who generated the report',
Expand Down Expand Up @@ -613,22 +614,36 @@ export class ReportPrinter{
);
}

async print(reportPath: string){
const nameLogo = ( await getConfiguration() )['customization.logo.reports'] || REPORTS_LOGO_IMAGE_ASSETS_RELATIVE_PATH;
async print(reportPath: string) {
return new Promise((resolve, reject) => {
try {
const configuration = getConfiguration();

const document = this._printer.createPdfKitDocument({...pageConfiguration(nameLogo), content: this._content});
await document.pipe(
fs.createWriteStream(reportPath)
);
document.end();
const pathToLogo = configuration['customization.logo.reports'] || getSettingDefaultValue('customization.logo.reports');
const pageHeader = configuration['customization.reports.header'] || getSettingDefaultValue('customization.reports.header');
const pageFooter = configuration['customization.reports.footer'] || getSettingDefaultValue('customization.reports.footer');

const document = this._printer.createPdfKitDocument({ ...pageConfiguration({ pathToLogo, pageHeader, pageFooter }), content: this._content });

document.on('error', reject);
document.on('end', resolve);

document.pipe(
fs.createWriteStream(reportPath)
);
document.end();
} catch (ex) {
reject(ex);
}
});
}

/**
* Returns the width of a given column
*
* @param column
* @param tableRows
* @param step
*
* @param column
* @param tableRows
* @param step
* @returns {number}
*/
getColumnWidth(column, tableRows, index){
Expand Down
Loading