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

View File

@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, On
import { skip, Subscription } from 'rxjs'; import { skip, Subscription } from 'rxjs';
import { ChatPanelDirective, ParticipantsPanelDirective } from '../../directives/template/openvidu-angular.directive'; import { ChatPanelDirective, ParticipantsPanelDirective } from '../../directives/template/openvidu-angular.directive';
import { MenuType } from '../../models/menu.model'; 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 * @ignore
*/ */
constructor(protected menuService: SidenavMenuService, private cd: ChangeDetectorRef) {} constructor(protected panelService: PanelService, private cd: ChangeDetectorRef) {}
ngOnInit(): void { ngOnInit(): void {
this.subscribeToPanelToggling(); this.subscribeToPanelToggling();
@ -95,7 +95,7 @@ export class PanelComponent implements OnInit {
} }
private subscribeToPanelToggling() { 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.isChatPanelOpened = ev.opened && ev.type === MenuType.CHAT;
this.isParticipantsPanelOpened = ev.opened && ev.type === MenuType.PARTICIPANTS; this.isParticipantsPanelOpened = ev.opened && ev.type === MenuType.PARTICIPANTS;
this.cd.markForCheck(); this.cd.markForCheck();

View File

@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, OnDestroy, OnInit, TemplateRef } from '@angular/core'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, OnDestroy, OnInit, TemplateRef } from '@angular/core';
import { ParticipantAbstractModel } from '../../../../models/participant.model'; import { ParticipantAbstractModel } from '../../../../models/participant.model';
import { ParticipantService } from '../../../../services/participant/participant.service'; 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 { ParticipantPanelItemDirective } from '../../../../directives/template/openvidu-angular.directive';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
@ -70,7 +70,7 @@ export class ParticipantsPanelComponent implements OnInit, OnDestroy {
*/ */
constructor( constructor(
protected participantService: ParticipantService, protected participantService: ParticipantService,
protected menuService: SidenavMenuService, protected PanelService: PanelService,
private cd: ChangeDetectorRef private cd: ChangeDetectorRef
) {} ) {}
@ -100,6 +100,6 @@ export class ParticipantsPanelComponent implements OnInit, OnDestroy {
} }
close() { 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 { LayoutService } from '../../services/layout/layout.service';
import { Subscription, skip } from 'rxjs'; import { Subscription, skip } from 'rxjs';
import { MenuType } from '../../models/menu.model'; 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'; import { PlatformService } from '../../services/platform/platform.service';
/** /**
@ -73,7 +73,7 @@ export class SessionComponent implements OnInit {
protected chatService: ChatService, protected chatService: ChatService,
protected tokenService: TokenService, protected tokenService: TokenService,
protected layoutService: LayoutService, protected layoutService: LayoutService,
protected menuService: SidenavMenuService, protected panelService: PanelService,
private platformService: PlatformService private platformService: PlatformService
) { ) {
this.log = this.loggerSrv.get('SessionComponent'); this.log = this.loggerSrv.get('SessionComponent');
@ -153,7 +153,7 @@ export class SessionComponent implements OnInit {
this.updateLayoutInterval = setInterval(() => this.layoutService.update(), 50); 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) { if (this.sideMenu) {
this.isChatPanelOpened = ev.opened && ev.type === MenuType.CHAT; this.isChatPanelOpened = ev.opened && ev.type === MenuType.CHAT;
this.isParticipantsPanelOpened = ev.opened && ev.type === MenuType.PARTICIPANTS; this.isParticipantsPanelOpened = ev.opened && ev.type === MenuType.PARTICIPANTS;

View File

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

View File

@ -51,7 +51,7 @@ import { ActionService } from './services/action/action.service';
import { ChatService } from './services/chat/chat.service'; import { ChatService } from './services/chat/chat.service';
import { DocumentService } from './services/document/document.service'; import { DocumentService } from './services/document/document.service';
import { LayoutService } from './services/layout/layout.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 { ParticipantService } from './services/participant/participant.service';
import { ParticipantPanelItemComponent } from './components/panel/participants-panel/participant-panel-item/participant-panel-item.component'; 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'; 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, CdkOverlayContainer,
{ provide: OverlayContainer, useClass: CdkOverlayContainer }, { provide: OverlayContainer, useClass: CdkOverlayContainer },
ChatService, ChatService,
SidenavMenuService, PanelService,
DeviceService, DeviceService,
DocumentService, DocumentService,
LayoutService, LayoutService,

View File

@ -10,7 +10,7 @@ import { ActionService } from '../action/action.service';
import { OpenViduService } from '../openvidu/openvidu.service'; import { OpenViduService } from '../openvidu/openvidu.service';
import { LoggerService } from '../logger/logger.service'; import { LoggerService } from '../logger/logger.service';
import { Signal } from '../../models/signal.model'; 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 { ParticipantService } from '../participant/participant.service';
import { MenuType } from '../../models/menu.model'; import { MenuType } from '../../models/menu.model';
@ -30,7 +30,7 @@ export class ChatService {
protected loggerSrv: LoggerService, protected loggerSrv: LoggerService,
protected openviduService: OpenViduService, protected openviduService: OpenViduService,
protected participantService: ParticipantService, protected participantService: ParticipantService,
protected menuService: SidenavMenuService, protected panelService: PanelService,
protected actionService: ActionService protected actionService: ActionService
) { ) {
this.log = this.loggerSrv.get('ChatService'); this.log = this.loggerSrv.get('ChatService');
@ -50,7 +50,7 @@ export class ChatService {
nickname: data.nickname, nickname: data.nickname,
message: data.message message: data.message
}); });
if (!this.menuService.isMenuOpened()) { if (!this.panelService.isMenuOpened()) {
const notificationOptions: INotificationOptions = { const notificationOptions: INotificationOptions = {
message: `${data.nickname.toUpperCase()} sent a message`, message: `${data.nickname.toUpperCase()} sent a message`,
cssClassName: 'messageSnackbar', cssClassName: 'messageSnackbar',
@ -77,6 +77,6 @@ export class ChatService {
} }
protected launchNotification(options: INotificationOptions) { 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({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class SidenavMenuService { export class PanelService {
menuOpenedObs: Observable<{ opened: boolean; type?: MenuType }>; menuOpenedObs: Observable<{ opened: boolean; type?: MenuType }>;
protected log: ILogger; protected log: ILogger;
protected isChatMenuOpened: boolean = false; protected isChatMenuOpened: boolean = false;
@ -18,7 +18,7 @@ export class SidenavMenuService {
protected _menuOpened = <BehaviorSubject<{ opened: boolean; type?: MenuType }>>new BehaviorSubject({ opened: false }); protected _menuOpened = <BehaviorSubject<{ opened: boolean; type?: MenuType }>>new BehaviorSubject({ opened: false });
constructor(protected loggerSrv: LoggerService) { constructor(protected loggerSrv: LoggerService) {
this.log = this.loggerSrv.get('SidenavMenuService'); this.log = this.loggerSrv.get('PanelService');
this.menuOpenedObs = this._menuOpened.asObservable(); 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/device/device.service';
export * from './lib/services/action/action.service'; export * from './lib/services/action/action.service';
export * from './lib/services/layout/layout.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/cdk-overlay/cdk-overlay.service';
export * from './lib/services/storage/storage.service'; export * from './lib/services/storage/storage.service';