require(["esri/opsdashboard/WidgetConfigurationProxy"], function(WidgetConfigurationProxy) { /* code goes here */ });
Description
(Added at v3.14)
(Currently in Mature Support) WidgetConfigurationProxy is a class used to provide the configuration user experience for an operations dashboard extension widget. WidgetConfigurationProxy can be directly instantiated to communicate with the host operations dashboard application or used as a mixin in a Dojo or Dijit class, see declare. When the proxy is instantiated, it will automatically start an initialization process with the the host operations dashboard. If the initialization is successful, the event host-ready will fired, or if using as a mixin, the function hostReady will be called. It's only when the initialization is finished that configuration properties, functions to communicate with the host will be available, and host's events will be fired. If an error occured during the initialization process, the event initialization-error is fired, or for mixin the function hostInitializationError is called, passing the error as argument. Some of the configuration properties can be automatically captured by the host and controlled by properties in the manifest, such as 'requireDataSource' or 'requireMapWidget'. Anything else should be captured by a user experience built with the WidgetConfigurationProxy.
Example 1: Used as a mixin in dijit class
require([
"dojo/_base/declare",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"esri/opsdashboard/WidgetConfigurationProxy"
], function(declare, _WidgetBase, _TemplatedMixin, WidgetConfigurationProxy){
return declare("MyWidgetExtensionConfiguration", [_WidgetBase, _TemplatedMixin, WidgetConfigurationProxy], {
templateString: "<div>hello operation dashboard</div>",
hostReady: function(){},
dataSourceSelectionChanged: function(dataSourceProxy, dataSourceConfig){
this.config.propertyIWantoSave = "Hello";
dataSourceConfig.xField = "income";
this.readyToPersistConfig(true);
}
});
});
Example 2: Used as plain proxy object
require([
"esri/opsdashboard/WidgetConfigurationProxy"
], function(WidgetConfigurationProxy){
var proxy = new WidgetConfigurationProxy();
proxy.on("host-ready", function(){});
proxy.on("data-source-selection-changed", function(dataSourceProxy, dataSourceConfig){
this.config.propertyIWantoSave = "Hello";
dataSourceConfig.xField = "income";
this.readyToPersistConfig(true);
});
});
An extension is defined by the json manifest file. Some configuration properties could or could not be available based on the manifest properties. The same is applicable to functions and callbacks exposed by the mixin (see
the manifest documentation).
See also
Samples
Search for
samples that use this class.
Class hierarchy
esri/opsdashboard/ExtensionBase
|_esri/opsdashboard/ExtensionConfigurationBase
|_esri/opsdashboard/WidgetConfigurationProxy
Properties
config | Object | The object that will store the Widget/MapTool/FeatureAction configuration. |
isNative | Boolean | Read-only: Indicates if the host application is the Windows Operations Dashboard. |
portalHelperServices | Object | Read-only: It will list all of the Portal helper services. |
portalUrl | String | Read-only: The URL to the ArcGIS.com site or in-house portal that you are currently signed in to. |
Methods
Events
[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.
Property Details
The object that will store the Widget/MapTool/FeatureAction configuration.
Read-only: Indicates if the host application is the Windows Operations Dashboard. If false, the host application is the browser based Operations Dashboard.
Read-only: It will list all of the Portal helper services. (Added at v3.16)
Read-only: The URL to the ArcGIS.com site or in-house portal that you are currently signed in to. (Added at v3.15)
Method Details
Called by the host application when the user has changed the selected data source in the data source selector. Note: This function will only be invoked if the property "configuration.requireDataSource" and "useDataFromView" in the manifest are set to true.
Parameters:
<DataSourceProxy > dataSourceProxy |
Required |
The selected data source. |
<Object > dataSourceConfig |
Required |
The associated data source config. |
Get the data source config for a data source.
Get the collection of data sources from the host application. Note: The promise this function returns will fail if the extension manifest do not have a property "useDataFromView" set to true. Deprecated at v3.18
Get the data source corresponding to the data source id from the host application. Note: The promise this function returns will fail if the extension manifest do not have a property "useDataFromView" set to true.
Parameters:
<String > dataSourceId |
Required |
The data source id |
Get the collection of map widgets from the host application.
Get the map widget corresponding to the map widget id from the host application.
Parameters:
<String > mapWidgetId |
Required |
A map widget id |
Called when an error occurred during the initialization process with the host application.
Parameters:
<Error > err |
Required |
The error that occurred. |
Called by the host application when the relationship has been established with the extension. All the configuration properties will be available and the extension functions will be usable when this function has been invoked.
Called by the host application when a map widget has been added to the current view. It could occur when a publisher is adding a map widget when configuring the operation view.
Called by the host application when a map widget has been removed from the current view. It could occur when a publisher is removing a map widget when configuring the operation view.
Parameters:
<String > mapWidgetId |
Required |
A map widget id. |
Called by the host application when the user has changed the selected map widget in the map widget selector. Note: This function will only be invoked if the property "configuration.requireMapWidget" is set to 'true' in the manifest.
Indicates if the configuration is ready to be persisted or not.
Parameters:
<Boolean > ready |
Required |
Indicates that the configuration is ready to be persisted or not. If 'true', indicates that all the properties in the config property are valid and can be persisted by the host application. |
Event Details
[ On Style Events | Connect Style Event ]
Event indicating that a new data source has been added into the host operation view.
Event Object Properties:
<Object > dataSourceProxy |
The new data source that has been added in the host operation view. |
Event indicating that a data source has been removed from the host operation view.
Event indicating the user has changed the selected data source for the configuration. This event is raised only if the property "configuration.requireDataSource" is set to true in the extension manifest.
Event Object Properties:
<Object > dataSourceConfig |
The associated data source config object. |
<DataSourceProxy > dataSourceProxy |
The selected data source. |
Event indicating that the initialization process was successful. The configuration properties are available, the proxy functions are available, and the proxy events will be fired.
Event indicating that the initialization process encountered an error.
Event indicating that a new map widget has been added into the host operation view.
Event Object Properties:
<MapWidgetProxy > mapWidgetProxy |
The new map widget that has been added in the host operation view. |
Event indicating that a map widget has been removed from the host operation view.
Event indicating the user has changed the selected map widget for the configuration. This event is raised only if the property "configuration.requireMapWidget" is set to true in the extension manifest.