frontend: update video room component and feature configuration service to enhance toolbar features and permissions handling

This commit is contained in:
juancarmore 2025-07-10 00:33:17 +02:00
parent 39f41560de
commit 166c3573d7
3 changed files with 31 additions and 27 deletions

View File

@ -113,27 +113,27 @@
[prejoinDisplayParticipantName]="false" [prejoinDisplayParticipantName]="false"
[videoEnabled]="features().videoEnabled" [videoEnabled]="features().videoEnabled"
[audioEnabled]="features().audioEnabled" [audioEnabled]="features().audioEnabled"
[toolbarLeaveButton]="!features().canModerateRoom"
[toolbarCameraButton]="features().showCamera" [toolbarCameraButton]="features().showCamera"
[toolbarMicrophoneButton]="features().showMicrophone" [toolbarMicrophoneButton]="features().showMicrophone"
[toolbarScreenshareButton]="features().showScreenShare" [toolbarScreenshareButton]="features().showScreenShare"
[toolbarFullscreenButton]="features().showFullscreen" [toolbarLeaveButton]="!features().canModerateRoom"
[toolbarChatPanelButton]="features().showChat" [toolbarRecordingButton]="features().canRecordRoom"
[toolbarParticipantsPanelButton]="features().showParticipantList"
[toolbarRecordingButton]="features().showRecording"
[toolbarBroadcastingButton]="false" [toolbarBroadcastingButton]="false"
[toolbarChatPanelButton]="features().showChat"
[toolbarBackgroundEffectsButton]="features().showBackgrounds" [toolbarBackgroundEffectsButton]="features().showBackgrounds"
[toolbarActivitiesPanelButton]="features().showRecording" [toolbarParticipantsPanelButton]="features().showParticipantList"
[toolbarSettingsButton]="features().showSettings" [toolbarSettingsButton]="features().showSettings"
[activitiesPanelRecordingActivity]="features().showRecording" [toolbarFullscreenButton]="features().showFullscreen"
[toolbarActivitiesPanelButton]="features().showRecordings"
[activitiesPanelRecordingActivity]="features().showRecordings"
[activitiesPanelBroadcastingActivity]="false" [activitiesPanelBroadcastingActivity]="false"
[showDisconnectionDialog]="false" [showDisconnectionDialog]="false"
(onTokenRequested)="onTokenRequested()" (onTokenRequested)="onTokenRequested()"
(onRoomCreated)="onRoomCreated($event)"
(onParticipantConnected)="onParticipantConnected($event)" (onParticipantConnected)="onParticipantConnected($event)"
(onParticipantLeft)="onParticipantLeft($event)" (onParticipantLeft)="onParticipantLeft($event)"
(onRecordingStartRequested)="onRecordingStartRequested($event)" (onRecordingStartRequested)="onRecordingStartRequested($event)"
(onRecordingStopRequested)="onRecordingStopRequested($event)" (onRecordingStopRequested)="onRecordingStopRequested($event)"
(onRoomCreated)="onRoomCreated($event)"
> >
@if (features().canModerateRoom) { @if (features().canModerateRoom) {
<div *ovToolbarAdditionalButtons> <div *ovToolbarAdditionalButtons>

View File

@ -161,7 +161,7 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
} }
} }
async onTokenRequested() { onTokenRequested() {
// Participant token must be set only when requested // Participant token must be set only when requested
this.participantToken = this.participantTokenService.getParticipantToken() || ''; this.participantToken = this.participantTokenService.getParticipantToken() || '';
} }

View File

@ -1,5 +1,5 @@
import { computed, Injectable, signal } from '@angular/core'; import { computed, Injectable, signal } from '@angular/core';
import { MeetRoomPreferences, ParticipantPermissions, ParticipantRole } from '@lib/typings/ce'; import { MeetRoomPreferences, ParticipantPermissions, ParticipantRole, TrackSource } from '@lib/typings/ce';
import { LoggerService } from 'openvidu-components-angular'; import { LoggerService } from 'openvidu-components-angular';
/** /**
@ -14,15 +14,16 @@ export interface ApplicationFeatures {
showScreenShare: boolean; showScreenShare: boolean;
// UI Features // UI Features
showRecordings: boolean;
showChat: boolean; showChat: boolean;
showRecording: boolean;
showBackgrounds: boolean; showBackgrounds: boolean;
showParticipantList: boolean; showParticipantList: boolean;
showSettings: boolean; showSettings: boolean;
showFullscreen: boolean; showFullscreen: boolean;
// Admin Features // Permissions
canModerateRoom: boolean; canModerateRoom: boolean;
canRecordRoom: boolean;
} }
/** /**
@ -34,13 +35,16 @@ const DEFAULT_FEATURES: ApplicationFeatures = {
showMicrophone: true, showMicrophone: true,
showCamera: true, showCamera: true,
showScreenShare: true, showScreenShare: true,
showRecordings: true,
showChat: true, showChat: true,
showRecording: true,
showBackgrounds: true, showBackgrounds: true,
showParticipantList: true, showParticipantList: true,
showSettings: true, showSettings: true,
showFullscreen: true, showFullscreen: true,
canModerateRoom: false
canModerateRoom: false,
canRecordRoom: false
}; };
/** /**
@ -111,33 +115,33 @@ export class FeatureConfigurationService {
// Apply room configurations // Apply room configurations
if (roomPrefs) { if (roomPrefs) {
features.showRecordings = roomPrefs.recordingPreferences.enabled;
features.showChat = roomPrefs.chatPreferences.enabled; features.showChat = roomPrefs.chatPreferences.enabled;
features.showRecording = roomPrefs.recordingPreferences.enabled;
features.showBackgrounds = roomPrefs.virtualBackgroundPreferences.enabled; features.showBackgrounds = roomPrefs.virtualBackgroundPreferences.enabled;
} }
// Apply participant permissions (these can restrict enabled features) // Apply participant permissions (these can restrict enabled features)
if (participantPerms) { if (participantPerms) {
// Only restrict if the feature is already enabled // Only restrict if the feature is already enabled
if (features.showRecordings) {
// features.showRecordings = !!recordingRole;
features.canRecordRoom = participantPerms.openvidu.canRecord;
}
if (features.showChat) { if (features.showChat) {
features.showChat = participantPerms.openvidu.canChat; features.showChat = participantPerms.openvidu.canChat;
} }
if (features.showRecording) {
features.showRecording = participantPerms.openvidu.canRecord;
}
if (features.showBackgrounds) { if (features.showBackgrounds) {
features.showBackgrounds = participantPerms.openvidu.canChangeVirtualBackground; features.showBackgrounds = participantPerms.openvidu.canChangeVirtualBackground;
} }
if (features.showScreenShare) {
features.showScreenShare = participantPerms.openvidu.canPublishScreen;
}
// Check if the participant can publish media // Media features
const canPublish = participantPerms.livekit.canPublish ?? true; const canPublish = participantPerms.livekit.canPublish;
features.videoEnabled = canPublish; const canPublishSources = participantPerms.livekit.canPublishSources ?? [];
features.audioEnabled = canPublish; features.videoEnabled = canPublish || canPublishSources.includes(TrackSource.CAMERA);
features.showMicrophone = canPublish; features.audioEnabled = canPublish || canPublishSources.includes(TrackSource.MICROPHONE);
features.showCamera = canPublish; features.showMicrophone = features.audioEnabled;
features.showCamera = features.videoEnabled;
features.showScreenShare = canPublish || canPublishSources.includes(TrackSource.SCREEN_SHARE);
} }
// Apply role-based configurations // Apply role-based configurations