openvidu-components: Displayed dialog on PRO features

pull/763/head
Carlos Santos 2022-11-16 10:55:36 +01:00
parent 14debd515c
commit 41e9cc95eb
23 changed files with 150 additions and 24 deletions

View File

@ -1,14 +1,7 @@
import { Component, Inject } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { DialogData } from '../../models/dialog.model';
/**
* @internal
*/
export interface DialogData {
title: string;
description: string;
showActionButtons: boolean;
}
/** /**
* @internal * @internal
*/ */

View File

@ -0,0 +1,34 @@
import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { DialogData } from '../../models/dialog.model';
/**
* @internal
*/
@Component({
selector: 'ov-pro-feature-template',
template: `
<h1 mat-dialog-title>{{ data.title }}</h1>
<div mat-dialog-content>{{ data.description }}</div>
<div mat-dialog-actions *ngIf="data.showActionButtons">
<button mat-button (click)="seeMore()">
<span>{{'PANEL.SEE_MORE' | translate}}</span>
<mat-icon>open_in_new</mat-icon>
</button>
<button mat-button (click)="close()">{{'PANEL.CLOSE' | translate}}</button>
</div>
`
})
export class ProFeatureDialogTemplateComponent {
constructor(public dialogRef: MatDialogRef<ProFeatureDialogTemplateComponent>, @Inject(MAT_DIALOG_DATA) public data: DialogData) {}
close() {
this.dialogRef.close();
}
seeMore() {
window.open('https://docs.openvidu.io/en/stable/openvidu-pro/', '_blank')?.focus();
}
}

View File

@ -1,5 +1,6 @@
import { Component, Inject } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { RecordingDialogData } from '../../models/dialog.model';
/** /**
* @internal * @internal
@ -25,9 +26,8 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
}) })
export class RecordingDialogComponent { export class RecordingDialogComponent {
src: string; src: string;
type: string;
constructor(public dialogRef: MatDialogRef<RecordingDialogComponent>, @Inject(MAT_DIALOG_DATA) public data: any) { constructor(public dialogRef: MatDialogRef<RecordingDialogComponent>, @Inject(MAT_DIALOG_DATA) public data: RecordingDialogData) {
this.src = data.src; this.src = data.src;
} }
close() { close() {

View File

@ -14,6 +14,14 @@
color: var(--ov-text-color); color: var(--ov-text-color);
} }
.pro-feature {
text-align: center;
}
.pro-feture p {
font-size: 14px;
}
::ng-deep .mat-slide-toggle.mat-checked .mat-slide-toggle-bar { ::ng-deep .mat-slide-toggle.mat-checked .mat-slide-toggle-bar {
background-color: var(--ov-tertiary-color); background-color: var(--ov-tertiary-color);
} }

View File

@ -2,6 +2,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { CaptionService } from '../../../services/caption/caption.service'; import { CaptionService } from '../../../services/caption/caption.service';
import { LayoutService } from '../../../services/layout/layout.service'; import { LayoutService } from '../../../services/layout/layout.service';
import { OpenViduService } from '../../../services/openvidu/openvidu.service';
/** /**
* @internal * @internal
@ -16,13 +17,17 @@ export class CaptionsSettingComponent implements OnInit, OnDestroy {
languagesAvailable: { name: string; ISO: string }[] = []; languagesAvailable: { name: string; ISO: string }[] = [];
captionsSubscription: Subscription; captionsSubscription: Subscription;
langSelected: string; langSelected: string;
isOpenViduPro: boolean = false;
constructor(private layoutService: LayoutService, private captionService: CaptionService) {} constructor(private layoutService: LayoutService, private captionService: CaptionService, private openviduService: OpenViduService) {}
ngOnInit(): void { ngOnInit(): void {
this.subscribeToCaptions(); this.isOpenViduPro = this.openviduService.isOpenViduPro();
this.langSelected = this.captionService.getLangSelected().name; if (this.isOpenViduPro) {
this.languagesAvailable = this.captionService.getCaptionLanguages(); this.subscribeToCaptions();
this.langSelected = this.captionService.getLangSelected().name;
this.languagesAvailable = this.captionService.getCaptionLanguages();
}
} }
ngOnDestroy() { ngOnDestroy() {

View File

@ -541,14 +541,28 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
* @ignore * @ignore
*/ */
toggleBackgroundEffects() { toggleBackgroundEffects() {
this.panelService.togglePanel(PanelType.BACKGROUND_EFFECTS); if (this.openviduService.isOpenViduPro()) {
this.panelService.togglePanel(PanelType.BACKGROUND_EFFECTS);
} else {
this.actionService.openProFeatureDialog(
this.translateService.translate('PANEL.BACKGROUND.TITLE'),
this.translateService.translate('PANEL.PRO_FEATURE')
);
}
} }
/** /**
* @ignore * @ignore
*/ */
toggleCaptions() { toggleCaptions() {
this.layoutService.toggleCaptions(); if (this.openviduService.isOpenViduPro()) {
this.layoutService.toggleCaptions();
} else {
this.actionService.openProFeatureDialog(
this.translateService.translate('PANEL.SETTINGS.CAPTIONS'),
this.translateService.translate('PANEL.PRO_FEATURE')
);
}
} }
/** /**

View File

@ -280,8 +280,6 @@ export class VideoconferenceComponent implements OnInit, OnDestroy, AfterViewIni
this.openviduService.setOpenViduEdition(OpenViduEdition.PRO); this.openviduService.setOpenViduEdition(OpenViduEdition.PRO);
} else { } else {
this.openviduService.setOpenViduEdition(OpenViduEdition.CE); this.openviduService.setOpenViduEdition(OpenViduEdition.CE);
this.libService.backgroundEffectsButton.next(false);
this.libService.captionsButton.next(false);
} }
if (tokens.screen) { if (tokens.screen) {

View File

@ -57,6 +57,8 @@
}, },
"PANEL": { "PANEL": {
"CLOSE": "关闭", "CLOSE": "关闭",
"SEE_MORE": "查看更多",
"PRO_FEATURE": "此功能属于OpenVidu PRO级别",
"CHAT": { "CHAT": {
"TITLE": "聊天", "TITLE": "聊天",
"YOU": "你", "YOU": "你",

View File

@ -57,6 +57,8 @@
}, },
"PANEL": { "PANEL": {
"CLOSE": "Schließen", "CLOSE": "Schließen",
"SEE_MORE": "Mehr sehen",
"PRO_FEATURE": "Diese Funktion ist Teil des OpenVidu PRO-Tiers",
"CHAT": { "CHAT": {
"TITLE": "Chat", "TITLE": "Chat",
"YOU": "Sie", "YOU": "Sie",

View File

@ -57,6 +57,8 @@
}, },
"PANEL": { "PANEL": {
"CLOSE": "Close", "CLOSE": "Close",
"SEE_MORE": "See more",
"PRO_FEATURE": "This feature is part of OpenVidu PRO tier",
"CHAT": { "CHAT": {
"TITLE": "Chat", "TITLE": "Chat",
"YOU": "You", "YOU": "You",

View File

@ -57,6 +57,8 @@
}, },
"PANEL": { "PANEL": {
"CLOSE": "Cerrar", "CLOSE": "Cerrar",
"SEE_MORE": "Ver más",
"PRO_FEATURE": "Esta funcionalidad es parte de OpenVidu PRO",
"CHAT": { "CHAT": {
"TITLE": "Chat", "TITLE": "Chat",
"YOU": "Tú", "YOU": "Tú",

View File

@ -57,6 +57,8 @@
}, },
"PANEL": { "PANEL": {
"CLOSE": "Fermer", "CLOSE": "Fermer",
"SEE_MORE": "Voir plus",
"PRO_FEATURE": "Cette fonctionnalité fait partie de la gamme OpenVidu PRO",
"CHAT": { "CHAT": {
"TITLE": "Chat", "TITLE": "Chat",
"YOU": "Vous", "YOU": "Vous",

View File

@ -57,6 +57,8 @@
}, },
"PANEL": { "PANEL": {
"CLOSE": "बंद करें", "CLOSE": "बंद करें",
"SEE_MORE": "और देखें",
"PRO_FEATURE": "यह सुविधा OpenVidu PRO टायर का हिस्सा है",
"CHAT": { "CHAT": {
"TITLE": "बातचीत", "TITLE": "बातचीत",
"YOU": "आप", "YOU": "आप",

View File

@ -57,6 +57,8 @@
}, },
"PANEL": { "PANEL": {
"CLOSE": "Chiudi", "CLOSE": "Chiudi",
"SEE_MORE": "Vedi di più",
"PRO_FEATURE": "Questa funzione fa parte del livello OpenVidu PRO",
"CHAT": { "CHAT": {
"TITLE": "Chat", "TITLE": "Chat",
"YOU": "Tu", "YOU": "Tu",

View File

@ -57,6 +57,8 @@
}, },
"PANEL": { "PANEL": {
"CLOSE": "閉じる", "CLOSE": "閉じる",
"PRO_FEATURE": "この機能はOpenVidu PROの機能です",
"SEE_MORE": "もっと見る",
"CHAT": { "CHAT": {
"TITLE": "チャット", "TITLE": "チャット",
"YOU": "あなた", "YOU": "あなた",

View File

@ -57,6 +57,8 @@
}, },
"PANEL": { "PANEL": {
"CLOSE": "Sluiten", "CLOSE": "Sluiten",
"SEE_MORE": "Zie meer",
"PRO_FEATURE": "Deze functie is onderdeel van OpenVidu PRO tier",
"CHAT": { "CHAT": {
"TITLE": "Chat", "TITLE": "Chat",
"YOU": "Jij", "YOU": "Jij",

View File

@ -57,6 +57,8 @@
}, },
"PANEL": { "PANEL": {
"CLOSE": "Fechar", "CLOSE": "Fechar",
"SEE_MORE": "Ver mais",
"PRO_FEATURE": "Esta funcionalidade é parte do OpenVidu PRO tier",
"CHAT": { "CHAT": {
"TITLE": "Chat", "TITLE": "Chat",
"YOU": "Você", "YOU": "Você",

View File

@ -0,0 +1,16 @@
/**
* @internal
*/
export interface DialogData {
title: string;
description: string;
showActionButtons: boolean;
}
/**
* @internal
*/
export interface RecordingDialogData {
src: string;
showActionButtons: boolean;
}

View File

@ -47,6 +47,7 @@ import { AdminDashboardComponent } from './admin/dashboard/dashboard.component';
import { AdminLoginComponent } from './admin/login/login.component'; import { AdminLoginComponent } from './admin/login/login.component';
import { AvatarProfileComponent } from './components/avatar-profile/avatar-profile.component'; import { AvatarProfileComponent } from './components/avatar-profile/avatar-profile.component';
import { CaptionsComponent } from './components/captions/captions.component'; import { CaptionsComponent } from './components/captions/captions.component';
import { ProFeatureDialogTemplateComponent } from './components/dialogs/pro-feature-dialog.component';
import { ActivitiesPanelComponent } from './components/panel/activities-panel/activities-panel.component'; import { ActivitiesPanelComponent } from './components/panel/activities-panel/activities-panel.component';
import { RecordingActivityComponent } from './components/panel/activities-panel/recording-activity-panel/recording-activity.component'; import { RecordingActivityComponent } from './components/panel/activities-panel/recording-activity-panel/recording-activity.component';
import { BackgroundEffectsPanelComponent } from './components/panel/background-effects-panel/background-effects-panel.component'; import { BackgroundEffectsPanelComponent } from './components/panel/background-effects-panel/background-effects-panel.component';
@ -82,6 +83,7 @@ const privateComponents = [
AudioWaveComponent, AudioWaveComponent,
CaptionsComponent, CaptionsComponent,
DialogTemplateComponent, DialogTemplateComponent,
ProFeatureDialogTemplateComponent,
RecordingDialogComponent, RecordingDialogComponent,
DeleteDialogComponent, DeleteDialogComponent,
AvatarProfileComponent, AvatarProfileComponent,

View File

@ -9,6 +9,8 @@ export class TranslatePipe implements PipeTransform {
constructor(private translateService: TranslateService) {} constructor(private translateService: TranslateService) {}
transform(str: string): string { transform(str: string): string {
return this.translateService.translate(str);
const translation = this.translateService.translate(str);
return translation.replace('OpenVidu PRO', '<a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank">OpenVidu PRO</a>');
} }
} }

View File

@ -3,8 +3,9 @@ import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dial
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { DeleteDialogComponent } from '../../components/dialogs/delete-recording.component'; import { DeleteDialogComponent } from '../../components/dialogs/delete-recording.component';
import { RecordingDialogComponent } from '../../components/dialogs/recording-dialog.component';
import { DialogTemplateComponent } from '../../components/dialogs/dialog.component'; import { DialogTemplateComponent } from '../../components/dialogs/dialog.component';
import { ProFeatureDialogTemplateComponent } from '../../components/dialogs/pro-feature-dialog.component';
import { RecordingDialogComponent } from '../../components/dialogs/recording-dialog.component';
import { INotificationOptions } from '../../models/notification-options.model'; import { INotificationOptions } from '../../models/notification-options.model';
/** /**
@ -14,7 +15,9 @@ import { INotificationOptions } from '../../models/notification-options.model';
providedIn: 'root' providedIn: 'root'
}) })
export class ActionService { export class ActionService {
private dialogRef: MatDialogRef<DialogTemplateComponent | RecordingDialogComponent | DeleteDialogComponent>; private dialogRef:
| MatDialogRef<DialogTemplateComponent | RecordingDialogComponent | DeleteDialogComponent | ProFeatureDialogTemplateComponent>
| undefined;
private dialogSubscription: Subscription; private dialogSubscription: Subscription;
constructor(private snackBar: MatSnackBar, public dialog: MatDialog) {} constructor(private snackBar: MatSnackBar, public dialog: MatDialog) {}
@ -47,7 +50,24 @@ export class ActionService {
}; };
this.dialogRef = this.dialog.open(DialogTemplateComponent, config); this.dialogRef = this.dialog.open(DialogTemplateComponent, config);
this.dialogSubscription = this.dialogRef.afterClosed().subscribe((result) => { this.dialogSubscription = this.dialogRef.afterClosed().subscribe((result) => {
this.dialogRef = null; this.dialogRef = undefined;
});
}
}
openProFeatureDialog(titleMessage: string, descriptionMessage: string, allowClose = true) {
try {
this.closeDialog();
} catch (error) {
} finally {
const config: MatDialogConfig = {
minWidth: '250px',
data: { title: titleMessage, description: descriptionMessage, showActionButtons: allowClose },
disableClose: !allowClose
};
this.dialogRef = this.dialog.open(ProFeatureDialogTemplateComponent, config);
this.dialogSubscription = this.dialogRef.afterClosed().subscribe((result) => {
this.dialogRef = undefined;
}); });
} }
} }
@ -82,7 +102,7 @@ export class ActionService {
} }
closeDialog() { closeDialog() {
this.dialogRef.close(); this.dialogRef?.close();
if (this.dialogSubscription) this.dialogSubscription.unsubscribe(); if (this.dialogSubscription) this.dialogSubscription.unsubscribe();
} }
} }

View File

@ -106,6 +106,13 @@ export class OpenViduService {
return this.ovEdition === OpenViduEdition.CE; return this.ovEdition === OpenViduEdition.CE;
} }
/**
* @internal
*/
isOpenViduPro(): boolean {
return this.ovEdition === OpenViduEdition.PRO;
}
/** /**
* @internal * @internal
*/ */