import {Component, Input} from '@angular/core'; import {HelperFunctions} from "../../utils/HelperFunctions.class"; import {EnvProperties} from "../../utils/properties/env-properties"; @Component({ selector: 'availableOn', template: `
{{available.downloadName}} [href]="url" target="_blank"> [{{(i + 1) | number}}] {{available.downloadName}}
{{available.type}} . {{available.year}}
Provider: {{available.collectedName}} {{available.collectedName}}
View less
View more
` }) export class AvailableOnComponent { @Input() availableOn: { "downloadName": string, "downloadUrl": string[], "collectedName": string, "collectedId": string, "accessMode": string[], "bestAccessMode": string, "type": string, "year": string, icon: string }[]; @Input() properties: EnvProperties; public open = 'assets/common-assets/unlock.svg'; public closed = 'assets/common-assets/lock.svg'; public unknown = 'assets/common-assets/question.svg'; public threshold: number = 4; public showNum: number = 4; constructor() { } ngOnInit() { this.availableOn.forEach(available => { if (available.bestAccessMode) { if (available.bestAccessMode.toLowerCase().indexOf('open') !== -1) { available.icon = this.open; } else if (available.bestAccessMode.toLowerCase().indexOf('not available') !== -1) { available.icon = this.unknown; } else { available.icon = this.closed; } } else { available.icon = this.unknown; } } ); } public removeUnknown(value: string): string { if(this.properties.environment === 'production') { if (value.toLowerCase() === 'unknown') { return null; } } return value; } public scroll() { HelperFunctions.scroll(); } }