diff --git a/dashboard/users/members/members.component.html b/dashboard/users/members/members.component.html index afe2b37f..75bf2135 100644 --- a/dashboard/users/members/members.component.html +++ b/dashboard/users/members/members.component.html @@ -5,7 +5,7 @@ {{error}} -
+
  • diff --git a/monitor/services/stakeholder.service.ts b/monitor/services/stakeholder.service.ts index b7617474..4ea164ee 100644 --- a/monitor/services/stakeholder.service.ts +++ b/monitor/services/stakeholder.service.ts @@ -1,9 +1,11 @@ import {Injectable} from "@angular/core"; import {HttpClient} from "@angular/common/http"; -import {BehaviorSubject, Observable} from "rxjs"; +import {BehaviorSubject, from, Observable} from "rxjs"; import {Indicator, Section, Stakeholder, StakeholderInfo, Visibility} from "../entities/stakeholder"; import {HelperFunctions} from "../../utils/HelperFunctions.class"; import {map} from "rxjs/operators"; +import {ActivatedRoute} from "@angular/router"; +import {properties} from "../../../../environments/environment"; let maps: string[] = ['parameters', 'filters']; @@ -13,19 +15,32 @@ let maps: string[] = ['parameters', 'filters']; export class StakeholderService { private stakeholderSubject: BehaviorSubject = null; + private promise: Promise; - constructor(private http: HttpClient) { + constructor(private http: HttpClient, private route: ActivatedRoute) { this.stakeholderSubject = new BehaviorSubject(null); } - getStakeholder(url: string, alias:string): Observable { - /*return new BehaviorSubject( - StakeholderCreator.createFunderFromDefaultProfile("ec","funder","ec__________::EC", - "European Commission","EC", - false,"ec",true,true)).asObservable();*/ - return this.http.get(url + '/stakeholder/' + encodeURIComponent(alias)).pipe(map(stakeholder => { - return this.formalize(stakeholder); - })); + getStakeholder(alias:string): Observable { + if(!this.stakeholderSubject.value || this.stakeholderSubject.value.alias !== alias) { + this.promise = new Promise((resolve, reject) => { + this.http.get(properties.monitorServiceAPIURL + '/stakeholder/' + encodeURIComponent(alias)).pipe(map(stakeholder => { + return this.formalize(stakeholder); + })).subscribe(stakeholder => { + this.stakeholderSubject.next(stakeholder); + resolve(); + }, error => { + this.stakeholderSubject.next(null); + reject(); + }); + }); + } + return from(this.getStakeholderAsync()); + } + + async getStakeholderAsync() { + await this.promise; + return this.stakeholderSubject.getValue(); } getAllStakeholders(url: string, type: string = null): Observable { diff --git a/utils/loading/loading.component.ts b/utils/loading/loading.component.ts index 0e407eee..a1d7d415 100644 --- a/utils/loading/loading.component.ts +++ b/utils/loading/loading.component.ts @@ -3,18 +3,28 @@ import {Component, Input} from "@angular/core"; @Component({ selector: 'loading', template: ` -
    + +
    +
    + +
    +
    +
    + +
    -
    ` +
    + ` }) export class LoadingComponent { /** * Possible values '': blue, 'success': green, 'warning': orange and 'danger': red */ @Input() color: 'success' | 'warning' | 'danger' = null; + @Input() full: boolean = false; constructor() { }