reporttool
This bundle adds the ability to generate a report for ArcGIS feature service and map service data sources to the resultcenter
(as a Tool) and result-ui
(as a BulkAction).
Additionally, static reports can be generated that combine ArcGIS data sources with optional queries.
The reporttool triggers the report service by sending the URL of the map service or feature service and the IDs of the selected items. The report service then queries ArcGIS Server for the features. By default a generic report template is being used. Additionally, a mapping for a certain report template and data source can be configured.
Usage
No configuration is required, default values are applied.
To create a report for all features in the result center, the following options are available:
- Switch the number of items per page in the result center, so that it is bigger than the total number of items. Then select all items by clicking the topmost checkbox and click the report tool button.
- When the total number of items is larger than the maximum number of items per page, select all items with the topmost checkbox and navigate through all available pages and finally click the report tool button.
The following result-ui action is provided by this bundle:
ID | Type | Description |
---|---|---|
create-report |
bulk | Trigger PDF report generation for the selected items. |
For more details, see the bundle's API documentation.
Constraints
The reporttool bundle support is limited to ArcGIS Server map services and feature services.
Configuration Reference
The following sample shows the configurable properties and its default values:
"reporttool": {
"ReportTask": {
"defaultReportId": "s_default",
"defaultFileName": "Report.pdf",
"directDownload": false,
"mappings": [],
"windowProperties": {
"maximizable": true,
"closable": true,
"marginBox": {
"w": 400,
"h": 570
}
}
}
}
Property | Type | Description |
---|---|---|
defaultReportId |
String | ID of the default report. This report is used if no mapping is found for a certain data source. |
defaultFileName |
String | Default filename for the generated report. The filename is used if no mapping is found for a certain data source. |
directDownload |
Boolean | Defines wether to download a report directly instead of showing it in a window. |
mappings |
Array | Mappings to combine certain data sources with certain reports. For details, see the following table. |
windowProperties |
Object | Properties for the window that shows the report (only used if property directDownload is set to false ). |
Mapping a data source to a report template
You can override the default configuration for a data store by providing a custom "data-store-to-report-template" mapping.
The following sample shows how to map the data source country_store
to the non-default report template country_report
, also overriding the fileName
and directDownload
properties:
"reporttool": {
"ReportTask": {
"defaultReportId": "s_default",
"defaultFileName": "Report.pdf",
"directDownload": false,
"mappings": [{
"storeId": "country_store",
"reportId": "country_report",
"fileName": "Country_Report.pdf",
"directDownload": true
}]
}
}
Properties of a mappings
object:
Property | Type | Description |
---|---|---|
storeId |
String | ID of the data source (data store). |
reportId |
String | ID of the report. |
fileName |
String | Overwrites property defaultFileName for this report (optional). |
directDownload |
Boolean | Overwrites global property for this report (optional). |
Defining a static reporting tool
"reporttool": {
"StaticReportTool": [{
"id": "statesReport",
"title": "Static Report for Median Ages",
"storeId": "medianAgeStore",
"query": {
$or: [
{"name": "Arizona"},
{"name": "California"},
{"name": "Nevada"}
]},
"iconClass": "icon-globe"
}]
}
Property | Type | Description |
---|---|---|
id |
String | ID of the tool. |
title |
String | Title of the tool. |
storeId |
String | ID of the data source (data store). |
query |
Object | Query to filter features from the data source, see Development Guide for further details. |
iconClass |
String | Icon class to use for the tool. See https://developernetwork.conterra.de/icons for available icons. |
Use Cases
Create a report programmatically
Note: The interface of the ReportTask should not be considered as final! It may change in the future.
The bundle allows to trigger the generation of reports with the component ReportTask
.
This component can be referenced with interface reporttool.ReportTask
.
See this bundle's API documentation for details.
Sample code
First, reference service reporttool.ReportTask
in your manifest.json
file:
"components": [{
"name": "MyReportComponent",
"references": [{
"name": "_reportTask",
"providing": "reporttool.ReportTask"
}]
}]
Next, this reference can be used to trigger the report generation:
class MyReportComponent {
createMedianAgeReport() {
// injected
let reportTask = this._reportTask;
let parameters = {
storeId: "medianAgeStore"
dsUrl: "https://server.arcgisonline.com/arcgis/rest/services/Demographics/USA_Median_Age/MapServer/4",
ids: [1, 2, 3, 4, 5]
}
reportTask.createReport(parameters);
}
}