Carlos Santos ab0cf2a343 openvidu-components: Added streaming activity
- Added streaming activity panel 
- Added streaming structurals directives
- Added streaming attributes directives
- Added e2e test
- Updated test app

openvidu-components: Updated e2e configuration


openvidu-components: Skipped pro e2e tests


openvidu-components: Allowed streaming for moderators only


openvidu-components: Request MODERATOR connection in testapp


openvidu-components: Fixed streaming signals


openvidu-components: Fixed bug with streaming status


openvidu-components: Fixed streaming button on status failed


openvidu-components: Refactored activities checks


openvidu-components: Forced streaming status to enum value


openvidu-components: Added non available error in streaming activity  

Streaming activity will show paid feature error if the service is not available
openvidu-components: Created and exported streaming error type


openvidu-components: Updated e2e tests


openvidu-components: Updated testapp 


openvidu-components: Enabled streaming input wehn module is disabled


openvidu-components: Updated e2e tests


openvidu-components: Updated docs


openvidu-components: Moved streaming directive to its component 

Moved streaming directive to streaming component instead of activities component 
openvidu-components: Updated testapp 


openvidu-components: Made streaming service public


ci: Send branch name in event dispatch


openvidu-components: Updated test app
2022-12-23 16:19:01 +01:00

119 lines
3.4 KiB
TypeScript

import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { ILogger } from '../../models/logger.model';
import { PanelEvent, PanelSettingsOptions, PanelType } from '../../models/panel.model';
import { LoggerService } from '../logger/logger.service';
@Injectable({
providedIn: 'root'
})
export class PanelService {
/**
* Panel Observable which pushes the panel status in every update.
*/
panelOpenedObs: Observable<PanelEvent>;
protected log: ILogger;
private isExternalOpened: boolean = false;
private externalType: string;
protected _panelOpened = <BehaviorSubject<PanelEvent>>new BehaviorSubject({ opened: false });
private panelMap: Map<string, boolean> = new Map();
/**
* @internal
*/
constructor(protected loggerSrv: LoggerService) {
this.log = this.loggerSrv.get('PanelService');
this.panelOpenedObs = this._panelOpened.asObservable();
Object.values(PanelType).forEach((panel) => this.panelMap.set(panel, false));
}
/**
* Open or close the panel type received. Calling this method with the panel opened and the same type panel, will close the panel.
* If the type is differente, it will switch to the properly panel.
*/
togglePanel(type: PanelType | string, expand?: PanelSettingsOptions | string) {
let nextOpenedValue: boolean = false;
if (this.panelMap.has(type)) {
this.log.d(`Toggling ${type} menu`);
this.panelMap.forEach((opened: boolean, panel: string) => {
if (panel === type) {
// Toggle panel
this.panelMap.set(panel, !opened);
nextOpenedValue = !opened;
} else {
// Close others
this.panelMap.set(panel, false);
}
});
} else {
// Panel is external
this.log.d('Toggling external panel');
// Close all panels
this.panelMap.forEach((_, panel: string) => this.panelMap.set(panel, false));
// Opening when external panel is closed or is opened with another type
this.isExternalOpened = !this.isExternalOpened || this.externalType !== type;
this.externalType = !this.isExternalOpened ? '' : type;
nextOpenedValue = this.isExternalOpened;
}
const oldType = this._panelOpened.getValue().type;
this._panelOpened.next({ opened: nextOpenedValue, type, expand, oldType });
}
/**
* @internal
*/
isPanelOpened(): boolean {
const anyOpened = Array.from(this.panelMap.values()).some((opened) => opened);
return anyOpened || this.isExternalPanelOpened();
}
/**
* Closes the panel (if opened)
*/
closePanel(): void {
this.panelMap.forEach((_, panel: string) => this.panelMap.set(panel, false));
this._panelOpened.next({ opened: false });
}
/**
* Whether the chat panel is opened or not.
*/
isChatPanelOpened(): boolean {
return !!this.panelMap.get(PanelType.CHAT);
}
/**
* Whether the participants panel is opened or not.
*/
isParticipantsPanelOpened(): boolean {
return !!this.panelMap.get(PanelType.PARTICIPANTS);
}
/**
* Whether the activities panel is opened or not.
*/
isActivitiesPanelOpened(): boolean {
return !!this.panelMap.get(PanelType.ACTIVITIES);
}
/**
* Whether the settings panel is opened or not.
*/
isSettingsPanelOpened(): boolean {
return !!this.panelMap.get(PanelType.SETTINGS);
}
/**
* Whether the background effects panel is opened or not.
*/
isBackgroundEffectsPanelOpened(): boolean {
return !!this.panelMap.get(PanelType.BACKGROUND_EFFECTS);
}
isExternalPanelOpened(): boolean {
return this.isExternalOpened;
}
}