UI: Add help to function 'Get Dashboard State with Parameters'
This commit is contained in:
parent
8b7bf4a633
commit
c6bb337d23
@ -145,7 +145,7 @@
|
|||||||
[globalVariables]="functionScopeVariables"
|
[globalVariables]="functionScopeVariables"
|
||||||
[functionArgs]="['data']"
|
[functionArgs]="['data']"
|
||||||
functionTitle="{{ 'widgets.value-action.parse-value-function' | translate }}"
|
functionTitle="{{ 'widgets.value-action.parse-value-function' | translate }}"
|
||||||
helpId="widget/lib/rpc/parse_value_fn">
|
[helpId]="getParseValueFunctionHelpId()">
|
||||||
</tb-js-func>
|
</tb-js-func>
|
||||||
<div *ngIf="valueType === ValueType.BOOLEAN" class="tb-form-row align-start no-gap column-xs">
|
<div *ngIf="valueType === ValueType.BOOLEAN" class="tb-form-row align-start no-gap column-xs">
|
||||||
<div class="fixed-title-width fixed-title-height">{{ 'widgets.value-action.state-when-result-is' | translate:{state: stateLabel} }}</div>
|
<div class="fixed-title-width fixed-title-height">{{ 'widgets.value-action.state-when-result-is' | translate:{state: stateLabel} }}</div>
|
||||||
|
|||||||
@ -167,6 +167,14 @@ export class GetValueActionSettingsPanelComponent extends PageComponent implemen
|
|||||||
this.getValueSettingsApplied.emit(getValueSettings);
|
this.getValueSettingsApplied.emit(getValueSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getParseValueFunctionHelpId(): string {
|
||||||
|
const action: GetValueAction = this.getValueSettingsFormGroup.get('action').value;
|
||||||
|
if (action === GetValueAction.GET_DASHBOARD_STATE_WITH_PARAMS) {
|
||||||
|
return 'widget/config/parse_value_get_dashboard_state_with_params_fn';
|
||||||
|
}
|
||||||
|
return 'widget/lib/rpc/parse_value_fn';
|
||||||
|
}
|
||||||
|
|
||||||
private updateValidators() {
|
private updateValidators() {
|
||||||
const action: GetValueAction = this.getValueSettingsFormGroup.get('action').value;
|
const action: GetValueAction = this.getValueSettingsFormGroup.get('action').value;
|
||||||
let dataToValueType: DataToValueType = this.getValueSettingsFormGroup.get('dataToValue').get('type').value;
|
let dataToValueType: DataToValueType = this.getValueSettingsFormGroup.get('dataToValue').get('type').value;
|
||||||
|
|||||||
@ -0,0 +1,40 @@
|
|||||||
|
#### Parse value function
|
||||||
|
|
||||||
|
<div class="divider"></div>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
*function (data): boolean*
|
||||||
|
|
||||||
|
A JavaScript function that converts the current dashboard state and parameters into a boolean value.
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><b>data:</b> <a href="https://github.com/thingsboard/thingsboard/blob/master/ui-ngx/src/app/core/api/widget-api.models.ts#L150" target="_blank">StateObject</a> - the current dashboard state object.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
`true` if the widget should be in an activated state, `false` otherwise.
|
||||||
|
|
||||||
|
<div class="divider"></div>
|
||||||
|
|
||||||
|
##### Examples
|
||||||
|
|
||||||
|
* Check if the current dashboard state ID is "default":
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
return data.id === 'default' ? true : false;
|
||||||
|
{:copy-code}
|
||||||
|
```
|
||||||
|
|
||||||
|
* Check if the current dashboard state parameters are empty:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
return Object.keys(data.params).length ? true : false;
|
||||||
|
{:copy-code}
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
Loading…
x
Reference in New Issue
Block a user