From a5a18076814ed912b2c62b1802ea8a2171a869f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20K=C3=A4sler?= Date: Fri, 4 Oct 2019 13:39:32 +0200 Subject: [PATCH] Add enpoint for room stats and query on room page --- .../shared/room-page/room-page.component.ts | 5 +++++ src/app/models/content-group-statistics.ts | 12 ++++++++++++ src/app/models/room-statistics.ts | 17 +++++++++++++++++ src/app/services/http/room.service.ts | 12 +++++++++++- 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/app/models/content-group-statistics.ts create mode 100644 src/app/models/room-statistics.ts diff --git a/src/app/components/shared/room-page/room-page.component.ts b/src/app/components/shared/room-page/room-page.component.ts index 94d5605f..0c33513c 100644 --- a/src/app/components/shared/room-page/room-page.component.ts +++ b/src/app/components/shared/room-page/room-page.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { Room } from '../../../models/room'; +import { RoomStatistics } from '../../../models/room-statistics'; import { RoomService } from '../../../services/http/room.service'; import { ActivatedRoute } from '@angular/router'; import { Location } from '@angular/common'; @@ -17,6 +18,7 @@ export class RoomPageComponent implements OnInit { isLoading = true; commentCounter: number; protected moderationEnabled = false; + protected roomStatistics: RoomStatistics; constructor(protected roomService: RoomService, protected route: ActivatedRoute, @@ -60,6 +62,9 @@ export class RoomPageComponent implements OnInit { this.commentCounter = this.commentCounter - 1; } }); + this.roomService.getStats(this.room.id).subscribe((roomStatistics: RoomStatistics) => { + this.roomStatistics = roomStatistics; + }); this.afterRoomLoadHook(); }); } diff --git a/src/app/models/content-group-statistics.ts b/src/app/models/content-group-statistics.ts new file mode 100644 index 00000000..eb38e0e7 --- /dev/null +++ b/src/app/models/content-group-statistics.ts @@ -0,0 +1,12 @@ +export class ContentGroupStatistics { + groupName: string; + contentCount: number; + + constructor( + groupName: string, + contentCount: number + ) { + this.groupName = groupName; + this.contentCount = contentCount + } +} \ No newline at end of file diff --git a/src/app/models/room-statistics.ts b/src/app/models/room-statistics.ts new file mode 100644 index 00000000..922dd259 --- /dev/null +++ b/src/app/models/room-statistics.ts @@ -0,0 +1,17 @@ +import { ContentGroupStatistics } from './content-group-statistics'; + +export class RoomStatistics { + currentParticipants: number; + contentCount: number; + unansweredContentCount: number; + answerCount: number; + unreadAnswerCount: number; + commentCount: number; + unreadCommentCount: number; + groupStats: ContentGroupStatistics[]; + + constructor( + roomId: string = '', + ack: boolean = true) { + } +} diff --git a/src/app/services/http/room.service.ts b/src/app/services/http/room.service.ts index 3dc8aaa0..842299c7 100644 --- a/src/app/services/http/room.service.ts +++ b/src/app/services/http/room.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { Room } from '../../models/room'; +import { RoomStatistics } from '../../models/room-statistics'; import { RoomJoined } from '../../models/events/room-joined'; import { RoomCreated } from '../../models/events/room-created'; import { UserRole } from '../../models/user-roles.enum'; @@ -21,7 +22,8 @@ export class RoomService extends BaseHttpService { base: '/api', rooms: '/room', user: '/user', - findRooms: '/find' + findRooms: '/find', + stats: '/stats' }; private joinDate = new Date(Date.now()); @@ -115,6 +117,14 @@ export class RoomService extends BaseHttpService { ); } + getStats(roomId: string): Observable { + const connectionUrl = `${ this.apiUrl.base + this.apiUrl.rooms }/${ roomId }${ this.apiUrl.stats }`; + return this.http.get(connectionUrl, httpOptions).pipe( + tap(() => ''), + catchError(this.handleError('getStats')) + ); + } + parseExtensions(room: Room): Room { if (room.extensions) { let extensions: TSMap> = new TSMap(); -- GitLab