From db774eacf9f80fc72342601debd95459a8e19394 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Tue, 4 Jun 2024 13:18:18 +0300 Subject: [PATCH 1/7] UI: Fixed queue statistics --- ui-ngx/src/app/core/http/entity.service.ts | 16 ++++++++++++-- ui-ngx/src/app/core/http/queue.service.ts | 11 +++++++++- .../entity/entity-filter.component.html | 5 ++++- .../entity/entity-autocomplete.component.ts | 17 +++++++++++++- .../entity/entity-list.component.ts | 22 +++++++++++++++++-- .../entity/entity-select.component.html | 1 + .../entity/entity-select.component.ts | 5 +++++ .../entity/entity-type-select.component.ts | 8 ++++++- .../app/shared/models/entity-type.models.ts | 6 ++++- ui-ngx/src/app/shared/models/queue.models.ts | 6 +++++ .../assets/locale/locale.constant-en_US.json | 9 ++++++++ 11 files changed, 97 insertions(+), 9 deletions(-) diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index 8777cc9780..f0ce94c574 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -169,6 +169,8 @@ export class EntityService { case EntityType.QUEUE: observable = this.queueService.getQueueById(entityId, config); break; + case EntityType.QUEUE_STATS: + observable = this.queueService.getQueueStatisticsById(entityId, config); } return observable; } @@ -267,6 +269,11 @@ export class EntityService { case EntityType.NOTIFICATION_TARGET: observable = this.notificationService.getNotificationTargetsByIds(entityIds, config); break; + case EntityType.QUEUE_STATS: + observable = this.getEntitiesByIdsObservable( + (id) => this.queueService.getQueueStatisticsById(id, config), + entityIds); + break; } return observable; } @@ -444,6 +451,9 @@ export class EntityService { pageLink.sortOrder.property = 'title'; entitiesObservable = this.resourceService.getTenantResources(pageLink, config); break; + case EntityType.QUEUE_STATS: + pageLink.sortOrder.property = 'createdTime'; + entitiesObservable = this.queueService.getQueueStatistics(pageLink, config); } return entitiesObservable; } @@ -701,7 +711,7 @@ export class EntityService { } public prepareAllowedEntityTypesList(allowedEntityTypes: Array, - useAliasEntityTypes?: boolean): Array { + useAliasEntityTypes?: boolean, addQueueStats = false): Array { const authState = getCurrentAuthState(this.store); const entityTypes: Array = []; switch (authState.authUser.authority) { @@ -716,7 +726,9 @@ export class EntityService { entityTypes.push(EntityType.CUSTOMER); entityTypes.push(EntityType.USER); entityTypes.push(EntityType.DASHBOARD); - entityTypes.push(EntityType.QUEUE_STATS); + if (addQueueStats) { + entityTypes.push(EntityType.QUEUE_STATS); + } if (authState.edgesSupportEnabled) { entityTypes.push(EntityType.EDGE); } diff --git a/ui-ngx/src/app/core/http/queue.service.ts b/ui-ngx/src/app/core/http/queue.service.ts index b300a1c0a7..1fe42efa2e 100644 --- a/ui-ngx/src/app/core/http/queue.service.ts +++ b/ui-ngx/src/app/core/http/queue.service.ts @@ -18,7 +18,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { defaultHttpOptionsFromConfig, RequestConfig } from '@core/http/http-utils'; import { Observable } from 'rxjs'; -import { QueueInfo, ServiceType } from '@shared/models/queue.models'; +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'; @@ -53,4 +53,13 @@ export class QueueService { public deleteQueue(queueId: string) { return this.http.delete(`/api/queues/${queueId}`); } + + public getQueueStatistics(pageLink: PageLink, config?: RequestConfig): Observable> { + return this.http.get>(`/api/queueStats${pageLink.toQuery()}`, + defaultHttpOptionsFromConfig(config)); + } + + public getQueueStatisticsById(queueStatId: string, config?: RequestConfig): Observable { + return this.http.get(`/api/queueStats/${queueStatId}`, defaultHttpOptionsFromConfig(config)); + } } 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 61d22dcff4..8f9223f8cb 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,6 +37,7 @@ @@ -49,6 +50,7 @@ @@ -65,6 +67,7 @@ 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 9792d9f1e9..40740a9bb7 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,6 +40,7 @@ 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', @@ -185,7 +186,9 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit } }), // startWith>(''), - map(value => value ? (typeof value === 'string' ? value : value.name) : ''), + map(value => + value ? (typeof value === 'string' ? value : value.name) : '' + ), switchMap(name => this.fetchEntities(name)), share() ) @@ -249,6 +252,11 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit this.noEntitiesMatchingText = 'alarm.no-alarms-matching'; this.entityRequiredText = 'alarm.alarm-required'; break; + case EntityType.QUEUE_STATS: + this.entityText = 'queue-statistics.queue-statistics'; + this.noEntitiesMatchingText = 'queue-statistics.no-queue-statistics-matching'; + this.entityRequiredText = 'queue-statistics.queue-statistics-required'; + break; case AliasEntityType.CURRENT_CUSTOMER: this.entityText = 'customer.default-customer'; this.noEntitiesMatchingText = 'customer.no-customers-matching'; @@ -313,6 +321,10 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit } catch (e) { this.propagateChange(null); } + if (this.entityTypeValue === EntityType.QUEUE_STATS && isDefinedAndNotNull(entity)) { + const queueStat = entity as QueueStatisticsInfo; + entity.name = `${queueStat.queueName} (${queueStat.serviceId})`; + } this.modelValue = entity !== null ? (this.useFullEntityId ? entity.id : entity.id.id) : null; this.entityURL = getEntityDetailsPageURL(this.modelValue as string, targetEntityType); this.selectEntityFormGroup.get('entity').patchValue(entity !== null ? entity : '', {emitEvent: false}); @@ -361,6 +373,9 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit data.forEach(entity => !excludeEntityIdsSet.has(entity.id.id) && entities.push(entity)); return entities; } else { + if (this.entityTypeValue === EntityType.QUEUE_STATS) { + data.forEach((entity: QueueStatisticsInfo) => entity.name = `${entity.queueName} (${entity.serviceId})`); + } return data; } } else { 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 9ed95285af..e3165a42ad 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,7 +25,13 @@ import { SimpleChanges, ViewChild } from '@angular/core'; -import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms'; +import { + ControlValueAccessor, + NG_VALUE_ACCESSOR, + UntypedFormBuilder, + UntypedFormGroup, + Validators +} from '@angular/forms'; import { Observable } from 'rxjs'; import { filter, map, mergeMap, share, tap } from 'rxjs/operators'; import { Store } from '@ngrx/store'; @@ -39,6 +45,7 @@ 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', @@ -178,6 +185,9 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV this.entityService.getEntities(this.entityType, value).subscribe( (entities) => { this.entities = entities; + if (this.entityType === EntityType.QUEUE_STATS) { + this.entities.forEach((queueStat: QueueStatisticsInfo) => queueStat.name = `${queueStat.queueName} (${queueStat.serviceId})`); + } this.entityListFormGroup.get('entities').setValue(this.entities); } ); @@ -238,7 +248,15 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV return this.entityService.getEntitiesByNameFilter(this.entityType, searchText, 50, this.subType ? this.subType : '', {ignoreLoading: true}).pipe( - map((data) => data ? data : [])); + map((data) => { + if (data) { + if (this.entityType === EntityType.QUEUE_STATS) { + data.forEach((entity: QueueStatisticsInfo) => entity.name = `${entity.queueName} (${entity.serviceId})`); + } + return data; + } + return []; + })); } onFocus() { 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 783febec7e..2bae7cdcbe 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,6 +22,7 @@ [required]="required" [useAliasEntityTypes]="useAliasEntityTypes" [allowedEntityTypes]="allowedEntityTypes" + [addQueueStats]="addQueueStats" formControlName="entityType"> { let modelValue; diff --git a/ui-ngx/src/app/shared/models/entity-type.models.ts b/ui-ngx/src/app/shared/models/entity-type.models.ts index 885ea90929..045e95983c 100644 --- a/ui-ngx/src/app/shared/models/entity-type.models.ts +++ b/ui-ngx/src/app/shared/models/entity-type.models.ts @@ -367,7 +367,11 @@ export const entityTypeTranslations = new Map, HasTenantId { duplicateMsgToAllPartitions?: boolean; }; } + +export interface QueueStatisticsInfo extends BaseData, HasTenantId { + queueName: string; + serviceId: string; + name?: string; +} diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 170d4836ee..0f35beb054 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -4322,6 +4322,15 @@ "retry-failed-and-timeout-hint": "Retry all failed and timed-out messages from processing pack" } }, + "queue-statistics": { + "queue-statistics": "Queue statistics", + "no-queue-statistics-matching": "No queue statistics matching '{{entity}}' were found.", + "queue-statistics-required": "Queue statistics is required.", + "list-of-queue-statistics": "{ count, plural, =1 {One queue statistic} other {List of # queue statistics} }", + "selected-queue-statistics": "{ count, plural, =1 {1 queue statistic} other {# queue statistics} } selected", + "no-queue-statistics-text": "No queue statistics found", + "queue-statistics-starts-with": "Queue statistics whose names start with '{{prefix}}'" + }, "server-error": { "general": "General server error", "authentication": "Authentication error", From edfe1065801e2989e8601d8a7aa50c61836505ed Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Tue, 4 Jun 2024 14:00:56 +0300 Subject: [PATCH 2/7] UI: Add tenant id for interface --- ui-ngx/src/app/shared/models/queue.models.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ui-ngx/src/app/shared/models/queue.models.ts b/ui-ngx/src/app/shared/models/queue.models.ts index 0c795a789c..fb4ef04968 100644 --- a/ui-ngx/src/app/shared/models/queue.models.ts +++ b/ui-ngx/src/app/shared/models/queue.models.ts @@ -131,4 +131,5 @@ export interface QueueStatisticsInfo extends BaseData, HasTenantId { queueName: string; serviceId: string; name?: string; + tenantId?: TenantId; } From 15ad1ce7e0b3b02b7a0480ba40e1447b016367ef Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Wed, 5 Jun 2024 11:32:47 +0300 Subject: [PATCH 3/7] UI: Add api for queue stats get by ids --- ui-ngx/src/app/core/http/entity.service.ts | 4 +--- ui-ngx/src/app/core/http/queue.service.ts | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index f0ce94c574..6402aebe8a 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -270,9 +270,7 @@ export class EntityService { observable = this.notificationService.getNotificationTargetsByIds(entityIds, config); break; case EntityType.QUEUE_STATS: - observable = this.getEntitiesByIdsObservable( - (id) => this.queueService.getQueueStatisticsById(id, config), - entityIds); + observable = this.queueService.getQueueStatisticsByIds(entityIds, config); break; } return observable; diff --git a/ui-ngx/src/app/core/http/queue.service.ts b/ui-ngx/src/app/core/http/queue.service.ts index 1fe42efa2e..b106b1afb4 100644 --- a/ui-ngx/src/app/core/http/queue.service.ts +++ b/ui-ngx/src/app/core/http/queue.service.ts @@ -21,6 +21,7 @@ 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'; @Injectable({ providedIn: 'root' @@ -62,4 +63,9 @@ export class QueueService { public getQueueStatisticsById(queueStatId: string, config?: RequestConfig): Observable { return this.http.get(`/api/queueStats/${queueStatId}`, defaultHttpOptionsFromConfig(config)); } + + public getQueueStatisticsByIds(queueStatIds: Array, config?: RequestConfig): Observable> { + return this.http.get>(`/api/queueStats?strQueueStatsIds=${queueStatIds.join(',')}`, + defaultHttpOptionsFromConfig(config)); + } } From eabaaa59a122fa5037c0eafb649898e89114d581 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Wed, 5 Jun 2024 15:31:39 +0300 Subject: [PATCH 4/7] UI: Refactoring --- ui-ngx/src/app/core/http/queue.service.ts | 20 ++++++++++++++++--- .../entity/entity-autocomplete.component.ts | 11 +--------- .../entity/entity-list.component.ts | 13 +----------- ui-ngx/src/app/shared/models/queue.models.ts | 4 +--- 4 files changed, 20 insertions(+), 28 deletions(-) diff --git a/ui-ngx/src/app/core/http/queue.service.ts b/ui-ngx/src/app/core/http/queue.service.ts index b106b1afb4..d93f7b143c 100644 --- a/ui-ngx/src/app/core/http/queue.service.ts +++ b/ui-ngx/src/app/core/http/queue.service.ts @@ -22,6 +22,7 @@ import { QueueInfo, QueueStatisticsInfo, ServiceType } from '@shared/models/queu 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({ providedIn: 'root' @@ -55,17 +56,30 @@ export class QueueService { return this.http.delete(`/api/queues/${queueId}`); } + private parseQueueStatName = (queueStat: QueueStatisticsInfo) => Object.defineProperty(queueStat, 'name', { + get() { return `${this.queueName} (${this.serviceId})`; } + }); + public getQueueStatistics(pageLink: PageLink, config?: RequestConfig): Observable> { return this.http.get>(`/api/queueStats${pageLink.toQuery()}`, - defaultHttpOptionsFromConfig(config)); + defaultHttpOptionsFromConfig(config)).pipe( + map(queueData => { + queueData.data.map(queueStat => this.parseQueueStatName(queueStat)); + return queueData; + }) + ); } public getQueueStatisticsById(queueStatId: string, config?: RequestConfig): Observable { - return this.http.get(`/api/queueStats/${queueStatId}`, defaultHttpOptionsFromConfig(config)); + return this.http.get(`/api/queueStats/${queueStatId}`, defaultHttpOptionsFromConfig(config)).pipe( + map(queueStat => this.parseQueueStatName(queueStat))); } public getQueueStatisticsByIds(queueStatIds: Array, config?: RequestConfig): Observable> { return this.http.get>(`/api/queueStats?strQueueStatsIds=${queueStatIds.join(',')}`, - defaultHttpOptionsFromConfig(config)); + defaultHttpOptionsFromConfig(config)).pipe( + map(queueStats => queueStats.map(queueStat => this.parseQueueStatName(queueStat)) + ) + ); } } 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 40740a9bb7..fd35298cad 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 @@ -186,9 +186,7 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit } }), // startWith>(''), - map(value => - value ? (typeof value === 'string' ? value : value.name) : '' - ), + map(value => value ? (typeof value === 'string' ? value : value.name) : ''), switchMap(name => this.fetchEntities(name)), share() ) @@ -321,10 +319,6 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit } catch (e) { this.propagateChange(null); } - if (this.entityTypeValue === EntityType.QUEUE_STATS && isDefinedAndNotNull(entity)) { - const queueStat = entity as QueueStatisticsInfo; - entity.name = `${queueStat.queueName} (${queueStat.serviceId})`; - } this.modelValue = entity !== null ? (this.useFullEntityId ? entity.id : entity.id.id) : null; this.entityURL = getEntityDetailsPageURL(this.modelValue as string, targetEntityType); this.selectEntityFormGroup.get('entity').patchValue(entity !== null ? entity : '', {emitEvent: false}); @@ -373,9 +367,6 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit data.forEach(entity => !excludeEntityIdsSet.has(entity.id.id) && entities.push(entity)); return entities; } else { - if (this.entityTypeValue === EntityType.QUEUE_STATS) { - data.forEach((entity: QueueStatisticsInfo) => entity.name = `${entity.queueName} (${entity.serviceId})`); - } return data; } } else { 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 e3165a42ad..2226f26ece 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 @@ -185,9 +185,6 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV this.entityService.getEntities(this.entityType, value).subscribe( (entities) => { this.entities = entities; - if (this.entityType === EntityType.QUEUE_STATS) { - this.entities.forEach((queueStat: QueueStatisticsInfo) => queueStat.name = `${queueStat.queueName} (${queueStat.serviceId})`); - } this.entityListFormGroup.get('entities').setValue(this.entities); } ); @@ -248,15 +245,7 @@ export class EntityListComponent implements ControlValueAccessor, OnInit, AfterV return this.entityService.getEntitiesByNameFilter(this.entityType, searchText, 50, this.subType ? this.subType : '', {ignoreLoading: true}).pipe( - map((data) => { - if (data) { - if (this.entityType === EntityType.QUEUE_STATS) { - data.forEach((entity: QueueStatisticsInfo) => entity.name = `${entity.queueName} (${entity.serviceId})`); - } - return data; - } - return []; - })); + map((data) => data ? data : [])); } onFocus() { diff --git a/ui-ngx/src/app/shared/models/queue.models.ts b/ui-ngx/src/app/shared/models/queue.models.ts index fb4ef04968..5e1559cda9 100644 --- a/ui-ngx/src/app/shared/models/queue.models.ts +++ b/ui-ngx/src/app/shared/models/queue.models.ts @@ -127,9 +127,7 @@ export interface QueueInfo extends BaseData, HasTenantId { }; } -export interface QueueStatisticsInfo extends BaseData, HasTenantId { +export interface QueueStatisticsInfo extends Omit, 'label'>, HasTenantId { queueName: string; serviceId: string; - name?: string; - tenantId?: TenantId; } From 734f11439dabb98b2ebbbe0ead4e422f2686749b Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Wed, 5 Jun 2024 15:34:09 +0300 Subject: [PATCH 5/7] UI: update url --- ui-ngx/src/app/core/http/queue.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/core/http/queue.service.ts b/ui-ngx/src/app/core/http/queue.service.ts index d93f7b143c..bf01b0a6e4 100644 --- a/ui-ngx/src/app/core/http/queue.service.ts +++ b/ui-ngx/src/app/core/http/queue.service.ts @@ -76,7 +76,7 @@ export class QueueService { } public getQueueStatisticsByIds(queueStatIds: Array, config?: RequestConfig): Observable> { - return this.http.get>(`/api/queueStats?strQueueStatsIds=${queueStatIds.join(',')}`, + return this.http.get>(`/api/queueStats?QueueStatsIds=${queueStatIds.join(',')}`, defaultHttpOptionsFromConfig(config)).pipe( map(queueStats => queueStats.map(queueStat => this.parseQueueStatName(queueStat)) ) From ef2dc383255d97b5eb16a75c3e2537477addaac9 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Wed, 5 Jun 2024 16:38:00 +0300 Subject: [PATCH 6/7] 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"> { From 2aa90d81367bb68ba2806cdcaa8de61c2bf3bb4b Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Wed, 5 Jun 2024 16:54:04 +0300 Subject: [PATCH 7/7] UI: refactoring --- .../components/entity/entity-type-select.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts b/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts index a33b00e08f..04754e4a20 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts @@ -90,9 +90,9 @@ export class EntityTypeSelectComponent implements ControlValueAccessor, OnInit, } ngOnInit() { - this.entityTypes = this.filterAllowedEntityTypes ? - this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, this.useAliasEntityTypes) : - this.allowedEntityTypes; + this.entityTypes = this.filterAllowedEntityTypes + ? this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, this.useAliasEntityTypes) + : this.allowedEntityTypes; this.entityTypeFormGroup.get('entityType').valueChanges.subscribe( (value) => { let modelValue;