mirror of https://github.com/OpenVidu/openvidu.git
ov-components: Implement toolbar room name directive and update toolbar to display room name dynamically
parent
6c78abdcc0
commit
020413257f
|
@ -6,7 +6,7 @@
|
||||||
id="session-info-container"
|
id="session-info-container"
|
||||||
[class.collapsed]="recordingStatus === _recordingStatus.STARTED || broadcastingStatus === _broadcastingStatus.STARTED"
|
[class.collapsed]="recordingStatus === _recordingStatus.STARTED || broadcastingStatus === _broadcastingStatus.STARTED"
|
||||||
>
|
>
|
||||||
<span id="session-name" *ngIf="!isMinimal && room && room.name && showSessionName">{{ room.name }}</span>
|
<span id="session-name" *ngIf="!isMinimal && showRoomName">{{ roomName }}</span>
|
||||||
<div
|
<div
|
||||||
id="activities-tag"
|
id="activities-tag"
|
||||||
*ngIf="recordingStatus === _recordingStatus.STARTED || broadcastingStatus === _broadcastingStatus.STARTED"
|
*ngIf="recordingStatus === _recordingStatus.STARTED || broadcastingStatus === _broadcastingStatus.STARTED"
|
||||||
|
|
|
@ -290,7 +290,12 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
showSessionName: boolean = true;
|
showRoomName: boolean = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
roomName: string = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
|
@ -419,6 +424,7 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.room = this.openviduService.getRoom();
|
this.room = this.openviduService.getRoom();
|
||||||
|
this.evalAndSetRoomName(this.libService.getRoomName());
|
||||||
|
|
||||||
this.hasVideoDevices = this.oVDevicesService.hasVideoDeviceAvailable();
|
this.hasVideoDevices = this.oVDevicesService.hasVideoDeviceAvailable();
|
||||||
this.hasAudioDevices = this.oVDevicesService.hasAudioDeviceAvailable();
|
this.hasAudioDevices = this.oVDevicesService.hasAudioDeviceAvailable();
|
||||||
|
@ -856,7 +862,12 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.libService.displayRoomName$.pipe(takeUntil(this.destroy$)).subscribe((value: boolean) => {
|
this.libService.displayRoomName$.pipe(takeUntil(this.destroy$)).subscribe((value: boolean) => {
|
||||||
this.showSessionName = value;
|
this.showRoomName = value;
|
||||||
|
this.cd.markForCheck();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.libService.roomName$.pipe(takeUntil(this.destroy$)).subscribe((value: string) => {
|
||||||
|
this.evalAndSetRoomName(value);
|
||||||
this.cd.markForCheck();
|
this.cd.markForCheck();
|
||||||
});
|
});
|
||||||
// this.libService.captionsButton$.pipe(takeUntil(this.destroy$)).subscribe((value: boolean) => {
|
// this.libService.captionsButton$.pipe(takeUntil(this.destroy$)).subscribe((value: boolean) => {
|
||||||
|
@ -894,4 +905,14 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
this.showBroadcastingButton ||
|
this.showBroadcastingButton ||
|
||||||
this.showSettingsButton;
|
this.showSettingsButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private evalAndSetRoomName(value: string) {
|
||||||
|
if (!!value) {
|
||||||
|
this.roomName = value;
|
||||||
|
} else if (!!this.room && this.room.name) {
|
||||||
|
this.roomName = this.room.name;
|
||||||
|
} else {
|
||||||
|
this.roomName = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,8 @@ import {
|
||||||
RecordingActivityShowControlsDirective,
|
RecordingActivityShowControlsDirective,
|
||||||
StartStopRecordingButtonsDirective,
|
StartStopRecordingButtonsDirective,
|
||||||
RecordingActivityViewRecordingsButtonDirective,
|
RecordingActivityViewRecordingsButtonDirective,
|
||||||
RecordingActivityShowRecordingsListDirective
|
RecordingActivityShowRecordingsListDirective,
|
||||||
|
ToolbarRoomNameDirective
|
||||||
} from './internals.directive';
|
} from './internals.directive';
|
||||||
import { ParticipantPanelItemMuteButtonDirective } from './participant-panel-item.directive';
|
import { ParticipantPanelItemMuteButtonDirective } from './participant-panel-item.directive';
|
||||||
import {
|
import {
|
||||||
|
@ -109,7 +110,8 @@ const directives = [
|
||||||
LayoutRemoteParticipantsDirective,
|
LayoutRemoteParticipantsDirective,
|
||||||
StartStopRecordingButtonsDirective,
|
StartStopRecordingButtonsDirective,
|
||||||
RecordingActivityViewRecordingsButtonDirective,
|
RecordingActivityViewRecordingsButtonDirective,
|
||||||
RecordingActivityShowRecordingsListDirective
|
RecordingActivityShowRecordingsListDirective,
|
||||||
|
ToolbarRoomNameDirective
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
|
@ -473,4 +473,54 @@ export class RecordingActivityShowRecordingsListDirective implements AfterViewIn
|
||||||
private update(value: boolean) {
|
private update(value: boolean) {
|
||||||
this.libService.updateRecordingActivityConfig({ showRecordingsList: value });
|
this.libService.updateRecordingActivityConfig({ showRecordingsList: value });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* The **toolbarRoomName** directive allows to display a specific room name in the toolbar.
|
||||||
|
* If the room name is not set, it will display the room ID instead.
|
||||||
|
*
|
||||||
|
* Can be used in {@link ToolbarComponent}.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* <ov-videoconference [toolbarRoomName]="roomName"></ov-videoconference>
|
||||||
|
*/
|
||||||
|
@Directive({
|
||||||
|
selector: 'ov-videoconference[toolbarRoomName], ov-toolbar[roomName]',
|
||||||
|
standalone: false
|
||||||
|
})
|
||||||
|
export class ToolbarRoomNameDirective implements AfterViewInit, OnDestroy {
|
||||||
|
@Input() set toolbarRoomName(value: string | undefined) {
|
||||||
|
this._roomName = value;
|
||||||
|
this.updateRoomName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Input() set roomName(value: string | undefined) {
|
||||||
|
this._roomName = value;
|
||||||
|
this.updateRoomName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _roomName?: string;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public elementRef: ElementRef,
|
||||||
|
private libService: OpenViduComponentsConfigService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
this.updateRoomName();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private clear() {
|
||||||
|
this._roomName = undefined;
|
||||||
|
this.updateRoomName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateRoomName() {
|
||||||
|
this.libService.updateToolbarConfig({ roomName: this._roomName || '' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ interface ToolbarConfig {
|
||||||
chatPanel: boolean;
|
chatPanel: boolean;
|
||||||
activitiesPanel: boolean;
|
activitiesPanel: boolean;
|
||||||
displayRoomName: boolean;
|
displayRoomName: boolean;
|
||||||
|
roomName: string;
|
||||||
displayLogo: boolean;
|
displayLogo: boolean;
|
||||||
backgroundEffects: boolean;
|
backgroundEffects: boolean;
|
||||||
recording: boolean;
|
recording: boolean;
|
||||||
|
@ -237,6 +238,7 @@ export class OpenViduComponentsConfigService {
|
||||||
prev.chatPanel === curr.chatPanel &&
|
prev.chatPanel === curr.chatPanel &&
|
||||||
prev.activitiesPanel === curr.activitiesPanel &&
|
prev.activitiesPanel === curr.activitiesPanel &&
|
||||||
prev.displayRoomName === curr.displayRoomName &&
|
prev.displayRoomName === curr.displayRoomName &&
|
||||||
|
prev.roomName === curr.roomName &&
|
||||||
prev.displayLogo === curr.displayLogo &&
|
prev.displayLogo === curr.displayLogo &&
|
||||||
prev.backgroundEffects === curr.backgroundEffects &&
|
prev.backgroundEffects === curr.backgroundEffects &&
|
||||||
prev.recording === curr.recording &&
|
prev.recording === curr.recording &&
|
||||||
|
@ -333,6 +335,7 @@ export class OpenViduComponentsConfigService {
|
||||||
chatPanel: true,
|
chatPanel: true,
|
||||||
activitiesPanel: true,
|
activitiesPanel: true,
|
||||||
displayRoomName: true,
|
displayRoomName: true,
|
||||||
|
roomName: '',
|
||||||
displayLogo: true,
|
displayLogo: true,
|
||||||
backgroundEffects: true,
|
backgroundEffects: true,
|
||||||
recording: true,
|
recording: true,
|
||||||
|
@ -409,6 +412,7 @@ export class OpenViduComponentsConfigService {
|
||||||
chatPanelButton$: Observable<boolean> = this.toolbarConfig.observable$.pipe(map((config) => config.chatPanel));
|
chatPanelButton$: Observable<boolean> = this.toolbarConfig.observable$.pipe(map((config) => config.chatPanel));
|
||||||
activitiesPanelButton$: Observable<boolean> = this.toolbarConfig.observable$.pipe(map((config) => config.activitiesPanel));
|
activitiesPanelButton$: Observable<boolean> = this.toolbarConfig.observable$.pipe(map((config) => config.activitiesPanel));
|
||||||
displayRoomName$: Observable<boolean> = this.toolbarConfig.observable$.pipe(map((config) => config.displayRoomName));
|
displayRoomName$: Observable<boolean> = this.toolbarConfig.observable$.pipe(map((config) => config.displayRoomName));
|
||||||
|
roomName$: Observable<string> = this.toolbarConfig.observable$.pipe(map((config) => config.roomName));
|
||||||
brandingLogo$: Observable<string> = this.toolbarConfig.observable$.pipe(map((config) => config.brandingLogo));
|
brandingLogo$: Observable<string> = this.toolbarConfig.observable$.pipe(map((config) => config.brandingLogo));
|
||||||
displayLogo$: Observable<boolean> = this.toolbarConfig.observable$.pipe(map((config) => config.displayLogo));
|
displayLogo$: Observable<boolean> = this.toolbarConfig.observable$.pipe(map((config) => config.displayLogo));
|
||||||
toolbarAdditionalButtonsPosition$: Observable<ToolbarAdditionalButtonsPosition> = this.toolbarConfig.observable$.pipe(
|
toolbarAdditionalButtonsPosition$: Observable<ToolbarAdditionalButtonsPosition> = this.toolbarConfig.observable$.pipe(
|
||||||
|
@ -551,6 +555,10 @@ export class OpenViduComponentsConfigService {
|
||||||
|
|
||||||
// Toolbar configuration methods
|
// Toolbar configuration methods
|
||||||
|
|
||||||
|
getRoomName(): string {
|
||||||
|
return this.toolbarConfig.subject.getValue().roomName;
|
||||||
|
}
|
||||||
|
|
||||||
setBroadcastingButton(broadcastingButton: boolean) {
|
setBroadcastingButton(broadcastingButton: boolean) {
|
||||||
this.updateToolbarConfig({ broadcasting: broadcastingButton });
|
this.updateToolbarConfig({ broadcasting: broadcastingButton });
|
||||||
}
|
}
|
||||||
|
@ -575,4 +583,4 @@ export class OpenViduComponentsConfigService {
|
||||||
showRecordingActivityRecordingsList(): boolean {
|
showRecordingActivityRecordingsList(): boolean {
|
||||||
return this.recordingActivityConfig.subject.getValue().showRecordingsList;
|
return this.recordingActivityConfig.subject.getValue().showRecordingsList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue