openaire-library/utils/result-preview/result-preview.component.ts

174 lines
6.2 KiB
TypeScript
Raw Normal View History

import {Component, Input, OnChanges, OnInit, SimpleChanges} from "@angular/core";
import {ResultPreview} from "./result-preview";
import {EnvProperties} from "../properties/env-properties";
import {RouterHelper} from "../routerHelper.class";
import {AlertModal} from "../modal/alert";
import {properties} from "../../../../environments/environment";
[Trunk | Library]: 1. error-interceptor.service.ts: Add "properties.orcidAPIURL" in UNAUTHORIZED_WHITELIST. 2. resultLanding.component.html: If result has identifiers and user is logged in, call <orcid-work>. 3. resultLanding.module.ts: Import OrcidModule. 4. searchResult.component.ts: If user is logged in, call "orcidService.getPutCodes()" and set orcidPutCodes of previewResults. 5. searchResults.module.ts: Add "OrcidService" in providers. 6. searchResearchResults.service.ts: In method "parseResults()", call "this.parsingFunctions.parseIdentifiers(resData['pid'])" to set identifiers. 7. customOptions.class.ts: Change method return type: "public static registryOptions(): any" --> public static registryOptions(): {}". (caused problem in return type of services (e.g. HttpEvent<string> instead of string). 8. searchResult.ts: Add field "identifiers: Map<string, string[]>". 9. env-properties.ts: Add field "orcidAPIURL". 10. result-preview.component.html: a. If result has identifiers and user is logged in, call <orcid-work>. b. In bottom line with impact factors and orcid, add class "result-preview-bottom" (set color to #747474 (like muted text) when not on hover). 11. result-preview.component.ts: Add field "loggedIn" and check on init if user is logged in (via Session). 12. result-preview.module.ts: Import OrcidModule. 13. result-preview.ts: Add field "orcidPutCodes" | In method "searchResultConvert()", set resultPreview.identifiers with all identifiers (not only dois). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60231 d315682c-612b-4755-9ff5-7f18f6832af3
2021-01-13 19:30:25 +01:00
import {Session} from "../../login/utils/helper.class";
import {Identifier, StringUtils} from "../string-utils.class";
import {OpenaireEntities} from "../properties/searchFields";
@Component({
selector: 'result-preview',
templateUrl: 'result-preview.component.html',
styleUrls: ['result-preview.component.less']
})
export class ResultPreviewComponent implements OnInit, OnChanges {
@Input() result: ResultPreview;
@Input() properties: EnvProperties;
public openaireEntities = OpenaireEntities;
@Input() showSubjects: boolean = true;
@Input() showOrganizations: boolean = true;
@Input() modal: AlertModal = null;
@Input() promoteWebsiteURL: boolean = false;
@Input() hasLink: boolean = true;
2022-03-15 12:13:28 +01:00
@Input() isCard: boolean = false;
public routerHelper: RouterHelper = new RouterHelper();
public urlParam: string;
public url: string;
@Input() externalUrl: string;
public type: string;
public beforeTitle: string[] = [];
public dataProviderUrl = properties.searchLinkToDataProvider.split('?')[0];
@Input() showOrcid: boolean = true;
@Input() showEnermaps: boolean = false;
[Explore | Library | new-theme]: Added more refine filters in Repositories, Journals, Registries pages | Search & Datasource landing: Show not compatible datasources | Result Landing: get relations names by relationsVocabulary (dnet:relation_relClass.json). 1. env-properties.ts & environments/: Removed old properties searchLinkToEntityRegistriesDataProvidersTable and searchLinkToJournalsTable. 2. fetchDataproviders.class.ts & searchDataproviders.service.ts: Removed old unused methods related to subjects/ tables/ csv. 3. searchFields.ts: Added more refine filters in Repositories, Journals, Registries pages (COMPATIBLE_DATAPROVIDER_FIELDS, ENTITY_REGISTRIES_FIELDS, JOURNAL_FIELDS). 4. result-preview.component.ts: Added field @Input() deposit: boolean = false; 5. result-preview.component.html: a. Added link to landing page even for not compatible datasources. b. Added class "uk-label-danger" when compatibility = "not available" only when deposit=true. 6. searchResultsInDeposit.component.html: In <result-preview> added parameter deposit="true". 7. dataProvider.component.html: a. Added class "uk-label-danger" when compatibility = "not available". b. Show custom "Not yet registered" compatibility label when compatibility = "not available". 8. ISVocabularies.service.ts: Added methods for getting relationsVocabulary (dnet:relation_relClass.json). 9. resultLanding.service.ts & parsingFunctions.class.ts: When parsing relations, get relationName from relationsVocabulary. 10. resultLanding.component.ts: Get relationsVocabulary and pass it to "getResultLandingInfo()". 11. orcid-work.component.ts: When calling "getResultLandingInfo()", added null parameter for relationsVocabulary. 12. configuration.service.ts: [Bug fix] Added more checks in method "isPageEnabledByStateAsync()".
2022-08-03 17:21:14 +02:00
@Input() deposit: boolean = false;
[Trunk | Library]: 1. error-interceptor.service.ts: Add "properties.orcidAPIURL" in UNAUTHORIZED_WHITELIST. 2. resultLanding.component.html: If result has identifiers and user is logged in, call <orcid-work>. 3. resultLanding.module.ts: Import OrcidModule. 4. searchResult.component.ts: If user is logged in, call "orcidService.getPutCodes()" and set orcidPutCodes of previewResults. 5. searchResults.module.ts: Add "OrcidService" in providers. 6. searchResearchResults.service.ts: In method "parseResults()", call "this.parsingFunctions.parseIdentifiers(resData['pid'])" to set identifiers. 7. customOptions.class.ts: Change method return type: "public static registryOptions(): any" --> public static registryOptions(): {}". (caused problem in return type of services (e.g. HttpEvent<string> instead of string). 8. searchResult.ts: Add field "identifiers: Map<string, string[]>". 9. env-properties.ts: Add field "orcidAPIURL". 10. result-preview.component.html: a. If result has identifiers and user is logged in, call <orcid-work>. b. In bottom line with impact factors and orcid, add class "result-preview-bottom" (set color to #747474 (like muted text) when not on hover). 11. result-preview.component.ts: Add field "loggedIn" and check on init if user is logged in (via Session). 12. result-preview.module.ts: Import OrcidModule. 13. result-preview.ts: Add field "orcidPutCodes" | In method "searchResultConvert()", set resultPreview.identifiers with all identifiers (not only dois). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60231 d315682c-612b-4755-9ff5-7f18f6832af3
2021-01-13 19:30:25 +01:00
ngOnInit(): void {
if(this.hasLink) {
if (this.result.resultType === "publication") {
this.urlParam = "articleId";
this.url = properties.searchLinkToPublication.split('?')[0];
} else if (this.result.resultType === "dataset") {
this.urlParam = "datasetId";
this.url = properties.searchLinkToDataset.split('?')[0];
} else if (this.result.resultType === "software") {
this.urlParam = "softwareId";
this.url = properties.searchLinkToSoftwareLanding.split('?')[0];
} else if (this.result.resultType === "other") {
this.urlParam = "orpId";
this.url = properties.searchLinkToOrp.split('?')[0];
} else if (this.result.resultType == "project") {
if(this.result.id) {
this.urlParam = "projectId";
}else if(this.result.code && this.result.funderShortname){
this.result.id = this.result.code;
this.urlParam = "grantId";
}
this.url = properties.searchLinkToProject.split('?')[0];
} else if (this.result.resultType == "organization") {
this.urlParam = "organizationId";
this.url = properties.searchLinkToOrganization.split('?')[0];
} else if (this.result.resultType == "dataprovider") {
if(this.result.compatibilityUNKNOWN && properties.adminToolsPortalType == "eosc") {
this.urlParam = "serviceId";
this.url = properties.searchLinkToService.split('?')[0];
} else {
this.urlParam = "datasourceId";
this.url = properties.searchLinkToDataProvider.split('?')[0];
}
2022-05-13 14:57:31 +02:00
} else if (this.result.resultType == "service") {
this.urlParam = "serviceId";
this.url = properties.searchLinkToService.split('?')[0];
} else {
this.urlParam = "id";
this.url = properties.searchLinkToResult.split('?')[0];
}
this.checkPID();
}
this.initBeforeTitle();
if(this.result.languages) {
this.result.languages = this.removeUnknown(this.result.languages);
}
if(this.result.countries) {
this.result.countries = this.removeUnknown(this.result.countries);
}
}
ngOnChanges(changes: SimpleChanges) {
if(changes.result && this.hasLink) {
this.checkPID();
}
}
checkPID() {
// if result has a pid use it as parameter instead of openaireId
let pid:Identifier =this.getPID();
if(pid){
this.urlParam = "pid";
this.result.id = pid.id;
}
}
getPID() {
[Library | new-theme]: Allow also ?pid url parameter in datasource landing | Fixes in newSearchPage for service filters. 1. dataProvider.component.ts: [Bug fix] Allow also ?pid url parameter, query accordingly and set canonicalUrl to use it in seoService and scema2jsonld. 2. dataProvider.component.html: Set canonicalUrl into URL of <schema2jsonld> | Use <landing-header> instead of <showTitle>. 3. dataProvider.service.ts: Set url for querying a datasource by pid (if ?pid in landing url param) and parse also the whole record, the objIdentifier and the relcanId. 4. landing-header.component.ts: Added @Input() isSticky: boolean = false; to set less margins when sticky. 5. resultLanding.component.html: Use <landing-header> instead of <showTitle>. 6. resultLanding.component.ts: Use renamed Identifier.getResultPIDFromIdentifiers --> Identifier.getPIDFromIdentifiers. 7. metrics.service.ts: Removed console.log. 8. searchDataproviders.service.ts: Added parsing for relcanId. 9. dataProviderInfo.ts: Added relcanId, objIdentifier, record. 10. result-preview.component.ts: Use renamed Identifier.getResultPIDFromIdentifiers --> Identifier.getPIDFromIdentifiers. 11. string-utils.class.ts: Renamed Identifier.getResultPIDFromIdentifiers --> Identifier.getPIDFromIdentifiers. 12. [SITEMAPS] extractUrlsFromSearch.ts: Use renamed Identifier.getResultPIDFromIdentifiers --> Identifier.getPIDFromIdentifiers. 13. newSearchPage.component.ts: [Bug fix] a. entityType for datasources is "dataprovider". b. Added service filter options only when entityType == "service".
2022-05-30 09:39:10 +02:00
return Identifier.getPIDFromIdentifiers(this.result.identifiers);
}
public initBeforeTitle() {
if(this.result.resultType && this.result.resultType !== 'dataprovider') {
this.type = this.getTypeName(this.result.resultType);
}
if(this.result.types) {
this.removeUnknown(this.removeDuplicates(this.result.types)).forEach(type => {
this.beforeTitle.push(type);
});
}
if(this.result.year) {
this.beforeTitle.push(this.result.year.toString());
}
if(this.result.startYear && this.result.endYear) {
this.beforeTitle.push(this.result.startYear.toString() + ' - ' + this.result.endYear.toString());
}
if(this.result.provenanceAction) {
this.beforeTitle.push(this.result.provenanceAction);
}
if(this.result.relationName) {
this.beforeTitle.push(this.result.relationName);
}
// if(this.result.percentage) {
// this.beforeTitle.push((this.result.relation ? this.result.relation+": " : "") + this.result.percentage.toString() + "%");
// }
}
public getTypeName(type: string): string {
return StringUtils.getEntityName(type, false);
}
public removeUnknown(array: string[]): string[] {
return array.filter(value => value.toLowerCase() !== 'unknown');
}
public removeDuplicates(array: string[]): string[] {
return array.filter(value => value.toLowerCase() !== this.result.resultType);
}
public accessClass(accessMode: string): string {
if(accessMode.toLowerCase().indexOf('open') !== -1) {
2022-03-15 12:13:28 +01:00
return 'success';
} else if(accessMode.toLowerCase() === 'not available') {
2022-03-15 12:13:28 +01:00
return 'disabled'; // unknown
} else {
2022-03-15 12:13:28 +01:00
return 'disabled'; // closed
}
}
public onClick() {
if(this.modal) {
this.modal.cancel();
}
}
createParam(){
if(this.urlParam == "grantId" ){
return this.routerHelper.createQueryParams([this.urlParam,"funder"],[this.result.id,this.result.funderShortname])
}
return this.routerHelper.createQueryParam(this.urlParam,this.result.id)
}
public get isResultType() {
return this.result.resultType == "publication" || this.result.resultType == "dataset" ||
this.result.resultType == "software" || this.result.resultType == "other" || this.result.resultType == "result";
}
}