mirror of https://github.com/OpenVidu/openvidu.git
ov-components: Add directive for injecting custom elements into settings panel
parent
e59ed89a0b
commit
171a5104ae
|
|
@ -93,6 +93,12 @@
|
||||||
</mat-list>
|
</mat-list>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
<!-- Additional elements injected via directive -->
|
||||||
|
@if (generalAdditionalElementsTemplate) {
|
||||||
|
<div class="additional-elements-section">
|
||||||
|
<ng-container *ngTemplateOutlet="generalAdditionalElementsTemplate"></ng-container>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="showCameraButton && selectedOption === settingsOptions.VIDEO" class="video-settings">
|
<div *ngIf="showCameraButton && selectedOption === settingsOptions.VIDEO" class="video-settings">
|
||||||
<ov-video-devices-select
|
<ov-video-devices-select
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
import { Component, ContentChild, EventEmitter, OnInit, Output, TemplateRef } from '@angular/core';
|
||||||
import { Subject, takeUntil } from 'rxjs';
|
import { Subject, takeUntil } from 'rxjs';
|
||||||
import { PanelStatusInfo, PanelSettingsOptions, PanelType } from '../../../models/panel.model';
|
import { PanelStatusInfo, PanelSettingsOptions, PanelType } from '../../../models/panel.model';
|
||||||
import { OpenViduComponentsConfigService } from '../../../services/config/directive-config.service';
|
import { OpenViduComponentsConfigService } from '../../../services/config/directive-config.service';
|
||||||
|
|
@ -7,6 +7,7 @@ import { PlatformService } from '../../../services/platform/platform.service';
|
||||||
import { ViewportService } from '../../../services/viewport/viewport.service';
|
import { ViewportService } from '../../../services/viewport/viewport.service';
|
||||||
import { CustomDevice } from '../../../models/device.model';
|
import { CustomDevice } from '../../../models/device.model';
|
||||||
import { LangOption } from '../../../models/lang.model';
|
import { LangOption } from '../../../models/lang.model';
|
||||||
|
import { SettingsPanelGeneralAdditionalElementsDirective } from '../../../directives/template/internals.directive';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
|
@ -23,6 +24,14 @@ export class SettingsPanelComponent implements OnInit {
|
||||||
@Output() onAudioEnabledChanged = new EventEmitter<boolean>();
|
@Output() onAudioEnabledChanged = new EventEmitter<boolean>();
|
||||||
@Output() onAudioDeviceChanged = new EventEmitter<CustomDevice>();
|
@Output() onAudioDeviceChanged = new EventEmitter<CustomDevice>();
|
||||||
@Output() onLangChanged = new EventEmitter<LangOption>();
|
@Output() onLangChanged = new EventEmitter<LangOption>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* ContentChild for custom elements in general section
|
||||||
|
*/
|
||||||
|
@ContentChild(SettingsPanelGeneralAdditionalElementsDirective)
|
||||||
|
externalGeneralAdditionalElements!: SettingsPanelGeneralAdditionalElementsDirective;
|
||||||
|
|
||||||
settingsOptions: typeof PanelSettingsOptions = PanelSettingsOptions;
|
settingsOptions: typeof PanelSettingsOptions = PanelSettingsOptions;
|
||||||
selectedOption: PanelSettingsOptions = PanelSettingsOptions.GENERAL;
|
selectedOption: PanelSettingsOptions = PanelSettingsOptions.GENERAL;
|
||||||
showCameraButton: boolean = true;
|
showCameraButton: boolean = true;
|
||||||
|
|
@ -32,6 +41,14 @@ export class SettingsPanelComponent implements OnInit {
|
||||||
isMobile: boolean = false;
|
isMobile: boolean = false;
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* Gets the template for additional elements in general section
|
||||||
|
*/
|
||||||
|
get generalAdditionalElementsTemplate(): TemplateRef<any> | undefined {
|
||||||
|
return this.externalGeneralAdditionalElements?.template;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private panelService: PanelService,
|
private panelService: PanelService,
|
||||||
private platformService: PlatformService,
|
private platformService: PlatformService,
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,11 @@
|
||||||
(onAudioDeviceChanged)="onAudioDeviceChanged.emit($event)"
|
(onAudioDeviceChanged)="onAudioDeviceChanged.emit($event)"
|
||||||
(onAudioEnabledChanged)="onAudioEnabledChanged.emit($event)"
|
(onAudioEnabledChanged)="onAudioEnabledChanged.emit($event)"
|
||||||
(onLangChanged)="onLangChanged.emit($event)"
|
(onLangChanged)="onLangChanged.emit($event)"
|
||||||
></ov-settings-panel>
|
>
|
||||||
|
<ng-container *ovSettingsPanelGeneralAdditionalElements>
|
||||||
|
<ng-container *ngTemplateOutlet="ovSettingsPanelGeneralAdditionalElementsTemplate"></ng-container>
|
||||||
|
</ng-container>
|
||||||
|
</ov-settings-panel>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ng-template #activitiesPanel>
|
<ng-template #activitiesPanel>
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,8 @@ import {
|
||||||
LayoutAdditionalElementsDirective,
|
LayoutAdditionalElementsDirective,
|
||||||
ParticipantPanelAfterLocalParticipantDirective,
|
ParticipantPanelAfterLocalParticipantDirective,
|
||||||
PreJoinDirective,
|
PreJoinDirective,
|
||||||
LeaveButtonDirective
|
LeaveButtonDirective,
|
||||||
|
SettingsPanelGeneralAdditionalElementsDirective
|
||||||
} from '../../directives/template/internals.directive';
|
} from '../../directives/template/internals.directive';
|
||||||
import { OpenViduThemeService } from '../../services/theme/theme.service';
|
import { OpenViduThemeService } from '../../services/theme/theme.service';
|
||||||
import { E2eeService } from '../../services/e2ee/e2ee.service';
|
import { E2eeService } from '../../services/e2ee/e2ee.service';
|
||||||
|
|
@ -375,6 +376,22 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
|
||||||
return this._externalLayoutAdditionalElements;
|
return this._externalLayoutAdditionalElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _externalSettingsPanelGeneralAdditionalElements?: SettingsPanelGeneralAdditionalElementsDirective;
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
@ContentChild(SettingsPanelGeneralAdditionalElementsDirective)
|
||||||
|
set externalSettingsPanelGeneralAdditionalElements(value: SettingsPanelGeneralAdditionalElementsDirective) {
|
||||||
|
this._externalSettingsPanelGeneralAdditionalElements = value;
|
||||||
|
this.setupTemplates();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
get externalSettingsPanelGeneralAdditionalElements(): SettingsPanelGeneralAdditionalElementsDirective | undefined {
|
||||||
|
return this._externalSettingsPanelGeneralAdditionalElements;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
|
@ -477,6 +494,10 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
ovLayoutAdditionalElementsTemplate: TemplateRef<any>;
|
ovLayoutAdditionalElementsTemplate: TemplateRef<any>;
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
ovSettingsPanelGeneralAdditionalElementsTemplate: TemplateRef<any>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
|
@ -786,7 +807,8 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
|
||||||
layout: this.externalLayout,
|
layout: this.externalLayout,
|
||||||
stream: this.externalStream,
|
stream: this.externalStream,
|
||||||
preJoin: this.externalPreJoin,
|
preJoin: this.externalPreJoin,
|
||||||
layoutAdditionalElements: this.externalLayoutAdditionalElements
|
layoutAdditionalElements: this.externalLayoutAdditionalElements,
|
||||||
|
settingsPanelGeneralAdditionalElements: this.externalSettingsPanelGeneralAdditionalElements
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultTemplates: DefaultTemplates = {
|
const defaultTemplates: DefaultTemplates = {
|
||||||
|
|
@ -861,6 +883,9 @@ export class VideoconferenceComponent implements OnDestroy, AfterViewInit {
|
||||||
if (this.templateConfig.layoutAdditionalElementsTemplate) {
|
if (this.templateConfig.layoutAdditionalElementsTemplate) {
|
||||||
assignIfChanged('ovLayoutAdditionalElementsTemplate', this.templateConfig.layoutAdditionalElementsTemplate);
|
assignIfChanged('ovLayoutAdditionalElementsTemplate', this.templateConfig.layoutAdditionalElementsTemplate);
|
||||||
}
|
}
|
||||||
|
if (this.templateConfig.settingsPanelGeneralAdditionalElementsTemplate) {
|
||||||
|
assignIfChanged('ovSettingsPanelGeneralAdditionalElementsTemplate', this.templateConfig.settingsPanelGeneralAdditionalElementsTemplate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -308,3 +308,38 @@ export class ParticipantPanelParticipantBadgeDirective {
|
||||||
public container: ViewContainerRef
|
public container: ViewContainerRef
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ***ovSettingsPanelGeneralAdditionalElements** directive allows you to inject custom HTML or Angular templates
|
||||||
|
* into the general section of the settings panel.
|
||||||
|
* This enables you to add custom controls, information, or UI elements to extend the settings panel functionality.
|
||||||
|
*
|
||||||
|
* Usage example:
|
||||||
|
* ```html
|
||||||
|
* <ov-videoconference>
|
||||||
|
* <ng-container *ovSettingsPanelGeneralAdditionalElements>
|
||||||
|
* <div class="custom-settings-section">
|
||||||
|
* <mat-list>
|
||||||
|
* <mat-list-item>
|
||||||
|
* <mat-icon matListItemIcon>tune</mat-icon>
|
||||||
|
* <div matListItemTitle>Custom Setting</div>
|
||||||
|
* <mat-slide-toggle matListItemMeta [(ngModel)]="customSetting"></mat-slide-toggle>
|
||||||
|
* </mat-list-item>
|
||||||
|
* </mat-list>
|
||||||
|
* </div>
|
||||||
|
* </ng-container>
|
||||||
|
* </ov-videoconference>
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
@Directive({
|
||||||
|
selector: '[ovSettingsPanelGeneralAdditionalElements]',
|
||||||
|
standalone: false
|
||||||
|
})
|
||||||
|
export class SettingsPanelGeneralAdditionalElementsDirective {
|
||||||
|
constructor(
|
||||||
|
public template: TemplateRef<any>,
|
||||||
|
public container: ViewContainerRef
|
||||||
|
) {}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ import {
|
||||||
ParticipantPanelAfterLocalParticipantDirective,
|
ParticipantPanelAfterLocalParticipantDirective,
|
||||||
ParticipantPanelParticipantBadgeDirective,
|
ParticipantPanelParticipantBadgeDirective,
|
||||||
PreJoinDirective,
|
PreJoinDirective,
|
||||||
LeaveButtonDirective
|
LeaveButtonDirective,
|
||||||
|
SettingsPanelGeneralAdditionalElementsDirective
|
||||||
} from './internals.directive';
|
} from './internals.directive';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
@ -40,7 +41,8 @@ import {
|
||||||
PreJoinDirective,
|
PreJoinDirective,
|
||||||
ParticipantPanelAfterLocalParticipantDirective,
|
ParticipantPanelAfterLocalParticipantDirective,
|
||||||
LayoutAdditionalElementsDirective,
|
LayoutAdditionalElementsDirective,
|
||||||
ParticipantPanelParticipantBadgeDirective
|
ParticipantPanelParticipantBadgeDirective,
|
||||||
|
SettingsPanelGeneralAdditionalElementsDirective
|
||||||
// BackgroundEffectsPanelDirective
|
// BackgroundEffectsPanelDirective
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
|
|
@ -60,7 +62,8 @@ import {
|
||||||
PreJoinDirective,
|
PreJoinDirective,
|
||||||
ParticipantPanelAfterLocalParticipantDirective,
|
ParticipantPanelAfterLocalParticipantDirective,
|
||||||
LayoutAdditionalElementsDirective,
|
LayoutAdditionalElementsDirective,
|
||||||
ParticipantPanelParticipantBadgeDirective
|
ParticipantPanelParticipantBadgeDirective,
|
||||||
|
SettingsPanelGeneralAdditionalElementsDirective
|
||||||
// BackgroundEffectsPanelDirective
|
// BackgroundEffectsPanelDirective
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ import {
|
||||||
PreJoinDirective,
|
PreJoinDirective,
|
||||||
ParticipantPanelAfterLocalParticipantDirective,
|
ParticipantPanelAfterLocalParticipantDirective,
|
||||||
LayoutAdditionalElementsDirective,
|
LayoutAdditionalElementsDirective,
|
||||||
LeaveButtonDirective
|
LeaveButtonDirective,
|
||||||
|
SettingsPanelGeneralAdditionalElementsDirective
|
||||||
} from '../../directives/template/internals.directive';
|
} from '../../directives/template/internals.directive';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -49,6 +50,9 @@ export interface TemplateConfiguration {
|
||||||
streamTemplate: TemplateRef<any>;
|
streamTemplate: TemplateRef<any>;
|
||||||
layoutAdditionalElementsTemplate?: TemplateRef<any>;
|
layoutAdditionalElementsTemplate?: TemplateRef<any>;
|
||||||
|
|
||||||
|
// Settings panel templates
|
||||||
|
settingsPanelGeneralAdditionalElementsTemplate?: TemplateRef<any>;
|
||||||
|
|
||||||
// PreJoin template
|
// PreJoin template
|
||||||
preJoinTemplate?: TemplateRef<any>;
|
preJoinTemplate?: TemplateRef<any>;
|
||||||
}
|
}
|
||||||
|
|
@ -126,6 +130,7 @@ export interface ExternalDirectives {
|
||||||
stream?: StreamDirective;
|
stream?: StreamDirective;
|
||||||
preJoin?: PreJoinDirective;
|
preJoin?: PreJoinDirective;
|
||||||
layoutAdditionalElements?: LayoutAdditionalElementsDirective;
|
layoutAdditionalElements?: LayoutAdditionalElementsDirective;
|
||||||
|
settingsPanelGeneralAdditionalElements?: SettingsPanelGeneralAdditionalElementsDirective;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -208,6 +213,11 @@ export class TemplateManagerService {
|
||||||
config.layoutAdditionalElementsTemplate = externalDirectives.layoutAdditionalElements.template;
|
config.layoutAdditionalElementsTemplate = externalDirectives.layoutAdditionalElements.template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (externalDirectives.settingsPanelGeneralAdditionalElements) {
|
||||||
|
this.log.v('Setting EXTERNAL SETTINGS PANEL GENERAL ADDITIONAL ELEMENTS');
|
||||||
|
config.settingsPanelGeneralAdditionalElementsTemplate = externalDirectives.settingsPanelGeneralAdditionalElements.template;
|
||||||
|
}
|
||||||
|
|
||||||
this.log.v('Template setup completed', config);
|
this.log.v('Template setup completed', config);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue