openvidu/openvidu-testapp/src/app/components/dialogs/events-dialog/events-dialog.component.ts

72 lines
2.6 KiB
TypeScript
Raw Normal View History

import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
selector: 'app-events-dialog',
template: `
<h2 mat-dialog-title>{{target}} events</h2>
<mat-dialog-content>
<mat-slide-toggle [(ngModel)]="checkAll" (change)="updateAll()" [color]="'warn'"><i>ALL</i></mat-slide-toggle>
<mat-divider></mat-divider>
2024-07-02 19:19:05 +02:00
<div class="row no-wrap-row">
<div class="col-50">
<div *ngFor="let event of eventArray | slice:0:(eventArray.length/2)" class="toggle">
<mat-slide-toggle
(change)="toggleEvent($event)"
[checked]="eventCollection.get(event)"
[name]="event"
color="warn">{{event}}
</mat-slide-toggle>
</div>
</div>
<div class="col-50">
<div *ngFor="let event of eventArray | slice:(eventArray.length/2 + 1):(eventArray.length)" class="toggle">
<mat-slide-toggle
(change)="toggleEvent($event)"
[checked]="eventCollection.get(event)"
[name]="event"
color="warn">{{event}}
</mat-slide-toggle>
</div>
</div>
</div>
</mat-dialog-content>
<mat-dialog-actions>
2024-07-02 19:19:05 +02:00
<button mat-button id="close-dialog-btn" mat-dialog-close="">CLOSE</button>
</mat-dialog-actions>
`,
styles: [
'mat-dialog-content { display: inline; }',
2024-07-02 19:19:05 +02:00
'mat-divider { margin-top: 5px; margin-bottom: 5px; }',
'.col-50 {flex-basis: 50%; box-sizing: border-box; padding-left: 20px; }',
'.toggle { }'
2025-02-19 12:03:43 +01:00
],
standalone: false
})
export class EventsDialogComponent {
target = '';
checkAll = true;
2024-07-02 19:19:05 +02:00
eventCollection: Map<string, boolean>;
eventArray: string[];
constructor(public dialogRef: MatDialogRef<EventsDialogComponent>,
2024-07-02 19:19:05 +02:00
@Inject(MAT_DIALOG_DATA) public data: any) {
this.target = data.target;
this.eventCollection = data.eventCollection;
2024-07-02 19:19:05 +02:00
this.eventArray = Array.from(this.eventCollection.keys());
}
updateAll() {
2024-07-02 19:19:05 +02:00
this.eventCollection.forEach((value: boolean, key: string) => {
this.eventCollection.set(key, this.checkAll);
});
}
2024-07-02 19:19:05 +02:00
toggleEvent(event: any) {
this.eventCollection.set(event.source.name, event.checked);
}
}