diff --git a/landingPages/dataProvider/dataProvider.component.html b/landingPages/dataProvider/dataProvider.component.html index 61e66a49..9a5eb2d5 100644 --- a/landingPages/dataProvider/dataProvider.component.html +++ b/landingPages/dataProvider/dataProvider.component.html @@ -270,12 +270,12 @@
- + View all {{dataProviderInfo.subjects.length | number}} subjects
- View less subjects + View less subjects
@@ -315,12 +315,12 @@
- + View all {{dataProviderInfo.organizations.length | number}} organizations
- View less organizations + View less organizations
diff --git a/landingPages/feedback/feedback.component.html b/landingPages/feedback/feedback.component.html index b51831ba..837c76bc 100644 --- a/landingPages/feedback/feedback.component.html +++ b/landingPages/feedback/feedback.component.html @@ -5,7 +5,7 @@ Back -

Report issues in...

+

Give us feedback in...

-
Issue #{{i + 1}}
+
Comment #{{i + 1}}
-
+
@@ -61,7 +61,7 @@
@@ -82,4 +82,4 @@ - + diff --git a/landingPages/feedback/feedback.component.ts b/landingPages/feedback/feedback.component.ts index f2bfc0d7..8864209a 100644 --- a/landingPages/feedback/feedback.component.ts +++ b/landingPages/feedback/feedback.component.ts @@ -38,6 +38,7 @@ export class FeedbackComponent implements OnInit, OnChanges { @Input() properties: EnvProperties = null; @Input() entityType: string = null; @Input() fields: string[] = []; + @Input() preSelectedField: string = ""; public sending: boolean = false; public sent: boolean = false; @@ -94,7 +95,7 @@ export class FeedbackComponent implements OnInit, OnChanges { public addIssue() { let issue: FormGroup = this.fb.group({ - field: this.fb.control('', Validators.required), + field: this.fb.control(this.preSelectedField, Validators.required), report: this.fb.control('', Validators.required) }); this.issues.push(issue); diff --git a/landingPages/landing-utils/availableOn.component.ts b/landingPages/landing-utils/availableOn.component.ts index fe88d78b..e28a334c 100644 --- a/landingPages/landing-utils/availableOn.component.ts +++ b/landingPages/landing-utils/availableOn.component.ts @@ -13,8 +13,8 @@ import {properties} from "../../../../environments/environment"; Download from - View less - View less + View all {{availableOn.length}} sources @@ -37,6 +37,14 @@ import {properties} from "../../../../environments/environment"; . {{instance.years.join(" . ")}} +
+ License: + + {{instance.license}} + + {{instance.license}} +
Providers: - +
Beta
+
+ - {{title}} + {{title}} - {{title}} - View less + {{title}} + View more + (click)="viewAllClick();" class="view-more-less-link uk-text-truncate" uk-tooltip="View all & feedback"> + View all & feedback + + Feedback
@@ -30,24 +36,33 @@ export class FosComponent { @Input() subjects: string[]; @Input() viewAll: boolean = false; @Output() viewAllClicked = new EventEmitter(); + @Output() feedbackClicked = new EventEmitter(); public lessBtn: boolean = false; public threshold: number = 2; public routerHelper: RouterHelper = new RouterHelper(); public properties = properties; - public title: string = "Fields of Science (FOS) [Beta]"; + public title: string = "Fields of Science"; public viewAllClick() { - if(this.subjects.length <= this.threshold*2) { - this.viewAll = true; - this.lessBtn = true; - } else { + // if(this.subjects.length <= this.threshold*2) { + // this.viewAll = true; + // this.lessBtn = true; + // } else { this.viewAll = true; this.viewAllClicked.emit('fos'); - } + // } } public viewLessClick() { this.viewAll = false; this.viewAllClicked.emit(""); } + + public feedbackClick() { + this.feedbackClicked.emit(""); + } + + public urlEncodeAndQuote(str: string): string { + return StringUtils.quote(StringUtils.URIEncode(str)); + } } \ No newline at end of file diff --git a/landingPages/landing-utils/fundedBy.component.ts b/landingPages/landing-utils/fundedBy.component.ts index 64d1b3b7..23fd374f 100644 --- a/landingPages/landing-utils/fundedBy.component.ts +++ b/landingPages/landing-utils/fundedBy.component.ts @@ -11,14 +11,14 @@ import {properties} from "../../../../environments/environment"; {{title}} {{title}} - View less + View less View more + (click)="viewAllClick();" class="view-more-less-link">View all
- + {{item['funderShortname'] ? item['funderShortname'] : item['funderName']}} [no funder available] diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts index ff6f6b8e..0b1dc570 100644 --- a/landingPages/landing-utils/parsingFunctions.class.ts +++ b/landingPages/landing-utils/parsingFunctions.class.ts @@ -271,7 +271,8 @@ export class ParsingFunctions { "accessRight": null, "accessRightIcon": "", "types": [], - "years": [] + "years": [], + "license": "" }; if (instance.hasOwnProperty("hostedby")) { @@ -355,6 +356,10 @@ export class ParsingFunctions { available.accessRightIcon = this.unknown; } + if(instance.hasOwnProperty("license")) { + available.license = Array.isArray(instance['license']) ? instance['license'][0] : instance['license']; + } + hostedBy_collectedFrom.push(available); } @@ -570,7 +575,7 @@ export class ParsingFunctions { } // publication & dataset landing : for subjects and otherSubjects and classifiedSubjects - parseAllSubjects(_subjects: any): [string[], Map, Map, string[], string[], any[]] { + parseAllSubjects(_subjects: any, vocabulary: any): [string[], Map, Map, string[], string[], any[]] { let eoscSubjectsFound = []; let subjects: string[]; let otherSubjects: Map; @@ -586,7 +591,22 @@ export class ParsingFunctions { for (let i = 0; i < length; i++) { subject = Array.isArray(_subjects) ? _subjects[i] : _subjects; if (subject.classid != "") { - if (subject.inferred && subject.inferred == true) { + if (subject.classid == "keyword") { + let content: string = subject.content+""; + let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, eoscSubjectsFound, subject, content); + let found: boolean = checkAndAddEoscSubjectResp["found"]; + if(found) { + setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"]; + classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"]; + eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"]; + } else { + if (subjects == undefined) { + subjects = new Array(); + } + subjects.push(content); + } + } else if (!vocabulary || vocabulary[subject.classid] || subject.classid === "SDG" || subject.classid === "FOS") { + // if (subject.inferred && subject.inferred == true) { if(subject.classid === "SDG") { if (sdg == undefined) { sdg = new Array(); @@ -617,35 +637,19 @@ export class ParsingFunctions { } } } else { - if (subject.classid == "keyword") { - let content: string = subject.content+""; - let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, eoscSubjectsFound, subject, content); - let found: boolean = checkAndAddEoscSubjectResp["found"]; - if(found) { - setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"]; - classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"]; - eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"]; - } else { - if (subjects == undefined) { - subjects = new Array(); - } - subjects.push(content); - } + let content: string = subject.content+""; + let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, eoscSubjectsFound, subject, content); + let found: boolean = checkAndAddEoscSubjectResp["found"]; + if(found) { + setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"]; + classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"]; + eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"]; } else { - let content: string = subject.content+""; - let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, eoscSubjectsFound, subject, content); - let found: boolean = checkAndAddEoscSubjectResp["found"]; - if(found) { - setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"]; - classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"]; - eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"]; - } else { - let classname: string = subject.classname + ""; - if (subjects == undefined) { - subjects = new Array(); - } - subjects.push(content); + let classname: string = subject.classname + ""; + if (subjects == undefined) { + subjects = new Array(); } + subjects.push(content); } } } diff --git a/landingPages/landing-utils/relatedTo.component.ts b/landingPages/landing-utils/relatedTo.component.ts index 659807c7..b9c64222 100644 --- a/landingPages/landing-utils/relatedTo.component.ts +++ b/landingPages/landing-utils/relatedTo.component.ts @@ -19,9 +19,9 @@ import {OpenaireEntities} from "../../utils/properties/searchFields"; {{title}} {{title}} - View less + View less View more + (click)="viewAllClick();" class="view-more-less-link">View all
diff --git a/landingPages/landing-utils/sdg.component.ts b/landingPages/landing-utils/sdg.component.ts index 29a8199e..7aa5283c 100644 --- a/landingPages/landing-utils/sdg.component.ts +++ b/landingPages/landing-utils/sdg.component.ts @@ -1,19 +1,25 @@ import {Component, EventEmitter, Input, Output} from "@angular/core"; import {RouterHelper} from "../../utils/routerHelper.class"; import {properties} from "../../../../environments/environment"; +import {StringUtils} from "../../utils/string-utils.class"; @Component({ selector: 'sdg', template: ` -
- +
Beta
+
+ - {{title}} + {{title}} - {{title}} - View less + {{title}} + View more + (click)="viewAllClick();" class="view-more-less-link uk-text-truncate" uk-tooltip="View all & feedback"> + View all & feedback + Feedback
@@ -21,8 +27,8 @@ import {properties} from "../../../../environments/environment"; loading="lazy" alt="sdg_colors" style="width:27px; height:27px">
@@ -35,24 +41,33 @@ export class SdgComponent { @Input() subjects: string[]; @Input() viewAll: boolean = false; @Output() viewAllClicked = new EventEmitter(); + @Output() feedbackClicked = new EventEmitter(); public lessBtn: boolean = false; public threshold: number = 4; public routerHelper: RouterHelper = new RouterHelper(); public properties = properties; - public title: string = "Sustainable Development Goals (SDG) [Beta]"; + public title: string = "SDGs"; public viewAllClick() { - if(this.subjects.length <= this.threshold*2) { - this.viewAll = true; - this.lessBtn = true; - } else { + // if(this.subjects.length <= this.threshold*2) { + // this.viewAll = true; + // this.lessBtn = true; + // } else { this.viewAll = true; this.viewAllClicked.emit('sdg'); - } + // } } public viewLessClick() { this.viewAll = false; this.viewAllClicked.emit(""); } + + public feedbackClick() { + this.feedbackClicked.emit(""); + } + + public urlEncodeAndQuote(str: string): string { + return StringUtils.quote(StringUtils.URIEncode(str)); + } } \ No newline at end of file diff --git a/landingPages/landing-utils/showIdentifiers.component.ts b/landingPages/landing-utils/showIdentifiers.component.ts index 5203b285..21e55ecb 100644 --- a/landingPages/landing-utils/showIdentifiers.component.ts +++ b/landingPages/landing-utils/showIdentifiers.component.ts @@ -44,7 +44,7 @@ import {properties} from "../../../../environments/environment";
diff --git a/landingPages/landing-utils/showSubjects.component.ts b/landingPages/landing-utils/showSubjects.component.ts index 20684e75..92096e41 100644 --- a/landingPages/landing-utils/showSubjects.component.ts +++ b/landingPages/landing-utils/showSubjects.component.ts @@ -17,23 +17,11 @@ import {properties} from "../../../../environments/environment";
Subjects by Vocabulary
-
- - - {{key}}: - - - - {{subject}} - - - - - - - - + + +
@@ -41,7 +29,7 @@ import {properties} from "../../../../environments/environment";
@@ -65,6 +53,30 @@ import {properties} from "../../../../environments/environment";
+ + +
+

+ + + {{key}}: + + + + {{subject}} + + +

+
+
+ + +
+ +
+
` }) @@ -73,14 +85,18 @@ export class ShowSubjectsComponent { @Input() otherSubjects: Map; @Input() classifiedSubjects: Map; isLarge: boolean = false; + isClassifiedLarge: boolean = false; properties = properties; specialSubjects = []; @ViewChildren("content", { read: ElementRef }) content: QueryList; + @ViewChildren("classifiedContent", { read: ElementRef }) classifiedContent: QueryList; @ViewChild('subjectsModal') subjectsModal; + @ViewChild('subjectsByVocabularyModal') subjectsByVocabularyModal; @HostListener('window:resize', ['$event']) onResize(event) { this.checkLarge(); + this.checkLargeClassified(); } constructor(private cdr: ChangeDetectorRef) { @@ -113,6 +129,7 @@ export class ShowSubjectsComponent { ngAfterViewInit() { this.checkLarge(); + this.checkLargeClassified(); } checkLarge() { @@ -124,6 +141,19 @@ export class ShowSubjectsComponent { } } + checkLargeClassified() { + let overflow = 42; + if(typeof document !== "undefined") { + this.getKeys(this.classifiedSubjects).forEach(key => { + let tag = this.classifiedContent.find(tag => tag.nativeElement.id === "content_"+key); + if(tag && tag.nativeElement.offsetHeight > overflow) { + this.isClassifiedLarge = true; + } + }); + this.cdr.detectChanges(); + } + } + public getKeys(map) { return Array.from(map.keys()); } @@ -137,4 +167,11 @@ export class ShowSubjectsComponent { this.subjectsModal.alertTitle = "Subjects"; this.subjectsModal.open(); } + + public openSubjectsByVocabularyModal() { + this.subjectsByVocabularyModal.cancelButton = false; + this.subjectsByVocabularyModal.okButton = false; + this.subjectsByVocabularyModal.alertTitle = "Subjects by Vocabulary"; + this.subjectsByVocabularyModal.open(); + } } diff --git a/landingPages/project/project.component.html b/landingPages/project/project.component.html index 8e1d1ee3..3e3b11e8 100644 --- a/landingPages/project/project.component.html +++ b/landingPages/project/project.component.html @@ -352,12 +352,12 @@
diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index 89bb4013..a06eda61 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -94,8 +94,8 @@
- See an issue? - Report it here + See an issue? + Give us feedback
@@ -287,12 +287,12 @@
- - View more + + View all
- View less + View less
@@ -458,10 +458,10 @@
- +
- +
@@ -485,7 +485,7 @@ + [(showForm)]="showFeedback" [preSelectedField]="feedbackPreSelectedField">
{ - this.getResultLandingInfo(provenanceActionVocabulary); + let observables: Array> = []; + observables.push(this._vocabulariesService.getProvenanceActionVocabulary(this.properties)); + observables.push(this._vocabulariesService.getSubjectsVocabulary(this.properties)); + // observables.push(this.indexInfoService.getLastIndexDate(properties)); + // observables.push(this.indexInfoService.getLastOrcidUpdateDate(properties)); + + this.subscriptions.push(forkJoin(observables) + .subscribe( + // this.subscriptions.push(forkJoin(observables).subscribe( + // this.subscriptions.push(this._vocabulariesService.getProvenanceActionVocabulary(this.properties).subscribe( + vocabularies => { + this.getResultLandingInfo(vocabularies[0], vocabularies[1]); }, err => { - this.getResultLandingInfo(null); + this.getResultLandingInfo(null, null); this.handleError("Error getting provenance action vocabulary for " + this.type, err); } )); } else { - this.getResultLandingInfo(null); + this.getResultLandingInfo(null, null); } } @@ -424,14 +434,14 @@ export class ResultLandingComponent { // return numberOfTabs; // } - private getResultLandingInfo(provenanceActionVocabulary: any) { + private getResultLandingInfo(provenanceActionVocabulary: any, subjectsVocabulary?: string) { if(this.resultFromInput && this.resultLandingInfo){ this.showLoading = false; return; } this.resultLandingInfo = null; this.hasAltMetrics = false; - this.subscriptions.push(this._resultLandingService.getResultLandingInfo(this.id, this.identifier, this.type, provenanceActionVocabulary, this.properties).subscribe( + this.subscriptions.push(this._resultLandingService.getResultLandingInfo(this.id, this.identifier, this.type, provenanceActionVocabulary, subjectsVocabulary, this.properties).subscribe( data => { this.resultLandingInfo = data; this.id = this.resultLandingInfo.objIdentifier; @@ -531,6 +541,7 @@ export class ResultLandingComponent { return !!this.resultLandingInfo && ( (!!this.resultLandingInfo.description && this.resultLandingInfo.description.length > 0) || !!this.resultLandingInfo.subjects + || (this.resultLandingInfo.classifiedSubjects && this.resultLandingInfo.classifiedSubjects.size > 0) || (!!this.resultLandingInfo.organizations && this.resultLandingInfo.organizations.length > 0)); } @@ -873,4 +884,11 @@ export class ResultLandingComponent { this.organizationsModal.alertTitle = "Related "+this.openaireEntities.ORGANIZATIONS; this.organizationsModal.open(); } + + public feedbackClicked(preSelectedField: string = "") { + this.feedbackPreSelectedField=preSelectedField; + this.showFeedback = true; + this.scroll(); + this.viewAll = ""; + } } diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index 917d104a..9cb0e20b 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -56,7 +56,7 @@ export class ResultLandingService { } } - getResultLandingInfo (id: string, identifier: Identifier, type: string, provenanceActionVocabulary: any, properties: EnvProperties): any { + getResultLandingInfo (id: string, identifier: Identifier, type: string, provenanceActionVocabulary: any, subjectsVocabulary: any, properties: EnvProperties): any { let url: string = this.buildResultLandingInfoUrl(id, identifier, type); let finalUrl: string = (properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url; @@ -94,9 +94,11 @@ export class ResultLandingService { (res[1]['extraInfo'] !== undefined && res[1]['extraInfo']['references'] !== undefined) ? res[1]['extraInfo']['references']['reference'] : null, // 12 res[0], // 13 - res[2] // 14 + res[2], // 14 + (res[1]['extraInfo'] !== undefined && res[1]['extraInfo']['citations'] !== undefined) + ? res[1]['extraInfo']['citations']['citation'] : null, // 15 ])) - .pipe(map(res => this.parseResultLandingInfo(res, provenanceActionVocabulary, properties))); + .pipe(map(res => this.parseResultLandingInfo(res, provenanceActionVocabulary, subjectsVocabulary, properties))); } // getProvenanceActionVocabulary (properties: EnvProperties): any { @@ -122,7 +124,7 @@ export class ResultLandingService { return throwError(error || 'Server error'); } - parseResultLandingInfo (data: any, provenanceActionVocabulary: any, properties: EnvProperties): any { + parseResultLandingInfo (data: any, provenanceActionVocabulary: any, subjectsVocabulary: any, properties: EnvProperties): any { this.resultLandingInfo = new ResultLandingInfo(); // res @@ -331,7 +333,7 @@ export class ResultLandingService { // res['result']['metadata']['oaf:entity']['oaf:result']['subject'] if(data[7] != null) { - let subjectResults: [string[], Map, Map, string[], string[], any[]] = this.parsingFunctions.parseAllSubjects(data[7]); + let subjectResults: [string[], Map, Map, string[], string[], any[]] = this.parsingFunctions.parseAllSubjects(data[7], subjectsVocabulary); this.resultLandingInfo.subjects = subjectResults[0]; this.resultLandingInfo.otherSubjects = subjectResults[1]; this.resultLandingInfo.classifiedSubjects = subjectResults[2]; @@ -358,11 +360,16 @@ export class ResultLandingService { this.resultLandingInfo.programmingLanguages = this.parsingFunctions.parseProgrammingLanguages(data[11]); } - // res['result']['metadata']['oaf:entity']['extraInfo']['citations']['citation'] + // res['result']['metadata']['oaf:entity']['extraInfo']['references']['reference'] if(data[12] != null) { this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[12]); } + // #7509 - OLD: res['result']['metadata']['oaf:entity']['extraInfo']['citations']['citation'] + if(data[12] == null && data[15] != null) { + this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[15]); + } + // res['result']['metadata']['oaf:entity']['oaf:result']['context'] if(data[8] != null) { this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[8]); diff --git a/orcid/orcid-work.component.ts b/orcid/orcid-work.component.ts index 30b4d15c..f94d03bf 100644 --- a/orcid/orcid-work.component.ts +++ b/orcid/orcid-work.component.ts @@ -441,7 +441,7 @@ export class OrcidWorkComponent { } private getResultLandingInfo(action: string) { - this.subscriptions.push(this.resultLandingService.getResultLandingInfo(this.resultId, null, this.type, null, properties).subscribe( + this.subscriptions.push(this.resultLandingService.getResultLandingInfo(this.resultId, null, this.type, null, null, properties).subscribe( resultLandingInfo => { this.resultLandingInfo = resultLandingInfo; if (this.resultLandingInfo && this.resultLandingInfo.identifiers) { diff --git a/searchPages/searchUtils/searchFilter.component.html b/searchPages/searchUtils/searchFilter.component.html index a3507caa..a923ec76 100644 --- a/searchPages/searchUtils/searchFilter.component.html +++ b/searchPages/searchUtils/searchFilter.component.html @@ -12,10 +12,11 @@
- - + View all + + View all + View less -
+
Top 100 values are shown in the filters
@@ -34,9 +35,6 @@
- - - View less -
diff --git a/searchPages/searchUtils/searchFilter.module.ts b/searchPages/searchUtils/searchFilter.module.ts index c4985d15..382884c1 100644 --- a/searchPages/searchUtils/searchFilter.module.ts +++ b/searchPages/searchUtils/searchFilter.module.ts @@ -8,11 +8,12 @@ import {ModalModule} from '../../utils/modal/modal.module'; import { MatSelectModule } from "@angular/material/select"; import {RouterModule} from "@angular/router"; import {InputModule} from '../../sharedComponents/input/input.module'; +import {IconsModule} from "../../utils/icons/icons.module"; @NgModule({ imports: [ CommonModule, FormsModule, ModalModule, MatSelectModule, RouterModule, - InputModule + InputModule, IconsModule ], declarations: [ SearchFilterComponent, SearchFilterModalComponent diff --git a/utils/authors/showAuthors.component.ts b/utils/authors/showAuthors.component.ts index 2004fc0e..a63eb362 100644 --- a/utils/authors/showAuthors.component.ts +++ b/utils/authors/showAuthors.component.ts @@ -83,7 +83,7 @@ import {properties} from "../../../../environments/environment"; diff --git a/utils/result-preview/result-preview.ts b/utils/result-preview/result-preview.ts index 6b97b825..68763e87 100644 --- a/utils/result-preview/result-preview.ts +++ b/utils/result-preview/result-preview.ts @@ -10,6 +10,7 @@ export interface HostedByCollectedFrom { types: string[]; years: string[]; accessRightIcon: string; + license?: string; } export interface Journal { diff --git a/utils/staticAutoComplete/ISVocabularies.service.ts b/utils/staticAutoComplete/ISVocabularies.service.ts index 664bffb0..b1216b81 100644 --- a/utils/staticAutoComplete/ISVocabularies.service.ts +++ b/utils/staticAutoComplete/ISVocabularies.service.ts @@ -10,6 +10,7 @@ import {catchError, map} from 'rxjs/operators'; export class ISVocabulariesService { private vocabularies: Map> = new Map>(); private provenanceActionVocabulary: BehaviorSubject<{}> = new BehaviorSubject(null); + private subjectsVocabulary: BehaviorSubject = new BehaviorSubject(null); private subscriptions = []; constructor(private http: HttpClient) {} @@ -213,7 +214,7 @@ export class ISVocabulariesService { } )); }); - this.clearSubscriptions(); + // this.clearSubscriptions(); } return this.provenanceActionVocabulary.getValue(); } @@ -234,6 +235,50 @@ export class ISVocabulariesService { return provenanceActionVocabulary; } + getSubjectsVocabulary(properties: EnvProperties): Observable { + let vocabulary = "dnet:subject_classification_typologies.json"; + return from(this.getSubjectsVocabularyFromServiceAsync(vocabulary, properties)); + } + + async getSubjectsVocabularyFromServiceAsync (vocabularyName: string, properties: EnvProperties): Promise<{}> { + if(!this.subjectsVocabulary || !this.subjectsVocabulary.getValue()) { + await new Promise(resolve => { + this.subscriptions.push(this.getSubjectsVocabularyFromService(vocabularyName, properties).subscribe( + vocabularyRes => { + // console.log(vocabularyRes); + this.subjectsVocabulary.next(vocabularyRes); + resolve(); + }, + error => { + this.subjectsVocabulary.next(null); + resolve(); + } + )); + }); + // this.clearSubscriptions(); + } + return this.subjectsVocabulary.getValue(); + } + + getSubjectsVocabularyFromService (vocabularyName: string, properties: EnvProperties): any { + let url = properties.vocabulariesAPI+vocabularyName; + + return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) + .pipe(map(res => res['terms'])) + // .pipe(map(res => res.code)) + .pipe(map(res => this.parseSubjectsVocabulary(res))); + } + + parseSubjectsVocabulary(terms: any) { + var subjectsVocabulary: {} = {}; + for(let term of terms) { + if(term.code != "keyword") { + subjectsVocabulary[term.code] = term.englishName; + } + } + return subjectsVocabulary; + } + private handleError(error: HttpErrorResponse) { // in a real world app, we may send the error to some remote logging infrastructure