UI: Add to map functions arguments widgetContext
This commit is contained in:
parent
d2707f0042
commit
14d9779978
@ -57,7 +57,7 @@ export class DataLayerPatternProcessor {
|
||||
|
||||
public setup(): Observable<void> {
|
||||
if (this.settings.type === DataLayerPatternType.function) {
|
||||
return parseTbFunction<MapStringFunction>(this.dataLayer.getCtx().http, this.settings.patternFunction, ['data', 'dsData']).pipe(
|
||||
return parseTbFunction<MapStringFunction>(this.dataLayer.getCtx().http, this.settings.patternFunction, ['data', 'dsData', 'ctx']).pipe(
|
||||
map((parsed) => {
|
||||
this.patternFunction = parsed;
|
||||
return null;
|
||||
@ -72,7 +72,7 @@ export class DataLayerPatternProcessor {
|
||||
public processPattern(data: FormattedData<TbMapDatasource>, dsData: FormattedData<TbMapDatasource>[]): string {
|
||||
let pattern: string;
|
||||
if (this.settings.type === DataLayerPatternType.function) {
|
||||
pattern = safeExecuteTbFunction(this.patternFunction, [data, dsData]);
|
||||
pattern = safeExecuteTbFunction(this.patternFunction, [data, dsData, this.dataLayer.getCtx()]);
|
||||
} else {
|
||||
pattern = this.pattern;
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
required
|
||||
withModules
|
||||
[globalVariables]="functionScopeVariables"
|
||||
[functionArgs]="['data', 'dsData']"
|
||||
[functionArgs]="['data', 'dsData', 'ctx']"
|
||||
functionTitle="{{ (patternType === 'label' ? 'widgets.maps.data-layer.label-function' : 'widgets.maps.data-layer.tooltip-function') | translate }}"
|
||||
[helpId]="helpId"
|
||||
[helpPopupStyle]="{width: '900px'}">
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<div class="divider"></div>
|
||||
<br/>
|
||||
|
||||
*function (data, dsData): string*
|
||||
*function (data, dsData, ctx): string*
|
||||
|
||||
A JavaScript function used to compute text or HTML code of the marker label.
|
||||
|
||||
|
||||
@ -5,4 +5,6 @@
|
||||
resolved from configured datasources. Each object represents basic entity properties (ex. <code>entityId</code>, <code>entityName</code>)<br/>
|
||||
and provides access to other entity attributes/timeseries declared in datasources of data layers configuration including additional datasources of the map configuration.
|
||||
</li>
|
||||
|
||||
<li><b>ctx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/5bb6403407aa4898084832d6698aa9ea6d484889/ui-ngx/src/app/modules/home/models/widget-component.models.ts#L107" target="_blank">WidgetContext</a></code> - A reference to <a href="https://github.com/thingsboard/thingsboard/blob/5bb6403407aa4898084832d6698aa9ea6d484889/ui-ngx/src/app/modules/home/models/widget-component.models.ts#L107" target="_blank">WidgetContext</a> that has all necessary API
|
||||
and data used by widget instance.
|
||||
</li>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user