ov-components: introduce isVideoconferenceHost utility function and update clear logic in directives

pull/900/head
CSantosM 2026-05-11 13:09:00 +02:00
parent dae34746dc
commit ac546ed130
5 changed files with 88 additions and 24 deletions

View File

@ -1,6 +1,10 @@
import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular/core'; import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular/core';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service'; import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
function isVideoconferenceHost(elementRef: ElementRef): boolean {
return elementRef.nativeElement?.tagName?.toLowerCase() === 'ov-videoconference';
}
/** /**
* The **recordingActivity** directive allows show/hide the recording activity in {@link ActivitiesPanelComponent}. * The **recordingActivity** directive allows show/hide the recording activity in {@link ActivitiesPanelComponent}.
* *
@ -41,8 +45,10 @@ export class ActivitiesPanelRecordingActivityDirective implements AfterViewInit,
this.update(this.recordingActivityValue); this.update(this.recordingActivityValue);
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
clear() { clear() {
this.recordingActivityValue = true; this.recordingActivityValue = true;
this.update(true); this.update(true);
@ -93,8 +99,10 @@ export class ActivitiesPanelBroadcastingActivityDirective implements AfterViewIn
this.update(this.broadcastingActivityValue); this.update(this.broadcastingActivityValue);
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
clear() { clear() {
this.broadcastingActivityValue = true; this.broadcastingActivityValue = true;
this.update(true); this.update(true);

View File

@ -4,6 +4,10 @@ import { AfterViewInit, Directive, ElementRef, HostListener, Input, OnDestroy, O
import { ParticipantModel } from '../../models/participant.model'; import { ParticipantModel } from '../../models/participant.model';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service'; import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
function isVideoconferenceHost(elementRef: ElementRef): boolean {
return elementRef.nativeElement?.tagName?.toLowerCase() === 'ov-videoconference';
}
/** /**
* Load default OpenVidu logo if custom one is not exist * Load default OpenVidu logo if custom one is not exist
* @internal * @internal
@ -70,8 +74,10 @@ export class LayoutRemoteParticipantsDirective {
) {} ) {}
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
ngAfterViewInit() { ngAfterViewInit() {
this.update(this._ovRemoteParticipants); this.update(this._ovRemoteParticipants);
@ -117,8 +123,10 @@ export class ToolbarBrandingLogoDirective implements AfterViewInit, OnDestroy {
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this._brandingLogo = ''; this._brandingLogo = '';
this.update(this._brandingLogo); this.update(this._brandingLogo);
@ -153,8 +161,10 @@ export class PrejoinDisplayParticipantName implements OnDestroy {
) {} ) {}
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.update(true); this.update(true);
@ -333,7 +343,7 @@ export class ToolbarViewRecordingsButtonDirective implements AfterViewInit, OnDe
} }
private clear() { private clear() {
this.viewRecordingsValue = false; this.viewRecordingsValue = false;
this.update(true); this.update(this.viewRecordingsValue);
} }
private update(value: boolean) { private update(value: boolean) {
@ -469,7 +479,7 @@ export class RecordingActivityShowRecordingsListDirective implements AfterViewIn
} }
private clear() { private clear() {
this._value = true; this._value = false;
this.update(this._value); this.update(this._value);
} }

View File

@ -1,6 +1,10 @@
import { Directive, AfterViewInit, OnDestroy, Input, ElementRef } from '@angular/core'; import { Directive, AfterViewInit, OnDestroy, Input, ElementRef } from '@angular/core';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service'; import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
function isVideoconferenceHost(elementRef: ElementRef): boolean {
return elementRef.nativeElement?.tagName?.toLowerCase() === 'ov-videoconference';
}
/** /**
* The **muteButton** directive allows show/hide the muted button in participant panel item component. * The **muteButton** directive allows show/hide the muted button in participant panel item component.
* *
@ -41,8 +45,10 @@ export class ParticipantPanelItemMuteButtonDirective implements AfterViewInit, O
this.update(this.muteValue); this.update(this.muteValue);
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
clear() { clear() {
this.muteValue = true; this.muteValue = true;
this.update(true); this.update(true);

View File

@ -1,6 +1,10 @@
import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular/core'; import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular/core';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service'; import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
function isVideoconferenceHost(elementRef: ElementRef): boolean {
return elementRef.nativeElement?.tagName?.toLowerCase() === 'ov-videoconference';
}
/** /**
* The **displayParticipantName** directive allows show/hide the participants name in stream component. * The **displayParticipantName** directive allows show/hide the participants name in stream component.
* *
@ -38,8 +42,10 @@ export class StreamDisplayParticipantNameDirective implements AfterViewInit, OnD
) {} ) {}
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
ngAfterViewInit() { ngAfterViewInit() {
this.update(this.displayParticipantNameValue); this.update(this.displayParticipantNameValue);
@ -94,8 +100,10 @@ export class StreamDisplayAudioDetectionDirective implements AfterViewInit, OnDe
this.update(this.displayAudioDetectionValue); this.update(this.displayAudioDetectionValue);
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
update(value: boolean) { update(value: boolean) {
this.libService.updateStreamConfig({ displayAudioDetection: value }); this.libService.updateStreamConfig({ displayAudioDetection: value });
@ -146,8 +154,10 @@ export class StreamVideoControlsDirective implements AfterViewInit, OnDestroy {
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
update(value: boolean) { update(value: boolean) {
this.libService.updateStreamConfig({ videoControls: value }); this.libService.updateStreamConfig({ videoControls: value });

View File

@ -2,6 +2,10 @@ import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service'; import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
import { ToolbarAdditionalButtonsPosition } from '../../models/toolbar.model'; import { ToolbarAdditionalButtonsPosition } from '../../models/toolbar.model';
function isVideoconferenceHost(elementRef: ElementRef): boolean {
return elementRef.nativeElement?.tagName?.toLowerCase() === 'ov-videoconference';
}
/** /**
* The **cameraButton** directive allows show/hide the camera toolbar button. * The **cameraButton** directive allows show/hide the camera toolbar button.
* *
@ -53,8 +57,10 @@ export class ToolbarCameraButtonDirective implements AfterViewInit, OnDestroy {
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.cameraValue = true; this.cameraValue = true;
@ -117,8 +123,10 @@ export class ToolbarMicrophoneButtonDirective implements AfterViewInit, OnDestro
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.microphoneValue = true; this.microphoneValue = true;
@ -181,8 +189,10 @@ export class ToolbarScreenshareButtonDirective implements AfterViewInit, OnDestr
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.screenshareValue = true; this.screenshareValue = true;
@ -243,8 +253,10 @@ export class ToolbarRecordingButtonDirective implements AfterViewInit, OnDestroy
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.recordingValue = true; this.recordingValue = true;
this.update(true); this.update(true);
@ -305,8 +317,10 @@ export class ToolbarBroadcastingButtonDirective implements AfterViewInit, OnDest
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.broadcastingValue = true; this.broadcastingValue = true;
this.update(true); this.update(true);
@ -366,8 +380,10 @@ export class ToolbarFullscreenButtonDirective implements AfterViewInit, OnDestro
this.update(this.fullscreenValue); this.update(this.fullscreenValue);
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.fullscreenValue = true; this.fullscreenValue = true;
this.update(true); this.update(true);
@ -427,8 +443,10 @@ export class ToolbarBackgroundEffectsButtonDirective implements AfterViewInit, O
this.update(this.backgroundEffectsValue); this.update(this.backgroundEffectsValue);
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.backgroundEffectsValue = true; this.backgroundEffectsValue = true;
this.update(true); this.update(true);
@ -547,8 +565,10 @@ export class ToolbarSettingsButtonDirective implements AfterViewInit, OnDestroy
this.update(this.settingsValue); this.update(this.settingsValue);
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.settingsValue = true; this.settingsValue = true;
this.update(true); this.update(true);
@ -609,8 +629,10 @@ export class ToolbarLeaveButtonDirective implements AfterViewInit, OnDestroy {
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.leaveValue = true; this.leaveValue = true;
this.update(true); this.update(true);
@ -672,8 +694,10 @@ export class ToolbarParticipantsPanelButtonDirective implements AfterViewInit, O
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.participantsPanelValue = true; this.participantsPanelValue = true;
this.update(true); this.update(true);
@ -733,8 +757,10 @@ export class ToolbarChatPanelButtonDirective implements AfterViewInit, OnDestroy
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.toolbarChatPanelValue = true; this.toolbarChatPanelValue = true;
this.update(true); this.update(true);
@ -794,8 +820,10 @@ export class ToolbarActivitiesPanelButtonDirective implements AfterViewInit, OnD
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.toolbarActivitiesPanelValue = true; this.toolbarActivitiesPanelValue = true;
this.update(true); this.update(true);
@ -856,8 +884,10 @@ export class ToolbarDisplayRoomNameDirective implements AfterViewInit, OnDestroy
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (isVideoconferenceHost(this.elementRef)) {
this.clear(); this.clear();
} }
}
private clear() { private clear() {
this.displayRoomValue = true; this.displayRoomValue = true;
this.update(true); this.update(true);