From 5376ef08461ff2e65e4d977f7aff6d40437796e9 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Tue, 1 Apr 2025 18:59:37 +0200 Subject: [PATCH] frontend: Refactor room-related terminology from 'roomName' to 'roomId' --- .../src/lib/guards/auth.guard.ts | 6 ++-- .../lib/guards/extract-query-params.guard.ts | 6 ++-- .../src/lib/guards/participant-name.guard.ts | 4 +-- .../guards/replace-moderator-secret.guard.ts | 13 ++++----- .../lib/guards/validate-room-access.guard.ts | 8 +++--- .../src/lib/interceptors/http.interceptor.ts | 6 ++-- .../src/lib/models/context.model.ts | 2 +- .../pages/console/rooms/rooms.component.html | 2 +- .../pages/console/rooms/rooms.component.ts | 25 ++++++++--------- .../src/lib/pages/login/login.component.scss | 6 ++-- .../room-creator/room-creator.component.html | 28 ++++++++----------- .../room-creator/room-creator.component.scss | 6 ++-- .../room-creator/room-creator.component.ts | 20 ++++++------- .../pages/video-room/video-room.component.ts | 16 +++++------ .../src/lib/routes/base-routes.ts | 6 ++-- .../lib/services/context/context.service.ts | 10 +++---- .../global-preferences.service.ts | 4 +-- .../src/lib/services/http/http.service.ts | 23 +++++++-------- .../src/lib/services/room/room.service.ts | 18 ++++++------ .../session-storage.service.ts | 18 ++++++------ .../webcomponent-manager.service.ts | 4 +-- 21 files changed, 108 insertions(+), 123 deletions(-) diff --git a/frontend/projects/shared-meet-components/src/lib/guards/auth.guard.ts b/frontend/projects/shared-meet-components/src/lib/guards/auth.guard.ts index 715e72e..bd8e36e 100644 --- a/frontend/projects/shared-meet-components/src/lib/guards/auth.guard.ts +++ b/frontend/projects/shared-meet-components/src/lib/guards/auth.guard.ts @@ -57,11 +57,11 @@ export const checkParticipantRoleAndAuthGuard: CanActivateFn = async ( let participantRole: ParticipantRole; try { - const roomName = contextService.getRoomName(); + const roomId = contextService.getRoomId(); const secret = contextService.getSecret(); - const storageSecret = sessionStorageService.getModeratorSecret(roomName); + const storageSecret = sessionStorageService.getModeratorSecret(roomId); - participantRole = await httpService.getParticipantRole(roomName, storageSecret || secret); + participantRole = await httpService.getParticipantRole(roomId, storageSecret || secret); } catch (error) { console.error('Error getting participant role:', error); return router.createUrlTree(['unauthorized'], { queryParams: { reason: 'unauthorized-participant' } }); diff --git a/frontend/projects/shared-meet-components/src/lib/guards/extract-query-params.guard.ts b/frontend/projects/shared-meet-components/src/lib/guards/extract-query-params.guard.ts index 96da9a7..80e01bf 100644 --- a/frontend/projects/shared-meet-components/src/lib/guards/extract-query-params.guard.ts +++ b/frontend/projects/shared-meet-components/src/lib/guards/extract-query-params.guard.ts @@ -4,13 +4,13 @@ import { ContextService } from '../services'; export const extractQueryParamsGuard: CanActivateFn = (route: ActivatedRouteSnapshot) => { const contextService = inject(ContextService); - const { roomName, participantName, secret, leaveRedirectUrl } = extractParams(route); + const { roomId, participantName, secret, leaveRedirectUrl } = extractParams(route); if (isValidUrl(leaveRedirectUrl)) { contextService.setLeaveRedirectUrl(leaveRedirectUrl); } - contextService.setRoomName(roomName); + contextService.setRoomId(roomId); contextService.setParticipantName(participantName); contextService.setSecret(secret); @@ -18,7 +18,7 @@ export const extractQueryParamsGuard: CanActivateFn = (route: ActivatedRouteSnap }; const extractParams = (route: ActivatedRouteSnapshot) => ({ - roomName: route.params['room-name'], + roomId: route.params['room-id'], participantName: route.queryParams['participant-name'], secret: route.queryParams['secret'], leaveRedirectUrl: route.queryParams['leave-redirect-url'] diff --git a/frontend/projects/shared-meet-components/src/lib/guards/participant-name.guard.ts b/frontend/projects/shared-meet-components/src/lib/guards/participant-name.guard.ts index ff57e69..374207f 100644 --- a/frontend/projects/shared-meet-components/src/lib/guards/participant-name.guard.ts +++ b/frontend/projects/shared-meet-components/src/lib/guards/participant-name.guard.ts @@ -6,13 +6,13 @@ import { ContextService } from '../services'; export const checkParticipantNameGuard: CanActivateFn = (route, state) => { const router = inject(Router); const contextService = inject(ContextService); - const roomName = route.params['room-name']; + const roomId = route.params['room-id']; const hasParticipantName = !!contextService.getParticipantName(); // Check if participant name exists in the service if (!hasParticipantName) { // Redirect to a page where the participant can input their participant name - const participantNameRoute = router.createUrlTree([`room/${roomName}/participant-name`], { + const participantNameRoute = router.createUrlTree([`room/${roomId}/participant-name`], { queryParams: { originUrl: state.url, t: Date.now() } }); return new RedirectCommand(participantNameRoute, { diff --git a/frontend/projects/shared-meet-components/src/lib/guards/replace-moderator-secret.guard.ts b/frontend/projects/shared-meet-components/src/lib/guards/replace-moderator-secret.guard.ts index 19a2a3d..f131dd2 100644 --- a/frontend/projects/shared-meet-components/src/lib/guards/replace-moderator-secret.guard.ts +++ b/frontend/projects/shared-meet-components/src/lib/guards/replace-moderator-secret.guard.ts @@ -33,10 +33,10 @@ export const replaceModeratorSecretGuard: CanActivateFn = (route, _state) => { ) .subscribe(async () => { if (contextService.isModeratorParticipant()) { - const roomName = contextService.getRoomName(); - const { moderatorSecret, publisherSecret } = await getUrlSecret(httpService, roomName); + const roomId = contextService.getRoomId(); + const { moderatorSecret, publisherSecret } = await getUrlSecret(httpService, roomId); - sessionStorageService.setModeratorSecret(roomName, moderatorSecret); + sessionStorageService.setModeratorSecret(roomId, moderatorSecret); // Replace secret in URL by the publisher secret const queryParams = { ...route.queryParams, secret: publisherSecret }; const urlTree = router.createUrlTree([], { queryParams, queryParamsHandling: 'merge' }); @@ -55,12 +55,9 @@ export const replaceModeratorSecretGuard: CanActivateFn = (route, _state) => { const getUrlSecret = async ( httpService: HttpService, - roomName: string + roomId: string ): Promise<{ moderatorSecret: string; publisherSecret: string }> => { - const { moderatorRoomUrl, publisherRoomUrl } = await httpService.getRoom( - roomName, - 'moderatorRoomUrl,publisherRoomUrl' - ); + const { moderatorRoomUrl, publisherRoomUrl } = await httpService.getRoom(roomId); const extractSecret = (urlString: string, type: string): string => { const url = new URL(urlString); diff --git a/frontend/projects/shared-meet-components/src/lib/guards/validate-room-access.guard.ts b/frontend/projects/shared-meet-components/src/lib/guards/validate-room-access.guard.ts index 0790eaf..13d3a33 100644 --- a/frontend/projects/shared-meet-components/src/lib/guards/validate-room-access.guard.ts +++ b/frontend/projects/shared-meet-components/src/lib/guards/validate-room-access.guard.ts @@ -14,15 +14,15 @@ export const validateRoomAccessGuard: CanActivateFn = async ( const router = inject(Router); const sessionStorageService = inject(SessionStorageService); - const roomName = contextService.getRoomName(); + const roomId = contextService.getRoomId(); const participantName = contextService.getParticipantName(); const secret = contextService.getSecret(); - const storageSecret = sessionStorageService.getModeratorSecret(roomName); + const storageSecret = sessionStorageService.getModeratorSecret(roomId); try { // Generate a participant token const response = await httpService.generateParticipantToken({ - roomName, + roomId, participantName, secret: storageSecret || secret }); @@ -34,7 +34,7 @@ export const validateRoomAccessGuard: CanActivateFn = async ( case 409: // Participant already exists. // Send a timestamp to force update the query params and show the error message in participant name input form - const participantNameRoute = router.createUrlTree([`room/${roomName}/participant-name`], { + const participantNameRoute = router.createUrlTree([`room/${roomId}/participant-name`], { queryParams: { originUrl: state.url, accessError: 'participant-exists', t: Date.now() } }); return new RedirectCommand(participantNameRoute, { diff --git a/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts b/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts index ae4d392..c4a34cb 100644 --- a/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts +++ b/frontend/projects/shared-meet-components/src/lib/interceptors/http.interceptor.ts @@ -46,12 +46,12 @@ export const httpInterceptor: HttpInterceptorFn = (req: HttpRequest, ne const refreshParticipantToken = (firstError: HttpErrorResponse): Observable> => { console.log('Refreshing participant token...'); - const roomName = contextService.getRoomName(); + const roomId = contextService.getRoomId(); const participantName = contextService.getParticipantName(); - const storedSecret = sessionStorageService.getModeratorSecret(roomName); + const storedSecret = sessionStorageService.getModeratorSecret(roomId); const secret = storedSecret || contextService.getSecret(); - return from(httpService.refreshParticipantToken({ roomName, participantName, secret })).pipe( + return from(httpService.refreshParticipantToken({ roomId, participantName, secret })).pipe( switchMap((data) => { console.log('Participant token refreshed'); contextService.setToken(data.token); diff --git a/frontend/projects/shared-meet-components/src/lib/models/context.model.ts b/frontend/projects/shared-meet-components/src/lib/models/context.model.ts index c26d84f..1bfeb15 100644 --- a/frontend/projects/shared-meet-components/src/lib/models/context.model.ts +++ b/frontend/projects/shared-meet-components/src/lib/models/context.model.ts @@ -5,7 +5,7 @@ import { } from 'projects/shared-meet-components/src/public-api'; export interface ContextData { - roomName: string; + roomId: string; participantName: string; secret: string; token: string; diff --git a/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.html b/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.html index c407811..ee7e666 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.html +++ b/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.html @@ -50,7 +50,7 @@
video_camera_front
-
{{ item.roomName }}
+
{{ item.roomId }}
auto_delete diff --git a/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.ts b/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.ts index c7516a3..de7179a 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.ts @@ -1,8 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { RoomService, NotificationService } from '../../../services'; import { DynamicGridComponent, ToggleCardComponent } from '../../../components'; -import { RoomPreferences } from '@lib/typings/ce'; -import { ILogger, LoggerService, Room } from 'openvidu-components-angular'; +import { ILogger, LoggerService } from 'openvidu-components-angular'; import { MatCardModule } from '@angular/material/card'; import { DatePipe } from '@angular/common'; import { MatButtonModule } from '@angular/material/button'; @@ -33,8 +32,7 @@ export class RoomsComponent implements OnInit { recordingEnabled = false; chatEnabled = false; backgroundsEnabled = false; - - protected log; + protected log: ILogger; constructor( protected loggerService: LoggerService, @@ -56,12 +54,12 @@ export class RoomsComponent implements OnInit { } isInRoomForm(): boolean { - return this.route.snapshot.firstChild !== null; // Verifica si hay un hijo en la ruta + return this.route.snapshot.firstChild !== null; // Verify if the current route has a child route } async createRoom() { //TODO: Go to room details page - await this.router.navigate(['new'], { relativeTo: this.route }); + await this.router.navigate(['new'], { relativeTo: this.route }); // try { // const room = await this.roomService.createRoom(); // this.notificationService.showSnackbar('Room created'); @@ -73,14 +71,14 @@ export class RoomsComponent implements OnInit { // } } - openRoom(roomName: string) { - window.open(`/${roomName}`, '_blank'); + openRoom(roomId: string) { + window.open(`/${roomId}`, '_blank'); } - deleteRoom(room: MeetRoom) { + deleteRoom({ roomId }: MeetRoom) { try { - this.roomService.deleteRoom(room.roomName); - this.createdRooms = this.createdRooms.filter((r) => r.roomName !== room.roomName); + this.roomService.deleteRoom(roomId); + this.createdRooms = this.createdRooms.filter((r) => r.roomId !== roomId); this.notificationService.showSnackbar('Room deleted'); } catch (error) { this.notificationService.showAlert('Error deleting room'); @@ -88,10 +86,9 @@ export class RoomsComponent implements OnInit { } } - async onRoomClicked(room: MeetRoom) { - console.log('Room clicked:', room); + async onRoomClicked({ roomId }: MeetRoom) { //TODO: Go to room details page - await this.router.navigate([room.roomName, 'edit'], { relativeTo: this.route }); + await this.router.navigate([roomId, 'edit'], { relativeTo: this.route }); } // async onRecordingToggle(enabled: boolean) { diff --git a/frontend/projects/shared-meet-components/src/lib/pages/login/login.component.scss b/frontend/projects/shared-meet-components/src/lib/pages/login/login.component.scss index 830a0ab..fe6d357 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/login/login.component.scss +++ b/frontend/projects/shared-meet-components/src/lib/pages/login/login.component.scss @@ -173,7 +173,7 @@ input[type='submit'] { border-radius: $loginBorderRadius; padding: 0.85rem; } -#room-name-input { +#room-id-input { border-radius: 0; } @@ -222,7 +222,7 @@ input[type='submit'] { .login button[type='submit']:hover { background-color: $loginSubmitHoverBackgroundColor; } -#clear-room-name-btn { +#clear-room-id-btn { height: auto; background-color: $loginInputBackgroundColor; border-radius: 0; @@ -231,7 +231,7 @@ input[type='submit'] { vertical-align: middle; } } -#room-name-generator-btn { +#room-id-generator-btn { height: auto; background-color: $loginInputBackgroundColor; border-radius: $loginBorderRadius; diff --git a/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.html b/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.html index 62f6ae1..85995c7 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.html +++ b/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.html @@ -20,45 +20,39 @@
- - @if (roomForm.get('roomNamePrefix')?.value) { + @if (roomForm.get('roomIdPrefix')?.value) { }
- @if (roomForm.get('roomNamePrefix')?.hasError('required')) { -
Room name is required
- } - @if (roomForm.get('roomNamePrefix')?.hasError('minlength')) { -
Room name is too short!
- }
diff --git a/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.scss b/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.scss index c3755fc..3b55680 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.scss +++ b/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.scss @@ -174,7 +174,7 @@ input[type='submit'] { padding: 0.85rem; } -#room-name-input { +#room-id-input { border-radius: 0; } @@ -223,7 +223,7 @@ input[type='submit'] { .room-prefix button[type='submit']:hover { background-color: $formSubmitHoverBackgroundColor; } -#clear-room-name-btn { +#clear-room-id-btn { height: auto; background-color: $formInputBackgroundColor; border-radius: 0; @@ -232,7 +232,7 @@ input[type='submit'] { vertical-align: middle; } } -#room-name-generator-btn { +#room-id-generator-btn { height: auto; background-color: $formInputBackgroundColor; border-radius: $formBorderRadius; diff --git a/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.ts b/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.ts index 5c589ef..b85d7b7 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/pages/room-creator/room-creator.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { FormGroup, Validators, FormsModule, ReactiveFormsModule, FormControl } from '@angular/forms'; +import { FormGroup, FormsModule, ReactiveFormsModule, FormControl } from '@angular/forms'; import { MatIcon } from '@angular/material/icon'; import { MatTooltip } from '@angular/material/tooltip'; import { MatIconButton, MatButton } from '@angular/material/button'; @@ -23,7 +23,7 @@ export class RoomCreatorComponent implements OnInit { backgroundImageUrl = ''; roomForm = new FormGroup({ - roomNamePrefix: new FormControl(this.getRandomName(), [Validators.required, Validators.minLength(6)]) + roomIdPrefix: new FormControl(this.getRandomName(), []) }); username = ''; @@ -45,13 +45,13 @@ export class RoomCreatorComponent implements OnInit { } } - generateRoomName(event: any) { + generateRoomId(event: any) { event.preventDefault(); - this.roomForm.get('roomNamePrefix')?.setValue(this.getRandomName()); + this.roomForm.get('roomIdPrefix')?.setValue(this.getRandomName()); } - clearRoomName() { - this.roomForm.get('roomNamePrefix')?.setValue(''); + clearRoomId() { + this.roomForm.get('roomIdPrefix')?.setValue(''); } async logout() { @@ -68,12 +68,12 @@ export class RoomCreatorComponent implements OnInit { return; } - const roomNamePrefix = this.roomForm.get('roomNamePrefix')?.value!.replace(/ /g, '-'); + const roomIdPrefix = this.roomForm.get('roomIdPrefix')?.value!.replace(/ /g, '-'); try { // TODO: Fix expiration date const options: MeetRoomOptions = { - roomNamePrefix, + roomIdPrefix, expirationDate: Date.now() + 3600 * 1000 // 1 hour }; @@ -81,9 +81,9 @@ export class RoomCreatorComponent implements OnInit { const accessRoomUrl = new URL(room.moderatorRoomUrl); const secret = accessRoomUrl.searchParams.get('secret'); - const roomName = accessRoomUrl.pathname; + const roomId = accessRoomUrl.pathname; - this.router.navigate([roomName], { queryParams: { secret } }); + this.router.navigate([roomId], { queryParams: { secret } }); } catch (error) { console.error('Error creating room ', error); } diff --git a/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts b/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts index ac6c72f..ff91af8 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/pages/video-room/video-room.component.ts @@ -11,7 +11,7 @@ import { OpenViduComponentsUiModule } from 'openvidu-components-angular'; -import { ChatPreferences, RecordingPreferences, VirtualBackgroundPreferences } from '@lib/typings/ce'; +import { MeetChatPreferences, MeetRecordingPreferences, MeetVirtualBackgroundPreferences } from '@lib/typings/ce'; import { HttpService, WebComponentManagerService, ContextService, RoomService } from '../../services'; import { OpenViduMeetMessage, WebComponentEventType } from 'webcomponent/src/types/message.type'; @@ -24,14 +24,14 @@ import { OpenViduMeetMessage, WebComponentEventType } from 'webcomponent/src/typ imports: [OpenViduComponentsUiModule, ApiDirectiveModule, MatIcon] }) export class VideoRoomComponent implements OnInit, OnDestroy { - roomName = ''; + roomId = ''; participantName = ''; token = ''; serverError = ''; loading = true; - chatPreferences: ChatPreferences = { enabled: true }; - recordingPreferences: RecordingPreferences = { enabled: true }; - virtualBackgroundPreferences: VirtualBackgroundPreferences = { enabled: true }; + chatPreferences: MeetChatPreferences = { enabled: true }; + recordingPreferences: MeetRecordingPreferences = { enabled: true }; + virtualBackgroundPreferences: MeetVirtualBackgroundPreferences = { enabled: true }; featureFlags = { videoEnabled: true, audioEnabled: true, @@ -55,7 +55,7 @@ export class VideoRoomComponent implements OnInit, OnDestroy { async ngOnInit() { try { - this.roomName = this.ctxService.getRoomName(); + this.roomId = this.ctxService.getRoomId(); this.participantName = this.ctxService.getParticipantName(); if (this.ctxService.isEmbeddedMode()) { @@ -102,7 +102,7 @@ export class VideoRoomComponent implements OnInit, OnDestroy { const message: OpenViduMeetMessage = { eventType: WebComponentEventType.LOCAL_PARTICIPANT_CONNECTED, payload: { - roomName: event.getProperties().room?.name, + roomId: event.getProperties().room?.name, participantName: event.name } }; @@ -117,7 +117,7 @@ export class VideoRoomComponent implements OnInit, OnDestroy { const message: OpenViduMeetMessage = { eventType: WebComponentEventType.LOCAL_PARTICIPANT_LEFT, payload: { - roomName: event.roomName, + roomId: event.roomName, participantName: event.participantName } }; diff --git a/frontend/projects/shared-meet-components/src/lib/routes/base-routes.ts b/frontend/projects/shared-meet-components/src/lib/routes/base-routes.ts index c216657..451864f 100644 --- a/frontend/projects/shared-meet-components/src/lib/routes/base-routes.ts +++ b/frontend/projects/shared-meet-components/src/lib/routes/base-routes.ts @@ -82,7 +82,7 @@ export const baseRoutes: Routes = [ component: RoomsComponent, children: [ { path: 'new', component: RoomFormComponent }, - { path: ':roomName/edit', component: RoomFormComponent } + { path: ':roomId/edit', component: RoomFormComponent } ] }, { @@ -110,7 +110,7 @@ export const baseRoutes: Routes = [ ] }, { - path: 'room/:room-name', + path: 'room/:room-id', component: VideoRoomComponent, canActivate: [ runGuardsSerially( @@ -124,7 +124,7 @@ export const baseRoutes: Routes = [ ] }, { - path: 'room/:room-name/participant-name', + path: 'room/:room-id/participant-name', component: ParticipantNameFormComponent }, diff --git a/frontend/projects/shared-meet-components/src/lib/services/context/context.service.ts b/frontend/projects/shared-meet-components/src/lib/services/context/context.service.ts index 01f7146..643618c 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/context/context.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/context/context.service.ts @@ -12,7 +12,7 @@ import { AuthMode, HttpService, ParticipantRole } from 'projects/shared-meet-com */ export class ContextService { private context: ContextData = { - roomName: '', + roomId: '', participantName: '', secret: '', token: '', @@ -126,12 +126,12 @@ export class ContextService { return this.context.leaveRedirectUrl; } - getRoomName(): string { - return this.context.roomName; + getRoomId(): string { + return this.context.roomId; } - setRoomName(roomName: string): void { - this.context.roomName = roomName; + setRoomId(roomId: string): void { + this.context.roomId = roomId; } getParticipantName(): string { diff --git a/frontend/projects/shared-meet-components/src/lib/services/global-preferences/global-preferences.service.ts b/frontend/projects/shared-meet-components/src/lib/services/global-preferences/global-preferences.service.ts index 5a1886f..7a1d35b 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/global-preferences/global-preferences.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/global-preferences/global-preferences.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { RoomPreferences } from '@lib/typings/ce'; +import { MeetRoomPreferences } from '@lib/typings/ce'; import { LoggerService } from 'openvidu-components-angular'; import { HttpService } from '../http/http.service'; @@ -9,7 +9,7 @@ import { HttpService } from '../http/http.service'; // This service is used to store the global preferences of the application export class GlobalPreferencesService { protected log; - protected roomPreferences: RoomPreferences | undefined; + protected roomPreferences: MeetRoomPreferences | undefined; constructor( protected loggerService: LoggerService, diff --git a/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts b/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts index a6a388a..b26dd0e 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts @@ -4,7 +4,7 @@ import { MeetRoom, MeetRoomOptions } from 'projects/shared-meet-components/src/l import { GlobalPreferences, ParticipantRole, - RoomPreferences, + MeetRoomPreferences, SecurityPreferencesDTO, TokenOptions, User @@ -27,8 +27,8 @@ export class HttpService { return this.postRequest(`${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/rooms`, options); } - deleteRoom(roomName: string): Promise { - return this.deleteRequest(`${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/rooms/${roomName}`); + deleteRoom(roomId: string): Promise { + return this.deleteRequest(`${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/rooms/${roomId}`); } listRooms(fields?: string): Promise { @@ -39,17 +39,14 @@ export class HttpService { return this.getRequest(path); } - getRoom(roomName: string, fields?: string): Promise { - let path = `${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/rooms/${roomName}`; - if (fields) { - path += `?fields=${encodeURIComponent(fields)}`; - } + getRoom(roomId: string): Promise { + let path = `${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/rooms/${roomId}`; return this.getRequest(path); } - getParticipantRole(roomName: string, secret: string): Promise { + getParticipantRole(roomId: string, secret: string): Promise { return this.getRequest( - `${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/rooms/${roomName}/participant-role?secret=${secret}` + `${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/rooms/${roomId}/participant-role?secret=${secret}` ); } @@ -79,9 +76,9 @@ export class HttpService { /** * Retrieves the room preferences. * - * @returns {Promise} A promise that resolves to the room preferences. + * @returns {Promise} A promise that resolves to the room preferences. */ - getRoomPreferences(): Promise { + getRoomPreferences(): Promise { return this.getRequest(`${this.API_PATH_PREFIX}/${this.API_V1_VERSION}/preferences/room`); } @@ -91,7 +88,7 @@ export class HttpService { * @param preferences - The room preferences to be saved. * @returns A promise that resolves when the preferences have been successfully saved. */ - saveRoomPreferences(preferences: RoomPreferences): Promise { + saveRoomPreferences(preferences: MeetRoomPreferences): Promise { return this.putRequest(`${this.API_PATH_PREFIX}/preferences/room`, preferences); } diff --git a/frontend/projects/shared-meet-components/src/lib/services/room/room.service.ts b/frontend/projects/shared-meet-components/src/lib/services/room/room.service.ts index ad4bf1f..21f22a5 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/room/room.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/room/room.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { RoomPreferences } from '@lib/typings/ce'; +import { MeetRoomPreferences } from '@lib/typings/ce'; import { LoggerService } from 'openvidu-components-angular'; import { HttpService } from '../http/http.service'; import { MeetRoom, MeetRoomOptions } from 'projects/shared-meet-components/src/lib/typings/ce/room'; @@ -9,7 +9,7 @@ import { MeetRoom, MeetRoomOptions } from 'projects/shared-meet-components/src/l }) export class RoomService { protected log; - protected roomPreferences: RoomPreferences | undefined; + protected roomPreferences: MeetRoomPreferences | undefined; constructor( protected loggerService: LoggerService, protected httpService: HttpService @@ -20,26 +20,26 @@ export class RoomService { async createRoom(): Promise { // TODO: Improve expiration date const options: MeetRoomOptions = { - roomNamePrefix: 'TestRoom-', + roomIdPrefix: 'TestRoom-', expirationDate: Date.now() + 1000 * 60 * 60 // 1 hour from now }; this.log.d('Creating room', options); return this.httpService.createRoom(options); } - async deleteRoom(roomName: string) { - return this.httpService.deleteRoom(roomName); + async deleteRoom(roomId: string) { + return this.httpService.deleteRoom(roomId); } async listRooms() { return this.httpService.listRooms(); } - async getRoom(roomName: string) { - return this.httpService.getRoom(roomName); + async getRoom(roomId: string) { + return this.httpService.getRoom(roomId); } - async getRoomPreferences(): Promise { + async getRoomPreferences(): Promise { if (!this.roomPreferences) { this.log.d('Room preferences not found, fetching from server'); // Fetch the room preferences from the server @@ -55,7 +55,7 @@ export class RoomService { * @param {RoomPreferences} preferences - The preferences to be saved. * @returns {Promise} A promise that resolves when the preferences have been saved. */ - async saveRoomPreferences(preferences: RoomPreferences): Promise { + async saveRoomPreferences(preferences: MeetRoomPreferences): Promise { this.log.d('Saving room preferences', preferences); await this.httpService.saveRoomPreferences(preferences); this.roomPreferences = preferences; diff --git a/frontend/projects/shared-meet-components/src/lib/services/session-storage/session-storage.service.ts b/frontend/projects/shared-meet-components/src/lib/services/session-storage/session-storage.service.ts index 42e32a0..90ca30f 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/session-storage/session-storage.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/session-storage/session-storage.service.ts @@ -13,30 +13,30 @@ export class SessionStorageService { /** * Stores a moderator secret for a specific room. * - * @param roomName The room name. + * @param roomId The room ID. * @param secret The secret string. */ - public setModeratorSecret(roomName: string, secret: string): void { - this.set(`moderator_secret_${roomName}`, secret); + public setModeratorSecret(roomId: string, secret: string): void { + this.set(`moderator_secret_${roomId}`, secret); } /** * Retrieves the moderator secret for a specific room. * - * @param roomName The room name. + * @param roomId The room ID. * @returns The stored secret or null if not found. */ - public getModeratorSecret(roomName: string): string | null { - return this.get(`moderator_secret_${roomName}`) ?? null; + public getModeratorSecret(roomId: string): string | null { + return this.get(`moderator_secret_${roomId}`) ?? null; } /** * Removes the moderator secret for a specific room. * - * @param roomName The room name. + * @param roomId The room ID. */ - public removeModeratorSecret(roomName: string): void { - this.remove(`moderator_secret_${roomName}`); + public removeModeratorSecret(roomId: string): void { + this.remove(`moderator_secret_${roomId}`); } /** diff --git a/frontend/projects/shared-meet-components/src/lib/services/webcomponent-manager/webcomponent-manager.service.ts b/frontend/projects/shared-meet-components/src/lib/services/webcomponent-manager/webcomponent-manager.service.ts index 1ad6b19..eff7fe1 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/webcomponent-manager/webcomponent-manager.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/webcomponent-manager/webcomponent-manager.service.ts @@ -70,8 +70,8 @@ export class WebComponentManagerService { case WebComponentActionType.END_MEETING: // Moderator only if (this.contextService.isModeratorParticipant()) { - const roomName = this.contextService.getRoomName(); - await this.httpService.deleteRoom(roomName); + const roomId = this.contextService.getRoomId(); + await this.httpService.deleteRoom(roomId); } break; case WebComponentActionType.TOGGLE_CHAT: