# new UBServerReport (reportCode: string | Object, reportTypeopt: string, params: Object, languageopt: String)
Members
# incomeParams instance
Report parameters
Name | Type | Description |
---|---|---|
incomeParams | Object |
# reportCode instance
Report code
Name | Type | Description |
---|---|---|
reportCode | string |
# reportOptions instance
The options of report. Known options: pageOrientation.
Name | Type | Description |
---|---|---|
reportOptions | Object |
# reportType instance
Possible values: 'html', 'pdf'
Name | Type | Description |
---|---|---|
reportCode | string |
Methods
# buildHTML (reportData: Object) → string instance
Render HTML report
Arguments:
reportData
: Object
# buildReport (reportParams: Object) → Promise | Object | String instance
This function must be defined in report code block.
Inside function you must:
- Prepare data
- Run method this.buildHTML(reportData); where reportData is data for mustache template
- If need create PDF run method this.buildPdf(htmlReport); where htmlReport is HTML
- If is server side function must return report as string otherwise Promise
Return:
If code run at server, method must return report data, else - Promise, which resolves to report data
Arguments:
reportParams
: Object
# getDocument (attribute: string) → string instance
load document
Arguments:
attribute
: string
# init () instance
Load report template and code.
# makeReport (paramsopt: Object) → ReportResult instance
Render report on server
Arguments:
params
: Object
const UBReport = require('@unitybase/ubs/modules/UBServerReport')
let reportResult = UBReport.makeReport('reportCode', 'html', {
login: email,
password: password,
activateUrl: registrationAddress,
appConfig: App.serverConfig
})
# transformToPdf (html: string, options: Object) → Promise instance
Prepare PDF report from html
Return:
A promise that resolves with an ArrayBuffer with PDF or instance of PDF.csPrintToPdf with rendered HTML on it when options.outputPdf is false.