diff --git a/frontend/projects/shared-meet-components/src/lib/pages/console/recordings/recordings.component.ts b/frontend/projects/shared-meet-components/src/lib/pages/console/recordings/recordings.component.ts index 13a9c0a..3e6cecb 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/console/recordings/recordings.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/pages/console/recordings/recordings.component.ts @@ -157,8 +157,8 @@ export class RecordingsComponent implements OnInit { await this.recordingService.deleteRecording(recording.recordingId); // Remove from local list - const currentRecordings = this.recordings(); - this.recordings.set(currentRecordings.filter((r) => r.recordingId !== recording.recordingId)); + this.recordings.set(this.recordings().filter((r) => r.recordingId !== recording.recordingId)); + this.notificationService.showSnackbar('Recording deleted successfully'); } catch (error) { this.log.e('Error deleting recording:', error); @@ -180,38 +180,37 @@ export class RecordingsComponent implements OnInit { const bulkDeleteCallback = async () => { try { const recordingIds = recordings.map((r) => r.recordingId); - const response = await this.recordingService.bulkDeleteRecordings(recordingIds); + const { deleted } = await this.recordingService.bulkDeleteRecordings(recordingIds); - const currentRecordings = this.recordings(); + // Remove deleted recordings from the list + this.recordings.set(this.recordings().filter((r) => !deleted.includes(r.recordingId))); - switch (response.statusCode) { - case 204: - // All recordings deleted successfully - this.recordings.set(currentRecordings.filter((r) => !recordingIds.includes(r.recordingId))); - this.notificationService.showSnackbar('All recordings deleted successfully'); - break; - case 200: - // Some recordings were deleted, some not - const { deleted = [], notDeleted = [] } = response; - - // Remove deleted recordings from the list - this.recordings.set(currentRecordings.filter((r) => !deleted.includes(r.recordingId))); - - let msg = ''; - if (deleted.length > 0) { - msg += `${deleted.length} recording(s) deleted successfully. `; - } - if (notDeleted.length > 0) { - msg += `${notDeleted.length} recording(s) could not be deleted.`; - } - - this.notificationService.showSnackbar(msg.trim()); - this.log.w('Some recordings could not be deleted:', notDeleted); - break; - } - } catch (error) { + this.notificationService.showSnackbar('All recordings deleted successfully'); + } catch (error: any) { this.log.e('Error deleting recordings:', error); - this.notificationService.showSnackbar('Failed to delete recordings'); + + const deleted = error.error?.deleted as string[]; + const failed = error.error?.failed as { recordingId: string; error: string }[]; + + // Some recordings were deleted, some not + if (failed) { + // Remove deleted recordings from the list + if (deleted.length > 0) { + this.recordings.set(this.recordings().filter((r) => !deleted.includes(r.recordingId))); + } + + let msg = ''; + if (deleted.length > 0) { + msg += `${deleted.length} recording(s) deleted successfully. `; + } + if (failed.length > 0) { + msg += `${failed.length} recording(s) could not be deleted.`; + } + + this.notificationService.showSnackbar(msg.trim()); + } else { + this.notificationService.showSnackbar('Failed to delete recordings'); + } } }; 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 f6ec148..8f4175c 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 @@ -298,19 +298,14 @@ export class RoomsComponent implements OnInit { private async closeRoom(room: MeetRoom) { try { - const { statusCode, room: updatedRoom } = await this.roomService.updateRoomStatus( + const { message, room: updatedRoom } = await this.roomService.updateRoomStatus( room.roomId, MeetRoomStatus.CLOSED ); // Update room in the list this.rooms.set(this.rooms().map((r) => (r.roomId === updatedRoom.roomId ? updatedRoom : r))); - - if (statusCode === 202) { - this.notificationService.showSnackbar('Room scheduled to be closed when the meeting ends'); - } else { - this.notificationService.showSnackbar('Room closed successfully'); - } + this.notificationService.showSnackbar(this.removeRoomIdFromMessage(message)); } catch (error) { this.notificationService.showSnackbar('Failed to close room'); this.log.e('Error closing room:', error); @@ -334,7 +329,7 @@ export class RoomsComponent implements OnInit { // Check if errorCode exists and is a valid MeetRoomDeletionErrorCode const errorCode = error.error?.error; if (errorCode && this.isValidMeetRoomDeletionErrorCode(errorCode)) { - const errorMessage = this.extractGenericMessage(error.error.message); + const errorMessage = this.removeRoomIdFromMessage(error.error.message); this.showDeletionErrorDialogWithOptions(roomId, errorMessage); } else { this.notificationService.showSnackbar('Failed to delete room'); @@ -372,7 +367,7 @@ export class RoomsComponent implements OnInit { this.rooms.set(this.rooms().filter((r) => r.roomId !== roomId)); } - this.notificationService.showSnackbar(this.extractGenericMessage(message)); + this.notificationService.showSnackbar(this.removeRoomIdFromMessage(message)); } private showDeletionErrorDialogWithOptions(roomId: string, errorMessage: string) { @@ -426,7 +421,7 @@ export class RoomsComponent implements OnInit { const successful = error.error?.successful; const errorMessage = error.error?.message; - if (failed && successful) { + if (failed) { this.handleSuccessfulBulkDeletion(successful); const hasRoomDeletionError = failed.some((result) => @@ -564,15 +559,13 @@ export class RoomsComponent implements OnInit { * @param message - The original message from the API response * @returns The message without the specific room ID */ - private extractGenericMessage(message: string): string { - // Pattern to match room IDs in single quotes: 'room-id' + private removeRoomIdFromMessage(message: string): string { + // Pattern to match room ID in single quotes: 'room-id' const roomIdPattern = /'[^']+'/g; - - // Remove room ID - let genericMessage = message.replace(roomIdPattern, ''); + let filteredMessage = message.replace(roomIdPattern, ''); // Clean up any double spaces that might result from the replacement - genericMessage = genericMessage.replace(/\s+/g, ' ').trim(); - return genericMessage; + filteredMessage = filteredMessage.replace(/\s+/g, ' ').trim(); + return filteredMessage; } } diff --git a/frontend/projects/shared-meet-components/src/lib/pages/room-recordings/room-recordings.component.ts b/frontend/projects/shared-meet-components/src/lib/pages/room-recordings/room-recordings.component.ts index 6cfd588..e01d8f2 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/room-recordings/room-recordings.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/pages/room-recordings/room-recordings.component.ts @@ -169,8 +169,8 @@ export class RoomRecordingsComponent implements OnInit { await this.recordingService.deleteRecording(recording.recordingId); // Remove from local list - const currentRecordings = this.recordings(); - this.recordings.set(currentRecordings.filter((r) => r.recordingId !== recording.recordingId)); + this.recordings.set(this.recordings().filter((r) => r.recordingId !== recording.recordingId)); + this.notificationService.showSnackbar('Recording deleted successfully'); } catch (error) { this.log.e('Error deleting recording:', error); @@ -192,38 +192,37 @@ export class RoomRecordingsComponent implements OnInit { const bulkDeleteCallback = async () => { try { const recordingIds = recordings.map((r) => r.recordingId); - const response = await this.recordingService.bulkDeleteRecordings(recordingIds); + const { deleted } = await this.recordingService.bulkDeleteRecordings(recordingIds); - const currentRecordings = this.recordings(); + // Remove deleted recordings from the list + this.recordings.set(this.recordings().filter((r) => !deleted.includes(r.recordingId))); - switch (response.statusCode) { - case 204: - // All recordings deleted successfully - this.recordings.set(currentRecordings.filter((r) => !recordingIds.includes(r.recordingId))); - this.notificationService.showSnackbar('All recordings deleted successfully'); - break; - case 200: - // Some recordings were deleted, some not - const { deleted = [], notDeleted = [] } = response; - - // Remove deleted recordings from the list - this.recordings.set(currentRecordings.filter((r) => !deleted.includes(r.recordingId))); - - let msg = ''; - if (deleted.length > 0) { - msg += `${deleted.length} recording(s) deleted successfully. `; - } - if (notDeleted.length > 0) { - msg += `${notDeleted.length} recording(s) could not be deleted.`; - } - - this.notificationService.showSnackbar(msg.trim()); - this.log.w('Some recordings could not be deleted:', notDeleted); - break; - } - } catch (error) { + this.notificationService.showSnackbar('All recordings deleted successfully'); + } catch (error: any) { this.log.e('Error deleting recordings:', error); - this.notificationService.showSnackbar('Failed to delete recordings'); + + const deleted = error.error?.deleted as string[]; + const failed = error.error?.failed as { recordingId: string; error: string }[]; + + // Some recordings were deleted, some not + if (failed) { + // Remove deleted recordings from the list + if (deleted.length > 0) { + this.recordings.set(this.recordings().filter((r) => !deleted.includes(r.recordingId))); + } + + let msg = ''; + if (deleted.length > 0) { + msg += `${deleted.length} recording(s) deleted successfully. `; + } + if (failed.length > 0) { + msg += `${failed.length} recording(s) could not be deleted.`; + } + + this.notificationService.showSnackbar(msg.trim()); + } else { + this.notificationService.showSnackbar('Failed to delete recordings'); + } } }; diff --git a/frontend/projects/shared-meet-components/src/lib/services/http.service.ts b/frontend/projects/shared-meet-components/src/lib/services/http.service.ts index bddc2d4..ce02e91 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/http.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/http.service.ts @@ -24,14 +24,8 @@ export class HttpService { } async putRequest(path: string, body: any = {}, headers?: Record): Promise { - const options = { - observe: 'response' as const, - ...(headers ? { headers: new HttpHeaders(headers) } : {}) - }; - return lastValueFrom(this.http.put(path, body, options)).then((response) => ({ - ...(response.body as T), - statusCode: response.status - })); + const options = headers ? { headers: new HttpHeaders(headers) } : {}; + return lastValueFrom(this.http.put(path, body, options)); } async patchRequest(path: string, body: any = {}, headers?: Record): Promise { @@ -40,13 +34,7 @@ export class HttpService { } async deleteRequest(path: string, headers?: Record): Promise { - const options = { - observe: 'response' as const, - ...(headers ? { headers: new HttpHeaders(headers) } : {}) - }; - return lastValueFrom(this.http.delete(path, options)).then((response) => ({ - ...(response.body as T), - statusCode: response.status - })); + const options = headers ? { headers: new HttpHeaders(headers) } : {}; + return lastValueFrom(this.http.delete(path, options)); } } diff --git a/frontend/projects/shared-meet-components/src/lib/services/meeting.service.ts b/frontend/projects/shared-meet-components/src/lib/services/meeting.service.ts index f5a9ed1..2854fad 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/meeting.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/meeting.service.ts @@ -41,7 +41,7 @@ export class MeetingService { const path = `${this.MEETINGS_API}/${roomId}/participants/${participantIdentity}`; const headers = this.participantService.getParticipantRoleHeader(); await this.httpService.deleteRequest(path, headers); - this.log.d(`Participant '${participantIdentity}' kicked from room ${roomId}`); + this.log.d(`Participant '${participantIdentity}' kicked from room '${roomId}'`); } /** diff --git a/frontend/projects/shared-meet-components/src/lib/services/recording.service.ts b/frontend/projects/shared-meet-components/src/lib/services/recording.service.ts index 913d2db..6357213 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/recording.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/recording.service.ts @@ -217,7 +217,10 @@ export class RecordingService { * @param recordingIds - An array of recording IDs to delete * @return A promise that resolves to the deletion response */ - async bulkDeleteRecordings(recordingIds: string[]): Promise { + async bulkDeleteRecordings(recordingIds: string[]): Promise<{ + message: string; + deleted: string[]; + }> { if (recordingIds.length === 0) { throw new Error('No recording IDs provided for bulk deletion'); } diff --git a/frontend/projects/shared-meet-components/src/lib/services/room.service.ts b/frontend/projects/shared-meet-components/src/lib/services/room.service.ts index 487b78e..a5fe773 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/room.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/room.service.ts @@ -120,7 +120,7 @@ export class RoomService { * @param status - The new status to be set * @return A promise that resolves to an object containing the updated room and a status code */ - async updateRoomStatus(roomId: string, status: MeetRoomStatus): Promise<{ statusCode: number; room: MeetRoom }> { + async updateRoomStatus(roomId: string, status: MeetRoomStatus): Promise<{ message: string; room: MeetRoom }> { const path = `${this.ROOMS_API}/${roomId}/status`; return this.httpService.putRequest(path, { status }); }