|
|
|
@ -18,9 +18,10 @@ 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'; |
|
|
|
import { map } from 'rxjs/operators'; |
|
|
|
|
|
|
|
@Injectable({ |
|
|
|
providedIn: 'root' |
|
|
|
@ -53,4 +54,31 @@ export class QueueService { |
|
|
|
public deleteQueue(queueId: string) { |
|
|
|
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)) |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|