new UBServerReport(reportCode, reportTypeopt, params, languageopt) protected
Server-side report builder
Arguments:
-
reportCode
(string|Object)
 If reportCode type is Object it is a config object { code: String, type: String, params: String|Object } -
[reportType='html']
(string)
 Possible values: 'html'|'pdf' -
params
(Object)
-
[language=Session.userLang]
(String)
Members
incomeParams
Report parameters
Properties:
Name | Type | Description |
---|---|---|
incomeParams |
Object |
reportCode
Report code
Properties:
Name | Type | Description |
---|---|---|
reportCode |
string |
reportOptions
The options of report. Known options: pageOrientation.
Properties:
Name | Type | Description |
---|---|---|
reportOptions |
Object |
reportType
Possible values: 'html', 'pdf'
Properties:
Name | Type | Description |
---|---|---|
reportCode |
string |
Methods
buildHTML(reportData) → string
Render HTML report
Arguments:
-
reportData
(Object)
buildReport(reportParams) → Promise|Object|String
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
Arguments:
-
reportParams
(Object)
getDocument(attribute) → string
load document
Arguments:
-
attribute
(string)
init()
Load report template and code.
makeReport(paramsopt) → ReportResult
Render report on server
Arguments:
-
[params]
(Object)
Example
const UBReport = require('@unitybase/ubs/modules/UBServerReport')
let reportResult = UBReport.makeReport('reportCode', 'html', {
login: email,
password: password,
activateUrl: registrationAddress,
appConfig: App.serverConfig
})
transformToPdf(html, options) → Promise
Prepare PDF report from html
Arguments:
reportData
(Object)
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
reportParams
(Object)
attribute
(string)
[params]
(Object)
const UBReport = require('@unitybase/ubs/modules/UBServerReport')
let reportResult = UBReport.makeReport('reportCode', 'html', {
login: email,
password: password,
activateUrl: registrationAddress,
appConfig: App.serverConfig
})