From ef2dc383255d97b5eb16a75c3e2537477addaac9 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Wed, 5 Jun 2024 16:38:00 +0300 Subject: [PATCH] UI: refactoring --- ui-ngx/src/app/core/http/entity.service.ts | 7 +++---- ui-ngx/src/app/core/http/queue.service.ts | 1 - .../components/entity/entity-filter.component.html | 14 +++++++------- .../components/entity/entity-filter.component.ts | 7 +++++++ .../entity/entity-autocomplete.component.ts | 1 - .../components/entity/entity-list.component.ts | 9 +-------- .../components/entity/entity-select.component.html | 1 - .../components/entity/entity-select.component.ts | 5 ----- .../entity/entity-type-select.component.ts | 7 +------ 9 files changed, 19 insertions(+), 33 deletions(-) diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index 6402aebe8a..b5b2b0e796 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -709,7 +709,7 @@ export class EntityService { } public prepareAllowedEntityTypesList(allowedEntityTypes: Array, - useAliasEntityTypes?: boolean, addQueueStats = false): Array { + useAliasEntityTypes?: boolean): Array { const authState = getCurrentAuthState(this.store); const entityTypes: Array = []; switch (authState.authUser.authority) { @@ -724,13 +724,12 @@ export class EntityService { entityTypes.push(EntityType.CUSTOMER); entityTypes.push(EntityType.USER); entityTypes.push(EntityType.DASHBOARD); - if (addQueueStats) { - entityTypes.push(EntityType.QUEUE_STATS); - } if (authState.edgesSupportEnabled) { entityTypes.push(EntityType.EDGE); } if (useAliasEntityTypes) { + entityTypes.push(EntityType.QUEUE_STATS); + entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); entityTypes.push(AliasEntityType.CURRENT_TENANT); } diff --git a/ui-ngx/src/app/core/http/queue.service.ts b/ui-ngx/src/app/core/http/queue.service.ts index bf01b0a6e4..ed2a189e0d 100644 --- a/ui-ngx/src/app/core/http/queue.service.ts +++ b/ui-ngx/src/app/core/http/queue.service.ts @@ -21,7 +21,6 @@ import { Observable } from 'rxjs'; import { QueueInfo, QueueStatisticsInfo, ServiceType } from '@shared/models/queue.models'; import { PageLink } from '@shared/models/page/page-link'; import { PageData } from '@shared/models/page/page-data'; -import { Asset } from '@shared/models/asset.models'; import { map } from 'rxjs/operators'; @Injectable({ diff --git a/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html b/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html index 8f9223f8cb..d1b39a8748 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html +++ b/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.html @@ -29,7 +29,7 @@
- @@ -37,8 +37,8 @@ @@ -67,8 +67,8 @@ diff --git a/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts b/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts index 0bc19aff01..31b31960f8 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/entity-filter.component.ts @@ -50,6 +50,8 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit, OnDe aliasFilterTypes: Array; + listEntityTypes: Array; + aliasFilterType = AliasFilterType; aliasFilterTypeTranslations = aliasFilterTypeTranslationMap; entityType = EntityType; @@ -71,6 +73,11 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit, OnDe this.aliasFilterTypes = this.entityService.getAliasFilterTypesByEntityTypes(this.allowedEntityTypes); + this.listEntityTypes = this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, false); + if (!this.allowedEntityTypes?.length || this.allowedEntityTypes.includes(EntityType.QUEUE_STATS)) { + this.listEntityTypes.push(EntityType.QUEUE_STATS); + } + this.entityFilterFormGroup = this.fb.group({ type: [null, [Validators.required]] }); diff --git a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts index fd35298cad..8703e0a10b 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts @@ -40,7 +40,6 @@ import { getCurrentAuthUser } from '@core/auth/auth.selectors'; import { Authority } from '@shared/models/authority.enum'; import { getEntityDetailsPageURL, isDefinedAndNotNull, isEqual } from '@core/utils'; import { coerceBoolean } from '@shared/decorators/coercion'; -import { QueueStatisticsInfo } from '@shared/models/queue.models'; @Component({ selector: 'tb-entity-autocomplete', diff --git a/ui-ngx/src/app/shared/components/entity/entity-list.component.ts b/ui-ngx/src/app/shared/components/entity/entity-list.component.ts index 2226f26ece..9ed95285af 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-list.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-list.component.ts @@ -25,13 +25,7 @@ import { SimpleChanges, ViewChild } from '@angular/core'; -import { - ControlValueAccessor, - NG_VALUE_ACCESSOR, - UntypedFormBuilder, - UntypedFormGroup, - Validators -} from '@angular/forms'; +import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms'; import { Observable } from 'rxjs'; import { filter, map, mergeMap, share, tap } from 'rxjs/operators'; import { Store } from '@ngrx/store'; @@ -45,7 +39,6 @@ import { MatAutocomplete } from '@angular/material/autocomplete'; import { MatChipGrid } from '@angular/material/chips'; import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { SubscriptSizing } from '@angular/material/form-field'; -import { QueueStatisticsInfo } from '@shared/models/queue.models'; @Component({ selector: 'tb-entity-list', diff --git a/ui-ngx/src/app/shared/components/entity/entity-select.component.html b/ui-ngx/src/app/shared/components/entity/entity-select.component.html index 2bae7cdcbe..783febec7e 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-select.component.html +++ b/ui-ngx/src/app/shared/components/entity/entity-select.component.html @@ -22,7 +22,6 @@ [required]="required" [useAliasEntityTypes]="useAliasEntityTypes" [allowedEntityTypes]="allowedEntityTypes" - [addQueueStats]="addQueueStats" formControlName="entityType"> {