Commit a5a18076 authored by Tom Käsler's avatar Tom Käsler

Add enpoint for room stats and query on room page

parent 5ce8fc80
Pipeline #31890 failed with stages
in 1 minute and 38 seconds
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();
});
}
......
export class ContentGroupStatistics {
groupName: string;
contentCount: number;
constructor(
groupName: string,
contentCount: number
) {
this.groupName = groupName;
this.contentCount = contentCount
}
}
\ No newline at end of file
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) {
}
}
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<RoomStatistics> {
const connectionUrl = `${ this.apiUrl.base + this.apiUrl.rooms }/${ roomId }${ this.apiUrl.stats }`;
return this.http.get<RoomStatistics>(connectionUrl, httpOptions).pipe(
tap(() => ''),
catchError(this.handleError<RoomStatistics>('getStats'))
);
}
parseExtensions(room: Room): Room {
if (room.extensions) {
let extensions: TSMap<string, TSMap<string, any>> = new TSMap();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment