[Trunk | Library]:

1. result-preview.ts & resultLanding.service.ts & deletedByInference.service.ts: Add "icon" field in HostedByCollectedFrom interface.
2. availableOn.component.ts: Access mode icons set at parsing (not here).
3. result-preview.component.html: Add access mode icon & remove external link functionality for collected from (provider).
4. parsingFunctions.class.ts: 
	a. When instance.hostedby has no name (or "Unknown Repository" or "other resources") and no name from "source" found, set url (first 30 chars) as name.
	b. Access mode icons set at parsing for HostedByCollectedFrom interface.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59038 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2020-07-01 12:11:57 +00:00
parent 5157c3614c
commit 71c1206619
6 changed files with 73 additions and 34 deletions

View File

@ -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 {

View File

@ -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<string>();
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);
}

View File

@ -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<string>();
let types = new Set<string>();
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<HostedByCollectedFrom>();
let counter = 0;
let instance;

View File

@ -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<HostedByCollectedFrom>();
this.resultLandingInfo.types = new Array<string>();

View File

@ -64,6 +64,11 @@
<span class="uk-text-muted">Project Code: </span>
{{result.code}}
</span>
<!-- Currently not parsed -->
<!-- <span *ngIf="result.callIdentifier" [class.uk-margin-left]="(result.funderShortname || result.code)">-->
<!-- <span class="uk-text-muted">Call for proposal: </span>-->
<!-- {{result.callIdentifier}}-->
<!-- </span>-->
</div>
<!-- Funder Budget -->
<div *ngIf="result.budget || result.contribution" class="uk-margin-small-bottom uk-text-small">
@ -209,7 +214,11 @@
<!-- Download from-->
<div *ngIf="result.hostedBy_collectedFrom && result.hostedBy_collectedFrom.length > 0"
class="uk-margin-small-bottom download-from">
<div *ngFor="let from of result.hostedBy_collectedFrom">
<div *ngFor="let from of result.hostedBy_collectedFrom"
[title]="from.bestAccessMode ? from.bestAccessMode : 'Not available'">
<span class="uk-margin-small-right">
<img [src]="from.icon">
</span>
<span class="uk-margin-right uk-display-inline-block">
<span class="uk-text-muted">Download from: </span>
<a *ngIf="from.downloadUrl && from.downloadUrl.length === 1"
@ -223,10 +232,11 @@
</span>
<span class="provider uk-display-inline-block">
<span class="uk-text-muted">Provider: </span>
<!-- target="_blank"-->
<a *ngIf="from.collectedId" routerLink="/search/dataprovider" [queryParams]="{datasourceId: from.collectedId}"
[href]="from.downloadUrl[0]" target="_blank">
[href]="from.downloadUrl[0]" (click)="onClick();">
{{from.collectedName}}
<span class="custom-external space"></span>
<!-- <span class="custom-external space"></span>-->
</a>
<span *ngIf="!from.collectedId">
{{from.collectedName}}

View File

@ -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;