From ced24dc2af5eb4e5efad7cbf753b60b7d78fbdd6 Mon Sep 17 00:00:00 2001 From: argirok Date: Thu, 11 Jan 2024 18:28:02 +0200 Subject: [PATCH] [angular-16-irish-monitor | DONE | ADDED] add getResearcherStakeholder method in stakeholder service, to get researcher profile and set the proper values based on current author --- monitor/services/stakeholder.service.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/monitor/services/stakeholder.service.ts b/monitor/services/stakeholder.service.ts index 21fffb88..358ee336 100644 --- a/monitor/services/stakeholder.service.ts +++ b/monitor/services/stakeholder.service.ts @@ -53,6 +53,30 @@ export class StakeholderService { } return from(this.getStakeholderAsync()); } + getResearcherStakeholder( orcid, name, results, shouldUpdate: boolean = false): Observable { + if (!this.stakeholderSubject.value || this.stakeholderSubject.value.alias !== orcid || shouldUpdate) { + this.promise = new Promise((resolve, reject) => { + this.sub = this.http.get(properties.monitorServiceAPIURL + '/stakeholder/' + encodeURIComponent("researcher"), CustomOptions.registryOptions()).pipe(map(stakeholder => { + return this.formalize(this.checkIsUpload(stakeholder)); + })).subscribe(stakeholder => { + stakeholder.index_id = orcid; + stakeholder.index_name = name; + stakeholder.name = name; + stakeholder.alias = orcid; + if(results <10 && stakeholder.topics[0]?.categories[0]?.subCategories[0]){ + stakeholder.topics[0].categories[0].subCategories[0].charts=[]; // keep only numbers - charts wont show much anyway + } + this.stakeholderSubject.next(stakeholder); + resolve(); + }, error => { + let stakeholder = new Stakeholder(null,"researcher", orcid,name,name,orcid,"PUBLIC", null, null,""); + this.stakeholderSubject.next(stakeholder); + resolve(); + }); + }); + } + return from(this.getStakeholderAsync()); + } async getStakeholderAsync() { if (this.promise) {