Skip to content

Commit

Permalink
ov-components: Refactored config service
Browse files Browse the repository at this point in the history
  • Loading branch information
CSantosM committed Aug 26, 2024
1 parent 95b8d05 commit 8db953b
Show file tree
Hide file tree
Showing 26 changed files with 90 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, OnInit, Output, EventEmitter, OnDestroy } from '@angular/cor
import { Subscription } from 'rxjs';
import { RecordingDeleteRequestedEvent, RecordingInfo, RecordingStatus } from '../../models/recording.model';
import { ActionService } from '../../services/action/action.service';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
import { RecordingService } from '../../services/recording/recording.service';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Validators, FormGroup, FormBuilder } from '@angular/forms';
import { Subscription } from 'rxjs';
import { ActionService } from '../../services/action/action.service';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';

@Component({
selector: 'ov-admin-login',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { LayoutService } from '../../services/layout/layout.service';
import { ParticipantService } from '../../services/participant/participant.service';
import { CdkDrag } from '@angular/cdk/drag-drop';
import { PanelService } from '../../services/panel/panel.service';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { GlobalConfigService } from '../../services/config/global-config.service';

/**
*
Expand Down Expand Up @@ -86,7 +86,7 @@ export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit {
private layoutService: LayoutService,
private panelService: PanelService,
private participantService: ParticipantService,
private libService: OpenViduComponentsConfigService,
private globalService: GlobalConfigService,
private cd: ChangeDetectorRef
) {}

Expand Down Expand Up @@ -207,7 +207,7 @@ export class LayoutComponent implements OnInit, OnDestroy, AfterViewInit {
};
this.cdkSubscription = this.cdkDrag.released.subscribe(handler);

if (this.libService.getConfig().production) return;
if (this.globalService.isProduction()) return;
// Just for allow E2E testing with drag and drop
document.addEventListener('webcomponentTestingEndedDragAndDropEvent', handler);
document.addEventListener('webcomponentTestingEndedDragAndDropRightEvent', (event: any) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Subscription } from 'rxjs';
import { PanelStatusInfo, PanelType } from '../../../models/panel.model';
import { OpenViduComponentsConfigService } from '../../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../../services/config/directive-config.service';
import { PanelService } from '../../../services/panel/panel.service';
import {
RecordingDeleteRequestedEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, In
import { Subscription } from 'rxjs';
import { ParticipantPanelItemElementsDirective } from '../../../../directives/template/openvidu-components-angular.directive';
import { ParticipantModel } from '../../../../models/participant.model';
import { OpenViduComponentsConfigService } from '../../../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../../../services/config/directive-config.service';
import { ParticipantService } from '../../../../services/participant/participant.service';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Subscription } from 'rxjs';
import { PanelStatusInfo, PanelSettingsOptions, PanelType } from '../../../models/panel.model';
import { OpenViduComponentsConfigService } from '../../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../../services/config/directive-config.service';
import { PanelService } from '../../../services/panel/panel.service';
import { PlatformService } from '../../../services/platform/platform.service';
import { CustomDevice } from '../../../models/device.model';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChangeDetectorRef, Component, EventEmitter, HostListener, Input, OnDest
import { Subscription } from 'rxjs';
import { ILogger } from '../../models/logger.model';
import { CdkOverlayService } from '../../services/cdk-overlay/cdk-overlay.service';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
import { LayoutService } from '../../services/layout/layout.service';
import { LoggerService } from '../../services/logger/logger.service';
import { OpenViduService } from '../../services/openvidu/openvidu.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { ActionService } from '../../services/action/action.service';
import { BroadcastingService } from '../../services/broadcasting/broadcasting.service';
// import { CaptionService } from '../../services/caption/caption.service';
import { ChatService } from '../../services/chat/chat.service';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
import { LayoutService } from '../../services/layout/layout.service';
import { LoggerService } from '../../services/logger/logger.service';
import { OpenViduService } from '../../services/openvidu/openvidu.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, ElementRef, Input, OnDestroy, OnInit, ViewChild } from '@ang
import { MatMenuPanel, MatMenuTrigger } from '@angular/material/menu';
import { Subscription } from 'rxjs';
import { CdkOverlayService } from '../../services/cdk-overlay/cdk-overlay.service';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
import { LayoutService } from '../../services/layout/layout.service';
import { OpenViduService } from '../../services/openvidu/openvidu.service';
import { ParticipantService } from '../../services/participant/participant.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
} from '../../models/recording.model';
import { ActionService } from '../../services/action/action.service';
import { BroadcastingService } from '../../services/broadcasting/broadcasting.service';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
import { DeviceService } from '../../services/device/device.service';
import { LayoutService } from '../../services/layout/layout.service';
import { LoggerService } from '../../services/logger/logger.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
} from '../../directives/template/openvidu-components-angular.directive';
import { ILogger } from '../../models/logger.model';
import { ActionService } from '../../services/action/action.service';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
import { DeviceService } from '../../services/device/device.service';
import { LoggerService } from '../../services/logger/logger.service';
import { OpenViduService } from '../../services/openvidu/openvidu.service';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular/core';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';

/**
* The **recordingActivity** directive allows show/hide the recording activity in {@link ActivitiesPanelComponent}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Directive, AfterViewInit, OnDestroy, Input, ElementRef } from '@angular/core';
import { RecordingInfo } from '../../models/recording.model';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';

/**
* The **recordingsList** directive allows show all recordings saved in your OpenVidu deployment in {@link AdminDashboardComponent}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Directive, AfterViewInit, OnDestroy, Input, ElementRef } from '@angular/core';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';

/**
* The **muteButton** directive allows show/hide the muted button in participant panel item component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular/core';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';

/**
* The **displayParticipantName** directive allows show/hide the participants name in stream component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterViewInit, Directive, ElementRef, Input, OnDestroy } from '@angular/core';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
import { ToolbarAdditionalButtonsPosition } from '../../models/toolbar.model';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';
import { CaptionsLangOption } from '../../models/caption.model';
// import { CaptionService } from '../../services/caption/caption.service';
import { OpenViduComponentsConfigService } from '../../services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from '../../services/config/directive-config.service';
import { TranslateService } from '../../services/translate/translate.service';
import { LangOption } from '../../models/lang.model';
import { StorageService } from '../../services/storage/storage.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { CdkOverlayContainer } from './config/custom-cdk-overlay';
import { OpenViduComponentsConfig } from './config/openvidu-components-angular.config';
import { ActionService } from './services/action/action.service';
import { ChatService } from './services/chat/chat.service';
import { OpenViduComponentsConfigService } from './services/config/openvidu-components-angular.config.service';
import { OpenViduComponentsConfigService } from './services/config/directive-config.service';
import { DeviceService } from './services/device/device.service';
import { DocumentService } from './services/document/document.service';
import { LayoutService } from './services/layout/layout.service';
Expand Down Expand Up @@ -97,7 +97,7 @@ const privateComponents = [
VideoDevicesComponent,
AudioDevicesComponent,
ParticipantNameInputComponent,
LangSelectorComponent,
LangSelectorComponent
// CaptionsSettingComponent
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { Inject, Injectable } from '@angular/core';
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { OpenViduComponentsConfig, ParticipantFactoryFunction } from '../../config/openvidu-components-angular.config';
import { RecordingInfo } from '../../models/recording.model';
import { DOCUMENT } from '@angular/common';
import { ToolbarAdditionalButtonsPosition } from '../../models/toolbar.model';

// import { version } from '../../../../package.json';

/**
* @internal
*/
@Injectable()
export class OpenViduComponentsConfigService {
private configuration: OpenViduComponentsConfig;
private token = <BehaviorSubject<string>>new BehaviorSubject('');
token$: Observable<string>;

Expand Down Expand Up @@ -92,13 +87,7 @@ export class OpenViduComponentsConfigService {
private adminLoginError = <BehaviorSubject<any>>new BehaviorSubject(null);
adminLoginError$: Observable<any>;

constructor(
@Inject('OPENVIDU_COMPONENTS_CONFIG') config: OpenViduComponentsConfig,
@Inject(DOCUMENT) private document: Document
) {
this.configuration = config;
console.log(this.configuration);
if (this.isProduction()) console.log('OpenVidu Angular Production Mode');
constructor() {
this.token$ = this.token.asObservable();
this.livekitUrl$ = this.livekitUrl.asObservable();
this.tokenError$ = this.tokenError.asObservable();
Expand Down Expand Up @@ -368,39 +357,6 @@ export class OpenViduComponentsConfigService {
return this.adminLoginError.getValue();
}

getConfig(): OpenViduComponentsConfig {
return this.configuration;
}
isProduction(): boolean {
return this.configuration?.production || false;
}

/**
* Retrieves the base href of the application.
*
* @returns The base href of the application as a string.
*/
getBaseHref(): string {
const base = this.document.getElementsByTagName('base');
if (!base || base.length === 0) {
return '/';
}

const baseHref = base[0].href;
if (baseHref) {
return baseHref;
}
return '/';
}

hasParticipantFactory(): boolean {
return typeof this.getConfig().participantFactory === 'function';
}

getParticipantFactory(): ParticipantFactoryFunction {
return this.getConfig().participantFactory;
}

isRecordingEnabled(): boolean {
return this.recordingButton.getValue() && this.recordingActivity.getValue();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { DOCUMENT } from '@angular/common';
import { Inject, Injectable} from '@angular/core';
import { ParticipantFactoryFunction, OpenViduComponentsConfig } from '../../config/openvidu-components-angular.config';

@Injectable({
providedIn: 'root'
})
export class GlobalConfigService {
private configuration: OpenViduComponentsConfig;

constructor(
@Inject('OPENVIDU_COMPONENTS_CONFIG') config: OpenViduComponentsConfig,
@Inject(DOCUMENT) private document: Document
) {
this.configuration = config;
console.log(this.configuration);
if (this.isProduction()) console.log('OpenVidu Angular Production Mode');
}

/**
* Retrieves the base href of the application.
*
* @returns The base href of the application as a string.
*/
getBaseHref(): string {
const base = this.document.getElementsByTagName('base');
if (!base || base.length === 0) {
return '/';
}

const baseHref = base[0].href;
if (baseHref) {
return baseHref;
}
return '/';
}

hasParticipantFactory(): boolean {
return typeof this.getConfig().participantFactory === 'function';
}

getParticipantFactory(): ParticipantFactoryFunction {
return this.getConfig().participantFactory;
}

getConfig(): OpenViduComponentsConfig {
return this.configuration;
}
isProduction(): boolean {
return this.configuration?.production || false;
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { ILogService } from '../../models/logger.model';

import { OpenViduComponentsConfigService } from '../config/openvidu-components-angular.config.service';
import { GlobalConfigService } from '../config/global-config.service';

/**
* @internal
Expand All @@ -18,7 +18,7 @@ export class LoggerService implements ILogService {
['[', '] ERROR: ']
];

constructor(private openviduAngularConfigSrv: OpenViduComponentsConfigService) {
constructor(private globalService: GlobalConfigService) {
}

private getLoggerFns(prefix: string) {
Expand All @@ -31,7 +31,7 @@ export class LoggerService implements ILogService {
}

public get(prefix: string) {
const prodMode = this.openviduAngularConfigSrv.isProduction();
const prodMode = this.globalService.isProduction();
const loggerService = this;
return {
d: function(...args: any[]) {
Expand Down
Loading

0 comments on commit 8db953b

Please sign in to comment.