From 3828670514abced53c9b479221c961ae7abc3b8e Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Tue, 21 Jul 2020 12:41:08 +0000 Subject: [PATCH] [Library|Trunk] JSONLD: -Home page: -Add description in Website with search action -In every search page add description based on the filters -In (project, content provider, organization) landing add description if available otherwise use the title -In project add id in funder entity Autocomplete: create event emitter to update entity or refine result label (used in jsonld) git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59152 d315682c-612b-4755-9ff5-7f18f6832af3 --- deposit/depositFirstPage.component.ts | 4 +- searchPages/find/searchAll.component.html | 3 +- .../advancedSearchForm.component.html | 12 ++-- .../advancedSearchForm.component.ts | 3 + .../searchUtils/newSearchPage.component.html | 2 +- .../searchUtils/newSearchPage.component.ts | 55 +++++++++++++++---- .../searchUtils/searchHelperClasses.class.ts | 1 + .../schema2jsonld/schema2jsonld.component.ts | 18 ++++-- .../open-aire-jsonld-converter.service.ts | 32 ++++++++--- .../entitiesAutoComplete.component.ts | 10 ++++ .../staticAutoComplete.component.ts | 12 +++- 11 files changed, 117 insertions(+), 35 deletions(-) diff --git a/deposit/depositFirstPage.component.ts b/deposit/depositFirstPage.component.ts index 8778e580..8744daf6 100644 --- a/deposit/depositFirstPage.component.ts +++ b/deposit/depositFirstPage.component.ts @@ -23,7 +23,7 @@ import {Breadcrumb} from "../utils/breadcrumbs/breadcrumbs.component";
-
+
@@ -136,7 +136,7 @@ import {Breadcrumb} from "../utils/breadcrumbs/breadcrumbs.component";
- +
diff --git a/searchPages/find/searchAll.component.html b/searchPages/find/searchAll.component.html index 63dd40a7..e492d5da 100644 --- a/searchPages/find/searchAll.component.html +++ b/searchPages/find/searchAll.component.html @@ -31,7 +31,8 @@
+ [logoURL]="properties.baseLink+logoURL" type="search" [name]=name + description="Search for research outcomes (publications, datasets, software, other research products), projects, organizations, content providers in the OpenAIRE Research Graph. ">
    diff --git a/searchPages/searchUtils/advancedSearchForm.component.html b/searchPages/searchUtils/advancedSearchForm.component.html index 5287a85d..78c574e3 100644 --- a/searchPages/searchUtils/advancedSearchForm.component.html +++ b/searchPages/searchUtils/advancedSearchForm.component.html @@ -63,7 +63,8 @@ [selectedValue]=selectedField.value [showSelected]=true [placeHolderMessage]="'Search for '+selectedField.name" [title]="selectedField.name" [multipleSelections]=false (selectedValueChanged)="valueChanged($event,i)" - (listUpdated)="listUpdated($event,selectedField.id)"> + (listUpdated)="listUpdated($event,selectedField.id)" + (updateValueLabel)="updatedValueLabel($event, i)"> + (updateValueLabel)="updatedValueLabel($event, i)"> @@ -98,14 +99,15 @@ - +
    - - +
    diff --git a/searchPages/searchUtils/advancedSearchForm.component.ts b/searchPages/searchUtils/advancedSearchForm.component.ts index 0f4a697d..a544190d 100644 --- a/searchPages/searchUtils/advancedSearchForm.component.ts +++ b/searchPages/searchUtils/advancedSearchForm.component.ts @@ -150,6 +150,9 @@ export class AdvancedSearchFormComponent { valueChanged($event,index:number){ this.selectedFields[index].value = $event.value; } + updatedValueLabel($event,index:number){ + this.selectedFields[index].valueLabel = $event.value; + } listUpdated($event,fieldId:number){ this.fieldList[fieldId] = $event.value; } diff --git a/searchPages/searchUtils/newSearchPage.component.html b/searchPages/searchUtils/newSearchPage.component.html index 6fe92772..8f3c22fc 100644 --- a/searchPages/searchUtils/newSearchPage.component.html +++ b/searchPages/searchUtils/newSearchPage.component.html @@ -178,7 +178,7 @@
+ [searchAction]=false [description]="metaDescription" >
diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts index 949b2b9f..38c6ebeb 100644 --- a/searchPages/searchUtils/newSearchPage.component.ts +++ b/searchPages/searchUtils/newSearchPage.component.ts @@ -57,7 +57,7 @@ export class NewSearchPageComponent { @Input() rangeFilters: RangeFilter[] = []; @Input() rangeFields: string[][] = []; @Input() refineFields = []; - @Input() filters = []; + @Input() filters:Filter[] = []; selectedFilters: number = 0; selectedRangeFilters: number = 0; private searchFieldsHelper: SearchFields = new SearchFields(); @@ -101,7 +101,7 @@ export class NewSearchPageComponent { public errorCodes: ErrorCodes = new ErrorCodes(); breadcrumbs:Breadcrumb[] = []; url = null; - + metaDescription = ""; @Input() entitiesSelection:boolean = true; @Input() showAdvancedSearchLink:boolean = true; @@ -128,10 +128,8 @@ export class NewSearchPageComponent { this.resultsPerPage = data.envSpecific.resultsPerPage; this.csvLimit = data.envSpecific.csvLimit; this.isPiwikEnabled = data.envSpecific.enablePiwikTrack; - if (typeof window !== 'undefined') { - this.updateUrl(data.envSpecific.baseLink + location.pathname); - this.url = data.envSpecific.baseLink + location.pathname - } + this.updateUrl(data.envSpecific.baseLink +this.router.url); + this.url = data.envSpecific.baseLink + this.router.url; if (typeof document !== 'undefined' && this.isPiwikEnabled) { this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); } @@ -142,10 +140,10 @@ export class NewSearchPageComponent { } this.customFilterEnabled = params['cf'] && params['cf'] == "true"; }); - var description = "Openaire, search, repositories, open access, type, content provider, funder, project, " + this.pageTitle; + this.metaDescription = this.pageTitle; this.updateTitle(this.pageTitle); - this.updateDescription(description); + this.updateDescription(); this.searchUtils.baseUrl = "/" + this.searchUtils.baseUrl; this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.router.url, false); @@ -179,9 +177,43 @@ export class NewSearchPageComponent { } } - updateDescription(description: string) { - this._meta.updateTag({content: description}, "name='description'"); - this._meta.updateTag({content: description}, "property='og:description'"); + updateDescription() { + this.metaDescription = "Search results for "; + if(this.resultTypes){ + let array = []; + for(let type of this.resultTypeOptions){ + if(this.resultTypes[type.id]== true){ + array.push(type.name); + } + } + if(array.length == 0){ + this.metaDescription += "research outcomes "; + }else{ + this.metaDescription += array.join(", ") + " "; + } + }else{ + this.metaDescription = this.pageTitle + " "; + } + let filterArray = []; + for(let filter of this.filters){ + if(filter.countSelectedValues> 0){ + for(let value of filter.values){ + if(value.selected) { + filterArray.push(value.name); + } + } + } + } + for(let field of this.selectedFields){ + if((field.type == "entity" || field.type == "refine") && field.valueLabel.length > 0 && filterArray.indexOf(field.valueLabel)==-1){ + filterArray.push(field.valueLabel) + }else if(!(field.type == "entity" || field.type == "refine") && field.value.length > 0 && filterArray.indexOf(field.value)==-1) { + filterArray.push(field.value); + } + } + this.metaDescription+= (filterArray.length > 0?" filtered for: ":"") + filterArray.join(", ") + " "; + this._meta.updateTag({content: this.metaDescription}, "name='description'"); + this._meta.updateTag({content: this.metaDescription}, "property='og:description'"); } updateTitle(title: string) { @@ -375,6 +407,7 @@ export class NewSearchPageComponent { } } this.filterFilterValues(this.filters); + this.updateDescription(); return filters; } diff --git a/searchPages/searchUtils/searchHelperClasses.class.ts b/searchPages/searchUtils/searchHelperClasses.class.ts index a2b2b586..52268e53 100644 --- a/searchPages/searchUtils/searchHelperClasses.class.ts +++ b/searchPages/searchUtils/searchHelperClasses.class.ts @@ -25,6 +25,7 @@ export class AdvancedField{ public name: string; // public type: string = "keyword"; //keyword, static or dynamic public value: string = ''; + public valueLabel: string = ''; public operatorId: string; public operatorName: string =""; public valid: boolean = true; diff --git a/sharedComponents/schema2jsonld/schema2jsonld.component.ts b/sharedComponents/schema2jsonld/schema2jsonld.component.ts index 518ac4f5..0ed0a96f 100644 --- a/sharedComponents/schema2jsonld/schema2jsonld.component.ts +++ b/sharedComponents/schema2jsonld/schema2jsonld.component.ts @@ -1,4 +1,4 @@ -import {Component, Input} from '@angular/core'; +import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; import {OpenAireJsonldConverterService} from './service/open-aire-jsonld-converter.service'; import {JsonldDocumentSerializerService} from './service/jsonld-document-serializer.service'; @@ -8,7 +8,7 @@ import {JsonldDocumentSerializerService} from './service/jsonld-document-seriali ` }) -export class Schema2jsonldComponent { +export class Schema2jsonldComponent implements OnInit, OnChanges { @Input() data; // for project, organization, datasource @Input() URL; @Input() logoURL; // for home, search @@ -23,14 +23,22 @@ export class Schema2jsonldComponent { private documentSerializer: JsonldDocumentSerializerService) { } - + ngOnChanges(changes: SimpleChanges): void { + if (changes.description) { + this.createJson(); + } + } ngOnInit() { + this.createJson(); + } + + createJson(){ var docOvject; if (this.type == 'project') { - docOvject = this.documentParser.convertProject(this.data, this.URL, this.otherURL); + docOvject = this.documentParser.convertProject(this.data, this.URL); this.json = this.documentSerializer.serializeOrganization(docOvject); } else if (this.type == 'organization') { - docOvject = this.documentParser.convertOrganization(this.data, this.URL); + docOvject = this.documentParser.convertOrganization(this.data, this.URL, this.description); this.json = this.documentSerializer.serializeOrganization(docOvject); } else if (this.type == 'datasource') { docOvject = this.documentParser.convertDatasource(this.data, this.URL, this.otherURL); diff --git a/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts b/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts index e8ae6f8c..67dcf685 100644 --- a/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts +++ b/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts @@ -36,6 +36,9 @@ export class OpenAireJsonldConverterService { searchPage["name"] = name; searchPage["url"] = properties.baseLink+"/search/find/"; searchPage["logo"] = logoURL; + if(description){ + searchPage["description"] = description; + } const action ={}; action["@type"]= "SearchAction"; action["@id"]= properties.baseLink+"/#search-action"; @@ -53,7 +56,10 @@ export class OpenAireJsonldConverterService { buffer["url"] = URL; if(description){ buffer["description"] = description; - } buffer["@id"] = URL; + }else{ + buffer["description"] = name; + } + buffer["@id"] = URL; return buffer; } createSearchPage(name, URL, logoURL, searchAction:boolean = true, description:string = null): any { @@ -88,7 +94,7 @@ export class OpenAireJsonldConverterService { doc.issn = this.getISSN(result); doc.description = this.getDescription(result); doc.identifier = this.getIdentifier(result); - doc.id = URL + doc.id = URL; doc.url = URL; doc.sameAs = this.getSameAs(result); doc.creator = this.getCreator(result); @@ -99,40 +105,50 @@ export class OpenAireJsonldConverterService { return doc; } - convertProject(project: any, URL, otherUrl): Organization { + convertProject(project: any, URL): Organization { const doc = new Organization(); doc.title = (project.title)?project.title:project.acronym; doc.identifier = new Array(); doc.identifier.push({id:project.funding.code, schema: "grantid"}); - var funder = new Organization(); - funder.title = project.funding.funderShortName; + let funder = new Organization(); + funder.id = properties.baseLink+"#funder-"+project.funding.funderShortName; + funder.title = project.funding.funderName; doc.funder = funder; doc.url = URL; + doc.id = URL; + doc["description"] = []; + doc["description"].push((project.title)?project.title:project.acronym); doc.sameAs =[project.url]; return doc; } -convertOrganization(organization: any, URL): Organization { +convertOrganization(organization: any, URL, description:string = null): Organization { const doc = new Organization(); doc.title = organization.title.name ; doc.legalName = organization.name; doc.areaServed = organization.country; doc.url = URL; - + doc.id = URL; + doc["description"] = []; + doc["description"].push(((organization.title.name?organization.title.name:"") + " - " + (organization.name?organization.name:""))); return doc; } convertDatasource(datasource: any, URL, otherUrl): Organization { const doc = new Organization(); - doc.title = datasource.title.name; + doc.title = datasource.title.name?datasource.title.name:datasource.officialName; //doc.identifier = datasource.contractNum; doc.legalName = datasource.officialName; if(datasource.countries && datasource.countries.length > 0){ doc.areaServed = datasource.countries[0]; } doc.url = URL; + doc.id = URL; + doc["description"] = []; + doc["description"].push(datasource.description?datasource.description:datasource.title.name?datasource.title.name:datasource.officialName); + if(datasource.oaiPmhURL || otherUrl || datasource.title.url){ doc.sameAs = []; if(otherUrl){ diff --git a/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts b/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts index 9228a312..4a2a3ba9 100644 --- a/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts +++ b/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts @@ -56,6 +56,7 @@ export class EntitiesAutocompleteComponent { @Input() title = "Autocomplete"; @Output() addItem = new EventEmitter(); // when selected list changes update parent component @Output() selectedValueChanged = new EventEmitter(); // when changed a method for filtering will be called + @Output() updateValueLabel = new EventEmitter(); //when the value is id sends an event to update the value (for meta tags) @Input() public list = []; // the entries resulted after filtering function @Input() public selected = []; // the entries selected from user @Input() public keywordlimit = 3; // the minimum length of keyword @@ -181,6 +182,9 @@ export class EntitiesAutocompleteComponent { this.selectedValueChanged.emit({ value: this.selectedValue }); + this.updateValueLabel.emit({ + value:"" + }); } @@ -213,6 +217,9 @@ export class EntitiesAutocompleteComponent { this.selectedValueChanged.emit({ value: this.selectedValue }); + this.updateValueLabel.emit({ + value:this.showItem(item) + }); this.focus=false; } @@ -267,6 +274,9 @@ export class EntitiesAutocompleteComponent { this.sub = this._search.fetchByType(this.selectedValue,this.entityType, this.properties).subscribe( data => { this.selected.push( data[0]); + this.updateValueLabel.emit({ + value:this.showItem(this.selected[0]) + }); this.showInput = false; }, err => { diff --git a/utils/staticAutoComplete/staticAutoComplete.component.ts b/utils/staticAutoComplete/staticAutoComplete.component.ts index 85e00dc1..6f02c98d 100644 --- a/utils/staticAutoComplete/staticAutoComplete.component.ts +++ b/utils/staticAutoComplete/staticAutoComplete.component.ts @@ -46,6 +46,7 @@ export class StaticAutoCompleteComponent implements OnChanges{ @Input() title = "Autocomplete"; @Output() addItem = new EventEmitter(); // when selected list changes update parent component @Output() selectedValueChanged = new EventEmitter(); // when changed a method for filtering will be called + @Output() updateValueLabel = new EventEmitter(); //when the value is id sends an event to update the value (for meta tags) @Output() listUpdated = new EventEmitter(); // when changed a method for filtering will be called @Input() public list = []; // the entries resulted after filtering function @Input() public filtered = []; // the entries resulted after filtering function @@ -197,7 +198,9 @@ export class StaticAutoCompleteComponent implements OnChanges{ this.selectedValueChanged.emit({ value: this.selectedValue }); - + this.updateValueLabel.emit({ + value:"" + }); } } @@ -229,7 +232,9 @@ export class StaticAutoCompleteComponent implements OnChanges{ this.selectedValueChanged.emit({ value: this.selectedValue }); - + this.updateValueLabel.emit({ + value:this.showItem(item) + }); } } @@ -279,6 +284,9 @@ export class StaticAutoCompleteComponent implements OnChanges{ this.selectedValue = this.list[i].label; this.selected.push(this.list[i]); this.showInput = false; + this.updateValueLabel.emit({ + value:this.showItem(this.list[i]) + }); return; }