diff --git a/landingPages/landing-utils/availableOn.component.ts b/landingPages/landing-utils/availableOn.component.ts index 0b635e4d..a3b3ff8f 100644 --- a/landingPages/landing-utils/availableOn.component.ts +++ b/landingPages/landing-utils/availableOn.component.ts @@ -1,6 +1,7 @@ import {Component, Input} from '@angular/core'; import {HelperFunctions} from "../../utils/HelperFunctions.class"; import {EnvProperties} from "../../utils/properties/env-properties"; +import {HostedByCollectedFrom} from "../../utils/result-preview/result-preview"; @Component({ selector: 'availableOn', @@ -57,16 +58,17 @@ import {EnvProperties} from "../../utils/properties/env-properties"; }) export class AvailableOnComponent { - @Input() availableOn: { - "downloadName": string, "downloadUrl": string[], - "collectedName": string, "collectedId": string, - "accessMode": string[], "bestAccessMode": string, - "type": string, "year": string, icon: string - }[]; + @Input() availableOn: HostedByCollectedFrom[]; + // { + // "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 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; @@ -74,20 +76,20 @@ export class AvailableOnComponent { } 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; - } - } - ); + // 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 { diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts index 2fcaede7..a319f120 100644 --- a/landingPages/landing-utils/parsingFunctions.class.ts +++ b/landingPages/landing-utils/parsingFunctions.class.ts @@ -2,7 +2,10 @@ import {HostedByCollectedFrom, Journal, Project, RelationResult} from "../../uti import {Reference} from "../../utils/entities/resultLandingInfo"; export class ParsingFunctions { - + public open = 'assets/common-assets/unlock.svg'; + public closed = 'assets/common-assets/lock.svg'; + public unknown = 'assets/common-assets/question.svg'; + constructor() { } @@ -147,7 +150,8 @@ export class ParsingFunctions { accessMode: null, bestAccessMode: null, type: "", - year: "" + year: "", + icon: "" }; if (journal && journal.journal) { @@ -162,6 +166,8 @@ export class ParsingFunctions { available.accessMode = new Array(); available.downloadUrl.push(url); + + available.icon = this.unknown; /* if(title != undefined && title['url'] == "") { title['url'] = url; @@ -245,7 +251,8 @@ export class ParsingFunctions { "accessMode": null, "bestAccessMode": null, "type": "", - "year": "" + "year": "", + "icon": "" }; if (instance['hostedby'].name && instance['hostedby'].name != "other resources" && instance['hostedby'].name != "Unknown Repository") { @@ -267,9 +274,13 @@ export class ParsingFunctions { available.downloadName = downloadName; } } - + } - + + if(!available.downloadName) { + available.downloadName = url.substring(0, 30) + '...'; // substring(from, to); + } + if (available.downloadName) { if (instance.hasOwnProperty("collectedfrom")) { available.collectedId = instance['collectedfrom'].id; @@ -317,6 +328,18 @@ export class ParsingFunctions { } else if (url) { available['accessMode'].push(""); } + + 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; + } hostedBy_collectedFrom.push(available); } diff --git a/landingPages/result/deletedByInference/deletedByInference.service.ts b/landingPages/result/deletedByInference/deletedByInference.service.ts index 340b777c..aca6897c 100644 --- a/landingPages/result/deletedByInference/deletedByInference.service.ts +++ b/landingPages/result/deletedByInference/deletedByInference.service.ts @@ -4,6 +4,7 @@ import {ResultLandingInfo} from '../../../utils/entities/resultLandingInfo'; import {EnvProperties} from '../../../utils/properties/env-properties'; import {ParsingFunctions} from '../../landing-utils/parsingFunctions.class'; import {map} from "rxjs/operators"; +import {HostedByCollectedFrom} from "../../../utils/result-preview/result-preview"; @Injectable() export class DeletedByInferenceService { @@ -86,7 +87,7 @@ export class DeletedByInferenceService { result.types = new Array(); let types = new Set(); - result.hostedBy_collectedFrom = new Array<{"downloadName": string, "downloadUrl": string[], "collectedName": string, "collectedId": string, "accessMode": string[], "bestAccessMode": string, "type": string, "year":string}>(); + result.hostedBy_collectedFrom = new Array(); let counter = 0; let instance; diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index 2090bfd0..71f43e7d 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -5,7 +5,7 @@ import {ResultLandingInfo} from '../../utils/entities/resultLandingInfo'; import {EnvProperties} from '../../utils/properties/env-properties'; import {ParsingFunctions} from '../landing-utils/parsingFunctions.class'; import {map, tap} from "rxjs/operators"; -import {Organization} from "../../utils/result-preview/result-preview"; +import {HostedByCollectedFrom, Organization} from "../../utils/result-preview/result-preview"; @Injectable() export class ResultLandingService { @@ -161,7 +161,7 @@ export class ResultLandingService { } if(data[3].hasOwnProperty("instance")) { - this.resultLandingInfo.hostedBy_collectedFrom = new Array<{"downloadName": string, "downloadUrl": string[], "collectedName": string, "collectedId": string, "accessMode": string[], "bestAccessMode": string, "type": string, "year":string}>(); + this.resultLandingInfo.hostedBy_collectedFrom = new Array(); this.resultLandingInfo.types = new Array(); diff --git a/utils/result-preview/result-preview.component.html b/utils/result-preview/result-preview.component.html index 392f3098..87ba2f38 100644 --- a/utils/result-preview/result-preview.component.html +++ b/utils/result-preview/result-preview.component.html @@ -64,6 +64,11 @@ Project Code: {{result.code}} + + + + +
@@ -209,7 +214,11 @@
-
+
+ + + Download from: Provider: + + [href]="from.downloadUrl[0]" (click)="onClick();"> {{from.collectedName}} - + {{from.collectedName}} diff --git a/utils/result-preview/result-preview.ts b/utils/result-preview/result-preview.ts index df3c7391..a45d82c5 100644 --- a/utils/result-preview/result-preview.ts +++ b/utils/result-preview/result-preview.ts @@ -11,6 +11,7 @@ export interface HostedByCollectedFrom { bestAccessMode: string; type: string; year: string; + icon: string } export interface Journal { @@ -102,6 +103,7 @@ export class ResultPreview { //projects: acronym: string; code: string; + // callIdentifier: string; // currently not parsed funderShortname: string; budget: string; contribution: string; @@ -154,6 +156,7 @@ export class ResultPreview { resultPreview.organizations = result.organizations; resultPreview.acronym = result.acronym; resultPreview.code = result.code; + // resultPreview.callIdentifier = result.callIdentifier; // currently not parsed resultPreview.funderShortname = result.funderShortname; resultPreview.budget = result.budget; resultPreview.contribution = result.contribution;