frontend: update delete room dialog to clarify error handling and enhance policy options
This commit is contained in:
parent
ceab629906
commit
87594dfe17
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
<div class="dialog-message" [innerHTML]="data.message"></div>
|
<div class="dialog-message" [innerHTML]="data.message"></div>
|
||||||
<p>Please choose how to handle this situation:</p>
|
<p>Please choose how to handle room deletion errors:</p>
|
||||||
|
|
||||||
<div class="policy-options-container">
|
<div class="policy-options-container">
|
||||||
@if (data.showWithMeetingPolicy) {
|
@if (data.showWithMeetingPolicy) {
|
||||||
|
|||||||
@ -33,28 +33,38 @@ export class DeleteRoomDialogComponent {
|
|||||||
readonly dialogRef = inject(MatDialogRef<DeleteRoomDialogComponent>);
|
readonly dialogRef = inject(MatDialogRef<DeleteRoomDialogComponent>);
|
||||||
|
|
||||||
meetingPolicyOptions = [
|
meetingPolicyOptions = [
|
||||||
|
{
|
||||||
|
value: MeetRoomDeletionPolicyWithMeeting.FORCE,
|
||||||
|
label: 'Force',
|
||||||
|
description:
|
||||||
|
'The meeting will be ended immediately, and the room will be deleted without waiting for participants to leave.'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
value: MeetRoomDeletionPolicyWithMeeting.WHEN_MEETING_ENDS,
|
value: MeetRoomDeletionPolicyWithMeeting.WHEN_MEETING_ENDS,
|
||||||
label: 'When meeting ends',
|
label: 'When meeting ends',
|
||||||
description: 'The room will be deleted when the meeting ends.'
|
description: 'The room will be deleted when the meeting ends.'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: MeetRoomDeletionPolicyWithMeeting.FORCE,
|
value: MeetRoomDeletionPolicyWithMeeting.FAIL,
|
||||||
label: 'Force',
|
label: 'Fail',
|
||||||
description:
|
description: 'The deletion will fail if there is an active meeting.'
|
||||||
'The meeting will be ended immediately, and the room will be deleted without waiting for participants to leave.'
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
recordingPolicyOptions = [
|
recordingPolicyOptions = [
|
||||||
|
{
|
||||||
|
value: MeetRoomDeletionPolicyWithRecordings.FORCE,
|
||||||
|
label: 'Force',
|
||||||
|
description: 'The room and its recordings will be deleted immediately.'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
value: MeetRoomDeletionPolicyWithRecordings.CLOSE,
|
value: MeetRoomDeletionPolicyWithRecordings.CLOSE,
|
||||||
label: 'Close',
|
label: 'Close',
|
||||||
description: 'The room will be closed instead of deleted, maintaining its recordings.'
|
description: 'The room will be closed instead of deleted, maintaining its recordings.'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: MeetRoomDeletionPolicyWithRecordings.FORCE,
|
value: MeetRoomDeletionPolicyWithRecordings.FAIL,
|
||||||
label: 'Force',
|
label: 'Fail',
|
||||||
description: 'The room and its recordings will be deleted immediately.'
|
description: 'The deletion will fail if the room has recordings.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -335,7 +335,7 @@ export class RoomsComponent implements OnInit {
|
|||||||
const errorCode = error.error?.error;
|
const errorCode = error.error?.error;
|
||||||
if (errorCode && this.isValidMeetRoomDeletionErrorCode(errorCode)) {
|
if (errorCode && this.isValidMeetRoomDeletionErrorCode(errorCode)) {
|
||||||
const errorMessage = this.extractGenericMessage(error.error.message);
|
const errorMessage = this.extractGenericMessage(error.error.message);
|
||||||
this.showDeletionErrorDialogWithOptions(roomId, errorCode, errorMessage);
|
this.showDeletionErrorDialogWithOptions(roomId, errorMessage);
|
||||||
} else {
|
} else {
|
||||||
this.notificationService.showSnackbar('Failed to delete room');
|
this.notificationService.showSnackbar('Failed to delete room');
|
||||||
this.log.e('Error deleting room:', error);
|
this.log.e('Error deleting room:', error);
|
||||||
@ -375,15 +375,7 @@ export class RoomsComponent implements OnInit {
|
|||||||
this.notificationService.showSnackbar(this.extractGenericMessage(message));
|
this.notificationService.showSnackbar(this.extractGenericMessage(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
private showDeletionErrorDialogWithOptions(
|
private showDeletionErrorDialogWithOptions(roomId: string, errorMessage: string) {
|
||||||
roomId: string,
|
|
||||||
errorCode: MeetRoomDeletionErrorCode,
|
|
||||||
errorMessage: string
|
|
||||||
) {
|
|
||||||
// Determine available policy options based on error code
|
|
||||||
const showWithMeetingPolicy = errorCode !== MeetRoomDeletionErrorCode.ROOM_HAS_RECORDINGS;
|
|
||||||
const showWithRecordingsPolicy = errorCode !== MeetRoomDeletionErrorCode.ROOM_HAS_ACTIVE_MEETING;
|
|
||||||
|
|
||||||
const deleteWithPoliciesCallback = async (
|
const deleteWithPoliciesCallback = async (
|
||||||
meetingPolicy: MeetRoomDeletionPolicyWithMeeting,
|
meetingPolicy: MeetRoomDeletionPolicyWithMeeting,
|
||||||
recordingPolicy: MeetRoomDeletionPolicyWithRecordings
|
recordingPolicy: MeetRoomDeletionPolicyWithRecordings
|
||||||
@ -406,8 +398,8 @@ export class RoomsComponent implements OnInit {
|
|||||||
title: 'Error Deleting Room',
|
title: 'Error Deleting Room',
|
||||||
message: errorMessage,
|
message: errorMessage,
|
||||||
confirmText: 'Delete with Options',
|
confirmText: 'Delete with Options',
|
||||||
showWithMeetingPolicy,
|
showWithMeetingPolicy: true,
|
||||||
showWithRecordingsPolicy,
|
showWithRecordingsPolicy: true,
|
||||||
confirmCallback: deleteWithPoliciesCallback
|
confirmCallback: deleteWithPoliciesCallback
|
||||||
};
|
};
|
||||||
this.dialog.open(DeleteRoomDialogComponent, {
|
this.dialog.open(DeleteRoomDialogComponent, {
|
||||||
@ -430,13 +422,22 @@ export class RoomsComponent implements OnInit {
|
|||||||
this.notificationService.showSnackbar(message);
|
this.notificationService.showSnackbar(message);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// Check if it's a structured error with failed rooms
|
// Check if it's a structured error with failed rooms
|
||||||
const failed = error.error?.failed;
|
const failed = error.error?.failed as { roomId: string; error: string; message: string }[];
|
||||||
const successful = error.error?.successful;
|
const successful = error.error?.successful;
|
||||||
const message = error.error?.message;
|
const errorMessage = error.error?.message;
|
||||||
|
|
||||||
if (failed && successful) {
|
if (failed && successful) {
|
||||||
this.handleSuccessfulBulkDeletion(successful);
|
this.handleSuccessfulBulkDeletion(successful);
|
||||||
this.showBulkDeletionErrorDialogWithOptions(failed, message);
|
|
||||||
|
const hasRoomDeletionError = failed.some((result) =>
|
||||||
|
this.isValidMeetRoomDeletionErrorCode(result.error)
|
||||||
|
);
|
||||||
|
if (hasRoomDeletionError) {
|
||||||
|
this.showBulkDeletionErrorDialogWithOptions(failed, errorMessage);
|
||||||
|
} else {
|
||||||
|
this.notificationService.showSnackbar(errorMessage);
|
||||||
|
this.log.e('Error in bulk delete:', failed);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.notificationService.showSnackbar('Failed to delete rooms');
|
this.notificationService.showSnackbar('Failed to delete rooms');
|
||||||
this.log.e('Error in bulk delete:', error);
|
this.log.e('Error in bulk delete:', error);
|
||||||
@ -499,25 +500,6 @@ export class RoomsComponent implements OnInit {
|
|||||||
}[],
|
}[],
|
||||||
errorMessage: string
|
errorMessage: string
|
||||||
) {
|
) {
|
||||||
// Determine available policy options based on error codes
|
|
||||||
const showWithMeetingPolicy = failedResults.some(
|
|
||||||
(result) =>
|
|
||||||
this.isValidMeetRoomDeletionErrorCode(result.error) &&
|
|
||||||
result.error !== MeetRoomDeletionErrorCode.ROOM_HAS_RECORDINGS
|
|
||||||
);
|
|
||||||
const showWithRecordingsPolicy = failedResults.some(
|
|
||||||
(result) =>
|
|
||||||
this.isValidMeetRoomDeletionErrorCode(result.error) &&
|
|
||||||
result.error !== MeetRoomDeletionErrorCode.ROOM_HAS_ACTIVE_MEETING
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!showWithMeetingPolicy && !showWithRecordingsPolicy) {
|
|
||||||
// Generic error
|
|
||||||
this.notificationService.showSnackbar(errorMessage);
|
|
||||||
this.log.e('Error in bulk delete:', failedResults);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const roomIds = failedResults.map((r) => r.roomId);
|
const roomIds = failedResults.map((r) => r.roomId);
|
||||||
|
|
||||||
const bulkDeleteWithPoliciesCallback = async (
|
const bulkDeleteWithPoliciesCallback = async (
|
||||||
@ -555,11 +537,10 @@ export class RoomsComponent implements OnInit {
|
|||||||
message: `${errorMessage}. They have active meetings and/or recordings:
|
message: `${errorMessage}. They have active meetings and/or recordings:
|
||||||
<p>${roomIds.join(', ')}</p>`,
|
<p>${roomIds.join(', ')}</p>`,
|
||||||
confirmText: 'Delete with Options',
|
confirmText: 'Delete with Options',
|
||||||
showWithMeetingPolicy,
|
showWithMeetingPolicy: true,
|
||||||
showWithRecordingsPolicy,
|
showWithRecordingsPolicy: true,
|
||||||
confirmCallback: bulkDeleteWithPoliciesCallback
|
confirmCallback: bulkDeleteWithPoliciesCallback
|
||||||
};
|
};
|
||||||
|
|
||||||
this.dialog.open(DeleteRoomDialogComponent, {
|
this.dialog.open(DeleteRoomDialogComponent, {
|
||||||
data: dialogOptions,
|
data: dialogOptions,
|
||||||
disableClose: true
|
disableClose: true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user