openvidu-components: Renamed menu service to panel service

pull/713/head
csantosm 2022-04-05 15:40:43 +02:00
parent 1ee8bd1f6e
commit b0afa580a7
11 changed files with 48 additions and 48 deletions

View File

@ -12,7 +12,7 @@ import { Subscription } from 'rxjs';
import { ChatMessage } from '../../../models/chat.model';
import { MenuType } from '../../../models/menu.model';
import { ChatService } from '../../../services/chat/chat.service';
import { SidenavMenuService } from '../../../services/sidenav-menu/sidenav-menu.service';
import { PanelService } from '../../../services/panel/panel.service';
/**
*
@ -65,14 +65,14 @@ export class ChatPanelComponent implements OnInit, AfterViewInit {
/**
* @ignore
*/
constructor(private chatService: ChatService, private menuService: SidenavMenuService, private cd: ChangeDetectorRef) {}
constructor(private chatService: ChatService, private PanelService: PanelService, private cd: ChangeDetectorRef) {}
/**
* @ignore
*/
@HostListener('document:keydown.escape', ['$event'])
onKeydownHandler(event: KeyboardEvent) {
if (this.menuService.isMenuOpened()) {
if (this.PanelService.isMenuOpened()) {
this.close();
}
}
@ -119,13 +119,13 @@ export class ChatPanelComponent implements OnInit, AfterViewInit {
}
close() {
this.menuService.toggleMenu(MenuType.CHAT);
this.PanelService.toggleMenu(MenuType.CHAT);
}
private subscribeToMessages() {
this.chatMessageSubscription = this.chatService.messagesObs.subscribe((messages: ChatMessage[]) => {
this.messageList = messages;
if (this.menuService.isMenuOpened()) {
if (this.PanelService.isMenuOpened()) {
this.scrollToBottom();
this.cd.markForCheck();
}

View File

@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, On
import { skip, Subscription } from 'rxjs';
import { ChatPanelDirective, ParticipantsPanelDirective } from '../../directives/template/openvidu-angular.directive';
import { MenuType } from '../../models/menu.model';
import { SidenavMenuService } from '../../services/sidenav-menu/sidenav-menu.service';
import { PanelService } from '../../services/panel/panel.service';
/**
*
@ -82,7 +82,7 @@ export class PanelComponent implements OnInit {
/**
* @ignore
*/
constructor(protected menuService: SidenavMenuService, private cd: ChangeDetectorRef) {}
constructor(protected panelService: PanelService, private cd: ChangeDetectorRef) {}
ngOnInit(): void {
this.subscribeToPanelToggling();
@ -95,7 +95,7 @@ export class PanelComponent implements OnInit {
}
private subscribeToPanelToggling() {
this.menuSubscription = this.menuService.menuOpenedObs.pipe(skip(1)).subscribe((ev: { opened: boolean; type?: MenuType }) => {
this.menuSubscription = this.panelService.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();

View File

@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, OnDestroy, OnInit, TemplateRef } from '@angular/core';
import { ParticipantAbstractModel } from '../../../../models/participant.model';
import { ParticipantService } from '../../../../services/participant/participant.service';
import { SidenavMenuService } from '../../../..//services/sidenav-menu/sidenav-menu.service';
import { PanelService } from '../../../..//services/panel/panel.service';
import { ParticipantPanelItemDirective } from '../../../../directives/template/openvidu-angular.directive';
import { Subscription } from 'rxjs';
@ -70,7 +70,7 @@ export class ParticipantsPanelComponent implements OnInit, OnDestroy {
*/
constructor(
protected participantService: ParticipantService,
protected menuService: SidenavMenuService,
protected PanelService: PanelService,
private cd: ChangeDetectorRef
) {}
@ -100,6 +100,6 @@ export class ParticipantsPanelComponent implements OnInit, OnDestroy {
}
close() {
this.menuService.closeMenu();
this.PanelService.closeMenu();
}
}

View File

@ -26,7 +26,7 @@ import { SidenavMode } from '../../models/layout.model';
import { LayoutService } from '../../services/layout/layout.service';
import { Subscription, skip } from 'rxjs';
import { MenuType } from '../../models/menu.model';
import { SidenavMenuService } from '../../services/sidenav-menu/sidenav-menu.service';
import { PanelService } from '../../services/panel/panel.service';
import { PlatformService } from '../../services/platform/platform.service';
/**
@ -73,7 +73,7 @@ export class SessionComponent implements OnInit {
protected chatService: ChatService,
protected tokenService: TokenService,
protected layoutService: LayoutService,
protected menuService: SidenavMenuService,
protected panelService: PanelService,
private platformService: PlatformService
) {
this.log = this.loggerSrv.get('SessionComponent');
@ -153,7 +153,7 @@ export class SessionComponent implements OnInit {
this.updateLayoutInterval = setInterval(() => this.layoutService.update(), 50);
});
this.menuSubscription = this.menuService.menuOpenedObs.pipe(skip(1)).subscribe((ev: { opened: boolean; type?: MenuType }) => {
this.menuSubscription = this.panelService.menuOpenedObs.pipe(skip(1)).subscribe((ev: { opened: boolean; type?: MenuType }) => {
if (this.sideMenu) {
this.isChatPanelOpened = ev.opened && ev.type === MenuType.CHAT;
this.isParticipantsPanelOpened = ev.opened && ev.type === MenuType.PARTICIPANTS;

View File

@ -13,7 +13,7 @@ import {
import { skip, Subscription } from 'rxjs';
import { TokenService } from '../../services/token/token.service';
import { ChatService } from '../../services/chat/chat.service';
import { SidenavMenuService } from '../../services/sidenav-menu/sidenav-menu.service';
import { PanelService } from '../../services/panel/panel.service';
import { DocumentService } from '../../services/document/document.service';
import { OpenViduService } from '../../services/openvidu/openvidu.service';
@ -217,7 +217,7 @@ export class ToolbarComponent implements OnInit, OnDestroy {
constructor(
protected documentService: DocumentService,
protected chatService: ChatService,
protected menuService: SidenavMenuService,
protected panelService: PanelService,
protected tokenService: TokenService,
protected participantService: ParticipantService,
protected openviduService: OpenViduService,
@ -302,7 +302,7 @@ export class ToolbarComponent implements OnInit, OnDestroy {
this.onCameraButtonClicked.emit();
try {
const publishVideo = !this.participantService.hasCameraVideoActive();
const publishVideo = !this.participantService.isMyVideoActive();
await this.openviduService.publishVideo(publishVideo);
} catch (error) {
this.log.e('There was an error toggling camera:', error.code, error.message);
@ -340,7 +340,7 @@ export class ToolbarComponent implements OnInit, OnDestroy {
*/
toggleParticipantsPanel() {
this.onParticipantsPanelButtonClicked.emit();
this.menuService.toggleMenu(MenuType.PARTICIPANTS);
this.panelService.toggleMenu(MenuType.PARTICIPANTS);
}
/**
@ -348,7 +348,7 @@ export class ToolbarComponent implements OnInit, OnDestroy {
*/
toggleChatPanel() {
this.onChatPanelButtonClicked.emit();
this.menuService.toggleMenu(MenuType.CHAT);
this.panelService.toggleMenu(MenuType.CHAT);
}
/**
@ -362,8 +362,8 @@ export class ToolbarComponent implements OnInit, OnDestroy {
protected subscribeToReconnection() {
this.session.on('reconnecting', () => {
if (this.menuService.isMenuOpened()) {
this.menuService.closeMenu();
if (this.panelService.isMenuOpened()) {
this.panelService.closeMenu();
}
this.isConnectionLost = true;
});
@ -372,7 +372,7 @@ export class ToolbarComponent implements OnInit, OnDestroy {
});
}
protected subscribeToMenuToggling() {
this.menuTogglingSubscription = this.menuService.menuOpenedObs.subscribe((ev: { opened: boolean; type?: MenuType }) => {
this.menuTogglingSubscription = this.panelService.menuOpenedObs.subscribe((ev: { opened: boolean; type?: MenuType }) => {
this.isChatOpened = ev.opened && ev.type === MenuType.CHAT;
this.isParticipantsOpened = ev.opened && ev.type === MenuType.PARTICIPANTS;
if (this.isChatOpened) {
@ -383,7 +383,7 @@ export class ToolbarComponent implements OnInit, OnDestroy {
protected subscribeToChatMessages() {
this.chatMessagesSubscription = this.chatService.messagesObs.pipe(skip(1)).subscribe((messages) => {
if (!this.menuService.isMenuOpened()) {
if (!this.panelService.isMenuOpened()) {
this.unreadMessages++;
}
this.messageList = messages;

View File

@ -51,7 +51,7 @@ import { ActionService } from './services/action/action.service';
import { ChatService } from './services/chat/chat.service';
import { DocumentService } from './services/document/document.service';
import { LayoutService } from './services/layout/layout.service';
import { SidenavMenuService } from './services/sidenav-menu/sidenav-menu.service';
import { PanelService } from './services/panel/panel.service';
import { ParticipantService } from './services/participant/participant.service';
import { ParticipantPanelItemComponent } from './components/panel/participants-panel/participant-panel-item/participant-panel-item.component';
import { ParticipantsPanelComponent } from './components/panel/participants-panel/participants-panel/participants-panel.component';
@ -119,7 +119,7 @@ import { ApiDirectiveModule } from './directives/api/api.directive.module';
CdkOverlayContainer,
{ provide: OverlayContainer, useClass: CdkOverlayContainer },
ChatService,
SidenavMenuService,
PanelService,
DeviceService,
DocumentService,
LayoutService,

View File

@ -10,7 +10,7 @@ import { ActionService } from '../action/action.service';
import { OpenViduService } from '../openvidu/openvidu.service';
import { LoggerService } from '../logger/logger.service';
import { Signal } from '../../models/signal.model';
import { SidenavMenuService } from '../sidenav-menu/sidenav-menu.service';
import { PanelService } from '../panel/panel.service';
import { ParticipantService } from '../participant/participant.service';
import { MenuType } from '../../models/menu.model';
@ -30,7 +30,7 @@ export class ChatService {
protected loggerSrv: LoggerService,
protected openviduService: OpenViduService,
protected participantService: ParticipantService,
protected menuService: SidenavMenuService,
protected panelService: PanelService,
protected actionService: ActionService
) {
this.log = this.loggerSrv.get('ChatService');
@ -50,7 +50,7 @@ export class ChatService {
nickname: data.nickname,
message: data.message
});
if (!this.menuService.isMenuOpened()) {
if (!this.panelService.isMenuOpened()) {
const notificationOptions: INotificationOptions = {
message: `${data.nickname.toUpperCase()} sent a message`,
cssClassName: 'messageSnackbar',
@ -77,6 +77,6 @@ export class ChatService {
}
protected launchNotification(options: INotificationOptions) {
this.actionService.launchNotification(options, this.menuService.toggleMenu.bind(this.menuService, MenuType.CHAT));
this.actionService.launchNotification(options, this.panelService.toggleMenu.bind(this.panelService, MenuType.CHAT));
}
}

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { PanelService } from './panel.service';
describe('SidenavMenuService', () => {
let service: PanelService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(PanelService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -10,7 +10,7 @@ import { LoggerService } from '../logger/logger.service';
@Injectable({
providedIn: 'root'
})
export class SidenavMenuService {
export class PanelService {
menuOpenedObs: Observable<{ opened: boolean; type?: MenuType }>;
protected log: ILogger;
protected isChatMenuOpened: boolean = false;
@ -18,7 +18,7 @@ export class SidenavMenuService {
protected _menuOpened = <BehaviorSubject<{ opened: boolean; type?: MenuType }>>new BehaviorSubject({ opened: false });
constructor(protected loggerSrv: LoggerService) {
this.log = this.loggerSrv.get('SidenavMenuService');
this.log = this.loggerSrv.get('PanelService');
this.menuOpenedObs = this._menuOpened.asObservable();
}

View File

@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { SidenavMenuService } from './sidenav-menu.service';
describe('SidenavMenuService', () => {
let service: SidenavMenuService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(SidenavMenuService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -16,7 +16,7 @@ export * from './lib/services/token/token.service';
export * from './lib/services/device/device.service';
export * from './lib/services/action/action.service';
export * from './lib/services/layout/layout.service';
export * from './lib/services/sidenav-menu/sidenav-menu.service';
export * from './lib/services/panel/panel.service';
export * from './lib/services/cdk-overlay/cdk-overlay.service';
export * from './lib/services/storage/storage.service';