Browse Source

Merge branch 'AD/imp/generator-node' of github.com:ArtemDzhereleiko/thingsboard into AD/imp/generator-node

pull/11220/head
Vladyslav_Prykhodko 2 years ago
parent
commit
bec4e811eb
  1. 2
      ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts
  2. 6
      ui-ngx/src/app/shared/components/entity/entity-select.component.html
  3. 10
      ui-ngx/src/app/shared/components/entity/entity-select.component.ts
  4. 3
      ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts
  5. 1
      ui-ngx/src/app/shared/components/js-func.component.html
  6. 8
      ui-ngx/src/app/shared/components/script-lang.component.html
  7. 1
      ui-ngx/src/app/shared/components/script-lang.component.scss
  8. 2
      ui-ngx/src/app/shared/components/script-lang.component.ts
  9. 10
      ui-ngx/src/app/shared/models/entity-type.models.ts
  10. 1
      ui-ngx/src/assets/locale/locale.constant-en_US.json

2
ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts

@ -414,6 +414,8 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
} else { } else {
return EntityType.CUSTOMER; return EntityType.CUSTOMER;
} }
} else if (entityType === AliasEntityType.CURRENT_RULE_NODE) {
return EntityType.RULE_NODE;
} }
return entityType; return entityType;
} }

6
ui-ngx/src/app/shared/components/entity/entity-select.component.html

@ -15,7 +15,7 @@
limitations under the License. limitations under the License.
--> -->
<div [formGroup]="entitySelectFormGroup"> <div [formGroup]="entitySelectFormGroup" class="tb-entity-select">
<tb-entity-type-select <tb-entity-type-select
*ngIf="displayEntityTypeSelect" *ngIf="displayEntityTypeSelect"
[showLabel]="true" [showLabel]="true"
@ -25,9 +25,7 @@
formControlName="entityType"> formControlName="entityType">
</tb-entity-type-select> </tb-entity-type-select>
<tb-entity-autocomplete <tb-entity-autocomplete
*ngIf="modelValue.entityType && modelValue.entityType !== AliasEntityType.CURRENT_TENANT *ngIf="modelValue.entityType && !entityTypeNullUid.has(modelValue.entityType)"
&& modelValue.entityType !== AliasEntityType.CURRENT_USER
&& modelValue.entityType !== AliasEntityType.CURRENT_USER_OWNER"
[required]="required" [required]="required"
[entityType]="modelValue.entityType" [entityType]="modelValue.entityType"
formControlName="entityId"> formControlName="entityId">

10
ui-ngx/src/app/shared/components/entity/entity-select.component.ts

@ -15,7 +15,7 @@
/// ///
import { AfterViewInit, Component, forwardRef, Input, OnInit } from '@angular/core'; import { AfterViewInit, Component, forwardRef, Input, OnInit } from '@angular/core';
import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'; import { ControlValueAccessor, NG_VALUE_ACCESSOR, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
@ -63,6 +63,10 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte
AliasEntityType = AliasEntityType; AliasEntityType = AliasEntityType;
entityTypeNullUid: Set<AliasEntityType | EntityType> = new Set([
AliasEntityType.CURRENT_TENANT, AliasEntityType.CURRENT_USER, AliasEntityType.CURRENT_USER_OWNER, AliasEntityType.CURRENT_RULE_NODE
]);
private readonly defaultEntityType: EntityType | AliasEntityType = null; private readonly defaultEntityType: EntityType | AliasEntityType = null;
private propagateChange = (v: any) => { }; private propagateChange = (v: any) => { };
@ -143,9 +147,7 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte
id: this.modelValue.entityType !== entityType ? null : entityId id: this.modelValue.entityType !== entityType ? null : entityId
}; };
if (this.modelValue.entityType === AliasEntityType.CURRENT_TENANT if (this.entityTypeNullUid.has(this.modelValue.entityType)) {
|| this.modelValue.entityType === AliasEntityType.CURRENT_USER
|| this.modelValue.entityType === AliasEntityType.CURRENT_USER_OWNER) {
this.modelValue.id = NULL_UUID; this.modelValue.id = NULL_UUID;
} else if (this.modelValue.entityType === AliasEntityType.CURRENT_CUSTOMER && !this.modelValue.id) { } else if (this.modelValue.entityType === AliasEntityType.CURRENT_CUSTOMER && !this.modelValue.id) {
this.modelValue.id = NULL_UUID; this.modelValue.id = NULL_UUID;

3
ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts

@ -93,6 +93,9 @@ export class EntityTypeSelectComponent implements ControlValueAccessor, OnInit,
this.entityTypes = this.filterAllowedEntityTypes this.entityTypes = this.filterAllowedEntityTypes
? this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, this.useAliasEntityTypes) ? this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, this.useAliasEntityTypes)
: this.allowedEntityTypes; : this.allowedEntityTypes;
if (this.allowedEntityTypes?.length && this.allowedEntityTypes.includes(AliasEntityType.CURRENT_RULE_NODE)) {
this.entityTypes.push(AliasEntityType.CURRENT_RULE_NODE);
}
this.entityTypeFormGroup.get('entityType').valueChanges.subscribe( this.entityTypeFormGroup.get('entityType').valueChanges.subscribe(
(value) => { (value) => {
let modelValue; let modelValue;

1
ui-ngx/src/app/shared/components/js-func.component.html

@ -24,6 +24,7 @@
{{ functionLabel }} {{ functionLabel }}
</label> </label>
<span fxFlex></span> <span fxFlex></span>
<ng-content select="[toolbarPrefixButton]"></ng-content>
<button type='button' *ngIf="!disabled" mat-button class="tidy" (click)="beautifyJs()"> <button type='button' *ngIf="!disabled" mat-button class="tidy" (click)="beautifyJs()">
{{'js-func.tidy' | translate }} {{'js-func.tidy' | translate }}
</button> </button>

8
ui-ngx/src/app/shared/components/script-lang.component.html

@ -17,9 +17,11 @@
--> -->
<div [formGroup]="scriptLangFormGroup" fxLayout="row" fxLayoutAlign="center"> <div [formGroup]="scriptLangFormGroup" fxLayout="row" fxLayoutAlign="center">
<mat-button-toggle-group class="tb-script-lang-toggle-group" <mat-button-toggle-group class="tb-script-lang-toggle-group"
style="width: 320px;" formControlName="scriptLang"
formControlName="scriptLang" aria-label="Script language"> aria-label="Script language">
<mat-button-toggle fxFlex value="{{ scriptLanguage.TBEL }}">{{ 'rulenode.script-lang-tbel' | translate }}</mat-button-toggle> <mat-button-toggle fxFlex value="{{ scriptLanguage.TBEL }}">{{ 'rulenode.script-lang-tbel' | translate }}</mat-button-toggle>
<mat-button-toggle fxFlex value="{{ scriptLanguage.JS }}">{{ 'rulenode.script-lang-java-script' | translate }}</mat-button-toggle> <mat-button-toggle fxFlex value="{{ scriptLanguage.JS }}">
{{ 'rulenode.script-lang-java-script' | translate }}
</mat-button-toggle>
</mat-button-toggle-group> </mat-button-toggle-group>
</div> </div>

1
ui-ngx/src/app/shared/components/script-lang.component.scss

@ -14,6 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
.mat-button-toggle-group.tb-script-lang-toggle-group { .mat-button-toggle-group.tb-script-lang-toggle-group {
width: 320px;
&.mat-button-toggle-group-appearance-standard { &.mat-button-toggle-group-appearance-standard {
border: none; border: none;
border-radius: 18px; border-radius: 18px;

2
ui-ngx/src/app/shared/components/script-lang.component.ts

@ -15,7 +15,7 @@
/// ///
import { Component, forwardRef, Input, OnInit, ViewEncapsulation } from '@angular/core'; import { Component, forwardRef, Input, OnInit, ViewEncapsulation } from '@angular/core';
import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'; import { ControlValueAccessor, NG_VALUE_ACCESSOR, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { PageComponent } from '@shared/components/page.component'; import { PageComponent } from '@shared/components/page.component';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';

10
ui-ngx/src/app/shared/models/entity-type.models.ts

@ -54,7 +54,8 @@ export enum AliasEntityType {
CURRENT_CUSTOMER = 'CURRENT_CUSTOMER', CURRENT_CUSTOMER = 'CURRENT_CUSTOMER',
CURRENT_TENANT = 'CURRENT_TENANT', CURRENT_TENANT = 'CURRENT_TENANT',
CURRENT_USER = 'CURRENT_USER', CURRENT_USER = 'CURRENT_USER',
CURRENT_USER_OWNER = 'CURRENT_USER_OWNER' CURRENT_USER_OWNER = 'CURRENT_USER_OWNER',
CURRENT_RULE_NODE = 'CURRENT_RULE_NODE'
} }
export interface EntityTypeTranslation { export interface EntityTypeTranslation {
@ -326,6 +327,13 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
list: 'entity.type-current-user-owner' list: 'entity.type-current-user-owner'
} }
], ],
[
AliasEntityType.CURRENT_RULE_NODE,
{
type: 'entity.type-current-rule-node',
list: 'entity.type-current-rule-node'
}
],
[ [
EntityType.TB_RESOURCE, EntityType.TB_RESOURCE,
{ {

1
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -2315,6 +2315,7 @@
"type-current-tenant": "Current Tenant", "type-current-tenant": "Current Tenant",
"type-current-user": "Current User", "type-current-user": "Current User",
"type-current-user-owner": "Current User Owner", "type-current-user-owner": "Current User Owner",
"type-current-rule-node": "Current Rule Node",
"type-widgets-bundle": "Widgets bundle", "type-widgets-bundle": "Widgets bundle",
"type-widgets-bundles": "Widgets bundles", "type-widgets-bundles": "Widgets bundles",
"list-of-widgets-bundles": "{ count, plural, =1 {One widgets bundle} other {List of # widget bundles} }", "list-of-widgets-bundles": "{ count, plural, =1 {One widgets bundle} other {List of # widget bundles} }",

Loading…
Cancel
Save