Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 28x 28x 28x 28x 50x 20x 19x 1x 1x | import { Injectable } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { Attachment } from 'ish-core/models/attachment/attachment.model';
import { getICMServerURL } from 'ish-core/store/core/configuration';
import { AttachmentData } from './attachment.interface';
@Injectable({ providedIn: 'root' })
export class AttachmentMapper {
private icmServerURL: string;
constructor(store: Store) {
store.pipe(select(getICMServerURL)).subscribe(url => (this.icmServerURL = url));
}
fromAttachments(attachments: AttachmentData[]): Attachment[] {
if (!attachments || attachments.length === 0) {
return;
}
return attachments.map(attachment => this.fromAttachment(attachment));
}
private fromAttachment(attachment: AttachmentData): Attachment {
return {
name: attachment.name,
type: attachment.type,
key: attachment.key,
description: attachment.description,
url: `${this.icmServerURL}/${attachment.link.uri}`,
};
}
}
|