From 49313a4a9d4ce8a9199f4a8814e4974710a7e941 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Thu, 24 Jan 2019 16:40:25 +0100 Subject: [PATCH] openvidu-ionic: settings alert to change OpenVidu Server config --- openvidu-ionic/src/app/app.component.html | 9 ++++- openvidu-ionic/src/app/app.component.ts | 40 +++++++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/openvidu-ionic/src/app/app.component.html b/openvidu-ionic/src/app/app.component.html index 95d64b99f..da418d365 100644 --- a/openvidu-ionic/src/app/app.component.html +++ b/openvidu-ionic/src/app/app.component.html @@ -12,7 +12,7 @@ - +

Join a video session

@@ -30,6 +30,13 @@

Join a video session

Join + + + + + +
diff --git a/openvidu-ionic/src/app/app.component.ts b/openvidu-ionic/src/app/app.component.ts index 5f29bd90d..9047a9d9c 100644 --- a/openvidu-ionic/src/app/app.component.ts +++ b/openvidu-ionic/src/app/app.component.ts @@ -3,7 +3,7 @@ import { Component, HostListener, OnDestroy } from '@angular/core'; import { AndroidPermissions } from '@ionic-native/android-permissions/ngx'; import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { StatusBar } from '@ionic-native/status-bar/ngx'; -import { Platform } from '@ionic/angular'; +import { Platform, AlertController } from '@ionic/angular'; import { OpenVidu, Publisher, Session, StreamEvent, StreamManager, Subscriber } from 'openvidu-browser'; import { throwError as observableThrowError } from 'rxjs'; import { catchError } from 'rxjs/operators'; @@ -41,6 +41,7 @@ export class AppComponent implements OnDestroy { private statusBar: StatusBar, private httpClient: HttpClient, private androidPermissions: AndroidPermissions, + public alertController: AlertController ) { this.initializeApp(); this.generateParticipantInfo(); @@ -152,7 +153,7 @@ export class AppComponent implements OnDestroy { // --- 6) Publish your stream --- this.session.publish(publisher).then(() => { - // Store our Publisher + // Store our Publisher this.publisher = publisher; }); } @@ -251,6 +252,41 @@ export class AppComponent implements OnDestroy { } } + async presentSettingsAlert() { + const alert = await this.alertController.create({ + header: 'OpenVidu Server config', + inputs: [ + { + name: 'url', + type: 'text', + value: 'https://demos.openvidu.io:4443/', + placeholder: 'URL' + }, + { + name: 'secret', + type: 'text', + value: 'MY_SECRET', + placeholder: 'Secret' + } + ], + buttons: [ + { + text: 'Cancel', + role: 'cancel', + cssClass: 'secondary' + }, { + text: 'Ok', + handler: data => { + this.OPENVIDU_SERVER_URL = data.url; + this.OPENVIDU_SERVER_SECRET = data.secret; + } + } + ] + }); + + await alert.present(); + } + /* * -------------------------- * SERVER-SIDE RESPONSIBILITY