Templates API in Siren Investigate
context.registerPerspectives
The context
global variable provides a registerPerspectives
function you can use to register perspectives in the Siren Platform.
You must define perspectives in groups corresponding to their type. At the moment, there are 2 possible types of template perspectives:
-
view
- for displaying interactive data. -
binary
- for statically opening and downloading data.
Example
context.registerPerspectives({
shareComputedDataAcrossPerspectives: false,
view: {
'View 1': view1Definition,
'View 2': view2Definition
},
binary: {
'Download pdf report': myPdfReportDefinition
}
});
Properties
Name | Type | Description |
---|---|---|
view |
|
(Optional) Dictionary of view perspectives. |
binary |
|
(Optional) Dictionary of binary perspectives. |
shareComputedDataAcrossPerspectives |
|
(Optional) Whether perspectives of the script will share the |
PerspectiveDefinition
An object that defines a perspective to register with context.registerPerspectives
.
Properties
Name | Type | Description |
---|---|---|
computedDataTTL |
|
(Optional) A number representing the time, in seconds, Investigate will keep the |
dataModelFormatting |
|
A boolean or list of strings that controls the content of the
|
PerspectiveDefinition.render(PerspectiveInput)
Renders the output of the perspective. The output of the function depends on its type:
-
view
-JSX.Element
, a React element to display. -
binary
-BinaryOutput
, a binary output representation.
When the perspective defines an enrich function, the render function must be synchronous.
Parameter | Type | Description |
---|---|---|
PerspectiveInput |
Properties used to render the data. |
Returns: the output type depends on the perspective type.
-
view
: must return a React element. -
binary
: must return a BinaryOutput object.
PerspectiveDefinition.enrich(PerspectiveInput)
An optional function that is responsible for fetching and processing data.
Use it to refresh view perspectives during long data processing. Investigate will call the render
function periodically until enrich
completes.
You can store computed data in the input computedData
property to make it available to the render
function.
Parameter | Type | Description |
---|---|---|
PerspectiveInput |
Properties used to process the data. |
PerspectiveInput
Input data passed to all perspective functions.
Name | Type | Description |
---|---|---|
source |
|
A raw source of the record data. |
sourceMeta.sourceType |
|
The type of input document. |
sourceMeta.fields |
|
The |
sourceMeta.formattedFields |
|
A key-value dictionary that maps field names to values as formatted strings ready to display. Only defined when |
sourceMeta.highlight |
|
A key-value dictionary that maps field names to lists of highlighted items. See
Highlighting
for more details. Only defined when |
record |
|
A DataRecord instance for the displayed record. |
dataModelEntity |
|
A DataModelEntity instance for the data model entity that prompted the record display. |
computedData |
|
An object used to store fetched data and make it available on |
computedMeta.creationTime |
|
The time the |
computedMeta.expirationTime |
|
The time the |
cancelPromise |
|
A promise rejected in case of cancellation for example, the user changes the page or closes the Record Viewer. |
isCanceled |
|
A function returning whether the execution was canceled. |
BinaryOutput
Representation of an output binary object. The object must have either the content
property or the templateId
property.
Name | Type | Description |
---|---|---|
filename |
|
File name used when downloading the resource. |
content |
|
(Optional) Static content of the binary object. |
templateId |
|
(Optional) A jsreport template id. See Creating downloadable reports for how to create jsreport templates. |
data |
|
(Optional) Data supplied to the jsreport template. |