UBServerReport

@unitybase/ubs.UBServerReport~ UBServerReport

new UBServerReport(reportCode, reportTypeopt, params, languageopt) protected

Server-side report builder
Arguments:
  1. reportCode (string|Object)  If reportCode type is Object it is a config object { code: String, type: String, params: String|Object }
  2. [reportType='html'] (string)  Possible values: 'html'|'pdf'
  3. params (Object)
  4. [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:
  1. 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:
  1. reportParams (Object)

getDocument(attribute)string

load document
Arguments:
  1. attribute (string)

init()

Load report template and code.

makeReport(paramsopt)ReportResult

Render report on server
Arguments:
  1. [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:
  1. html (string)
  2. options (Object)
    Properties
    1. [fonts] (Array|Object)  [{ fontName: "TimesNewRoman", fontStyle: "Normal" }, ..]
    2. [outputPdf] (Boolean)  If it is not False build PDF output at end. By default it is True.