2022-02-17 17:26:30 +01:00
|
|
|
import { AfterViewInit, Component, ContentChild, EventEmitter, Input, OnInit, Output, TemplateRef, ViewChild } from '@angular/core';
|
|
|
|
import {
|
|
|
|
ChatPanelDirective,
|
|
|
|
LayoutDirective,
|
|
|
|
PanelDirective,
|
|
|
|
ParticipantPanelItemDirective,
|
|
|
|
ParticipantsPanelDirective,
|
|
|
|
StreamDirective,
|
|
|
|
ToolbarDirective
|
2022-03-07 15:50:27 +01:00
|
|
|
} from '../../directives/template/openvidu-angular.directive';
|
2022-02-17 17:26:30 +01:00
|
|
|
import { ILogger } from '../../models/logger.model';
|
|
|
|
import { LoggerService } from '../../services/logger/logger.service';
|
2022-01-20 11:53:56 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'ov-videoconference',
|
|
|
|
templateUrl: './videoconference.component.html',
|
|
|
|
styleUrls: ['./videoconference.component.css']
|
|
|
|
})
|
2022-02-17 17:26:30 +01:00
|
|
|
export class VideoconferenceComponent implements OnInit, AfterViewInit {
|
2022-03-07 15:50:27 +01:00
|
|
|
// *** Toolbar ***
|
2022-02-17 17:26:30 +01:00
|
|
|
@ContentChild(ToolbarDirective) externalToolbar: ToolbarDirective;
|
2022-03-07 15:50:27 +01:00
|
|
|
|
|
|
|
// *** Panels ***
|
2022-02-17 17:26:30 +01:00
|
|
|
@ContentChild(PanelDirective) externalPanel: PanelDirective;
|
|
|
|
@ContentChild(ChatPanelDirective) externalChatPanel: ChatPanelDirective;
|
|
|
|
@ContentChild(ParticipantsPanelDirective) externalParticipantsPanel: ParticipantsPanelDirective;
|
|
|
|
@ContentChild(ParticipantPanelItemDirective) externalParticipantPanelItem: ParticipantPanelItemDirective;
|
2022-03-07 15:50:27 +01:00
|
|
|
|
|
|
|
// *** Layout ***
|
2022-02-17 17:26:30 +01:00
|
|
|
@ContentChild(LayoutDirective) externalLayout: LayoutDirective;
|
|
|
|
@ContentChild(StreamDirective) externalStream: StreamDirective;
|
2022-02-03 17:08:23 +01:00
|
|
|
|
2022-02-17 17:26:30 +01:00
|
|
|
@ViewChild('defaultToolbar', { static: false, read: TemplateRef }) defaultToolbarTemplate: TemplateRef<any>;
|
|
|
|
@ViewChild('defaultPanel', { static: false, read: TemplateRef }) defaultPanelTemplate: TemplateRef<any>;
|
|
|
|
@ViewChild('defaultChatPanel', { static: false, read: TemplateRef }) defaultChatPanelTemplate: TemplateRef<any>;
|
|
|
|
@ViewChild('defaultParticipantsPanel', { static: false, read: TemplateRef }) defaultParticipantsPanelTemplate: TemplateRef<any>;
|
|
|
|
@ViewChild('defaultParticipantPanelItem', { static: false, read: TemplateRef }) defaultParticipantPanelItemTemplate: TemplateRef<any>;
|
|
|
|
@ViewChild('defaultLayout', { static: false, read: TemplateRef }) defaultLayoutTemplate: TemplateRef<any>;
|
|
|
|
@ViewChild('defaultStream', { static: false, read: TemplateRef }) defaultStreamTemplate: TemplateRef<any>;
|
|
|
|
|
|
|
|
openviduAngularToolbarTemplate: TemplateRef<any>;
|
|
|
|
openviduAngularPanelTemplate: TemplateRef<any>;
|
|
|
|
openviduAngularChatPanelTemplate: TemplateRef<any>;
|
|
|
|
openviduAngularParticipantsPanelTemplate: TemplateRef<any>;
|
|
|
|
openviduAngularParticipantPanelItemTemplate: TemplateRef<any>;
|
|
|
|
openviduAngularLayoutTemplate: TemplateRef<any>;
|
|
|
|
openviduAngularStreamTemplate: TemplateRef<any>;
|
2022-01-20 11:53:56 +01:00
|
|
|
|
2022-03-07 15:50:27 +01:00
|
|
|
// *** Parameters ***
|
2022-02-11 13:18:50 +01:00
|
|
|
@Input() sessionName: string;
|
2022-03-07 15:50:27 +01:00
|
|
|
@Input() participantName: string;
|
2022-01-20 11:53:56 +01:00
|
|
|
|
2022-02-04 10:54:17 +01:00
|
|
|
@Input()
|
|
|
|
set tokens(tokens: { webcam: string; screen: string }) {
|
|
|
|
if (!tokens || (!tokens.webcam && !tokens.screen)) {
|
|
|
|
//No tokens received
|
|
|
|
// throw new Error('No tokens received');
|
2022-02-17 17:26:30 +01:00
|
|
|
this.log.w('No tokens received');
|
2022-02-04 10:54:17 +01:00
|
|
|
} else {
|
|
|
|
if (tokens.webcam || tokens.screen) {
|
|
|
|
this._tokens = {
|
|
|
|
webcam: tokens.webcam,
|
|
|
|
screen: tokens.screen
|
|
|
|
};
|
|
|
|
this.isSessionAlive = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-20 11:53:56 +01:00
|
|
|
|
2022-03-07 15:50:27 +01:00
|
|
|
// *** Events ***
|
|
|
|
|
|
|
|
// Event sent when user click on the join button in pre-join page
|
|
|
|
@Output() onJoinSessionClicked = new EventEmitter<any>();
|
|
|
|
|
|
|
|
// Event sent when participant has joined the session
|
|
|
|
@Output() onParticipantJoined = new EventEmitter<any>();
|
|
|
|
|
|
|
|
// Event sent when participant has left the session
|
|
|
|
@Output() onParticipantLeft = new EventEmitter<any>();
|
|
|
|
|
|
|
|
// Event sent when session has been created
|
|
|
|
@Output() onSessionCreated = new EventEmitter<any>();
|
|
|
|
|
2022-02-11 13:18:50 +01:00
|
|
|
joinSessionClicked: boolean = false;
|
2022-03-02 11:00:58 +01:00
|
|
|
// closeClicked: boolean = false;
|
2022-02-11 13:18:50 +01:00
|
|
|
isSessionAlive: boolean = false;
|
|
|
|
_tokens: { webcam: string; screen: string };
|
|
|
|
error: boolean = false;
|
|
|
|
errorMessage: string = '';
|
|
|
|
|
2022-02-17 17:26:30 +01:00
|
|
|
private log: ILogger;
|
|
|
|
|
|
|
|
constructor(private loggerSrv: LoggerService) {
|
|
|
|
this.log = this.loggerSrv.get('VideoconferenceComponent');
|
|
|
|
}
|
|
|
|
|
|
|
|
ngAfterViewInit() {
|
|
|
|
if (this.externalToolbar) {
|
|
|
|
this.openviduAngularToolbarTemplate = this.externalToolbar.template;
|
|
|
|
this.log.d('Setting EXTERNAL TOOLBAR');
|
|
|
|
} else {
|
|
|
|
this.openviduAngularToolbarTemplate = this.defaultToolbarTemplate;
|
|
|
|
this.log.d('Setting DEFAULT TOOLBAR');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.externalPanel) {
|
|
|
|
this.openviduAngularPanelTemplate = this.externalPanel.template;
|
|
|
|
this.log.d('Setting EXTERNAL PANEL');
|
|
|
|
} else {
|
|
|
|
this.log.d('Setting DEFAULT PANEL');
|
|
|
|
|
|
|
|
if (this.externalParticipantsPanel) {
|
|
|
|
this.openviduAngularParticipantsPanelTemplate = this.externalParticipantsPanel.template;
|
|
|
|
this.log.d('Setting EXTERNAL PARTICIPANTS PANEL');
|
|
|
|
} else {
|
|
|
|
this.log.d('Setting DEFAULT PARTICIPANTS PANEL');
|
|
|
|
if (this.externalParticipantPanelItem) {
|
|
|
|
this.openviduAngularParticipantPanelItemTemplate = this.externalParticipantPanelItem.template;
|
|
|
|
this.log.d('Setting EXTERNAL P ITEM');
|
|
|
|
} else {
|
|
|
|
this.openviduAngularParticipantPanelItemTemplate = this.defaultParticipantPanelItemTemplate;
|
|
|
|
this.log.d('Setting DEFAULT P ITEM');
|
|
|
|
}
|
|
|
|
this.openviduAngularParticipantsPanelTemplate = this.defaultParticipantsPanelTemplate;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.externalChatPanel) {
|
|
|
|
this.openviduAngularChatPanelTemplate = this.externalChatPanel.template;
|
|
|
|
this.log.d('Setting EXTERNAL CHAT PANEL');
|
|
|
|
} else {
|
|
|
|
this.openviduAngularChatPanelTemplate = this.defaultChatPanelTemplate;
|
|
|
|
this.log.d('Setting DEFAULT CHAT PANEL');
|
|
|
|
}
|
|
|
|
this.openviduAngularPanelTemplate = this.defaultPanelTemplate;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.externalLayout) {
|
|
|
|
this.openviduAngularLayoutTemplate = this.externalLayout.template;
|
|
|
|
this.log.d('Setting EXTERNAL LAYOUT');
|
|
|
|
} else {
|
|
|
|
this.log.d('Setting DEAFULT LAYOUT');
|
|
|
|
|
|
|
|
if (this.externalStream) {
|
|
|
|
this.openviduAngularStreamTemplate = this.externalStream.template;
|
|
|
|
this.log.d('Setting EXTERNAL STREAM');
|
|
|
|
} else {
|
|
|
|
this.openviduAngularStreamTemplate = this.defaultStreamTemplate;
|
|
|
|
this.log.d('Setting DEFAULT STREAM');
|
|
|
|
}
|
|
|
|
this.openviduAngularLayoutTemplate = this.defaultLayoutTemplate;
|
|
|
|
}
|
|
|
|
}
|
2022-02-11 13:18:50 +01:00
|
|
|
|
|
|
|
ngOnInit() {}
|
|
|
|
|
2022-02-04 10:54:17 +01:00
|
|
|
async _onJoinClicked() {
|
2022-03-02 11:00:58 +01:00
|
|
|
this.joinSessionClicked = true;
|
2022-03-07 15:50:27 +01:00
|
|
|
this.onJoinSessionClicked.emit();
|
2022-01-20 11:53:56 +01:00
|
|
|
}
|
2022-03-02 11:00:58 +01:00
|
|
|
// onLeaveSessionClicked() {
|
|
|
|
// this.isSessionAlive = false;
|
|
|
|
// this.closeClicked = true;
|
|
|
|
// }
|
2022-01-20 11:53:56 +01:00
|
|
|
}
|