2022-02-23 12:13:28 +01:00
|
|
|
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, OnInit, TemplateRef } from '@angular/core';
|
2022-02-03 17:08:23 +01:00
|
|
|
import { skip, Subscription } from 'rxjs';
|
2022-04-25 16:17:32 +02:00
|
|
|
import {
|
2023-09-29 13:36:32 +02:00
|
|
|
ActivitiesPanelDirective,
|
|
|
|
AdditionalPanelsDirective,
|
|
|
|
ChatPanelDirective,
|
|
|
|
ParticipantsPanelDirective
|
2022-04-25 16:17:32 +02:00
|
|
|
} from '../../directives/template/openvidu-angular.directive';
|
2022-12-23 16:17:04 +01:00
|
|
|
import { PanelEvent, PanelType } from '../../models/panel.model';
|
|
|
|
import { PanelService } from '../../services/panel/panel.service';
|
2022-02-02 13:42:33 +01:00
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* The **PanelComponent** is hosted inside of the {@link VideoconferenceComponent}.
|
|
|
|
* It is in charge of displaying the videoconference panels providing functionalities to the videoconference app
|
|
|
|
* such as the chat ({@link ChatPanelComponent}) and list of participants ({@link ParticipantsPanelComponent}) .
|
|
|
|
*
|
|
|
|
* <div class="custom-table-container">
|
|
|
|
|
|
|
|
* <div>
|
|
|
|
*
|
|
|
|
* <h3>OpenVidu Angular Directives</h3>
|
|
|
|
*
|
|
|
|
* The PanelComponent can be replaced with a custom component. It provides us the following {@link https://angular.io/guide/structural-directives Angular structural directives}
|
|
|
|
* for doing this.
|
|
|
|
*
|
|
|
|
* | **Directive** | **Reference** |
|
|
|
|
* |:----------------------------------:|:---------------------------------------------:|
|
|
|
|
* | ***ovPanel** | {@link PanelDirective} |
|
|
|
|
*
|
|
|
|
* </br>
|
|
|
|
*
|
|
|
|
* It is also providing us a way to **replace the children panels** to the default panel.
|
|
|
|
* It will recognise the following directive in a child element.
|
|
|
|
*
|
|
|
|
* | **Directive** | **Reference** |
|
|
|
|
* |:----------------------------------:|:---------------------------------------------:|
|
|
|
|
* | ***ovChatPanel** | {@link ChatPanelDirective} |
|
|
|
|
* | ***ovParticipantsPanel** | {@link ParticipantsPanelDirective} |
|
2022-04-06 12:00:42 +02:00
|
|
|
* | ***ovAdditionalPanels** | {@link AdditionalPanelsDirective} |
|
2022-03-23 13:48:17 +01:00
|
|
|
*
|
|
|
|
* <p class="component-link-text">
|
|
|
|
* <span class="italic">See all {@link OpenViduAngularDirectiveModule OpenVidu Angular Directives}</span>
|
|
|
|
* </p>
|
|
|
|
* </div>
|
|
|
|
* </div>
|
|
|
|
*/
|
|
|
|
|
2022-02-02 13:42:33 +01:00
|
|
|
@Component({
|
2022-02-03 17:08:23 +01:00
|
|
|
selector: 'ov-panel',
|
|
|
|
templateUrl: './panel.component.html',
|
2022-02-23 12:13:28 +01:00
|
|
|
styleUrls: ['./panel.component.css'],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
2022-02-02 13:42:33 +01:00
|
|
|
})
|
|
|
|
export class PanelComponent implements OnInit {
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
2022-04-25 16:17:32 +02:00
|
|
|
* @ignore
|
|
|
|
*/
|
2022-02-03 17:08:23 +01:00
|
|
|
@ContentChild('participantsPanel', { read: TemplateRef }) participantsPanelTemplate: TemplateRef<any>;
|
2022-03-23 13:48:17 +01:00
|
|
|
|
|
|
|
/**
|
2022-04-25 16:17:32 +02:00
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
@ContentChild('backgroundEffectsPanel', { read: TemplateRef }) backgroundEffectsPanelTemplate: TemplateRef<any>;
|
|
|
|
|
2022-06-16 14:01:07 +02:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
@ContentChild('settingsPanel', { read: TemplateRef }) settingsPanelTemplate: TemplateRef<any>;
|
|
|
|
|
2022-04-25 16:17:32 +02:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
@ContentChild('activitiesPanel', { read: TemplateRef }) activitiesPanelTemplate: TemplateRef<any>;
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-02-03 17:08:23 +01:00
|
|
|
@ContentChild('chatPanel', { read: TemplateRef }) chatPanelTemplate: TemplateRef<any>;
|
2022-02-02 13:42:33 +01:00
|
|
|
|
2022-04-06 12:00:42 +02:00
|
|
|
/**
|
2022-04-25 16:17:32 +02:00
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
@ContentChild('additionalPanels', { read: TemplateRef }) additionalPanelsTemplate: TemplateRef<any>;
|
2022-04-06 12:00:42 +02:00
|
|
|
|
2022-02-17 17:26:30 +01:00
|
|
|
@ContentChild(ParticipantsPanelDirective)
|
|
|
|
set externalParticipantPanel(externalParticipantsPanel: ParticipantsPanelDirective) {
|
|
|
|
// This directive will has value only when PARTICIPANTS PANEL component tagged with '*ovParticipantsPanel'
|
|
|
|
// is inside of the PANEL component tagged with '*ovPanel'
|
|
|
|
if (externalParticipantsPanel) {
|
|
|
|
this.participantsPanelTemplate = externalParticipantsPanel.template;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-15 15:20:13 +02:00
|
|
|
// TODO: backgroundEffectsPanel does not provides customization
|
|
|
|
// @ContentChild(BackgroundEffectsPanelDirective)
|
|
|
|
// set externalBackgroundEffectsPanel(externalBackgroundEffectsPanel: BackgroundEffectsPanelDirective) {
|
|
|
|
// This directive will has value only when BACKGROUND EFFECTS PANEL component tagged with '*ovBackgroundEffectsPanel'
|
|
|
|
// is inside of the PANEL component tagged with '*ovPanel'
|
|
|
|
// if (externalBackgroundEffectsPanel) {
|
|
|
|
// this.backgroundEffectsPanelTemplate = externalBackgroundEffectsPanel.template;
|
|
|
|
// }
|
|
|
|
// }
|
2022-04-25 16:17:32 +02:00
|
|
|
|
2022-06-16 14:01:07 +02:00
|
|
|
// TODO: settingsPanel does not provides customization
|
|
|
|
// @ContentChild(SettingsPanelDirective)
|
|
|
|
// set externalSettingsPanel(externalSettingsPanel: SettingsPanelDirective) {
|
2022-07-15 15:20:13 +02:00
|
|
|
// This directive will has value only when SETTINGS PANEL component tagged with '*ovSettingsPanel'
|
|
|
|
// is inside of the PANEL component tagged with '*ovPanel'
|
|
|
|
// if (externalSettingsPanel) {
|
|
|
|
// this.settingsPanelTemplate = externalSettingsPanel.template;
|
|
|
|
// }
|
2022-06-16 14:01:07 +02:00
|
|
|
// }
|
|
|
|
|
2022-04-25 16:17:32 +02:00
|
|
|
@ContentChild(ActivitiesPanelDirective)
|
|
|
|
set externalActivitiesPanel(externalActivitiesPanel: ActivitiesPanelDirective) {
|
|
|
|
// This directive will has value only when ACTIVITIES PANEL component tagged with '*ovActivitiesPanel'
|
|
|
|
// is inside of the PANEL component tagged with '*ovPanel'
|
|
|
|
if (externalActivitiesPanel) {
|
|
|
|
this.activitiesPanelTemplate = externalActivitiesPanel.template;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-17 17:26:30 +01:00
|
|
|
@ContentChild(ChatPanelDirective)
|
|
|
|
set externalChatPanel(externalChatPanel: ChatPanelDirective) {
|
|
|
|
// This directive will has value only when CHAT PANEL component tagged with '*ovChatPanel'
|
|
|
|
// is inside of the PANEL component tagged with '*ovPanel'
|
|
|
|
if (externalChatPanel) {
|
|
|
|
this.chatPanelTemplate = externalChatPanel.template;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-06 12:00:42 +02:00
|
|
|
@ContentChild(AdditionalPanelsDirective)
|
|
|
|
set externalAdditionalPanels(externalAdditionalPanels: AdditionalPanelsDirective) {
|
|
|
|
// This directive will has value only when ADDITIONAL PANELS component tagged with '*ovPanelAdditionalPanels'
|
|
|
|
// is inside of the PANEL component tagged with '*ovPanel'
|
|
|
|
if (externalAdditionalPanels) {
|
|
|
|
this.additionalPanelsTemplate = externalAdditionalPanels.template;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-03 17:08:23 +01:00
|
|
|
isParticipantsPanelOpened: boolean;
|
|
|
|
isChatPanelOpened: boolean;
|
2022-04-25 16:17:32 +02:00
|
|
|
isBackgroundEffectsPanelOpened: boolean;
|
2022-06-16 14:01:07 +02:00
|
|
|
isSettingsPanelOpened: boolean;
|
2022-04-25 16:17:32 +02:00
|
|
|
isActivitiesPanelOpened: boolean;
|
2022-04-06 12:00:42 +02:00
|
|
|
|
|
|
|
/**
|
2022-04-25 16:17:32 +02:00
|
|
|
* @internal
|
|
|
|
*/
|
2022-04-06 12:00:42 +02:00
|
|
|
isExternalPanelOpened: boolean;
|
|
|
|
private panelSubscription: Subscription;
|
2022-03-23 13:48:17 +01:00
|
|
|
|
|
|
|
/**
|
2022-04-25 16:17:32 +02:00
|
|
|
* @ignore
|
|
|
|
*/
|
2022-04-05 15:40:43 +02:00
|
|
|
constructor(protected panelService: PanelService, private cd: ChangeDetectorRef) {}
|
2022-02-02 13:42:33 +01:00
|
|
|
|
2022-02-03 17:08:23 +01:00
|
|
|
ngOnInit(): void {
|
|
|
|
this.subscribeToPanelToggling();
|
|
|
|
}
|
2022-02-02 13:42:33 +01:00
|
|
|
|
2022-02-03 17:08:23 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
this.isChatPanelOpened = false;
|
|
|
|
this.isParticipantsPanelOpened = false;
|
2022-04-06 12:00:42 +02:00
|
|
|
if (this.panelSubscription) this.panelSubscription.unsubscribe();
|
2022-02-03 17:08:23 +01:00
|
|
|
}
|
2022-03-23 13:48:17 +01:00
|
|
|
|
|
|
|
private subscribeToPanelToggling() {
|
2022-06-16 14:01:07 +02:00
|
|
|
this.panelSubscription = this.panelService.panelOpenedObs.pipe(skip(1)).subscribe((ev: PanelEvent) => {
|
|
|
|
this.isChatPanelOpened = ev.opened && ev.type === PanelType.CHAT;
|
|
|
|
this.isParticipantsPanelOpened = ev.opened && ev.type === PanelType.PARTICIPANTS;
|
|
|
|
this.isBackgroundEffectsPanelOpened = ev.opened && ev.type === PanelType.BACKGROUND_EFFECTS;
|
|
|
|
this.isSettingsPanelOpened = ev.opened && ev.type === PanelType.SETTINGS;
|
|
|
|
this.isActivitiesPanelOpened = ev.opened && ev.type === PanelType.ACTIVITIES;
|
2023-09-29 13:36:32 +02:00
|
|
|
this.isExternalPanelOpened =
|
|
|
|
ev.opened &&
|
|
|
|
!this.isChatPanelOpened &&
|
|
|
|
!this.isParticipantsPanelOpened &&
|
|
|
|
!this.isBackgroundEffectsPanelOpened &&
|
|
|
|
!this.isSettingsPanelOpened &&
|
|
|
|
!this.isActivitiesPanelOpened;
|
2022-06-16 14:01:07 +02:00
|
|
|
this.cd.markForCheck();
|
|
|
|
});
|
2022-03-23 13:48:17 +01:00
|
|
|
}
|
2022-02-02 13:42:33 +01:00
|
|
|
}
|