From 00087a7dc7503c5735093a84626a8eb742bc93cd Mon Sep 17 00:00:00 2001
From: csantosm <4a.santos@gmail.com>
Date: Thu, 3 Feb 2022 17:08:23 +0100
Subject: [PATCH] openvidu-components: Updated the dynamic components injection
Allowed the custom components injection from the view instead of the config file.
---
.../components/layout/layout.component.html | 52 +++++------
.../lib/components/layout/layout.component.ts | 13 ++-
.../lib/components/panel/panel.component.html | 10 ++-
.../lib/components/panel/panel.component.ts | 34 ++++++--
.../components/session/session.component.html | 29 ++-----
.../components/session/session.component.ts | 6 +-
.../lib/components/stream/stream.component.ts | 7 +-
.../videoconference.component.html | 87 ++++++++++++++++---
.../videoconference.component.ts | 72 ++++++++-------
.../src/app/openvidu-call/call.component.html | 39 ++++++++-
.../src/app/openvidu-call/call.component.ts | 4 +-
11 files changed, 238 insertions(+), 115 deletions(-)
diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.html b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.html
index db8e1767..73a3a1f8 100644
--- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.html
+++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.html
@@ -1,35 +1,23 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.ts
index 86815573..abf429c1 100644
--- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.ts
+++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/layout/layout.component.ts
@@ -1,4 +1,4 @@
-import { AfterViewInit, Component, ContentChild, OnDestroy, OnInit, TemplateRef } from '@angular/core';
+import { AfterViewInit, Component, ComponentRef, ContentChild, Directive, Input, OnDestroy, OnInit, TemplateRef, Type, ViewChild, ViewContainerRef } from '@angular/core';
import { Subscription } from 'rxjs';
import { ParticipantService } from '../../services/participant/participant.service';
import { ParticipantAbstractModel } from '../../models/participant.model';
@@ -10,8 +10,13 @@ import { LayoutService } from '../../services/layout/layout.service';
styleUrls: ['./layout.component.css']
})
export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit {
- @ContentChild('customLocalParticipant', { read: TemplateRef }) customLocalParticipantTemplate: TemplateRef;
- @ContentChild('customRemoteParticipants', { read: TemplateRef }) customRemoteParticipantsTemplate: TemplateRef;
+ // @ContentChild('customLocalParticipant', { read: TemplateRef }) customLocalParticipantTemplate: TemplateRef;
+ // @ContentChild('customRemoteParticipants', { read: TemplateRef }) customRemoteParticipantsTemplate: TemplateRef;
+
+ @ContentChild('stream', { read: TemplateRef }) streamTemplate: TemplateRef;
+
+
+
localParticipant: ParticipantAbstractModel;
remoteParticipants: ParticipantAbstractModel[] = [];
@@ -22,6 +27,8 @@ export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit {
constructor(protected layoutService: LayoutService, protected participantService: ParticipantService) {}
ngOnInit(): void {
+ this.layoutService.initialize();
+
this.subscribeToUsers();
}
diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/panel/panel.component.html b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/panel/panel.component.html
index 4d957c87..2016d3c9 100644
--- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/panel/panel.component.html
+++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/panel/panel.component.html
@@ -1 +1,9 @@
-panel works!
+
+
+
+
+
+
+
+
+
diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/panel/panel.component.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/panel/panel.component.ts
index aabdad27..f27ce24e 100644
--- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/panel/panel.component.ts
+++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/panel/panel.component.ts
@@ -1,15 +1,35 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, ContentChild, OnInit, TemplateRef } from '@angular/core';
+import { skip, Subscription } from 'rxjs';
+import { MenuType } from '../../models/menu.model';
+import { SidenavMenuService } from '../../services/sidenav-menu/sidenav-menu.service';
@Component({
- selector: 'ov-panel',
- templateUrl: './panel.component.html',
- styleUrls: ['./panel.component.css']
+ selector: 'ov-panel',
+ templateUrl: './panel.component.html',
+ styleUrls: ['./panel.component.css']
})
export class PanelComponent implements OnInit {
+ @ContentChild('participantsPanel', { read: TemplateRef }) participantsPanelTemplate: TemplateRef;
+ @ContentChild('chatPanel', { read: TemplateRef }) chatPanelTemplate: TemplateRef;
- constructor() { }
+ isParticipantsPanelOpened: boolean;
+ isChatPanelOpened: boolean;
+ menuSubscription: Subscription;
+ constructor(protected menuService: SidenavMenuService) {}
- ngOnInit(): void {
- }
+ ngOnInit(): void {
+ this.subscribeToPanelToggling();
+ }
+ 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;
+ });
+ }
+ ngOnDestroy() {
+ this.isChatPanelOpened = false;
+ this.isParticipantsPanelOpened = false;
+ if (this.menuSubscription) this.menuSubscription.unsubscribe();
+ }
}
diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.html b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.html
index 85367ff7..45758150 100644
--- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.html
+++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.html
@@ -1,6 +1,5 @@
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
+