From 87ffb845b7e27e39d6feb8fa6c3887111e17ebf4 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Mon, 1 Mar 2021 16:07:28 +0000 Subject: [PATCH] [Connect | Trunk]: Subscribe: Fix loading if a request has been interrupted. Curators: Change getCurators method git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@60530 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/curators/curators.component.ts | 22 ++++++------------ .../utils/subscribe/subscribe.component.ts | 23 +++++++++++-------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/app/curators/curators.component.ts b/src/app/curators/curators.component.ts index 69f7366..485eb35 100644 --- a/src/app/curators/curators.component.ts +++ b/src/app/curators/curators.component.ts @@ -22,10 +22,8 @@ import {UserRegistryService} from "../openaireLibrary/services/user-registry.ser templateUrl: './curators.component.html' }) - export class CuratorsComponent { @Input() longView = true; - managers: string[]; communityId = null; public downloadUrl = null; public showLoading = true; @@ -75,7 +73,7 @@ export class CuratorsComponent { })); } else { this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => { - if(community) { + if (community) { this.communityId = community.communityId; if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { this.subs.push(this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe()); @@ -100,19 +98,13 @@ export class CuratorsComponent { } private getCurators() { - this.subs.push(this.userRegistryService.getActiveEmail('community', this.communityId).subscribe(managers => { - this.managers = managers.map(manager => manager.email); - if(this.managers.length > 0) { - let emails = this.managers.join(); - this.subs.push(this.curatorsService.getCurators(this.properties, emails).subscribe(curators => { - this.curators = curators; - for (let i = 0; i < this.curators.length; i++) { - this.showMore[i] = false; - } - this.showLoading = false; - HelperFunctions.scroll(); - })); + this.subs.push(this.curatorsService.getCurators(this.properties, this.communityId).subscribe(curators => { + this.curators = curators; + for (let i = 0; i < this.curators.length; i++) { + this.showMore[i] = false; } + this.showLoading = false; + HelperFunctions.scroll(); })); } diff --git a/src/app/utils/subscribe/subscribe.component.ts b/src/app/utils/subscribe/subscribe.component.ts index b2b8c95..2fbac1b 100644 --- a/src/app/utils/subscribe/subscribe.component.ts +++ b/src/app/utils/subscribe/subscribe.component.ts @@ -23,8 +23,8 @@ declare var UIkit: any; template: `
- -

Please login first to subscribe

+ +

Please login first to subscribe

@@ -117,12 +117,17 @@ export class SubscribeComponent { sub.unsubscribe(); } } + this.subscribeService.setLoading(false); } private isSubscribed() { this.subscribed = Session.isSubscribedTo('community', this.communityId, this.user); } + private get isManager() { + return Session.isManager('community', this.communityId, this.user); + } + private init() { if (!this.showNumbers) { let email = (this.user) ? this.user.email : null; @@ -159,14 +164,14 @@ export class SubscribeComponent { } } - private successfulSubscribe(email) { + private successfulSubscribe() { if (!this.subscribed) { this.subscribed = true; this.subscribeEvent.emit({ value: "ok" }); - this.subs.push(this._emailService.notifyForNewManagers(this.properties, this.communityId, Composer.composeEmailToInformManagers(this.community.title, this.communityId, this.community.managers, - email, this.properties.adminPortalURL)).subscribe( + this.subs.push(this._emailService.notifyManagers(this.communityId, 'subscriber', + Composer.composeEmailToInformManagers(this.community.title, this.communityId, this.user.fullname)).subscribe( res => { //console.log("The email has been sent successfully!") }, @@ -195,7 +200,7 @@ export class SubscribeComponent { this.userManagementService.updateUserInfo(); this.subscribeService.setMembers(this.members + 1); this.subscribeService.setLoading(false); - this.successfulSubscribe(this.user.email); + this.successfulSubscribe(); }, error => { this.subscribeService.setLoading(false); UIkit.notification({