mirror of https://github.com/OpenVidu/openvidu.git
testapp components refactoring. Event chips added
parent
51020847dd
commit
3d98bc93e6
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "openvidu-testapp",
|
||||
"version": "0.0.0",
|
||||
"version": "1.1.0",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
|
@ -42,10 +42,10 @@
|
|||
"codelyzer": "~3.1.1",
|
||||
"jasmine-core": "~2.6.2",
|
||||
"jasmine-spec-reporter": "~4.1.0",
|
||||
"karma": "~1.7.0",
|
||||
"karma-chrome-launcher": "~2.1.1",
|
||||
"karma": "1.7.1",
|
||||
"karma-chrome-launcher": "2.2.0",
|
||||
"karma-cli": "~1.0.1",
|
||||
"karma-coverage-istanbul-reporter": "^1.2.1",
|
||||
"karma-coverage-istanbul-reporter": "^1.3.0",
|
||||
"karma-jasmine": "~1.1.0",
|
||||
"karma-jasmine-html-reporter": "^0.2.2",
|
||||
"protractor": "~5.1.2",
|
||||
|
|
|
@ -6,3 +6,13 @@
|
|||
main {
|
||||
padding: 30px 50px 30px 50px;
|
||||
}
|
||||
|
||||
#nav-logo {
|
||||
padding-right: 20px;
|
||||
font-weight: inherit;
|
||||
}
|
||||
|
||||
md-toolbar a {
|
||||
padding: 0 10px 0 10px;
|
||||
font-weight: bold;
|
||||
}
|
|
@ -1,10 +1,18 @@
|
|||
<md-sidenav-container fullscreen>
|
||||
<md-toolbar class="mat-elevation-z5" color="primary">
|
||||
<div layout-align='center center' layout='column'>
|
||||
<a routerLink="/"><img id="nav-img" src="assets/images/openvidu_vert_white_bg_trans_cropped.png"/> TestApp</a>
|
||||
</div>
|
||||
<a id="nav-logo" routerLink="/"><img id="nav-img" src="assets/images/openvidu_vert_white_bg_trans_cropped.png"/> TestApp</a>
|
||||
<a md-button routerLink="/test-sessions"><span>SESSIONS</span></a>
|
||||
<a md-button routerLink="/test-apirest"><span>API REST</span></a>
|
||||
</div>
|
||||
</md-toolbar>
|
||||
<main>
|
||||
<md-form-field>
|
||||
<input mdInput placeholder="OpenVidu Server URL" [ngModel]="openviduURL" (ngModelChange)="updateUrl($event)">
|
||||
</md-form-field>
|
||||
<md-form-field>
|
||||
<input mdInput placeholder="OpenVidu Server Secret" [ngModel]="openviduSecret" (ngModelChange)="updateSecret($event)">
|
||||
</md-form-field>
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
</md-sidenav-container>
|
||||
</md-sidenav-container>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { OpenviduParamsService } from './services/openvidu-params.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
|
@ -8,10 +9,23 @@ import { Router } from '@angular/router';
|
|||
})
|
||||
export class AppComponent {
|
||||
|
||||
constructor(private router: Router) { }
|
||||
openviduURL = 'https://localhost:8443';
|
||||
openviduSecret = 'MY_SECRET';
|
||||
|
||||
isVideoSessionUrl() {
|
||||
return (this.router.url.substring(0, '/lesson/'.length) === '/lesson/');
|
||||
constructor(private router: Router, private openviduParamsService: OpenviduParamsService) { }
|
||||
|
||||
updateUrl(url) {
|
||||
this.openviduURL = url;
|
||||
this.updateParams();
|
||||
}
|
||||
|
||||
updateSecret(secret) {
|
||||
this.openviduSecret = secret;
|
||||
this.updateParams();
|
||||
}
|
||||
|
||||
updateParams() {
|
||||
this.openviduParamsService.updateParams({ openviduUrl: this.openviduURL, openviduSecret: this.openviduSecret });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
MdListModule,
|
||||
MdRadioModule,
|
||||
MdSelectModule,
|
||||
MdChipsModule,
|
||||
MdSlideToggleModule
|
||||
} from '@angular/material';
|
||||
|
||||
|
@ -35,6 +36,7 @@ import {
|
|||
MdListModule,
|
||||
MdRadioModule,
|
||||
MdSelectModule,
|
||||
MdChipsModule,
|
||||
MdSlideToggleModule
|
||||
],
|
||||
})
|
||||
|
|
|
@ -7,16 +7,18 @@ import { AppMaterialModule } from './app.material.module';
|
|||
|
||||
import { routing } from './app.routing';
|
||||
import { AppComponent } from './app.component';
|
||||
import { DashboardComponent } from './components/dashboard/dashboard.component';
|
||||
|
||||
import { OpenviduRestService } from './services/openvidu-rest.service';
|
||||
import { TestSessionsComponent } from './components/test-sessions/test-sessions.component';
|
||||
import { TestApirestComponent } from './components/test-apirest/test-apirest.component';
|
||||
import { OpenviduInstanceComponent } from './components/openvidu-instance/openvidu-instance.component';
|
||||
import { OpenviduRestService } from './services/openvidu-rest.service';
|
||||
import { OpenviduParamsService } from './services/openvidu-params.service';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
DashboardComponent,
|
||||
OpenviduInstanceComponent
|
||||
OpenviduInstanceComponent,
|
||||
TestSessionsComponent,
|
||||
TestApirestComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -27,7 +29,8 @@ import { OpenviduInstanceComponent } from './components/openvidu-instance/openvi
|
|||
routing
|
||||
],
|
||||
providers: [
|
||||
OpenviduRestService
|
||||
OpenviduRestService,
|
||||
OpenviduParamsService
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
import { ModuleWithProviders } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
import { DashboardComponent } from './components/dashboard/dashboard.component';
|
||||
import { TestSessionsComponent } from './components/test-sessions/test-sessions.component';
|
||||
import { TestApirestComponent } from './components/test-apirest/test-apirest.component';
|
||||
|
||||
const appRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: DashboardComponent
|
||||
path: '', redirectTo: '/test-sessions', pathMatch: 'full'
|
||||
},
|
||||
{
|
||||
path: 'test-sessions',
|
||||
component: TestSessionsComponent
|
||||
},
|
||||
{
|
||||
path: 'test-apirest',
|
||||
component: TestApirestComponent
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
.demo-tab-content {
|
||||
margin-top: 30px;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table tr {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#table-row {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.first-col {
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
th {
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
#server-data-field {
|
||||
padding-top: 16px;
|
||||
}
|
||||
|
||||
app-openvidu-instance {
|
||||
display: inline-flex;
|
||||
margin: 15px 25px 0 0;
|
||||
background-color: #797979;
|
||||
padding: 10px;
|
||||
border-radius: 2px;
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
<md-form-field>
|
||||
<input mdInput placeholder="OpenVidu Server URL" [(ngModel)]="openviduURL">
|
||||
</md-form-field>
|
||||
|
||||
<md-form-field>
|
||||
<input mdInput placeholder="OpenVidu Server Secret" [(ngModel)]="openviduSecret">
|
||||
</md-form-field>
|
||||
|
||||
<md-tab-group class="demo-tab-group" dynamicHeight="true">
|
||||
|
||||
<md-tab id="audio-video" label="Test session">
|
||||
<div class="demo-tab-content">
|
||||
<div>
|
||||
<button id="add-user-btn" md-raised-button color="primary" (click)="users.push(true)">ADD USER</button>
|
||||
<button id="remove-user-btn" md-raised-button color="primary" (click)="users.pop()" [disabled]="!users.length">REMOVE USER</button>
|
||||
</div>
|
||||
<app-openvidu-instance *ngFor="let user of users" [openviduURL]="openviduURL" [openviduSecret]="openviduSecret"></app-openvidu-instance>
|
||||
</div>
|
||||
</md-tab>
|
||||
|
||||
<md-tab id="api-rest" label="API REST">
|
||||
<div class="demo-tab-content">
|
||||
<div fxLayout="row" fxLayoutGap="20px" fxLayoutAlign="start space-around">
|
||||
<div fxLayout="column" fxFlex="45" fxFlexAlign="center" fxFill>
|
||||
<button md-raised-button color="primary" (click)="getSessionId()">GET SESSIONID</button>
|
||||
</div>
|
||||
<div fxLayout="column" fxFlex="45" fxFlexAlign="center" fxFill>
|
||||
<button md-raised-button color="primary" (click)="getToken()" [disabled]="getTokenDisabled()">GET TOKEN</button>
|
||||
</div>
|
||||
<div fxLayout="column" fxFlex="10" fxFlexAlign="center" fxFill>
|
||||
<button md-raised-button color="warn" (click)="cleanAllSessions()" [disabled]="data.length == 0">CLEAN</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="table-row" fxLayout="row" fxLayoutGap="20px" fxLayoutAlign="start">
|
||||
<div fxLayout="column" fxFlex="65" fxFlexAlign="start" fxFill>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="first-col">sessionIds</th>
|
||||
<th>tokens</th>
|
||||
<th>Session</th>
|
||||
</tr>
|
||||
<tr *ngFor="let sid of this.data; let ind = index">
|
||||
<td class="first-col">
|
||||
<md-card [style.background]="getBackgroundColor(ind)">{{sid[0]}}</md-card>
|
||||
</td>
|
||||
<td>
|
||||
<md-card *ngIf="sid[1].length > 0" [style.background]="getBackgroundColor(ind)">
|
||||
<p *ngFor="let token of sid[1]">{{token}}</p>
|
||||
</md-card>
|
||||
</td>
|
||||
<td style="text-align: center">
|
||||
<md-radio-button [checked]="selectedRadioIndex === ind" (click)="selectedRadioIndex = ind" name="sidOption"></md-radio-button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div fxLayout="column" fxFlex="35" fxFlexAlign="start" fxFill>
|
||||
<table>
|
||||
<tr>
|
||||
<th>OpenVidu Role</th>
|
||||
<th>Server data</th>
|
||||
</tr>
|
||||
<tr id="tr-token-options" *ngIf="data.length > 0">
|
||||
<td>
|
||||
<md-select placeholder="OpenVidu Role" [(ngModel)]="selectedRole">
|
||||
<md-option *ngFor="let role of openViduRoles" [value]="role">
|
||||
{{ role }}
|
||||
</md-option>
|
||||
</md-select>
|
||||
</td>
|
||||
<td>
|
||||
<md-form-field id="server-data-field">
|
||||
<input mdInput placeholder="Server Data" [(ngModel)]="serverData">
|
||||
</md-form-field>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</md-tab>
|
||||
</md-tab-group>
|
|
@ -1,3 +1,10 @@
|
|||
.div-wrapper {
|
||||
display: inline-flex;
|
||||
background-color: #797979;
|
||||
padding: 10px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
md-card {
|
||||
background-color: #ffffff;
|
||||
margin: 0;
|
||||
|
@ -81,3 +88,34 @@ md-radio-button {
|
|||
.session-actions button:hover {
|
||||
color: #4d4d4d;
|
||||
}
|
||||
|
||||
.event-list {
|
||||
display: inline-block;
|
||||
width: 125px;
|
||||
max-height: 77.75px;
|
||||
margin-top: 12px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
md-chip {
|
||||
line-height: 6px;
|
||||
font-size: 9.5px;
|
||||
padding: 6px 9px !important;
|
||||
margin-bottom: 3.5px !important;
|
||||
margin-right: 5px !important;
|
||||
}
|
||||
|
||||
.scroll-custom::-webkit-scrollbar-track {
|
||||
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
|
||||
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
|
||||
background-color: #F5F5F5;
|
||||
}
|
||||
|
||||
.scroll-custom::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
background-color: #F5F5F5;
|
||||
}
|
||||
|
||||
.scroll-custom::-webkit-scrollbar-thumb {
|
||||
background-color: #797979;
|
||||
}
|
||||
|
|
|
@ -1,80 +1,91 @@
|
|||
<div>
|
||||
<md-card class="join-card">
|
||||
<div class="div-wrapper">
|
||||
|
||||
<md-card-content>
|
||||
<form class="session-form">
|
||||
<div>
|
||||
<md-card class="join-card">
|
||||
|
||||
<div>
|
||||
<md-form-field style="margin-right: 10px">
|
||||
<input mdInput placeholder="Session name" name="sessionName" [(ngModel)]="sessionName" [disabled]="session">
|
||||
</md-form-field>
|
||||
<md-card-content>
|
||||
<form class="session-form">
|
||||
|
||||
<md-form-field>
|
||||
<input mdInput placeholder="Client data" name="clientData" [(ngModel)]="clientData" [disabled]="session">
|
||||
</md-form-field>
|
||||
</div>
|
||||
<div>
|
||||
<md-form-field style="margin-right: 10px">
|
||||
<input mdInput placeholder="Session name" name="sessionName" [(ngModel)]="sessionName" [disabled]="session">
|
||||
</md-form-field>
|
||||
|
||||
<div>
|
||||
<button id="join-btn" md-button (click)="joinSession()" [disabled]="session">JOIN</button>
|
||||
<md-checkbox name="subscribeTo" (change)="toggleSubscribeTo()" [checked]="subscribeTo && checkSubscribeTo" [disabled]="disableSubscribeTo">Subscribe</md-checkbox>
|
||||
<md-checkbox name="publishTo" (change)="togglePublishTo()" [checked]="publishTo && checkPublishTo" [disabled]="disablePublishTo">Publish</md-checkbox>
|
||||
</div>
|
||||
|
||||
<div class="inner-card" fxLayout="row" fxLayoutAlign="start start">
|
||||
|
||||
<div fxFlex="60">
|
||||
<div>
|
||||
<h4>Send</h4>
|
||||
<div>
|
||||
<md-checkbox name="sendAudio" (change)="toggleSendAudio()" [checked]="sendAudio && checkSendAudio" [disabled]="disableSendAudio">Audio</md-checkbox>
|
||||
<md-checkbox name="sendVideo" (change)="toggleSendVideo()" [checked]="sendVideo && checkSendVideo" [disabled]="disableSendVideo">Video</md-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding-top: 5px;">
|
||||
<h4>Enter active</h4>
|
||||
<div>
|
||||
<md-checkbox name="activeAudio" (change)="toggleActiveAudio()" [checked]="activeAudio && checkActiveAudio" [disabled]="disableActiveAudio">Audio</md-checkbox>
|
||||
<md-checkbox name="activeVideo" (change)="toggleActiveVideo()" [checked]="activeVideo && checkActiveVideo" [disabled]="disableActiveVideo">Video</md-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
<md-form-field>
|
||||
<input mdInput placeholder="Client data" name="clientData" [(ngModel)]="clientData" [disabled]="session">
|
||||
</md-form-field>
|
||||
</div>
|
||||
|
||||
<div fxFlex="40">
|
||||
<md-radio-group [(ngModel)]="optionsVideo" [disabled]="disableRadioButtons" [ngModelOptions]="{standalone: true}">
|
||||
<div>
|
||||
<md-radio-button value="video" [checked]="checkRadioVideo && optionsVideo==='video'">Video</md-radio-button>
|
||||
</div>
|
||||
<div>
|
||||
<md-radio-button value="screen" [checked]="checkRadioScreen && optionsVideo==='screen'">Screen</md-radio-button>
|
||||
</div>
|
||||
</md-radio-group>
|
||||
<md-checkbox class="subscribe-remote-check" name="subscribeToRemote" (change)="subscribeToRemote = !subscribeToRemote" [disabled]="(!sendAudio && !sendVideo) || !publishTo || session"
|
||||
[checked]="(sendAudio || sendVideo) && publishTo && subscribeToRemote">Subscribe<br>to remote</md-checkbox>
|
||||
<div>
|
||||
<button id="join-btn" md-button (click)="joinSession()" [disabled]="session">JOIN</button>
|
||||
<md-checkbox name="subscribeTo" (change)="toggleSubscribeTo()" [checked]="subscribeTo && checkSubscribeTo" [disabled]="session || disableSubscribeTo">Subscribe</md-checkbox>
|
||||
<md-checkbox name="publishTo" (change)="togglePublishTo()" [checked]="publishTo && checkPublishTo" [disabled]="session || disablePublishTo">Publish</md-checkbox>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="inner-card" fxLayout="row" fxLayoutAlign="start start">
|
||||
|
||||
</form>
|
||||
</md-card-content>
|
||||
<div fxFlex="60">
|
||||
<div>
|
||||
<h4>Send</h4>
|
||||
<div>
|
||||
<md-checkbox name="sendAudio" (change)="toggleSendAudio()" [checked]="sendAudio && checkSendAudio" [disabled]="session || disableSendAudio">Audio</md-checkbox>
|
||||
<md-checkbox name="sendVideo" (change)="toggleSendVideo()" [checked]="sendVideo && checkSendVideo" [disabled]="session || disableSendVideo">Video</md-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding-top: 5px;">
|
||||
<h4>Enter active</h4>
|
||||
<div>
|
||||
<md-checkbox name="activeAudio" (change)="toggleActiveAudio()" [checked]="activeAudio && checkActiveAudio" [disabled]="session || disableActiveAudio">Audio</md-checkbox>
|
||||
<md-checkbox name="activeVideo" (change)="toggleActiveVideo()" [checked]="activeVideo && checkActiveVideo" [disabled]="session || disableActiveVideo">Video</md-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</md-card>
|
||||
</div>
|
||||
<div fxFlex="40">
|
||||
<md-radio-group [(ngModel)]="optionsVideo" [disabled]="session || disableRadioButtons" [ngModelOptions]="{standalone: true}">
|
||||
<div>
|
||||
<md-radio-button value="video" [checked]="checkRadioVideo && optionsVideo==='video'">Video</md-radio-button>
|
||||
</div>
|
||||
<div>
|
||||
<md-radio-button value="screen" [checked]="checkRadioScreen && optionsVideo==='screen'">Screen</md-radio-button>
|
||||
</div>
|
||||
</md-radio-group>
|
||||
<md-checkbox class="subscribe-remote-check" name="subscribeToRemote" (change)="subscribeToRemote = !subscribeToRemote" [disabled]="(!sendAudio && !sendVideo) || !publishTo || session"
|
||||
[checked]="(sendAudio || sendVideo) && publishTo && subscribeToRemote">Subscribe<br>to remote</md-checkbox>
|
||||
</div>
|
||||
|
||||
<div *ngIf="session">
|
||||
<md-card class="session-card">
|
||||
<div class="session-card-header">
|
||||
<div class="session-card-inner">
|
||||
<div class="session-title">{{sessionName}}</div>
|
||||
<div class="session-actions">
|
||||
<button><md-icon *ngIf="publishTo && sendVideo" class="md-24" aria-label="Mute video button" (click)="toggleVideo()">{{videoIcon}}</md-icon></button>
|
||||
<button><md-icon *ngIf="publishTo && sendAudio" class="md-24" aria-label="Mute audio button" (click)="toggleAudio()">{{audioIcon}}</md-icon></button>
|
||||
<button><md-icon class="md-24" aria-label="Leave button" (click)="leaveSession()">clear</md-icon></button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</md-card-content>
|
||||
|
||||
</md-card>
|
||||
</div>
|
||||
|
||||
<div *ngIf="session">
|
||||
<md-card class="session-card">
|
||||
<div class="session-card-header">
|
||||
<div class="session-card-inner">
|
||||
<div class="session-title">{{sessionName}}</div>
|
||||
<div class="session-actions">
|
||||
<button><md-icon *ngIf="publishTo && sendVideo" aria-label="Mute video button" (click)="toggleVideo()">{{videoIcon}}</md-icon></button>
|
||||
<button><md-icon *ngIf="publishTo && sendAudio" aria-label="Mute audio button" (click)="toggleAudio()">{{audioIcon}}</md-icon></button>
|
||||
<button><md-icon aria-label="Leave button" (click)="leaveSession()">clear</md-icon></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="session.connection" fxLayout>
|
||||
<div [attr.id]="'local-vid-' + session.connection.connectionId" fxFlex="135px" class="video-container"></div>
|
||||
<div [attr.id]="'remote-vid-' + session.connection.connectionId" fxFlex="270px" class="video-container"></div>
|
||||
</div>
|
||||
</md-card>
|
||||
<div *ngIf="session.connection" fxLayout>
|
||||
<div fxFlex="135px" class="video-container">
|
||||
<div [attr.id]="'local-vid-' + session.connection.connectionId"></div>
|
||||
<div #scrollMe class="event-list scroll-custom" [scrollTop]="scrollMe.scrollHeight">
|
||||
<md-chip-list class="mat-chip-list-stacked" aria-orientation="vertical">
|
||||
<md-chip *ngFor="let event of events">{{event}}</md-chip>
|
||||
</md-chip-list>
|
||||
</div>
|
||||
</div>
|
||||
<div [attr.id]="'remote-vid-' + session.connection.connectionId" fxFlex="270px" class="video-container"></div>
|
||||
</div>
|
||||
</md-card>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import { Component, Input, HostListener, ChangeDetectorRef, OnInit, OnDestroy } from '@angular/core';
|
||||
import {
|
||||
Component, Input, HostListener, ChangeDetectorRef, SimpleChanges, ElementRef, ViewChild,
|
||||
OnInit, OnDestroy, OnChanges
|
||||
} from '@angular/core';
|
||||
import { OpenVidu, Session, Subscriber, Publisher, Stream } from 'openvidu-browser';
|
||||
|
||||
declare var $: any;
|
||||
|
@ -8,10 +11,10 @@ declare var $: any;
|
|||
templateUrl: './openvidu-instance.component.html',
|
||||
styleUrls: ['./openvidu-instance.component.css']
|
||||
})
|
||||
export class OpenviduInstanceComponent implements OnInit, OnDestroy {
|
||||
export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
@Input()
|
||||
openviduURL: string;
|
||||
openviduUrl: string;
|
||||
|
||||
@Input()
|
||||
openviduSecret: string;
|
||||
|
@ -59,12 +62,23 @@ export class OpenviduInstanceComponent implements OnInit, OnDestroy {
|
|||
audioIcon = 'mic';
|
||||
videoIcon = 'videocam';
|
||||
|
||||
events: string[] = [];
|
||||
|
||||
constructor(private changeDetector: ChangeDetectorRef) {
|
||||
this.generateSessionInfo();
|
||||
}
|
||||
|
||||
ngOnInit() { }
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes.openviduSecret) {
|
||||
this.openviduSecret = changes.openviduSecret.currentValue;
|
||||
}
|
||||
if (changes.openviduUrl) {
|
||||
this.openviduUrl = changes.openviduUrl.currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.leaveSession();
|
||||
}
|
||||
|
@ -90,7 +104,7 @@ export class OpenviduInstanceComponent implements OnInit, OnDestroy {
|
|||
const OV: OpenVidu = new OpenVidu();
|
||||
|
||||
this.session = OV.initSession('wss://'
|
||||
+ this.removeHttps(this.openviduURL)
|
||||
+ this.removeHttps(this.openviduUrl)
|
||||
+ '/'
|
||||
+ this.sessionName + '?secret='
|
||||
+ this.openviduSecret);
|
||||
|
@ -103,19 +117,29 @@ export class OpenviduInstanceComponent implements OnInit, OnDestroy {
|
|||
const subscriber: Subscriber = this.session.subscribe(event.stream, 'remote-vid-' + this.session.connection.connectionId);
|
||||
subscriber.on('videoElementCreated', (e) => {
|
||||
this.appendUserData(e.element, subscriber.stream.connection.data, subscriber.stream.connection);
|
||||
this.updateEventList('videoElementCreated');
|
||||
});
|
||||
subscriber.on('videoPlaying', (e) => {
|
||||
this.updateEventList('videoPlaying');
|
||||
});
|
||||
}
|
||||
this.updateEventList('streamCreated');
|
||||
});
|
||||
|
||||
this.session.on('streamDestroyed', (event) => {
|
||||
this.removeUserData(event.stream.connection);
|
||||
this.updateEventList('streamDestroyed');
|
||||
});
|
||||
|
||||
this.session.on('connectionCreated', (event) => { });
|
||||
this.session.on('connetionDestroyed', (event) => { });
|
||||
this.session.on('sessionDisconnected', (event) => { });
|
||||
this.session.on('connectionCreated', (event) => {
|
||||
this.updateEventList('connectionCreated');
|
||||
});
|
||||
this.session.on('connetionDestroyed', (event) => {
|
||||
this.updateEventList('connetionDestroyed');
|
||||
});
|
||||
this.session.on('sessionDisconnected', (event) => {
|
||||
this.updateEventList('sessionDisconnected');
|
||||
});
|
||||
|
||||
this.session.connect(null, this.clientData, (error) => {
|
||||
if (!error) {
|
||||
|
@ -135,9 +159,15 @@ export class OpenviduInstanceComponent implements OnInit, OnDestroy {
|
|||
});
|
||||
|
||||
this.publisher.on('videoElementCreated', (event) => {
|
||||
this.updateEventList('videoElementCreated');
|
||||
});
|
||||
|
||||
this.publisher.on('videoPlaying', (e) => {
|
||||
this.updateEventList('videoPlaying');
|
||||
});
|
||||
|
||||
this.publisher.on('remoteVideoPlaying', (e) => {
|
||||
this.updateEventList('remoteVideoPlaying');
|
||||
});
|
||||
|
||||
if (this.subscribeToRemote) {
|
||||
|
@ -194,6 +224,10 @@ export class OpenviduInstanceComponent implements OnInit, OnDestroy {
|
|||
$('#remote-vid-' + this.session.connection.connectionId).find('#data-' + connection.connectionId).remove();
|
||||
}
|
||||
|
||||
private updateEventList(event: string) {
|
||||
this.events.push(event);
|
||||
}
|
||||
|
||||
toggleSubscribeTo(): void {
|
||||
this.subscribeTo = !this.subscribeTo;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table tr {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#table-row {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.first-col {
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
th {
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
#server-data-field {
|
||||
padding-top: 16px;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
<div>
|
||||
<div fxLayout="row" fxLayoutGap="20px" fxLayoutAlign="start space-around">
|
||||
<div fxLayout="column" fxFlex="45" fxFlexAlign="center" fxFill>
|
||||
<button md-raised-button color="primary" (click)="getSessionId()">GET SESSIONID</button>
|
||||
</div>
|
||||
<div fxLayout="column" fxFlex="45" fxFlexAlign="center" fxFill>
|
||||
<button md-raised-button color="primary" (click)="getToken()" [disabled]="getTokenDisabled()">GET TOKEN</button>
|
||||
</div>
|
||||
<div fxLayout="column" fxFlex="10" fxFlexAlign="center" fxFill>
|
||||
<button md-raised-button color="warn" (click)="cleanAllSessions()" [disabled]="data.length == 0">CLEAN</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="table-row" fxLayout="row" fxLayoutGap="20px" fxLayoutAlign="start">
|
||||
<div fxLayout="column" fxFlex="65" fxFlexAlign="start" fxFill>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="first-col">sessionIds</th>
|
||||
<th>tokens</th>
|
||||
<th>Session</th>
|
||||
</tr>
|
||||
<tr *ngFor="let sid of this.data; let ind = index">
|
||||
<td class="first-col">
|
||||
<md-card [style.background]="getBackgroundColor(ind)">{{sid[0]}}</md-card>
|
||||
</td>
|
||||
<td>
|
||||
<md-card *ngIf="sid[1].length > 0" [style.background]="getBackgroundColor(ind)">
|
||||
<p *ngFor="let token of sid[1]">{{token}}</p>
|
||||
</md-card>
|
||||
</td>
|
||||
<td style="text-align: center">
|
||||
<md-radio-button [checked]="selectedRadioIndex === ind" (click)="selectedRadioIndex = ind" name="sidOption"></md-radio-button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div fxLayout="column" fxFlex="35" fxFlexAlign="start" fxFill>
|
||||
<table>
|
||||
<tr>
|
||||
<th>OpenVidu Role</th>
|
||||
<th>Server data</th>
|
||||
</tr>
|
||||
<tr id="tr-token-options" *ngIf="data.length > 0">
|
||||
<td>
|
||||
<md-select placeholder="OpenVidu Role" [(ngModel)]="selectedRole">
|
||||
<md-option *ngFor="let role of openViduRoles" [value]="role">
|
||||
{{ role }}
|
||||
</md-option>
|
||||
</md-select>
|
||||
</td>
|
||||
<td>
|
||||
<md-form-field id="server-data-field">
|
||||
<input mdInput placeholder="Server Data" [(ngModel)]="serverData">
|
||||
</md-form-field>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,20 +1,20 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DashboardComponent } from './dashboard.component';
|
||||
import { TestApirestComponent } from './test-apirest.component';
|
||||
|
||||
describe('DashboardComponent', () => {
|
||||
let component: DashboardComponent;
|
||||
let fixture: ComponentFixture<DashboardComponent>;
|
||||
describe('TestApirestComponent', () => {
|
||||
let component: TestApirestComponent;
|
||||
let fixture: ComponentFixture<TestApirestComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ DashboardComponent ]
|
||||
declarations: [ TestApirestComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DashboardComponent);
|
||||
fixture = TestBed.createComponent(TestApirestComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
|
@ -1,26 +1,22 @@
|
|||
import { Component, HostListener, OnInit } from '@angular/core';
|
||||
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { OpenviduRestService } from '../../services/openvidu-rest.service';
|
||||
import { DataSource } from '@angular/cdk/table';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/observable/of';
|
||||
import { OpenviduParamsService } from '../../services/openvidu-params.service';
|
||||
|
||||
import * as colormap from 'colormap';
|
||||
const numColors = 64;
|
||||
|
||||
declare var $: any;
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
templateUrl: './dashboard.component.html',
|
||||
styleUrls: ['./dashboard.component.css'],
|
||||
selector: 'app-test-apirest',
|
||||
templateUrl: './test-apirest.component.html',
|
||||
styleUrls: ['./test-apirest.component.css']
|
||||
})
|
||||
export class DashboardComponent implements OnInit {
|
||||
export class TestApirestComponent implements OnInit, OnDestroy {
|
||||
|
||||
openviduURL = 'https://localhost:8443';
|
||||
openviduSecret = 'MY_SECRET';
|
||||
openviduUrl: string;
|
||||
openviduSecret: string;
|
||||
|
||||
// OpenViduInstance collection
|
||||
users = [true];
|
||||
paramsSubscription: Subscription;
|
||||
|
||||
// API REST params
|
||||
serverData = 'data_test';
|
||||
|
@ -33,7 +29,7 @@ export class DashboardComponent implements OnInit {
|
|||
|
||||
cg;
|
||||
|
||||
constructor(private openviduRestService: OpenviduRestService) {
|
||||
constructor(private openviduRestService: OpenviduRestService, private openviduParamsService: OpenviduParamsService) {
|
||||
const options = {
|
||||
colormap: [
|
||||
{ 'index': 0, 'rgb': [135, 196, 213] },
|
||||
|
@ -44,16 +40,24 @@ export class DashboardComponent implements OnInit {
|
|||
this.cg = colormap(options);
|
||||
}
|
||||
|
||||
ngOnInit() { }
|
||||
ngOnInit() {
|
||||
const openviduParams = this.openviduParamsService.getParams();
|
||||
this.openviduUrl = openviduParams.openviduUrl;
|
||||
this.openviduSecret = openviduParams.openviduSecret;
|
||||
|
||||
private addUser() {
|
||||
this.users.push(true);
|
||||
this.paramsSubscription = this.openviduParamsService.newParams$.subscribe(
|
||||
params => {
|
||||
this.openviduUrl = params.openviduUrl;
|
||||
this.openviduSecret = params.openviduSecret;
|
||||
});
|
||||
}
|
||||
|
||||
/* API REST TAB */
|
||||
ngOnDestroy() {
|
||||
this.paramsSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
private getSessionId() {
|
||||
this.openviduRestService.getSessionId(this.openviduURL, this.openviduSecret)
|
||||
this.openviduRestService.getSessionId(this.openviduUrl, this.openviduSecret)
|
||||
.then((sessionId) => {
|
||||
this.updateData();
|
||||
})
|
||||
|
@ -65,7 +69,7 @@ export class DashboardComponent implements OnInit {
|
|||
private getToken() {
|
||||
const sessionId = this.data[this.selectedRadioIndex][0];
|
||||
|
||||
this.openviduRestService.getToken(this.openviduURL, this.openviduSecret, sessionId, this.selectedRole, this.serverData)
|
||||
this.openviduRestService.getToken(this.openviduUrl, this.openviduSecret, sessionId, this.selectedRole, this.serverData)
|
||||
.then((token) => {
|
||||
this.updateData();
|
||||
})
|
||||
|
@ -92,6 +96,4 @@ export class DashboardComponent implements OnInit {
|
|||
this.openviduRestService.sessionIdTokenOpenViduRole.clear();
|
||||
}
|
||||
|
||||
/* API REST TAB */
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
app-openvidu-instance {
|
||||
display: inline-flex;
|
||||
margin: 25px 5px 0px 0px;
|
||||
}
|
||||
|
||||
.scenario-div {
|
||||
float: right;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<div>
|
||||
<div>
|
||||
<button id="add-user-btn" md-raised-button color="primary" (click)="users.push(true)">ADD USER</button>
|
||||
<button id="remove-user-btn" md-raised-button color="primary" (click)="users.pop()" [disabled]="!users.length">REMOVE USER</button>
|
||||
<div class="scenario-div">
|
||||
Load scenario
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<app-openvidu-instance *ngFor="let user of users; let i = index" [openviduUrl]="openviduUrl" [openviduSecret]="openviduSecret"></app-openvidu-instance>
|
||||
</div>
|
|
@ -0,0 +1,25 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TestSessionsComponent } from './test-sessions.component';
|
||||
|
||||
describe('TestSessionsComponent', () => {
|
||||
let component: TestSessionsComponent;
|
||||
let fixture: ComponentFixture<TestSessionsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ TestSessionsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TestSessionsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,42 @@
|
|||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { OpenviduParamsService } from '../../services/openvidu-params.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-test-sessions',
|
||||
templateUrl: './test-sessions.component.html',
|
||||
styleUrls: ['./test-sessions.component.css']
|
||||
})
|
||||
export class TestSessionsComponent implements OnInit, OnDestroy {
|
||||
|
||||
openviduUrl: string;
|
||||
openviduSecret: string;
|
||||
|
||||
paramsSubscription: Subscription;
|
||||
|
||||
// OpenViduInstance collection
|
||||
users = [true];
|
||||
|
||||
constructor(private openviduParamsService: OpenviduParamsService) { }
|
||||
|
||||
ngOnInit() {
|
||||
const openviduParams = this.openviduParamsService.getParams();
|
||||
this.openviduUrl = openviduParams.openviduUrl;
|
||||
this.openviduSecret = openviduParams.openviduSecret;
|
||||
|
||||
this.paramsSubscription = this.openviduParamsService.newParams$.subscribe(
|
||||
params => {
|
||||
this.openviduUrl = params.openviduUrl;
|
||||
this.openviduSecret = params.openviduSecret;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.paramsSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
private addUser() {
|
||||
this.users.push(true);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { OpenviduParamsService } from './openvidu-params.service';
|
||||
|
||||
describe('OpenviduParamsService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [OpenviduParamsService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([OpenviduParamsService], (service: OpenviduParamsService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
|
@ -0,0 +1,31 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
|
||||
export interface OpenviduParams {
|
||||
openviduUrl: string;
|
||||
openviduSecret: string;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class OpenviduParamsService {
|
||||
|
||||
params: OpenviduParams =
|
||||
{
|
||||
openviduUrl: 'https://localhost:8443/',
|
||||
openviduSecret: 'MY_SECRET'
|
||||
};
|
||||
|
||||
newParams$ = new Subject<OpenviduParams>();
|
||||
|
||||
constructor() { }
|
||||
|
||||
getParams() {
|
||||
return this.params;
|
||||
}
|
||||
|
||||
updateParams(params: any) {
|
||||
this.params = params;
|
||||
this.newParams$.next(params);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,3 @@
|
|||
* {
|
||||
font-family: 'Exo 2', sans-serif;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
|
@ -10,6 +6,10 @@ body {
|
|||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Roboto, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
cursor: inherit;
|
||||
|
@ -22,7 +22,7 @@ ul {
|
|||
}
|
||||
|
||||
video {
|
||||
max-width: 125px;
|
||||
width: 125px;
|
||||
}
|
||||
|
||||
button {
|
||||
|
@ -38,14 +38,14 @@ button {
|
|||
}
|
||||
|
||||
.video-container video {
|
||||
float: left;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.video-container div {
|
||||
.video-container div.data-node {
|
||||
float: left;
|
||||
position: relative;
|
||||
margin-left: -46%;
|
||||
margin-top: -5%;
|
||||
margin-left: -125px;
|
||||
margin-top: -14px;
|
||||
}
|
||||
|
||||
.video-container p {
|
||||
|
|
Loading…
Reference in New Issue