Add widget context to callbacks of entitites hierarchy widget.

This commit is contained in:
devaskim 2022-08-15 18:47:27 +05:00
parent 9929d11195
commit 0952395cd2
10 changed files with 59 additions and 37 deletions

View File

@ -159,21 +159,21 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
parentNodeCtx.level = 1; parentNodeCtx.level = 1;
testNodeCtx.parentNodeCtx = parentNodeCtx; testNodeCtx.parentNodeCtx = parentNodeCtx;
this.nodeRelationQueryFunction = loadNodeCtxFunction(this.settings.nodeRelationQueryFunction, 'nodeCtx', testNodeCtx); this.nodeRelationQueryFunction = loadNodeCtxFunction(this.settings.nodeRelationQueryFunction, 'widgetCtx, nodeCtx', this.ctx, testNodeCtx);
this.nodeIconFunction = loadNodeCtxFunction(this.settings.nodeIconFunction, 'nodeCtx', testNodeCtx); this.nodeIconFunction = loadNodeCtxFunction(this.settings.nodeIconFunction, 'widgetCtx, nodeCtx', this.ctx, testNodeCtx);
this.nodeTextFunction = loadNodeCtxFunction(this.settings.nodeTextFunction, 'nodeCtx', testNodeCtx); this.nodeTextFunction = loadNodeCtxFunction(this.settings.nodeTextFunction, 'widgetCtx, nodeCtx', this.ctx, testNodeCtx);
this.nodeDisabledFunction = loadNodeCtxFunction(this.settings.nodeDisabledFunction, 'nodeCtx', testNodeCtx); this.nodeDisabledFunction = loadNodeCtxFunction(this.settings.nodeDisabledFunction, 'widgetCtx, nodeCtx', this.ctx, testNodeCtx);
this.nodeOpenedFunction = loadNodeCtxFunction(this.settings.nodeOpenedFunction, 'nodeCtx', testNodeCtx); this.nodeOpenedFunction = loadNodeCtxFunction(this.settings.nodeOpenedFunction, 'widgetCtx, nodeCtx', this.ctx, testNodeCtx);
this.nodeHasChildrenFunction = loadNodeCtxFunction(this.settings.nodeHasChildrenFunction, 'nodeCtx', testNodeCtx); this.nodeHasChildrenFunction = loadNodeCtxFunction(this.settings.nodeHasChildrenFunction, 'widgetCtx, nodeCtx', this.ctx, testNodeCtx);
const testNodeCtx2 = deepClone(testNodeCtx); const testNodeCtx2 = deepClone(testNodeCtx);
testNodeCtx2.entity.name = 'TEST DEV2'; testNodeCtx2.entity.name = 'TEST DEV2';
this.nodesSortFunction = loadNodeCtxFunction(this.settings.nodesSortFunction, 'nodeCtx1,nodeCtx2', testNodeCtx, testNodeCtx2); this.nodesSortFunction = loadNodeCtxFunction(this.settings.nodesSortFunction, 'widgetCtx, nodeCtx1,nodeCtx2', this.ctx, testNodeCtx, testNodeCtx2);
this.nodeRelationQueryFunction = this.nodeRelationQueryFunction || defaultNodeRelationQueryFunction; this.nodeRelationQueryFunction = this.nodeRelationQueryFunction || defaultNodeRelationQueryFunction;
this.nodeIconFunction = this.nodeIconFunction || defaultNodeIconFunction; this.nodeIconFunction = this.nodeIconFunction || defaultNodeIconFunction;
this.nodeTextFunction = this.nodeTextFunction || ((nodeCtx) => nodeCtx.entity.name); this.nodeTextFunction = this.nodeTextFunction || ((widgetCtx, nodeCtx) => nodeCtx.entity.name);
this.nodeDisabledFunction = this.nodeDisabledFunction || (() => false); this.nodeDisabledFunction = this.nodeDisabledFunction || (() => false);
this.nodeOpenedFunction = this.nodeOpenedFunction || defaultNodeOpenedFunction; this.nodeOpenedFunction = this.nodeOpenedFunction || defaultNodeOpenedFunction;
this.nodeHasChildrenFunction = this.nodeHasChildrenFunction || (() => true); this.nodeHasChildrenFunction = this.nodeHasChildrenFunction || (() => true);
@ -322,7 +322,7 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
node.text = newText; node.text = newText;
this.nodeEditCallbacks.updateNode(node.id, node.text); this.nodeEditCallbacks.updateNode(node.id, node.text);
} }
const newDisabled = this.nodeDisabledFunction(node.data.nodeCtx); const newDisabled = this.nodeDisabledFunction(this.ctx, node.data.nodeCtx);
if (node.state.disabled !== newDisabled) { if (node.state.disabled !== newDisabled) {
node.state.disabled = newDisabled; node.state.disabled = newDisabled;
if (node.state.disabled) { if (node.state.disabled) {
@ -331,7 +331,7 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
this.nodeEditCallbacks.enableNode(node.id); this.nodeEditCallbacks.enableNode(node.id);
} }
} }
const newHasChildren = this.nodeHasChildrenFunction(node.data.nodeCtx); const newHasChildren = this.nodeHasChildrenFunction(this.ctx, node.data.nodeCtx);
if (node.children !== newHasChildren) { if (node.children !== newHasChildren) {
node.children = newHasChildren; node.children = newHasChildren;
this.nodeEditCallbacks.setNodeHasChildren(node.id, node.children); this.nodeEditCallbacks.setNodeHasChildren(node.id, node.children);
@ -340,22 +340,22 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
private prepareNodes(nodes: HierarchyNavTreeNode[]): HierarchyNavTreeNode[] { private prepareNodes(nodes: HierarchyNavTreeNode[]): HierarchyNavTreeNode[] {
nodes = nodes.filter((node) => node !== null); nodes = nodes.filter((node) => node !== null);
nodes.sort((node1, node2) => this.nodesSortFunction(node1.data.nodeCtx, node2.data.nodeCtx)); nodes.sort((node1, node2) => this.nodesSortFunction(this.ctx, node1.data.nodeCtx, node2.data.nodeCtx));
return nodes; return nodes;
} }
private prepareNodeText(node: HierarchyNavTreeNode): string { private prepareNodeText(node: HierarchyNavTreeNode): string {
const nodeIcon = this.prepareNodeIcon(node.data.nodeCtx); const nodeIcon = this.prepareNodeIcon(node.data.nodeCtx);
const nodeText = this.nodeTextFunction(node.data.nodeCtx); const nodeText = this.nodeTextFunction(this.ctx, node.data.nodeCtx);
node.data.searchText = nodeText ? nodeText.replace(/<[^>]+>/g, '').toLowerCase() : ''; node.data.searchText = nodeText ? nodeText.replace(/<[^>]+>/g, '').toLowerCase() : '';
return nodeIcon + nodeText; return nodeIcon + nodeText;
} }
private prepareNodeIcon(nodeCtx: HierarchyNodeContext): string { private prepareNodeIcon(nodeCtx: HierarchyNodeContext): string {
let iconInfo = this.nodeIconFunction(nodeCtx); let iconInfo = this.nodeIconFunction(this.ctx, nodeCtx);
if (iconInfo) { if (iconInfo) {
if (iconInfo === 'default') { if (iconInfo === 'default') {
iconInfo = defaultNodeIconFunction(nodeCtx); iconInfo = defaultNodeIconFunction(this.ctx, nodeCtx);
} }
if (iconInfo && iconInfo !== 'default' && (iconInfo.iconUrl || iconInfo.materialIcon)) { if (iconInfo && iconInfo !== 'default' && (iconInfo.iconUrl || iconInfo.materialIcon)) {
if (iconInfo.materialIcon) { if (iconInfo.materialIcon) {
@ -406,11 +406,11 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
nodeCtx nodeCtx
}; };
node.state = { node.state = {
disabled: this.nodeDisabledFunction(node.data.nodeCtx), disabled: this.nodeDisabledFunction(this.ctx, node.data.nodeCtx),
opened: this.nodeOpenedFunction(node.data.nodeCtx) opened: this.nodeOpenedFunction(this.ctx, node.data.nodeCtx)
}; };
node.text = this.prepareNodeText(node); node.text = this.prepareNodeText(node);
node.children = this.nodeHasChildrenFunction(node.data.nodeCtx); node.children = this.nodeHasChildrenFunction(this.ctx, node.data.nodeCtx);
return node; return node;
} }
@ -456,9 +456,9 @@ export class EntitiesHierarchyWidgetComponent extends PageComponent implements O
} }
private prepareNodeRelationQuery(nodeCtx: HierarchyNodeContext): EntityRelationsQuery { private prepareNodeRelationQuery(nodeCtx: HierarchyNodeContext): EntityRelationsQuery {
let relationQuery = this.nodeRelationQueryFunction(nodeCtx); let relationQuery = this.nodeRelationQueryFunction(this.ctx, nodeCtx);
if (relationQuery && relationQuery === 'default') { if (relationQuery && relationQuery === 'default') {
relationQuery = defaultNodeRelationQueryFunction(nodeCtx); relationQuery = defaultNodeRelationQueryFunction(this.ctx, nodeCtx);
} }
return relationQuery as EntityRelationsQuery; return relationQuery as EntityRelationsQuery;
} }

View File

@ -21,6 +21,7 @@ import { Datasource } from '@shared/models/widget.models';
import { isDefined, isUndefined } from '@core/utils'; import { isDefined, isUndefined } from '@core/utils';
import { EntityRelationsQuery, EntitySearchDirection, RelationTypeGroup } from '@shared/models/relation.models'; import { EntityRelationsQuery, EntitySearchDirection, RelationTypeGroup } from '@shared/models/relation.models';
import { EntityType } from '@shared/models/entity-type.models'; import { EntityType } from '@shared/models/entity-type.models';
import { WidgetContext } from '@home/models/widget-component.models';
export interface EntitiesHierarchyWidgetSettings { export interface EntitiesHierarchyWidgetSettings {
nodeRelationQueryFunction: string; nodeRelationQueryFunction: string;
@ -57,13 +58,13 @@ export interface HierarchyNodeIconInfo {
materialIcon?: string; materialIcon?: string;
} }
export type NodeRelationQueryFunction = (nodeCtx: HierarchyNodeContext) => EntityRelationsQuery | 'default'; export type NodeRelationQueryFunction = (widgetCtx: WidgetContext, nodeCtx: HierarchyNodeContext) => EntityRelationsQuery | 'default';
export type NodeTextFunction = (nodeCtx: HierarchyNodeContext) => string; export type NodeTextFunction = (widgetCtx: WidgetContext, nodeCtx: HierarchyNodeContext) => string;
export type NodeDisabledFunction = (nodeCtx: HierarchyNodeContext) => boolean; export type NodeDisabledFunction = (widgetCtx: WidgetContext, nodeCtx: HierarchyNodeContext) => boolean;
export type NodeIconFunction = (nodeCtx: HierarchyNodeContext) => HierarchyNodeIconInfo | 'default'; export type NodeIconFunction = (widgetCtx: WidgetContext, nodeCtx: HierarchyNodeContext) => HierarchyNodeIconInfo | 'default';
export type NodeOpenedFunction = (nodeCtx: HierarchyNodeContext) => boolean; export type NodeOpenedFunction = (widgetCtx: WidgetContext, nodeCtx: HierarchyNodeContext) => boolean;
export type NodeHasChildrenFunction = (nodeCtx: HierarchyNodeContext) => boolean; export type NodeHasChildrenFunction = (widgetCtx: WidgetContext, nodeCtx: HierarchyNodeContext) => boolean;
export type NodesSortFunction = (nodeCtx1: HierarchyNodeContext, nodeCtx2: HierarchyNodeContext) => number; export type NodesSortFunction = (widgetCtx: WidgetContext, nodeCtx1: HierarchyNodeContext, nodeCtx2: HierarchyNodeContext) => number;
export function loadNodeCtxFunction<F extends (...args: any[]) => any>(functionBody: string, argNames: string, ...args: any[]): F { export function loadNodeCtxFunction<F extends (...args: any[]) => any>(functionBody: string, argNames: string, ...args: any[]): F {
let nodeCtxFunction: F = null; let nodeCtxFunction: F = null;
@ -89,7 +90,7 @@ export function iconUrlHtml(iconUrl: string): string {
return '<div class="node-icon" style="background-image: url(' + iconUrl + ');">&nbsp;</div>'; return '<div class="node-icon" style="background-image: url(' + iconUrl + ');">&nbsp;</div>';
} }
export const defaultNodeRelationQueryFunction: NodeRelationQueryFunction = nodeCtx => { export const defaultNodeRelationQueryFunction: NodeRelationQueryFunction = (widgetContext, nodeCtx) => {
const entity = nodeCtx.entity; const entity = nodeCtx.entity;
const query: EntityRelationsQuery = { const query: EntityRelationsQuery = {
parameters: { parameters: {
@ -109,7 +110,7 @@ export const defaultNodeRelationQueryFunction: NodeRelationQueryFunction = nodeC
return query; return query;
}; };
export const defaultNodeIconFunction: NodeIconFunction = nodeCtx => { export const defaultNodeIconFunction: NodeIconFunction = (widgetContext, nodeCtx) => {
let materialIcon = 'insert_drive_file'; let materialIcon = 'insert_drive_file';
const entity = nodeCtx.entity; const entity = nodeCtx.entity;
if (entity && entity.id && entity.id.entityType) { if (entity && entity.id && entity.id.entityType) {
@ -148,11 +149,11 @@ export const defaultNodeIconFunction: NodeIconFunction = nodeCtx => {
}; };
}; };
export const defaultNodeOpenedFunction: NodeOpenedFunction = nodeCtx => { export const defaultNodeOpenedFunction: NodeOpenedFunction = (widgetCtx, nodeCtx) => {
return nodeCtx.level <= 4; return nodeCtx.level <= 4;
}; };
export const defaultNodesSortFunction: NodesSortFunction = (nodeCtx1, nodeCtx2) => { export const defaultNodesSortFunction: NodesSortFunction = (widgetCtx, nodeCtx1, nodeCtx2) => {
let result = 0; let result = 0;
if (!nodeCtx1.entity.id.entityType || !nodeCtx2.entity.id.entityType ) { if (!nodeCtx1.entity.id.entityType || !nodeCtx2.entity.id.entityType ) {
if (nodeCtx1.entity.id.entityType) { if (nodeCtx1.entity.id.entityType) {

View File

@ -20,13 +20,13 @@
<legend class="group-title" translate>widgets.entities-hierarchy.hierarchy-data-settings</legend> <legend class="group-title" translate>widgets.entities-hierarchy.hierarchy-data-settings</legend>
<tb-js-func formControlName="nodeRelationQueryFunction" <tb-js-func formControlName="nodeRelationQueryFunction"
[globalVariables]="functionScopeVariables" [globalVariables]="functionScopeVariables"
[functionArgs]="['nodeCtx']" [functionArgs]="['widgetCtx', 'nodeCtx']"
functionTitle="{{ 'widgets.entities-hierarchy.relations-query-function' | translate }}" functionTitle="{{ 'widgets.entities-hierarchy.relations-query-function' | translate }}"
helpId="widget/lib/entities_hierarchy/node_relation_query_fn"> helpId="widget/lib/entities_hierarchy/node_relation_query_fn">
</tb-js-func> </tb-js-func>
<tb-js-func formControlName="nodeHasChildrenFunction" <tb-js-func formControlName="nodeHasChildrenFunction"
[globalVariables]="functionScopeVariables" [globalVariables]="functionScopeVariables"
[functionArgs]="['nodeCtx']" [functionArgs]="['widgetCtx', 'nodeCtx']"
functionTitle="{{ 'widgets.entities-hierarchy.has-children-function' | translate }}" functionTitle="{{ 'widgets.entities-hierarchy.has-children-function' | translate }}"
helpId="widget/lib/entities_hierarchy/node_has_children_fn"> helpId="widget/lib/entities_hierarchy/node_has_children_fn">
</tb-js-func> </tb-js-func>
@ -35,13 +35,13 @@
<legend class="group-title" translate>widgets.entities-hierarchy.node-state-settings</legend> <legend class="group-title" translate>widgets.entities-hierarchy.node-state-settings</legend>
<tb-js-func formControlName="nodeOpenedFunction" <tb-js-func formControlName="nodeOpenedFunction"
[globalVariables]="functionScopeVariables" [globalVariables]="functionScopeVariables"
[functionArgs]="['nodeCtx']" [functionArgs]="['widgetCtx', 'nodeCtx']"
functionTitle="{{ 'widgets.entities-hierarchy.node-opened-function' | translate }}" functionTitle="{{ 'widgets.entities-hierarchy.node-opened-function' | translate }}"
helpId="widget/lib/entities_hierarchy/node_opened_fn"> helpId="widget/lib/entities_hierarchy/node_opened_fn">
</tb-js-func> </tb-js-func>
<tb-js-func formControlName="nodeDisabledFunction" <tb-js-func formControlName="nodeDisabledFunction"
[globalVariables]="functionScopeVariables" [globalVariables]="functionScopeVariables"
[functionArgs]="['nodeCtx']" [functionArgs]="['widgetCtx', 'nodeCtx']"
functionTitle="{{ 'widgets.entities-hierarchy.node-disabled-function' | translate }}" functionTitle="{{ 'widgets.entities-hierarchy.node-disabled-function' | translate }}"
helpId="widget/lib/entities_hierarchy/node_disabled_fn"> helpId="widget/lib/entities_hierarchy/node_disabled_fn">
</tb-js-func> </tb-js-func>
@ -50,13 +50,13 @@
<legend class="group-title" translate>widgets.entities-hierarchy.display-settings</legend> <legend class="group-title" translate>widgets.entities-hierarchy.display-settings</legend>
<tb-js-func formControlName="nodeIconFunction" <tb-js-func formControlName="nodeIconFunction"
[globalVariables]="functionScopeVariables" [globalVariables]="functionScopeVariables"
[functionArgs]="['nodeCtx']" [functionArgs]="['widgetCtx', 'nodeCtx']"
functionTitle="{{ 'widgets.entities-hierarchy.node-icon-function' | translate }}" functionTitle="{{ 'widgets.entities-hierarchy.node-icon-function' | translate }}"
helpId="widget/lib/entities_hierarchy/node_icon_fn"> helpId="widget/lib/entities_hierarchy/node_icon_fn">
</tb-js-func> </tb-js-func>
<tb-js-func formControlName="nodeTextFunction" <tb-js-func formControlName="nodeTextFunction"
[globalVariables]="functionScopeVariables" [globalVariables]="functionScopeVariables"
[functionArgs]="['nodeCtx']" [functionArgs]="['widgetCtx', 'nodeCtx']"
functionTitle="{{ 'widgets.entities-hierarchy.node-text-function' | translate }}" functionTitle="{{ 'widgets.entities-hierarchy.node-text-function' | translate }}"
helpId="widget/lib/entities_hierarchy/node_text_fn"> helpId="widget/lib/entities_hierarchy/node_text_fn">
</tb-js-func> </tb-js-func>
@ -65,7 +65,7 @@
<legend class="group-title" translate>widgets.entities-hierarchy.sort-settings</legend> <legend class="group-title" translate>widgets.entities-hierarchy.sort-settings</legend>
<tb-js-func formControlName="nodesSortFunction" <tb-js-func formControlName="nodesSortFunction"
[globalVariables]="functionScopeVariables" [globalVariables]="functionScopeVariables"
[functionArgs]="['nodeCtx1', 'nodeCtx2']" [functionArgs]="['widgetCtx', 'nodeCtx1', 'nodeCtx2']"
functionTitle="{{ 'widgets.entities-hierarchy.nodes-sort-function' | translate }}" functionTitle="{{ 'widgets.entities-hierarchy.nodes-sort-function' | translate }}"
helpId="widget/lib/entities_hierarchy/nodes_sort_fn"> helpId="widget/lib/entities_hierarchy/nodes_sort_fn">
</tb-js-func> </tb-js-func>

View File

@ -10,6 +10,9 @@ A JavaScript function evaluating whether current node should be disabled (not se
**Parameters:** **Parameters:**
<ul> <ul>
<li><b>widgetCtx:</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>
<li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An <li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An
<a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object <a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object
containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration. containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration.

View File

@ -10,6 +10,9 @@ A JavaScript function evaluating whether current node has children (whether it c
**Parameters:** **Parameters:**
<ul> <ul>
<li><b>widgetCtx:</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>
<li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An <li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An
<a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object <a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object
containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration. containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration.

View File

@ -10,6 +10,9 @@ A JavaScript function used to compute node icon info.
**Parameters:** **Parameters:**
<ul> <ul>
<li><b>widgetCtx:</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>
<li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An <li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An
<a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object <a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object
containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration. containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration.

View File

@ -10,6 +10,9 @@ A JavaScript function evaluating whether current node should be opened (expanded
**Parameters:** **Parameters:**
<ul> <ul>
<li><b>widgetCtx:</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>
<li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An <li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An
<a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object <a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object
containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration. containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration.

View File

@ -10,6 +10,9 @@ A JavaScript function used to compute child nodes relations query for current no
**Parameters:** **Parameters:**
<ul> <ul>
<li><b>widgetCtx:</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>
<li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An <li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An
<a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object <a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object
containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration. containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration.

View File

@ -10,6 +10,9 @@ A JavaScript function used to compute text or HTML code for the current node.
**Parameters:** **Parameters:**
<ul> <ul>
<li><b>widgetCtx:</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>
<li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An <li><b>nodeCtx:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - An
<a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object <a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a> object
containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration. containing <code>entity</code> field holding basic entity properties <br> (ex. <code>id</code>, <code>name</code>, <code>label</code>) and <code>data</code> field holding other entity attributes/timeseries declared in widget datasource configuration.

View File

@ -10,6 +10,9 @@ A JavaScript function used to compare nodes of the same level when sorting.
**Parameters:** **Parameters:**
<ul> <ul>
<li><b>widgetCtx:</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>
<li><b>nodeCtx1:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - First <li><b>nodeCtx1:</b> <code><a href="https://github.com/thingsboard/thingsboard/blob/e264f7b8ddff05bda85c4833bf497f47f447496e/ui-ngx/src/app/modules/home/components/widget/lib/entities-hierarchy-widget.models.ts#L35" target="_blank">HierarchyNodeContext</a></code> - First
node object to be compared. node object to be compared.
</li> </li>