mirror of https://github.com/OpenVidu/openvidu.git
ov-components: remove ServiceConfigService and update components to use LayoutService directly
parent
7315360fbc
commit
5fba250b1d
|
@ -19,7 +19,6 @@ import { ParticipantService } from '../../services/participant/participant.servi
|
||||||
import { CdkDrag } from '@angular/cdk/drag-drop';
|
import { CdkDrag } from '@angular/cdk/drag-drop';
|
||||||
import { PanelService } from '../../services/panel/panel.service';
|
import { PanelService } from '../../services/panel/panel.service';
|
||||||
import { GlobalConfigService } from '../../services/config/global-config.service';
|
import { GlobalConfigService } from '../../services/config/global-config.service';
|
||||||
import { ServiceConfigService } from '../../services/config/service-config.service';
|
|
||||||
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
|
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,21 +79,18 @@ export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
private resizeTimeout: NodeJS.Timeout;
|
private resizeTimeout: NodeJS.Timeout;
|
||||||
private videoIsAtRight: boolean = false;
|
private videoIsAtRight: boolean = false;
|
||||||
private lastLayoutWidth: number = 0;
|
private lastLayoutWidth: number = 0;
|
||||||
private layoutService: LayoutService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private serviceConfig: ServiceConfigService,
|
private layoutService: LayoutService,
|
||||||
private panelService: PanelService,
|
private panelService: PanelService,
|
||||||
private participantService: ParticipantService,
|
private participantService: ParticipantService,
|
||||||
private globalService: GlobalConfigService,
|
private globalService: GlobalConfigService,
|
||||||
private directiveService: OpenViduComponentsConfigService,
|
private directiveService: OpenViduComponentsConfigService,
|
||||||
private cd: ChangeDetectorRef
|
private cd: ChangeDetectorRef
|
||||||
) {
|
) {}
|
||||||
this.layoutService = this.serviceConfig.getLayoutService();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.subscribeToParticipants();
|
this.subscribeToParticipants();
|
||||||
|
@ -152,17 +148,17 @@ export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
this.remoteParticipantsSubs = combineLatest([
|
this.remoteParticipantsSubs = combineLatest([
|
||||||
this.participantService.remoteParticipants$,
|
this.participantService.remoteParticipants$,
|
||||||
this.directiveService.layoutRemoteParticipants$
|
this.directiveService.layoutRemoteParticipants$
|
||||||
])
|
])
|
||||||
.pipe(
|
.pipe(
|
||||||
map(([serviceParticipants, directiveParticipants]) =>
|
map(([serviceParticipants, directiveParticipants]) =>
|
||||||
directiveParticipants !== undefined ? directiveParticipants : serviceParticipants
|
directiveParticipants !== undefined ? directiveParticipants : serviceParticipants
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
.subscribe((participants) => {
|
||||||
.subscribe((participants) => {
|
this.remoteParticipants = participants;
|
||||||
this.remoteParticipants = participants;
|
this.layoutService.update();
|
||||||
this.layoutService.update();
|
this.cd.markForCheck();
|
||||||
this.cd.markForCheck();
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private listenToResizeLayout() {
|
private listenToResizeLayout() {
|
||||||
|
|
|
@ -47,7 +47,6 @@ import {
|
||||||
Track
|
Track
|
||||||
} from 'livekit-client';
|
} from 'livekit-client';
|
||||||
import { ParticipantLeftEvent, ParticipantModel } from '../../models/participant.model';
|
import { ParticipantLeftEvent, ParticipantModel } from '../../models/participant.model';
|
||||||
import { ServiceConfigService } from '../../services/config/service-config.service';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
@ -108,10 +107,9 @@ export class SessionComponent implements OnInit, OnDestroy {
|
||||||
private updateLayoutInterval: NodeJS.Timeout;
|
private updateLayoutInterval: NodeJS.Timeout;
|
||||||
private captionLanguageSubscription: Subscription;
|
private captionLanguageSubscription: Subscription;
|
||||||
private log: ILogger;
|
private log: ILogger;
|
||||||
private layoutService: LayoutService;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceConfig: ServiceConfigService,
|
private layoutService: LayoutService,
|
||||||
private actionService: ActionService,
|
private actionService: ActionService,
|
||||||
private openviduService: OpenViduService,
|
private openviduService: OpenViduService,
|
||||||
private participantService: ParticipantService,
|
private participantService: ParticipantService,
|
||||||
|
@ -127,7 +125,6 @@ export class SessionComponent implements OnInit, OnDestroy {
|
||||||
private cd: ChangeDetectorRef
|
private cd: ChangeDetectorRef
|
||||||
) {
|
) {
|
||||||
this.log = this.loggerSrv.get('SessionComponent');
|
this.log = this.loggerSrv.get('SessionComponent');
|
||||||
this.layoutService = this.serviceConfig.getLayoutService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('window:beforeunload')
|
@HostListener('window:beforeunload')
|
||||||
|
|
|
@ -23,11 +23,11 @@ export class CaptionsSettingComponent implements OnInit, OnDestroy {
|
||||||
private captionsStatusSubs: Subscription;
|
private captionsStatusSubs: Subscription;
|
||||||
private sttStatusSubs: Subscription;
|
private sttStatusSubs: Subscription;
|
||||||
|
|
||||||
private layoutService: LayoutService;
|
constructor(
|
||||||
|
private layoutService: LayoutService,
|
||||||
constructor(private serviceConfig: ServiceConfigService, private captionService: CaptionService, private openviduService: OpenViduService) {
|
private captionService: CaptionService,
|
||||||
this.layoutService = this.serviceConfig.getLayoutService();
|
private openviduService: OpenViduService
|
||||||
}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// this.isOpenViduPro = this.openviduService.isOpenViduPro();
|
// this.isOpenViduPro = this.openviduService.isOpenViduPro();
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { LayoutService } from '../../services/layout/layout.service';
|
||||||
import { ParticipantService } from '../../services/participant/participant.service';
|
import { ParticipantService } from '../../services/participant/participant.service';
|
||||||
import { Track } from 'livekit-client';
|
import { Track } from 'livekit-client';
|
||||||
import { ParticipantTrackPublication } from '../../models/participant.model';
|
import { ParticipantTrackPublication } from '../../models/participant.model';
|
||||||
import { ServiceConfigService } from '../../services/config/service-config.service';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The **StreamComponent** is hosted inside of the {@link LayoutComponent}.
|
* The **StreamComponent** is hosted inside of the {@link LayoutComponent}.
|
||||||
|
@ -98,18 +97,15 @@ export class StreamComponent implements OnInit, OnDestroy {
|
||||||
private videoControlsSub: Subscription;
|
private videoControlsSub: Subscription;
|
||||||
private readonly HOVER_TIMEOUT = 3000;
|
private readonly HOVER_TIMEOUT = 3000;
|
||||||
|
|
||||||
private layoutService: LayoutService;
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private serviceConfig: ServiceConfigService,
|
private layoutService: LayoutService,
|
||||||
private participantService: ParticipantService,
|
private participantService: ParticipantService,
|
||||||
private cdkSrv: CdkOverlayService,
|
private cdkSrv: CdkOverlayService,
|
||||||
private libService: OpenViduComponentsConfigService
|
private libService: OpenViduComponentsConfigService
|
||||||
) {
|
) {}
|
||||||
this.layoutService = this.serviceConfig.getLayoutService();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.subscribeToStreamDirectives();
|
this.subscribeToStreamDirectives();
|
||||||
|
|
|
@ -49,7 +49,6 @@ import { CdkOverlayService } from '../../services/cdk-overlay/cdk-overlay.servic
|
||||||
import { ParticipantLeftEvent, ParticipantModel } from '../../models/participant.model';
|
import { ParticipantLeftEvent, ParticipantModel } from '../../models/participant.model';
|
||||||
import { Room, RoomEvent } from 'livekit-client';
|
import { Room, RoomEvent } from 'livekit-client';
|
||||||
import { ToolbarAdditionalButtonsPosition } from '../../models/toolbar.model';
|
import { ToolbarAdditionalButtonsPosition } from '../../models/toolbar.model';
|
||||||
import { ServiceConfigService } from '../../services/config/service-config.service';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The **ToolbarComponent** is hosted inside of the {@link VideoconferenceComponent}.
|
* The **ToolbarComponent** is hosted inside of the {@link VideoconferenceComponent}.
|
||||||
|
@ -349,13 +348,12 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
private additionalButtonsPositionSub: Subscription;
|
private additionalButtonsPositionSub: Subscription;
|
||||||
private fullscreenChangeSubscription: Subscription;
|
private fullscreenChangeSubscription: Subscription;
|
||||||
private currentWindowHeight = window.innerHeight;
|
private currentWindowHeight = window.innerHeight;
|
||||||
private layoutService: LayoutService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private serviceConfig: ServiceConfigService,
|
private layoutService: LayoutService,
|
||||||
private documentService: DocumentService,
|
private documentService: DocumentService,
|
||||||
private chatService: ChatService,
|
private chatService: ChatService,
|
||||||
private panelService: PanelService,
|
private panelService: PanelService,
|
||||||
|
@ -374,7 +372,6 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
private cdkOverlayService: CdkOverlayService
|
private cdkOverlayService: CdkOverlayService
|
||||||
) {
|
) {
|
||||||
this.log = this.loggerSrv.get('ToolbarComponent');
|
this.log = this.loggerSrv.get('ToolbarComponent');
|
||||||
this.layoutService = this.serviceConfig.getLayoutService();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { ParticipantProperties } from '../models/participant.model';
|
||||||
export interface OpenViduComponentsConfig {
|
export interface OpenViduComponentsConfig {
|
||||||
production?: boolean;
|
production?: boolean;
|
||||||
participantFactory?: ParticipantFactoryFunction;
|
participantFactory?: ParticipantFactoryFunction;
|
||||||
services?: any;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ParticipantFactoryFunction = (props: ParticipantProperties) => any;
|
export type ParticipantFactoryFunction = (props: ParticipantProperties) => any;
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
import { Injectable, Inject, Injector, Optional } from '@angular/core';
|
|
||||||
import { LayoutService } from '../layout/layout.service';
|
|
||||||
import { OpenViduComponentsConfig } from '../../config/openvidu-components-angular.config';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class ServiceConfigService {
|
|
||||||
private configuration: OpenViduComponentsConfig;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
@Optional() private injector: Injector,
|
|
||||||
@Inject('OPENVIDU_COMPONENTS_CONFIG') config: OpenViduComponentsConfig
|
|
||||||
) {
|
|
||||||
this.configuration = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
getLayoutService(): LayoutService {
|
|
||||||
return this.getServiceSafely<LayoutService>('LayoutService', LayoutService);
|
|
||||||
}
|
|
||||||
|
|
||||||
private getService<T>(key: string): T {
|
|
||||||
const service = this.configuration.services ? this.configuration.services[key] : null;
|
|
||||||
if (!service) {
|
|
||||||
throw new Error(`No service registered with key ${key}`);
|
|
||||||
}
|
|
||||||
return this.injector.get(service) as T;
|
|
||||||
}
|
|
||||||
|
|
||||||
private getServiceSafely<T>(key: string, fallback: new (...args: any[]) => T): T {
|
|
||||||
try {
|
|
||||||
return this.getService<T>(key);
|
|
||||||
} catch {
|
|
||||||
return this.injector.get(fallback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue