Merge pull request #10928 from ArtemDzhereleiko/AD/bug-fix/queue-stats

Hotfix for queue statistics
This commit is contained in:
Igor Kulikov 2024-06-07 15:17:27 +03:00 committed by GitHub
commit a9aa96f982
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 79 additions and 8 deletions

View File

@ -169,6 +169,8 @@ export class EntityService {
case EntityType.QUEUE: case EntityType.QUEUE:
observable = this.queueService.getQueueById(entityId, config); observable = this.queueService.getQueueById(entityId, config);
break; break;
case EntityType.QUEUE_STATS:
observable = this.queueService.getQueueStatisticsById(entityId, config);
} }
return observable; return observable;
} }
@ -267,6 +269,9 @@ export class EntityService {
case EntityType.NOTIFICATION_TARGET: case EntityType.NOTIFICATION_TARGET:
observable = this.notificationService.getNotificationTargetsByIds(entityIds, config); observable = this.notificationService.getNotificationTargetsByIds(entityIds, config);
break; break;
case EntityType.QUEUE_STATS:
observable = this.queueService.getQueueStatisticsByIds(entityIds, config);
break;
} }
return observable; return observable;
} }
@ -444,6 +449,9 @@ export class EntityService {
pageLink.sortOrder.property = 'title'; pageLink.sortOrder.property = 'title';
entitiesObservable = this.resourceService.getTenantResources(pageLink, config); entitiesObservable = this.resourceService.getTenantResources(pageLink, config);
break; break;
case EntityType.QUEUE_STATS:
pageLink.sortOrder.property = 'createdTime';
entitiesObservable = this.queueService.getQueueStatistics(pageLink, config);
} }
return entitiesObservable; return entitiesObservable;
} }
@ -716,11 +724,12 @@ export class EntityService {
entityTypes.push(EntityType.CUSTOMER); entityTypes.push(EntityType.CUSTOMER);
entityTypes.push(EntityType.USER); entityTypes.push(EntityType.USER);
entityTypes.push(EntityType.DASHBOARD); entityTypes.push(EntityType.DASHBOARD);
entityTypes.push(EntityType.QUEUE_STATS);
if (authState.edgesSupportEnabled) { if (authState.edgesSupportEnabled) {
entityTypes.push(EntityType.EDGE); entityTypes.push(EntityType.EDGE);
} }
if (useAliasEntityTypes) { if (useAliasEntityTypes) {
entityTypes.push(EntityType.QUEUE_STATS);
entityTypes.push(AliasEntityType.CURRENT_CUSTOMER); entityTypes.push(AliasEntityType.CURRENT_CUSTOMER);
entityTypes.push(AliasEntityType.CURRENT_TENANT); entityTypes.push(AliasEntityType.CURRENT_TENANT);
} }

View File

@ -18,9 +18,10 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { defaultHttpOptionsFromConfig, RequestConfig } from '@core/http/http-utils'; import { defaultHttpOptionsFromConfig, RequestConfig } from '@core/http/http-utils';
import { Observable } from 'rxjs'; 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 { PageLink } from '@shared/models/page/page-link';
import { PageData } from '@shared/models/page/page-data'; import { PageData } from '@shared/models/page/page-data';
import { map } from 'rxjs/operators';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -53,4 +54,31 @@ export class QueueService {
public deleteQueue(queueId: string) { public deleteQueue(queueId: string) {
return this.http.delete(`/api/queues/${queueId}`); 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<PageData<QueueStatisticsInfo>> {
return this.http.get<PageData<QueueStatisticsInfo>>(`/api/queueStats${pageLink.toQuery()}`,
defaultHttpOptionsFromConfig(config)).pipe(
map(queueData => {
queueData.data.map(queueStat => this.parseQueueStatName(queueStat));
return queueData;
})
);
}
public getQueueStatisticsById(queueStatId: string, config?: RequestConfig): Observable<QueueStatisticsInfo> {
return this.http.get<QueueStatisticsInfo>(`/api/queueStats/${queueStatId}`, defaultHttpOptionsFromConfig(config)).pipe(
map(queueStat => this.parseQueueStatName(queueStat)));
}
public getQueueStatisticsByIds(queueStatIds: Array<string>, config?: RequestConfig): Observable<Array<QueueStatisticsInfo>> {
return this.http.get<Array<QueueStatisticsInfo>>(`/api/queueStats?QueueStatsIds=${queueStatIds.join(',')}`,
defaultHttpOptionsFromConfig(config)).pipe(
map(queueStats => queueStats.map(queueStat => this.parseQueueStatName(queueStat))
)
);
}
} }

View File

@ -37,7 +37,8 @@
<ng-template [ngSwitchCase]="aliasFilterType.entityList"> <ng-template [ngSwitchCase]="aliasFilterType.entityList">
<tb-entity-type-select required <tb-entity-type-select required
showLabel showLabel
[allowedEntityTypes]="allowedEntityTypes" useAliasEntityTypes="true"
[allowedEntityTypes]="listEntityTypes"
formControlName="entityType"> formControlName="entityType">
</tb-entity-type-select> </tb-entity-type-select>
<tb-entity-list required <tb-entity-list required
@ -49,7 +50,8 @@
<ng-template [ngSwitchCase]="aliasFilterType.entityName"> <ng-template [ngSwitchCase]="aliasFilterType.entityName">
<tb-entity-type-select required <tb-entity-type-select required
showLabel showLabel
[allowedEntityTypes]="allowedEntityTypes" useAliasEntityTypes="true"
[allowedEntityTypes]="listEntityTypes"
formControlName="entityType"> formControlName="entityType">
</tb-entity-type-select> </tb-entity-type-select>
<mat-form-field class="mat-block"> <mat-form-field class="mat-block">
@ -65,7 +67,8 @@
<ng-template [ngSwitchCase]="aliasFilterType.entityType"> <ng-template [ngSwitchCase]="aliasFilterType.entityType">
<tb-entity-type-select required <tb-entity-type-select required
showLabel showLabel
[allowedEntityTypes]="allowedEntityTypes" useAliasEntityTypes="true"
[allowedEntityTypes]="listEntityTypes"
formControlName="entityType"> formControlName="entityType">
</tb-entity-type-select> </tb-entity-type-select>
</ng-template> </ng-template>

View File

@ -50,6 +50,8 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit, OnDe
aliasFilterTypes: Array<AliasFilterType>; aliasFilterTypes: Array<AliasFilterType>;
listEntityTypes: Array<EntityType | AliasEntityType>;
aliasFilterType = AliasFilterType; aliasFilterType = AliasFilterType;
aliasFilterTypeTranslations = aliasFilterTypeTranslationMap; aliasFilterTypeTranslations = aliasFilterTypeTranslationMap;
entityType = EntityType; entityType = EntityType;
@ -71,6 +73,11 @@ export class EntityFilterComponent implements ControlValueAccessor, OnInit, OnDe
this.aliasFilterTypes = this.entityService.getAliasFilterTypesByEntityTypes(this.allowedEntityTypes); 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({ this.entityFilterFormGroup = this.fb.group({
type: [null, [Validators.required]] type: [null, [Validators.required]]
}); });

View File

@ -249,6 +249,11 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
this.noEntitiesMatchingText = 'alarm.no-alarms-matching'; this.noEntitiesMatchingText = 'alarm.no-alarms-matching';
this.entityRequiredText = 'alarm.alarm-required'; this.entityRequiredText = 'alarm.alarm-required';
break; 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: case AliasEntityType.CURRENT_CUSTOMER:
this.entityText = 'customer.default-customer'; this.entityText = 'customer.default-customer';
this.noEntitiesMatchingText = 'customer.no-customers-matching'; this.noEntitiesMatchingText = 'customer.no-customers-matching';

View File

@ -90,8 +90,9 @@ export class EntityTypeSelectComponent implements ControlValueAccessor, OnInit,
} }
ngOnInit() { ngOnInit() {
this.entityTypes = this.filterAllowedEntityTypes ? this.entityTypes = this.filterAllowedEntityTypes
this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, this.useAliasEntityTypes) : this.allowedEntityTypes; ? this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, this.useAliasEntityTypes)
: this.allowedEntityTypes;
this.entityTypeFormGroup.get('entityType').valueChanges.subscribe( this.entityTypeFormGroup.get('entityType').valueChanges.subscribe(
(value) => { (value) => {
let modelValue; let modelValue;

View File

@ -367,7 +367,11 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
EntityType.QUEUE_STATS, EntityType.QUEUE_STATS,
{ {
type: 'entity.type-queue-stats', type: 'entity.type-queue-stats',
typePlural: 'entity.type-queues-stats' typePlural: 'entity.type-queues-stats',
list: 'queue-statistics.list-of-queue-statistics',
noEntities: 'queue-statistics.no-queue-statistics-text',
selectedEntities: 'queue-statistics.selected-queue-statistics',
nameStartsWith: 'queue-statistics.queue-statistics-starts-with',
} }
], ],
[ [

View File

@ -126,3 +126,8 @@ export interface QueueInfo extends BaseData<QueueId>, HasTenantId {
duplicateMsgToAllPartitions?: boolean; duplicateMsgToAllPartitions?: boolean;
}; };
} }
export interface QueueStatisticsInfo extends Omit<BaseData<QueueId>, 'label'>, HasTenantId {
queueName: string;
serviceId: string;
}

View File

@ -4328,6 +4328,15 @@
"retry-failed-and-timeout-hint": "Retry all failed and timed-out messages from processing pack" "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": { "server-error": {
"general": "General server error", "general": "General server error",
"authentication": "Authentication error", "authentication": "Authentication error",