frontend: update room configuration methods to accept partial configurations and improve handling of optional properties

This commit is contained in:
juancarmore 2025-11-18 14:22:02 +01:00
parent 3f25ba6f74
commit 4f9116707c
5 changed files with 30 additions and 26 deletions

View File

@ -100,7 +100,7 @@
</div>
<mat-slide-toggle
[checked]="virtualBackgroundsEnabled"
[checked]="virtualBackgroundEnabled"
(change)="onVirtualBackgroundToggleChange($event)"
color="primary"
class="feature-toggle"

View File

@ -7,10 +7,10 @@ import { RoomWizardStateService } from '../../../../../../services';
import { Subject, takeUntil } from 'rxjs';
@Component({
selector: 'ov-room-config',
imports: [ReactiveFormsModule, MatCardModule, MatIconModule, MatSlideToggleModule],
templateUrl: './room-config.component.html',
styleUrl: './room-config.component.scss'
selector: 'ov-room-config',
imports: [ReactiveFormsModule, MatCardModule, MatIconModule, MatSlideToggleModule],
templateUrl: './room-config.component.html',
styleUrl: './room-config.component.scss'
})
export class RoomConfigComponent implements OnDestroy {
configForm: FormGroup;
@ -34,18 +34,16 @@ export class RoomConfigComponent implements OnDestroy {
}
private saveFormData(formValue: any): void {
const isE2EEEnabled = formValue.e2eeEnabled ?? false;
const stepData: any = {
config: {
chat: {
enabled: formValue.chatEnabled ?? false
},
virtualBackground: {
enabled: formValue.virtualBackgroundsEnabled ?? false
enabled: formValue.virtualBackgroundEnabled ?? false
},
e2ee: {
enabled: isE2EEEnabled
enabled: formValue.e2eeEnabled ?? false
}
}
};
@ -59,7 +57,7 @@ export class RoomConfigComponent implements OnDestroy {
e2eeEnabled: isEnabled
});
const recordingStep = this.wizardService.steps().find(step => step.id === 'recording');
const recordingStep = this.wizardService.steps().find((step) => step.id === 'recording');
if (!recordingStep) return;
if (isEnabled) {
@ -72,15 +70,21 @@ export class RoomConfigComponent implements OnDestroy {
}
// Disable recording automatically
recordingStep.formGroup.patchValue({
recordingEnabled: 'disabled'
}, { emitEvent: true });
recordingStep.formGroup.patchValue(
{
recordingEnabled: 'disabled'
},
{ emitEvent: true }
);
} else {
// Restore the previous recording state when E2EE is disabled
if (this.recordingStateBeforeE2EE !== null) {
recordingStep.formGroup.patchValue({
recordingEnabled: this.recordingStateBeforeE2EE
}, { emitEvent: true });
recordingStep.formGroup.patchValue(
{
recordingEnabled: this.recordingStateBeforeE2EE
},
{ emitEvent: true }
);
// Clear the saved state
this.recordingStateBeforeE2EE = null;
@ -95,15 +99,15 @@ export class RoomConfigComponent implements OnDestroy {
onVirtualBackgroundToggleChange(event: any): void {
const isEnabled = event.checked;
this.configForm.patchValue({ virtualBackgroundsEnabled: isEnabled });
this.configForm.patchValue({ virtualBackgroundEnabled: isEnabled });
}
get chatEnabled(): boolean {
return this.configForm.value.chatEnabled || false;
}
get virtualBackgroundsEnabled(): boolean {
return this.configForm.value.virtualBackgroundsEnabled ?? false;
get virtualBackgroundEnabled(): boolean {
return this.configForm.value.virtualBackgroundEnabled ?? false;
}
get e2eeEnabled(): boolean {

View File

@ -92,7 +92,7 @@ export class MeetingLobbyService {
this.state.roomSecret = this.roomService.getRoomSecret();
this.state.room = await this.roomService.getRoom(this.state.roomId);
this.state.roomClosed = this.state.room.status === MeetRoomStatus.CLOSED;
this.state.isE2EEEnabled = this.state.room.config.e2ee?.enabled || false;
this.state.isE2EEEnabled = this.state.room.config.e2ee.enabled;
// If E2EE is enabled, require e2eeKey
if (this.state.isE2EEEnabled) {

View File

@ -225,7 +225,7 @@ export class RoomService {
* @param config - The room config to be saved.
* @returns A promise that resolves when the config have been saved.
*/
async updateRoomConfig(roomId: string, config: MeetRoomConfig): Promise<void> {
async updateRoomConfig(roomId: string, config: Partial<MeetRoomConfig>): Promise<void> {
this.log.d('Saving room config', config);
const path = `${this.ROOMS_API}/${roomId}/config`;
await this.httpService.putRequest(path, { config });

View File

@ -157,8 +157,8 @@ export class RoomWizardStateService {
isActive: editMode, // Only active in edit mode
isVisible: true,
formGroup: this.formBuilder.group({
recordingEnabled: initialRoomOptions.config!.recording.enabled ? 'enabled' : 'disabled',
allowAccessTo: initialRoomOptions.config!.recording.allowAccessTo
recordingEnabled: initialRoomOptions.config!.recording!.enabled ? 'enabled' : 'disabled',
allowAccessTo: initialRoomOptions.config!.recording!.allowAccessTo
})
},
{
@ -188,9 +188,9 @@ export class RoomWizardStateService {
isActive: false,
isVisible: true,
formGroup: this.formBuilder.group({
chatEnabled: initialRoomOptions.config!.chat.enabled,
virtualBackgroundsEnabled: initialRoomOptions.config!.virtualBackground.enabled,
e2eeEnabled: initialRoomOptions.config!.e2ee?.enabled ?? false
chatEnabled: initialRoomOptions.config!.chat!.enabled,
virtualBackgroundEnabled: initialRoomOptions.config!.virtualBackground!.enabled,
e2eeEnabled: initialRoomOptions.config!.e2ee!.enabled
})
}
];