Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/workers
Class: WidgetProxy

require(["esri/opsdashboard/WidgetProxy"], function(WidgetProxy) { /* code goes here */ });

Description

(Added at v3.14)
WidgetProxy is a class used to define an operations dashboard extension widget. WidgetProxy 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.

A widget is a user experience area in the host operation view. A widget is instantiated when the operation view is loaded and it is destroyed when the operation view is closed. Configuration properties for a widget can be captured when the publisher decides to publish a particular widget in the operation view. For an extension widget, configuration properties can be captured automatically by using manifest configuration properties and additional properties can be captured if a widget configuration user experience is provided.

Example 1: Used as a mixin in dijit class
define([
  "dojo/_base/declare",
  "dijit/_WidgetBase",
  "dijit/_TemplatedMixin",
  "esri/opsdashboard/WidgetProxy"
], function(declare, _WidgetBase, _TemplatedMixin, WidgetProxy){
  return declare("MyWidgetExtension", [_WidgetBase, _TemplatedMixin, WidgetProxy], {
    templateString: "<div>hello operation dashboard</div>",
    hostReady: function(){
    var configProperty = this.propertyIWantoSave;
    },
    dataSourceExpired: function(dataSourceProxy, dataSourceConfig){}
  });
});


Example 2: Used as plain proxy object
require([
  "esri/opsdashboard/WidgetProxy"
], function(WidgetProxy){
  var proxy = new WidgetProxy();
  proxy.on("host-ready", function(){
    var configProperty = this.propertyIWantoSave;
  });
  proxy.on("data-source-expired", function(dataSourceProxy, dataSourceConfig){});
});
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/WidgetProxy

Properties

NameTypeSummary
dataSourceConfigsObject[]Read-only: If the widget was configured to consume data sources, the dataSourceConfig array will hold a collection of dataSourceConfig objects.
featureActionFeaturesFeatureActionFeaturesRead-only: The host collection of features used by the widget feature actions.
hasDefaultFeatureActionBooleanRead-only: Indicates if the widget has a default feature action associated with.
hasFeatureActionsBooleanRead-only: Indicates if the widget has feature actions associated with it.
isNativeBooleanRead-only: Indicates if the host application is the Windows Operations Dashboard.
portalHelperServicesObjectRead-only: It will list all of the Portal helper services.
portalUrlStringRead-only: The URL to the ArcGIS.com site or in-house portal that you are currently signed in to.

Methods

NameReturn typeSummary
activateDrawingToolbar(options?, mapWidgetProxy?)PromiseActivate a drawing toolbar on a map widget.
dataSourceExpired(dataSourceProxy, associated?)NoneCalled by the host application when a data source state has expired.
deactivateDrawingToolbar(mapWidgetProxy?)NoneDeactivate the drawing toolbar on the map widget.
drawingToolbarDeactivated()NoneCalled by the host application when the user has canceled the drawing activity.
executeDefaultFeatureAction(featuresOrObjectIds)NoneExecute the default feature action.
getDataSourceConfig(dataSourceProxyOrDataSourceId)ObjectGet the data source config for a data source.
getDataSourceProxies()PromiseGet the collection of data sources from the host application.
getDataSourceProxy(dataSourceId)PromiseGet the data source corresponding to the data source id from the host application.
getMapWidgetProxies()PromiseGet the collection of map widgets from the host application.
getMapWidgetProxy(mapWidgetId)PromiseGet the map widget corresponding to the map widget id from the host application.
hostInitializationError(err)NoneCalled when an error occurred during the initialization process with the host application.
hostReady()NoneCalled by the host application when the relationship has been established with the extension.
mapWidgetAdded(mapWidgetProxy)NoneCalled by the host application when a map widget has been added to the current view.
mapWidgetRemoved(mapWidgetId)NoneCalled by the host application when a map widget has been removed from the current view.
toolbarDrawComplete(geometry)NoneCalled by the host application when the user has finished the drawing activity.

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.

Events

NameEvent ObjectSummary
data-source-added
{
  dataSourceProxy: <Object>
}
Event indicating that a new data source has been added into the host operation view.
data-source-expired
{
  dataSourceConfig: <Object>,
  dataSourceProxy: <DataSourceProxy>
}
Event indicating that a data source validity has expired.
data-source-removed
{
  dataSourceId: <String>
}
Event indicating that a data source has been removed from the host operation view.
drawing-toolbar-deactivatedEvent indicating that the user has deactivated the previously activated drawing toolbar on the map widget.
host-readyEvent indicating that the initialization process was successful.
initialization-error
{
  error: <Error>
}
Event indicating that the initialization process encountered an error.
map-widget-added
{
  mapWidgetProxy: <MapWidgetProxy>
}
Event indicating that a new map widget has been added into the host operation view.
map-widget-removed
{
  mapWidgetId: <String>
}
Event indicating that a map widget has been removed from the host operation view.
toolbar-draw-complete
{
  geometry: <Geometry>
}
Event indicating the user has finished a drawing activity with the previously activated drawing toolbar.
Property Details

<Object[]> dataSourceConfigs

Read-only: If the widget was configured to consume data sources, the dataSourceConfig array will hold a collection of dataSourceConfig objects.

<FeatureActionFeatures> featureActionFeatures

Read-only: The host collection of features used by the widget feature actions. If the widget has associated feature actions, it's the developer responsibility to maintain and update this collection. Note: if the widget has no associated feature actions hasFeatureActions is false), this property will be null.

<Boolean> hasDefaultFeatureAction

Read-only: Indicates if the widget has a default feature action associated with. If true, the default feature action can be invoked by using the function executeDefaultFeatureAction. A default feature action can be associated with a widget only if the manifest property "configuration.supportFeatureActions" is true.

<Boolean> hasFeatureActions

Read-only: Indicates if the widget has feature actions associated with it. If true then it's the developer responsibility to maintain and update the host collection of features that can be used by the feature actions by using the property featureActionFeatures. Feature actions can be associated with a widget only if the manifest property "configuration.supportFeatureActions" is true.

<Boolean> isNative

Read-only: Indicates if the host application is the Windows Operations Dashboard. If false, the host application is the browser based Operations Dashboard.

<Object> portalHelperServices

Read-only: It will list all of the Portal helper services. (Added at v3.16)

<String> portalUrl

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

activateDrawingToolbar(options?, mapWidgetProxy?)

Activate a drawing toolbar on a map widget.

When resolved successfully, returns a boolean 'true'. If another toolbar beside the the default map toolbar is currently activated, it returns a boolean 'false'.
Return type: Promise
Parameters:
<Object> options Optional None
<MapWidgetProxy> mapWidgetProxy Optional The target map widget. If none provided, the map widget that the widget is associated with will be used.

dataSourceExpired(dataSourceProxy, associated?)

Called by the host application when a data source state has expired. It could happen on three different occasions: 1) Right after hostReady has been invoked. 2) If the data source is based on a map widget layer and the host user has updated the map extent 3) If the data source has a refresh interval that was triggered Note: This function will never be invoked if the manifest property "useDataFromView" has not been set to true.
Parameters:
<DataSourceProxy> dataSourceProxy Required None
<Object> associated Optional dataSourceConfig

deactivateDrawingToolbar(mapWidgetProxy?)

Deactivate the drawing toolbar on the map widget.
Parameters:
<MapWidgetProxy> mapWidgetProxy Optional The target map widget. If none provided, the map widget that the widget is associated with will be used.

drawingToolbarDeactivated()

Called by the host application when the user has canceled the drawing activity.

executeDefaultFeatureAction(featuresOrObjectIds)

Execute the default feature action.
Parameters:
<Graphic[] | Number[]> featuresOrObjectIds Required None

getDataSourceConfig(dataSourceProxyOrDataSourceId)

Get the data source config for a data source.
Return type: Object
Parameters:
<DataSourceProxy | String> dataSourceProxyOrDataSourceId Required A data source or a data source id.

getDataSourceProxies()

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
Return type: Promise

getDataSourceProxy(dataSourceId)

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.
Return type: Promise
Parameters:
<String> dataSourceId Required The data source id

getMapWidgetProxies()

Get the collection of map widgets from the host application.
Return type: Promise

getMapWidgetProxy(mapWidgetId)

Get the map widget corresponding to the map widget id from the host application.
Return type: Promise
Parameters:
<String> mapWidgetId Required A map widget id

hostInitializationError(err)

Called when an error occurred during the initialization process with the host application.
Parameters:
<Error> err Required The error that occurred.

hostReady()

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.

mapWidgetAdded(mapWidgetProxy)

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.
Parameters:
<MapWidgetProxy> mapWidgetProxy Required A map widget id.

mapWidgetRemoved(mapWidgetId)

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.

toolbarDrawComplete(geometry)

Called by the host application when the user has finished the drawing activity.
Parameters:
<Geometry> geometry Required None
Event Details
[ On Style Events | Connect Style Event ]

data-source-added

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.

data-source-expired

Event indicating that a data source validity has expired. It happens in three scenarios a) right after the initialization b) if the data source has a refresh interval defined and the interval has expired and c) if the data source is based on a map widget layer and the map widget extent has changed.
Event Object Properties:
<Object> dataSourceConfig The associated data source config object.
<DataSourceProxy> dataSourceProxy The data source that has expired.

data-source-removed

Event indicating that a data source has been removed from the host operation view.
Event Object Properties:
<String> dataSourceId None

drawing-toolbar-deactivated

Event indicating that the user has deactivated the previously activated drawing toolbar on the map widget.

host-ready

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.

initialization-error

Event indicating that the initialization process encountered an error.
Event Object Properties:
<Error> error None

map-widget-added

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.

map-widget-removed

Event indicating that a map widget has been removed from the host operation view.
Event Object Properties:
<String> mapWidgetId None

toolbar-draw-complete

Event indicating the user has finished a drawing activity with the previously activated drawing toolbar.
Event Object Properties:
<Geometry> geometry The result of the drawing activity.