diff --git a/frontend/projects/shared-meet-components/src/lib/models/custom-participant.model.ts b/frontend/projects/shared-meet-components/src/lib/models/custom-participant.model.ts index 4d7e49f..4ca5f32 100644 --- a/frontend/projects/shared-meet-components/src/lib/models/custom-participant.model.ts +++ b/frontend/projects/shared-meet-components/src/lib/models/custom-participant.model.ts @@ -3,22 +3,37 @@ import { ParticipantModel, ParticipantProperties } from 'openvidu-components-ang // Represents a participant in the application. export class CustomParticipantModel extends ParticipantModel { - // Indicates the role of the participant. + // Indicates the original role of the participant. + private _meetOriginalRole: ParticipantRole; + // Indicates the current role of the participant. private _meetRole: ParticipantRole; constructor(props: ParticipantProperties) { super(props); const participant = props.participant; - this._meetRole = extractParticipantRole(participant.metadata); + this._meetOriginalRole = extractParticipantRole(participant.metadata); + this._meetRole = this._meetOriginalRole; } set meetRole(role: ParticipantRole) { this._meetRole = role; } + /** + * Checks if the current role of the participant is moderator. + * @returns True if the current role is moderator, false otherwise. + */ isModerator(): boolean { return this._meetRole === ParticipantRole.MODERATOR; } + + /** + * Checks if the original role of the participant is moderator. + * @returns True if the original role is moderator, false otherwise. + */ + isOriginalModerator(): boolean { + return this._meetOriginalRole === ParticipantRole.MODERATOR; + } } const extractParticipantRole = (metadata: any): ParticipantRole => { diff --git a/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.html b/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.html index b34395a..d893f01 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.html +++ b/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.html @@ -1,7 +1,6 @@ @if (showMeeting) { - @if (features().canModerateRoom) { -
- + + + @if (features().canModerateRoom) { -
+ } + -
+ + @if (features().canModerateRoom) { -
+ } + - - @if (remoteParticipants.length === 0) { - - } - - } + + @if (features().canModerateRoom && remoteParticipants.length === 0) { + + } + @@ -130,25 +131,52 @@ }
- @if (!participant.isModerator()) { + @if (localParticipant!.isOriginalModerator()) { + @if (participant.isModerator() && !participant.isOriginalModerator()) { + + } @else { + @if (!participant.isModerator()) { + + } + } + } @else { + @if (!participant.isModerator()) { + + } + } + + + @if (!participant.isOriginalModerator()) { } - -
} @@ -172,7 +200,7 @@
} @else { - +
diff --git a/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.ts b/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.ts index da5a985..ef5e364 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/pages/meeting/meeting.component.ts @@ -492,6 +492,10 @@ export class MeetingComponent implements OnInit { } } + /** + * Makes a participant as moderator. + * @param participant The participant to make as moderator. + */ async makeModerator(participant: CustomParticipantModel) { if (!this.participantService.isModeratorParticipant()) return; @@ -507,6 +511,25 @@ export class MeetingComponent implements OnInit { } } + /** + * Unmakes a participant as moderator. + * @param participant The participant to unmake as moderator. + */ + async unmakeModerator(participant: CustomParticipantModel) { + if (!this.participantService.isModeratorParticipant()) return; + + try { + await this.meetingService.changeParticipantRole( + this.roomId, + participant.identity, + ParticipantRole.SPEAKER + ); + } catch (error) { + console.error('Error unmaking participant moderator:', error); + this.notificationService.showSnackbar('Failed to unmake participant moderator'); + } + } + async copyModeratorLink() { this.clipboard.copy(this.room!.moderatorRoomUrl); this.notificationService.showSnackbar('Moderator link copied to clipboard');