2022-01-19 17:24:11 +01:00
|
|
|
import { Pipe, PipeTransform } from '@angular/core';
|
2022-01-26 11:30:30 +01:00
|
|
|
import { StreamModel, ParticipantAbstractModel } from '../models/participant.model';
|
2022-05-13 17:11:04 +02:00
|
|
|
import { TranslateService } from '../services/translate/translate.service';
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-03-03 10:21:33 +01:00
|
|
|
@Pipe({ name: 'streams' })
|
2022-02-15 13:24:08 +01:00
|
|
|
export class ParticipantStreamsPipe implements PipeTransform {
|
2022-01-19 17:24:11 +01:00
|
|
|
constructor() {}
|
|
|
|
|
2022-01-26 11:30:30 +01:00
|
|
|
transform(participants: ParticipantAbstractModel[] | ParticipantAbstractModel): StreamModel[] {
|
2022-02-15 13:24:08 +01:00
|
|
|
let streams: StreamModel[] = [];
|
2022-03-03 10:21:33 +01:00
|
|
|
if(participants && Object.keys(participants).length > 0){
|
2022-03-02 17:35:14 +01:00
|
|
|
if (Array.isArray(participants)) {
|
|
|
|
participants.forEach((p) => {
|
|
|
|
streams = streams.concat(p.getAvailableConnections());
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
|
|
|
|
streams = participants.getAvailableConnections();
|
|
|
|
}
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
2022-02-15 13:24:08 +01:00
|
|
|
return streams;
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-03-03 10:21:33 +01:00
|
|
|
@Pipe({ name: 'streamTypesEnabled' })
|
2022-03-02 17:35:14 +01:00
|
|
|
export class StreamTypesEnabledPipe implements PipeTransform {
|
2022-05-13 17:11:04 +02:00
|
|
|
constructor(private translateService: TranslateService) {}
|
2022-01-19 17:24:11 +01:00
|
|
|
|
|
|
|
transform(participant: ParticipantAbstractModel): string {
|
2022-05-13 17:11:04 +02:00
|
|
|
let result = '';
|
|
|
|
let activeStreams = participant?.getConnectionTypesActive().toString();
|
|
|
|
const activeStreamsArr: string[] = activeStreams.split(',');
|
|
|
|
activeStreamsArr.forEach((type, index) => {
|
|
|
|
result += this.translateService.translate(`PANEL.PARTICIPANTS.${type}`)
|
|
|
|
if(activeStreamsArr.length > 0 && index < activeStreamsArr.length - 1){
|
|
|
|
result += ', ';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return `(${result})`;
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
}
|