openvidu-elements: Added participant panel item elements directive

Allowed to add html elements to participants item
pull/707/head
csantosm 2022-03-10 12:33:49 +01:00
parent 115e9131d0
commit 412a95ea43
7 changed files with 66 additions and 18 deletions

View File

@ -5,9 +5,18 @@
.participant-nickname { .participant-nickname {
font-weight: bold !important; font-weight: bold !important;
} }
.participant-action-buttons{ .participant-action-buttons{
display: flex; display: flex;
padding-top: 0px; }
::ng-deep .participant-action-buttons > *:not(#action-btn) {
display: contents;
}
::ng-deep .participant-action-buttons > *:not(#action-btn) > * {
margin: auto;
} }
mat-list-item { mat-list-item {

View File

@ -7,6 +7,7 @@
<span class="participant-subtitle"></span> <span class="participant-subtitle"></span>
</p> --> </p> -->
<div class="participant-action-buttons">
<button <button
mat-icon-button mat-icon-button
id="action-btn" id="action-btn"
@ -17,5 +18,11 @@
<mat-icon *ngIf="!_participant.isMutedForcibly">volume_up</mat-icon> <mat-icon *ngIf="!_participant.isMutedForcibly">volume_up</mat-icon>
<mat-icon *ngIf="_participant.isMutedForcibly">volume_off</mat-icon> <mat-icon *ngIf="_participant.isMutedForcibly">volume_off</mat-icon>
</button> </button>
<!-- External item elements -->
<ng-container *ngIf="participantPanelItemElementsTemplate">
<ng-container *ngTemplateOutlet="participantPanelItemElementsTemplate"></ng-container>
</ng-container>
</div>
</mat-list-item> </mat-list-item>
</mat-list> </mat-list>

View File

@ -1,4 +1,5 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input } from '@angular/core'; import { ChangeDetectionStrategy, Component, ContentChild, Input, TemplateRef } from '@angular/core';
import { ParticipantPanelItemElementsDirective } from '../../../../directives/template/openvidu-angular.directive';
import { ParticipantAbstractModel } from '../../../../models/participant.model'; import { ParticipantAbstractModel } from '../../../../models/participant.model';
@Component({ @Component({
@ -6,9 +7,17 @@ import { ParticipantAbstractModel } from '../../../../models/participant.model';
templateUrl: './participant-panel-item.component.html', templateUrl: './participant-panel-item.component.html',
styleUrls: ['./participant-panel-item.component.css'], styleUrls: ['./participant-panel-item.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class ParticipantPanelItemComponent { export class ParticipantPanelItemComponent {
@ContentChild('participantPanelItemElements', { read: TemplateRef }) participantPanelItemElementsTemplate: TemplateRef<any>;
@ContentChild(ParticipantPanelItemElementsDirective)
set externalItemElements(externalItemElements: ParticipantPanelItemElementsDirective) {
// This directive will has value only when ITEM ELEMENTS component tagget with '*ovParticipantPanelItemElements' directive
// is inside of the P PANEL ITEM component tagged with '*ovParticipantPanelItem' directive
if (externalItemElements) {
this.participantPanelItemElementsTemplate = externalItemElements.template;
}
}
@Input() @Input()
set participant(p: ParticipantAbstractModel) { set participant(p: ParticipantAbstractModel) {
@ -21,5 +30,4 @@ export class ParticipantPanelItemComponent {
toggleMuteForcibly() { toggleMuteForcibly() {
this._participant.setMutedForcibly(!this._participant.isMutedForcibly); this._participant.setMutedForcibly(!this._participant.isMutedForcibly);
} }
} }

View File

@ -82,7 +82,13 @@
</ng-template> </ng-template>
<ng-template #defaultParticipantPanelItem let-participant> <ng-template #defaultParticipantPanelItem let-participant>
<ov-participant-panel-item [participant]="participant"></ov-participant-panel-item> <ov-participant-panel-item [participant]="participant">
<ng-template #participantPanelItemElements>
<ng-container *ngTemplateOutlet="openviduAngularParticipantPanelItemElementsTemplate; context: { $implicit: participant }"></ng-container>
</ng-template>
</ov-participant-panel-item>
</ng-template> </ng-template>
<ng-template #defaultLayout> <ng-template #defaultLayout>

View File

@ -4,6 +4,7 @@ import {
LayoutDirective, LayoutDirective,
PanelDirective, PanelDirective,
ParticipantPanelItemDirective, ParticipantPanelItemDirective,
ParticipantPanelItemElementsDirective,
ParticipantsPanelDirective, ParticipantsPanelDirective,
StreamDirective, StreamDirective,
ToolbarAdditionalButtonsDirective, ToolbarAdditionalButtonsDirective,
@ -27,6 +28,8 @@ export class VideoconferenceComponent implements OnInit, AfterViewInit {
@ContentChild(ChatPanelDirective) externalChatPanel: ChatPanelDirective; @ContentChild(ChatPanelDirective) externalChatPanel: ChatPanelDirective;
@ContentChild(ParticipantsPanelDirective) externalParticipantsPanel: ParticipantsPanelDirective; @ContentChild(ParticipantsPanelDirective) externalParticipantsPanel: ParticipantsPanelDirective;
@ContentChild(ParticipantPanelItemDirective) externalParticipantPanelItem: ParticipantPanelItemDirective; @ContentChild(ParticipantPanelItemDirective) externalParticipantPanelItem: ParticipantPanelItemDirective;
@ContentChild(ParticipantPanelItemElementsDirective) externalParticipantPanelItemElements: ParticipantPanelItemElementsDirective;
// *** Layout *** // *** Layout ***
@ContentChild(LayoutDirective) externalLayout: LayoutDirective; @ContentChild(LayoutDirective) externalLayout: LayoutDirective;
@ -46,6 +49,7 @@ export class VideoconferenceComponent implements OnInit, AfterViewInit {
openviduAngularChatPanelTemplate: TemplateRef<any>; openviduAngularChatPanelTemplate: TemplateRef<any>;
openviduAngularParticipantsPanelTemplate: TemplateRef<any>; openviduAngularParticipantsPanelTemplate: TemplateRef<any>;
openviduAngularParticipantPanelItemTemplate: TemplateRef<any>; openviduAngularParticipantPanelItemTemplate: TemplateRef<any>;
openviduAngularParticipantPanelItemElementsTemplate: TemplateRef<any>;
openviduAngularLayoutTemplate: TemplateRef<any>; openviduAngularLayoutTemplate: TemplateRef<any>;
openviduAngularStreamTemplate: TemplateRef<any>; openviduAngularStreamTemplate: TemplateRef<any>;
@ -110,7 +114,7 @@ export class VideoconferenceComponent implements OnInit, AfterViewInit {
this.log.d('Setting EXTERNAL TOOLBAR'); this.log.d('Setting EXTERNAL TOOLBAR');
} else { } else {
if (this.externalToolbarAdditionalButtons) { if (this.externalToolbarAdditionalButtons) {
this.log.d('Setting EXTERNAL TOOLBAR ADDITIONAL BUTTONS', this.externalToolbarAdditionalButtons.template); this.log.d('Setting EXTERNAL TOOLBAR ADDITIONAL BUTTONS');
this.openviduAngularToolbarAdditionalButtonsTemplate = this.externalToolbarAdditionalButtons.template; this.openviduAngularToolbarAdditionalButtonsTemplate = this.externalToolbarAdditionalButtons.template;
} }
this.openviduAngularToolbarTemplate = this.defaultToolbarTemplate; this.openviduAngularToolbarTemplate = this.defaultToolbarTemplate;
@ -132,6 +136,10 @@ export class VideoconferenceComponent implements OnInit, AfterViewInit {
this.openviduAngularParticipantPanelItemTemplate = this.externalParticipantPanelItem.template; this.openviduAngularParticipantPanelItemTemplate = this.externalParticipantPanelItem.template;
this.log.d('Setting EXTERNAL P ITEM'); this.log.d('Setting EXTERNAL P ITEM');
} else { } else {
if (this.externalParticipantPanelItemElements) {
this.log.d('Setting EXTERNAL PARTICIPANT PANEL ITEM ELEMENT');
this.openviduAngularParticipantPanelItemElementsTemplate = this.externalParticipantPanelItemElements.template;
}
this.openviduAngularParticipantPanelItemTemplate = this.defaultParticipantPanelItemTemplate; this.openviduAngularParticipantPanelItemTemplate = this.defaultParticipantPanelItemTemplate;
this.log.d('Setting DEFAULT P ITEM'); this.log.d('Setting DEFAULT P ITEM');
} }

View File

@ -3,6 +3,7 @@ import {
ChatPanelDirective, ChatPanelDirective,
LayoutDirective, LayoutDirective,
PanelDirective, PanelDirective,
ParticipantPanelItemElementsDirective,
ParticipantPanelItemDirective, ParticipantPanelItemDirective,
ParticipantsPanelDirective, ParticipantsPanelDirective,
StreamDirective, StreamDirective,
@ -19,7 +20,8 @@ import {
ParticipantsPanelDirective, ParticipantsPanelDirective,
StreamDirective, StreamDirective,
ToolbarDirective, ToolbarDirective,
ToolbarAdditionalButtonsDirective ToolbarAdditionalButtonsDirective,
ParticipantPanelItemElementsDirective
], ],
exports: [ exports: [
ChatPanelDirective, ChatPanelDirective,
@ -29,7 +31,8 @@ import {
ParticipantsPanelDirective, ParticipantsPanelDirective,
StreamDirective, StreamDirective,
ToolbarDirective, ToolbarDirective,
ToolbarAdditionalButtonsDirective ToolbarAdditionalButtonsDirective,
ParticipantPanelItemElementsDirective
] ]
}) })
export class OpenViduAngularDirectiveModule {} export class OpenViduAngularDirectiveModule {}

View File

@ -42,6 +42,13 @@ export class ParticipantPanelItemDirective {
constructor(public template: TemplateRef<any>, public viewContainer: ViewContainerRef) {} constructor(public template: TemplateRef<any>, public viewContainer: ViewContainerRef) {}
} }
@Directive({
selector: '[ovParticipantPanelItemElements]'
})
export class ParticipantPanelItemElementsDirective {
constructor(public template: TemplateRef<any>, public viewContainer: ViewContainerRef) {}
}
@Directive({ @Directive({
selector: '[ovLayout]' selector: '[ovLayout]'
}) })