2019-10-24 19:52:19 +03:00
|
|
|
<!--
|
|
|
|
|
|
2023-01-31 10:43:56 +02:00
|
|
|
Copyright © 2016-2023 The Thingsboard Authors
|
2019-10-24 19:52:19 +03:00
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
|
|
|
|
|
-->
|
2021-10-06 21:03:29 +03:00
|
|
|
<form [formGroup]="widgetActionFormGroup" (ngSubmit)="save()" style="width: 800px;">
|
2020-04-21 11:53:26 +03:00
|
|
|
<mat-toolbar color="primary">
|
2019-10-24 19:52:19 +03:00
|
|
|
<h2>{{ (isAdd ? 'widget-config.add-action' : 'widget-config.edit-action' ) | translate }}</h2>
|
|
|
|
|
<span fxFlex></span>
|
2023-02-17 19:24:01 +02:00
|
|
|
<button mat-icon-button
|
2019-10-24 19:52:19 +03:00
|
|
|
(click)="cancel()"
|
|
|
|
|
type="button">
|
|
|
|
|
<mat-icon class="material-icons">close</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
</mat-toolbar>
|
|
|
|
|
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async">
|
|
|
|
|
</mat-progress-bar>
|
|
|
|
|
<div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
|
|
|
|
|
<div mat-dialog-content>
|
|
|
|
|
<fieldset [disabled]="isLoading$ | async">
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>widget-config.action-source</mat-label>
|
2020-04-21 11:53:26 +03:00
|
|
|
<mat-select required formControlName="actionSourceId">
|
2019-10-24 19:52:19 +03:00
|
|
|
<mat-option *ngFor="let actionSourceItem of data.actionsData.actionSources | keyvalue" [value]="actionSourceItem.key">
|
|
|
|
|
{{ actionSourceName(actionSourceItem.value) }}
|
|
|
|
|
</mat-option>
|
|
|
|
|
</mat-select>
|
|
|
|
|
<mat-error *ngIf="widgetActionFormGroup.get('actionSourceId').hasError('required')">
|
|
|
|
|
{{ 'widget-config.action-source-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
2020-04-21 11:53:26 +03:00
|
|
|
<mat-form-field class="mat-block">
|
2019-10-24 19:52:19 +03:00
|
|
|
<mat-label translate>widget-config.action-name</mat-label>
|
|
|
|
|
<input required matInput formControlName="name">
|
|
|
|
|
<mat-error *ngIf="widgetActionFormGroup.get('name').hasError('required')">
|
|
|
|
|
{{ 'widget-config.action-name-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
<mat-error *ngIf="widgetActionFormGroup.get('name').hasError('actionNameNotUnique')"
|
|
|
|
|
[innerHTML]="'widget-config.action-name-not-unique' | translate">
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<tb-material-icon-select
|
|
|
|
|
formControlName="icon">
|
|
|
|
|
</tb-material-icon-select>
|
2021-09-28 12:34:34 +03:00
|
|
|
<mat-checkbox *ngIf="displayShowWidgetActionForm()" formControlName="useShowWidgetActionFunction" style="padding-bottom: 16px;">
|
2021-10-04 14:46:43 +03:00
|
|
|
{{ 'widget-config.show-hide-action-using-function' | translate }}
|
2021-09-28 12:34:34 +03:00
|
|
|
</mat-checkbox>
|
|
|
|
|
<tb-js-func *ngIf="displayShowWidgetActionForm() && widgetActionFormGroup.get('useShowWidgetActionFunction').value"
|
|
|
|
|
formControlName="showWidgetActionFunction"
|
2021-10-06 21:03:29 +03:00
|
|
|
[helpId]="getWidgetActionFunctionHelpId()"
|
2021-09-28 12:34:34 +03:00
|
|
|
[functionArgs]="['widgetContext', 'data']"
|
|
|
|
|
[globalVariables]="functionScopeVariables"
|
|
|
|
|
[validationArgs]="[]"
|
|
|
|
|
[resultType]="'boolean'"
|
|
|
|
|
[editorCompleter]="customActionEditorCompleter"
|
|
|
|
|
></tb-js-func>
|
2019-10-24 19:52:19 +03:00
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>widget-config.action-type</mat-label>
|
2020-04-21 11:53:26 +03:00
|
|
|
<mat-select required formControlName="type">
|
2019-10-24 19:52:19 +03:00
|
|
|
<mat-option *ngFor="let actionType of widgetActionTypes" [value]="actionType">
|
2020-02-04 15:14:17 +02:00
|
|
|
{{ widgetActionTypeTranslations.get(widgetActionType[actionType]) | translate }}
|
2019-10-24 19:52:19 +03:00
|
|
|
</mat-option>
|
|
|
|
|
</mat-select>
|
|
|
|
|
<mat-error *ngIf="widgetActionFormGroup.get('type').hasError('required')">
|
|
|
|
|
{{ 'widget-config.action-type-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<section fxLayout="column" [formGroup]="actionTypeFormGroup" [ngSwitch]="widgetActionFormGroup.get('type').value">
|
|
|
|
|
<ng-template [ngSwitchCase]="widgetActionType.openDashboard">
|
2021-02-02 00:45:42 +02:00
|
|
|
<div class="mat-caption tb-required"
|
|
|
|
|
style="padding-left: 3px; padding-bottom: 10px; color: rgba(0,0,0,0.57);" translate>widget-action.target-dashboard</div>
|
|
|
|
|
<tb-dashboard-autocomplete
|
|
|
|
|
formControlName="targetDashboardId"
|
|
|
|
|
required
|
|
|
|
|
[selectFirstDashboard]="true"
|
|
|
|
|
></tb-dashboard-autocomplete>
|
2019-10-24 19:52:19 +03:00
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngSwitchCase]="widgetActionFormGroup.get('type').value === widgetActionType.openDashboardState ||
|
|
|
|
|
widgetActionFormGroup.get('type').value === widgetActionType.updateDashboardState ||
|
|
|
|
|
widgetActionFormGroup.get('type').value === widgetActionType.openDashboard ?
|
|
|
|
|
widgetActionFormGroup.get('type').value : ''">
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<input matInput type="text" placeholder="{{ 'widget-action.target-dashboard-state' | translate }}"
|
|
|
|
|
#dashboardStateInput
|
|
|
|
|
formControlName="targetDashboardStateId"
|
|
|
|
|
[required]="widgetActionFormGroup.get('type').value === widgetActionType.openDashboardState"
|
|
|
|
|
[matAutocomplete]="targetDashboardStateAutocomplete">
|
|
|
|
|
<button *ngIf="actionTypeFormGroup.get('targetDashboardStateId').value"
|
|
|
|
|
type="button"
|
2020-04-21 11:53:26 +03:00
|
|
|
matSuffix mat-icon-button aria-label="Clear"
|
2019-10-24 19:52:19 +03:00
|
|
|
(click)="clearTargetDashboardState()">
|
|
|
|
|
<mat-icon class="material-icons">close</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
<mat-autocomplete
|
|
|
|
|
class="tb-autocomplete"
|
|
|
|
|
#targetDashboardStateAutocomplete="matAutocomplete">
|
|
|
|
|
<mat-option *ngFor="let state of filteredDashboardStates | async" [value]="state">
|
|
|
|
|
<span [innerHTML]="state | highlight:targetDashboardStateSearchText"></span>
|
|
|
|
|
</mat-option>
|
|
|
|
|
</mat-autocomplete>
|
|
|
|
|
<mat-error *ngIf="actionTypeFormGroup.get('targetDashboardStateId').hasError('required')">
|
|
|
|
|
{{ 'widget-action.target-dashboard-state-required' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngSwitchCase]="widgetActionFormGroup.get('type').value === widgetActionType.openDashboardState ||
|
|
|
|
|
widgetActionFormGroup.get('type').value === widgetActionType.updateDashboardState ?
|
|
|
|
|
widgetActionFormGroup.get('type').value : ''">
|
|
|
|
|
<mat-checkbox formControlName="openRightLayout">
|
|
|
|
|
{{ 'widget-action.open-right-layout' | translate }}
|
|
|
|
|
</mat-checkbox>
|
|
|
|
|
</ng-template>
|
2021-01-14 13:17:23 +02:00
|
|
|
<ng-template [ngSwitchCase]="widgetActionFormGroup.get('type').value === widgetActionType.openDashboard ?
|
|
|
|
|
widgetActionFormGroup.get('type').value : ''">
|
|
|
|
|
<mat-checkbox formControlName="openNewBrowserTab">
|
|
|
|
|
{{ 'widget-action.open-new-browser-tab' | translate }}
|
|
|
|
|
</mat-checkbox>
|
|
|
|
|
</ng-template>
|
2019-10-24 19:52:19 +03:00
|
|
|
<ng-template [ngSwitchCase]="widgetActionFormGroup.get('type').value === widgetActionType.openDashboardState ||
|
|
|
|
|
widgetActionFormGroup.get('type').value === widgetActionType.updateDashboardState ||
|
|
|
|
|
widgetActionFormGroup.get('type').value === widgetActionType.openDashboard ?
|
|
|
|
|
widgetActionFormGroup.get('type').value : ''">
|
2021-05-20 13:25:34 +03:00
|
|
|
<mat-checkbox *ngIf="data.widgetType !== widgetType.static" formControlName="setEntityId">
|
2021-02-02 00:45:42 +02:00
|
|
|
{{ 'widget-action.set-entity-from-widget' | translate }}
|
|
|
|
|
</mat-checkbox>
|
|
|
|
|
<mat-form-field *ngIf="actionTypeFormGroup.get('setEntityId').value"
|
|
|
|
|
floatLabel="always"
|
|
|
|
|
class="mat-block">
|
|
|
|
|
<mat-label translate>alias.state-entity-parameter-name</mat-label>
|
|
|
|
|
<input matInput
|
|
|
|
|
placeholder="{{ 'alias.default-entity-parameter-name' | translate }}"
|
|
|
|
|
formControlName="stateEntityParamName">
|
|
|
|
|
</mat-form-field>
|
2019-10-24 19:52:19 +03:00
|
|
|
</ng-template>
|
2021-01-21 18:03:36 +02:00
|
|
|
<ng-template [ngSwitchCase]="widgetActionFormGroup.get('type').value === widgetActionType.openDashboardState ?
|
|
|
|
|
widgetActionFormGroup.get('type').value : ''">
|
2021-10-06 21:03:29 +03:00
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>widget-action.state-display-type</mat-label>
|
|
|
|
|
<mat-select formControlName="stateDisplayType">
|
|
|
|
|
<mat-option *ngFor="let displayType of allStateDisplayTypes" [value]="displayType">
|
|
|
|
|
{{ stateDisplayTypeName(displayType) }}
|
|
|
|
|
</mat-option>
|
|
|
|
|
</mat-select>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<section fxLayout="column" [formGroup]="stateDisplayTypeFormGroup" [ngSwitch]="actionTypeFormGroup.get('stateDisplayType').value">
|
|
|
|
|
<ng-template [ngSwitchCase]="'separateDialog'">
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>widget-action.dialog-title</mat-label>
|
|
|
|
|
<input matInput formControlName="dialogTitle">
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<mat-checkbox formControlName="dialogHideDashboardToolbar">
|
|
|
|
|
{{ 'widget-action.dialog-hide-dashboard-toolbar' | translate }}
|
|
|
|
|
</mat-checkbox>
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>widget-action.dialog-width</mat-label>
|
|
|
|
|
<input type="number" min="1" max="100" step="1" matInput formControlName="dialogWidth">
|
|
|
|
|
<mat-error *ngIf="stateDisplayTypeFormGroup.get('dialogWidth').hasError('min')">
|
|
|
|
|
{{ 'widget-action.dialog-size-range-error' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
<mat-error *ngIf="stateDisplayTypeFormGroup.get('dialogWidth').hasError('max')">
|
|
|
|
|
{{ 'widget-action.dialog-size-range-error' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>widget-action.dialog-height</mat-label>
|
|
|
|
|
<input type="number" min="1" max="100" step="1" matInput formControlName="dialogHeight">
|
|
|
|
|
<mat-error *ngIf="stateDisplayTypeFormGroup.get('dialogHeight').hasError('min')">
|
|
|
|
|
{{ 'widget-action.dialog-size-range-error' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
<mat-error *ngIf="stateDisplayTypeFormGroup.get('dialogHeight').hasError('max')">
|
|
|
|
|
{{ 'widget-action.dialog-size-range-error' | translate }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngSwitchCase]="'popover'">
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>widget-action.popover-preferred-placement</mat-label>
|
|
|
|
|
<mat-select formControlName="popoverPreferredPlacement">
|
|
|
|
|
<mat-option *ngFor="let placement of allPopoverPlacements" [value]="placement">
|
|
|
|
|
{{ popoverPlacementName(placement) }}
|
|
|
|
|
</mat-option>
|
|
|
|
|
</mat-select>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<mat-checkbox formControlName="popoverHideOnClickOutside">
|
|
|
|
|
{{ 'widget-action.popover-hide-on-click-outside' | translate }}
|
|
|
|
|
</mat-checkbox>
|
|
|
|
|
<mat-checkbox formControlName="popoverHideDashboardToolbar">
|
|
|
|
|
{{ 'widget-action.popover-hide-dashboard-toolbar' | translate }}
|
|
|
|
|
</mat-checkbox>
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>widget-action.popover-width</mat-label>
|
|
|
|
|
<input matInput formControlName="popoverWidth">
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<mat-form-field class="mat-block">
|
|
|
|
|
<mat-label translate>widget-action.popover-height</mat-label>
|
|
|
|
|
<input matInput formControlName="popoverHeight">
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<tb-json-object-edit
|
|
|
|
|
[editorStyle]="{minHeight: '100px'}"
|
|
|
|
|
label="{{ 'widget-action.popover-style' | translate }}"
|
|
|
|
|
formControlName="popoverStyle"
|
|
|
|
|
></tb-json-object-edit>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngSwitchCase]="'normal'">
|
|
|
|
|
</ng-template>
|
2021-01-21 18:03:36 +02:00
|
|
|
</section>
|
|
|
|
|
</ng-template>
|
2019-10-24 19:52:19 +03:00
|
|
|
<ng-template [ngSwitchCase]="widgetActionType.custom">
|
|
|
|
|
<tb-js-func
|
|
|
|
|
formControlName="customFunction"
|
2020-02-26 18:15:04 +02:00
|
|
|
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
2021-09-28 08:41:39 +03:00
|
|
|
[globalVariables]="functionScopeVariables"
|
2019-10-24 19:52:19 +03:00
|
|
|
[validationArgs]="[]"
|
2020-05-20 19:42:58 +03:00
|
|
|
[editorCompleter]="customActionEditorCompleter"
|
2021-10-13 20:35:10 +03:00
|
|
|
helpId="widget/action/custom_action_fn"
|
2019-10-24 19:52:19 +03:00
|
|
|
></tb-js-func>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template [ngSwitchCase]="widgetActionType.customPretty">
|
|
|
|
|
<tb-custom-action-pretty-editor
|
|
|
|
|
formControlName="customAction">
|
|
|
|
|
</tb-custom-action-pretty-editor>
|
|
|
|
|
</ng-template>
|
2021-05-04 19:44:15 +03:00
|
|
|
<ng-template [ngSwitchCase]="widgetActionType.mobileAction">
|
|
|
|
|
<tb-mobile-action-editor #mobileActionEditor
|
|
|
|
|
formControlName="mobileAction">
|
|
|
|
|
</tb-mobile-action-editor>
|
|
|
|
|
</ng-template>
|
2019-10-24 19:52:19 +03:00
|
|
|
</section>
|
|
|
|
|
</fieldset>
|
|
|
|
|
</div>
|
2020-04-21 11:53:26 +03:00
|
|
|
<div mat-dialog-actions fxLayoutAlign="end center">
|
2019-10-24 19:52:19 +03:00
|
|
|
<button mat-button color="primary"
|
|
|
|
|
type="button"
|
|
|
|
|
[disabled]="(isLoading$ | async)"
|
|
|
|
|
(click)="cancel()" cdkFocusInitial>
|
|
|
|
|
{{ 'action.cancel' | translate }}
|
|
|
|
|
</button>
|
2020-10-14 12:32:07 +03:00
|
|
|
<button mat-raised-button color="primary"
|
|
|
|
|
type="submit"
|
2021-10-06 21:03:29 +03:00
|
|
|
[disabled]="(isLoading$ | async) || widgetActionFormGroup.invalid || actionTypeFormGroup.invalid || stateDisplayTypeFormGroup?.invalid ||
|
|
|
|
|
(!widgetActionFormGroup.dirty && !actionTypeFormGroup.dirty && !stateDisplayTypeFormGroup?.dirty)">
|
2020-10-14 12:32:07 +03:00
|
|
|
{{ (isAdd ? 'action.add' : 'action.save') | translate }}
|
|
|
|
|
</button>
|
2019-10-24 19:52:19 +03:00
|
|
|
</div>
|
|
|
|
|
</form>
|