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 9d29702e..e3f6c8a8 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,9 +1,19 @@ -import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, OnDestroy, OnInit, TemplateRef } from '@angular/core'; +import { + AfterViewInit, + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + ContentChild, + OnDestroy, + OnInit, + TemplateRef +} from '@angular/core'; import { Subscription } from 'rxjs'; import { ParticipantService } from '../../services/participant/participant.service'; import { ParticipantAbstractModel } from '../../models/participant.model'; import { LayoutService } from '../../services/layout/layout.service'; import { StreamDirective } from '../../directives/template/openvidu-angular.directive'; +import { OpenViduAngularConfigService } from '../../services/config/openvidu-angular.config.service'; @Component({ selector: 'ov-layout', @@ -15,10 +25,10 @@ export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit { @ContentChild('stream', { read: TemplateRef }) streamTemplate: TemplateRef; @ContentChild(StreamDirective) - set externalStream (externalStream: StreamDirective) { + set externalStream(externalStream: StreamDirective) { // This directive will has value only when STREAM component tagget with '*ovStream' directive // is inside of the layout component tagged with '*ovLayout' directive - if(externalStream) { + if (externalStream) { this.streamTemplate = externalStream.template; } } @@ -28,15 +38,25 @@ export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit { protected localParticipantSubs: Subscription; protected remoteParticipantsSubs: Subscription; - constructor(protected layoutService: LayoutService, protected participantService: ParticipantService, private cd: ChangeDetectorRef) {} + constructor( + protected layoutService: LayoutService, + protected participantService: ParticipantService, + private libService: OpenViduAngularConfigService, + private cd: ChangeDetectorRef + ) {} ngOnInit(): void { this.subscribeToParticipants(); } ngAfterViewInit() { - this.layoutService.initialize(); - this.layoutService.update(); + let timeout: number = null; + if (this.libService.isWebcomponent()) { + timeout = 0; + } + + this.layoutService.initialize(timeout); + this.layoutService.update(timeout); } ngOnDestroy() { diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/toolbar/toolbar.component.css b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/toolbar/toolbar.component.css index de639455..cc09e664 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/toolbar/toolbar.component.css +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/toolbar/toolbar.component.css @@ -15,7 +15,7 @@ align-items: center; } #media-buttons-container { - max-height: 100%; + max-height: 100% !important; } #media-buttons-container > *, ::ng-deep #media-buttons-container > * { diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/config/openvidu-angular.config.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/config/openvidu-angular.config.ts index d0d91b33..2d287cec 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/config/openvidu-angular.config.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/config/openvidu-angular.config.ts @@ -1,6 +1,7 @@ export interface OpenViduAngularConfig { production?: boolean, participantFactory?: ParticipantFactoryFunction, + webcomponent?: boolean } diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/models/layout.model.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/models/layout.model.ts index d8755be3..68b064d9 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/models/layout.model.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/models/layout.model.ts @@ -141,7 +141,7 @@ export class OpenViduLayout { } getLayoutContainer(): HTMLElement { - return this.layoutContainer + return this.layoutContainer; } /** diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/config/openvidu-angular.config.service.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/config/openvidu-angular.config.service.ts index eedaa351..e66a5327 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/config/openvidu-angular.config.service.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/config/openvidu-angular.config.service.ts @@ -70,6 +70,10 @@ export class OpenViduAngularConfigService { return this.configuration?.production; } + isWebcomponent(): boolean { + return this.configuration?.webcomponent; + } + hasParticipantFactory(): boolean { return typeof this.getConfig().participantFactory === "function"; } diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/layout/layout.service.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/layout/layout.service.ts index 50d1e508..a7ab8989 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/layout/layout.service.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/layout/layout.service.ts @@ -17,23 +17,25 @@ export class LayoutService { } initialize(timeout: number = null) { - if (!!timeout) { + if (typeof timeout === 'number' && timeout >= 0) { setTimeout(() => { this._initialize(); + this.sendLayoutWidthEvent(); }, timeout); } else { this._initialize(); + this.sendLayoutWidthEvent(); } - this.sendLayoutWidthEvent(); } private _initialize() { this.openviduLayout = new OpenViduLayout(); this.openviduLayoutOptions = this.getOptions(); - this.openviduLayout.initLayoutContainer(document.getElementById('layout'), this.openviduLayoutOptions); + const element = document.getElementById('layout'); + this.openviduLayout.initLayoutContainer(element, this.openviduLayoutOptions); } - getOptions(): OpenViduLayoutOptions { + private getOptions(): OpenViduLayoutOptions { const options = { maxRatio: 3 / 2, // The narrowest ratio that will be used (default 2x3) minRatio: 9 / 16, // The widest ratio that will be used (default 16x9) @@ -51,16 +53,17 @@ export class LayoutService { return options; } - update(timeout?: number) { - if (!!this.openviduLayout) { - if (!timeout) { + update(timeout: number = null) { + const updateAux = () => { + if (!!this.openviduLayout) { this.openviduLayout.updateLayout(); - } else { - setTimeout(() => { - this.openviduLayout.updateLayout(); - }, timeout); + this.sendLayoutWidthEvent(); } - this.sendLayoutWidthEvent(); + }; + if (typeof timeout === 'number' && timeout >= 0) { + setTimeout(() => updateAux(), timeout); + } else { + updateAux(); } } @@ -74,10 +77,10 @@ export class LayoutService { private sendLayoutWidthEvent() { const sidenavLayoutElement = this.documentService.getHTMLElementByClassName( - this.openviduLayout.getLayoutContainer(), + this.openviduLayout?.getLayoutContainer(), LayoutClass.SIDENAV_CONTAINER ); - if(sidenavLayoutElement && sidenavLayoutElement.clientWidth) { + if (sidenavLayoutElement && sidenavLayoutElement.clientWidth) { this._layoutWidthObs.next(sidenavLayoutElement.clientWidth); } } diff --git a/openvidu-components-angular/src/app/openvidu-webcomponent/openvidu-webcomponent.component.scss b/openvidu-components-angular/src/app/openvidu-webcomponent/openvidu-webcomponent.component.scss index c0adb716..69e9f17f 100644 --- a/openvidu-components-angular/src/app/openvidu-webcomponent/openvidu-webcomponent.component.scss +++ b/openvidu-components-angular/src/app/openvidu-webcomponent/openvidu-webcomponent.component.scss @@ -73,4 +73,11 @@ $openvidu-components-theme: mat.define-light-theme(( } html, body { height: 100%; overflow: hidden;} -body { margin: 0; font-family: 'Roboto','RobotoDraft',Helvetica,Arial,sans-serif;} \ No newline at end of file +body { margin: 0; font-family: 'Roboto','RobotoDraft',Helvetica,Arial,sans-serif;} + +#poster-text { + padding: 0px !important; +} +ov-chat-panel .text-info { + margin: 3px auto !important; +} \ No newline at end of file diff --git a/openvidu-components-angular/src/app/openvidu-webcomponent/openvidu-webcomponent.module.ts b/openvidu-components-angular/src/app/openvidu-webcomponent/openvidu-webcomponent.module.ts index 23ae46b9..3b6acaea 100644 --- a/openvidu-components-angular/src/app/openvidu-webcomponent/openvidu-webcomponent.module.ts +++ b/openvidu-components-angular/src/app/openvidu-webcomponent/openvidu-webcomponent.module.ts @@ -5,23 +5,23 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { OpenviduWebComponentComponent } from './openvidu-webcomponent.component'; -import { OpenviduAngularModule, VideoconferenceComponent } from 'openvidu-angular'; +import { OpenViduAngularModule, VideoconferenceComponent } from 'openvidu-angular'; import { environment } from '../../environments/environment'; import { createCustomElement } from '@angular/elements'; @NgModule({ declarations: [OpenviduWebComponentComponent], - imports: [CommonModule, BrowserModule, BrowserAnimationsModule, OpenviduAngularModule.forRoot(environment)], + imports: [CommonModule, BrowserModule, BrowserAnimationsModule, OpenViduAngularModule.forRoot(environment)], // exports: [OpenviduWebComponentComponent], - providers: [{ provide: APP_BASE_HREF, useValue: '/' }, VideoconferenceComponent] + providers: [{ provide: APP_BASE_HREF, useValue: '/' }, VideoconferenceComponent], }) export class OpenviduWebComponentModule implements DoBootstrap { constructor(private injector: Injector) {} ngDoBootstrap(): void { const element = createCustomElement(OpenviduWebComponentComponent, { - injector: this.injector + injector: this.injector, }); customElements.define('openvidu-webcomponent', element); diff --git a/openvidu-components-angular/src/environments/environment.prod.ts b/openvidu-components-angular/src/environments/environment.prod.ts index 3612073b..1c8a72ed 100644 --- a/openvidu-components-angular/src/environments/environment.prod.ts +++ b/openvidu-components-angular/src/environments/environment.prod.ts @@ -1,3 +1,6 @@ export const environment = { - production: true + production: true, + // The webcomponent build will use this environment. + // Wee need this flag for settings a delay in the layout for correct behaviour + webcomponent: true }; diff --git a/openvidu-components-angular/src/environments/environment.ts b/openvidu-components-angular/src/environments/environment.ts index 7b4f817a..440926e1 100644 --- a/openvidu-components-angular/src/environments/environment.ts +++ b/openvidu-components-angular/src/environments/environment.ts @@ -3,7 +3,8 @@ // The list of file replacements can be found in `angular.json`. export const environment = { - production: false + production: false, + webcomponent: true }; /*