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-03-07 15:50:27 +01:00
|
|
|
import { ChatPanelDirective, ParticipantsPanelDirective } from '../../directives/template/openvidu-angular.directive';
|
2022-02-03 17:08:23 +01:00
|
|
|
import { MenuType } from '../../models/menu.model';
|
|
|
|
import { SidenavMenuService } from '../../services/sidenav-menu/sidenav-menu.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} |
|
|
|
|
*
|
|
|
|
* <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
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-02-03 17:08:23 +01:00
|
|
|
@ContentChild('participantsPanel', { read: TemplateRef }) participantsPanelTemplate: TemplateRef<any>;
|
2022-03-23 13:48:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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-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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@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-02-03 17:08:23 +01:00
|
|
|
isParticipantsPanelOpened: boolean;
|
|
|
|
isChatPanelOpened: boolean;
|
2022-03-23 13:48:17 +01:00
|
|
|
private menuSubscription: Subscription;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
2022-02-23 12:13:28 +01:00
|
|
|
constructor(protected menuService: SidenavMenuService, 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;
|
|
|
|
if (this.menuSubscription) this.menuSubscription.unsubscribe();
|
|
|
|
}
|
2022-03-23 13:48:17 +01:00
|
|
|
|
|
|
|
private subscribeToPanelToggling() {
|
|
|
|
this.menuSubscription = this.menuService.menuOpenedObs.pipe(skip(1)).subscribe((ev: { opened: boolean; type?: MenuType }) => {
|
|
|
|
this.isChatPanelOpened = ev.opened && ev.type === MenuType.CHAT;
|
|
|
|
this.isParticipantsPanelOpened = ev.opened && ev.type === MenuType.PARTICIPANTS;
|
|
|
|
this.cd.markForCheck();
|
|
|
|
});
|
|
|
|
}
|
2022-02-02 13:42:33 +01:00
|
|
|
}
|