[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
This commit is contained in:
k.triantafyllou 2021-03-01 16:07:28 +00:00
parent a066e76bec
commit 87ffb845b7
2 changed files with 21 additions and 24 deletions

View File

@ -22,10 +22,8 @@ import {UserRegistryService} from "../openaireLibrary/services/user-registry.ser
templateUrl: './curators.component.html' templateUrl: './curators.component.html'
}) })
export class CuratorsComponent { export class CuratorsComponent {
@Input() longView = true; @Input() longView = true;
managers: string[];
communityId = null; communityId = null;
public downloadUrl = null; public downloadUrl = null;
public showLoading = true; public showLoading = true;
@ -75,7 +73,7 @@ export class CuratorsComponent {
})); }));
} else { } else {
this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => { this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => {
if(community) { if (community) {
this.communityId = community.communityId; this.communityId = community.communityId;
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { 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()); 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() { private getCurators() {
this.subs.push(this.userRegistryService.getActiveEmail('community', this.communityId).subscribe(managers => { this.subs.push(this.curatorsService.getCurators(this.properties, this.communityId).subscribe(curators => {
this.managers = managers.map(manager => manager.email); this.curators = curators;
if(this.managers.length > 0) { for (let i = 0; i < this.curators.length; i++) {
let emails = this.managers.join(); this.showMore[i] = false;
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.showLoading = false;
HelperFunctions.scroll();
})); }));
} }

View File

@ -23,8 +23,8 @@ declare var UIkit: any;
template: ` template: `
<span *ngIf="subscribed != null && !showNumbers && showTemplate"> <span *ngIf="subscribed != null && !showNumbers && showTemplate">
<div *ngIf="!subscribed && showLoginAlert" class="uk-alert-warning uk-animation-slide-bottom" uk-alert=""> <div *ngIf="!subscribed && showLoginAlert" class="uk-alert-warning uk-animation-slide-bottom" uk-alert="">
<a class="uk-alert-close" uk-close></a> <a class="uk-alert-close" uk-close></a>
<p>Please login first to subscribe</p> <p>Please login first to subscribe</p>
</div> </div>
<button *ngIf="loading" class="uk-button portal-button-reverse uk-button-small uk-width-1-1"> <button *ngIf="loading" class="uk-button portal-button-reverse uk-button-small uk-width-1-1">
<span class="uk-icon"><loading [top_margin]="false" [size]="'small'" [color]="null"></loading></span> <span class="uk-icon"><loading [top_margin]="false" [size]="'small'" [color]="null"></loading></span>
@ -41,7 +41,7 @@ declare var UIkit: any;
</span> </span>
</button> </button>
<button *ngIf="subscribed && !loading" class="subscribed-button uk-button uk-button-small uk-width-1-1" <button *ngIf="subscribed && !loading" class="subscribed-button uk-button uk-button-small uk-width-1-1"
(click)="confirmOpen()"> (click)="confirmOpen()" [disabled]="isManager" [attr.uk-tooltip]="isManager?'You cannot unsubscribe because you are a manager':null">
<span class="uk-icon uk-flex uk-flex-middle"> <span class="uk-icon uk-flex uk-flex-middle">
<svg height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> <svg height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"></path> <path d="M0 0h24v24H0z" fill="none"></path>
@ -117,12 +117,17 @@ export class SubscribeComponent {
sub.unsubscribe(); sub.unsubscribe();
} }
} }
this.subscribeService.setLoading(false);
} }
private isSubscribed() { private isSubscribed() {
this.subscribed = Session.isSubscribedTo('community', this.communityId, this.user); this.subscribed = Session.isSubscribedTo('community', this.communityId, this.user);
} }
private get isManager() {
return Session.isManager('community', this.communityId, this.user);
}
private init() { private init() {
if (!this.showNumbers) { if (!this.showNumbers) {
let email = (this.user) ? this.user.email : null; let email = (this.user) ? this.user.email : null;
@ -159,14 +164,14 @@ export class SubscribeComponent {
} }
} }
private successfulSubscribe(email) { private successfulSubscribe() {
if (!this.subscribed) { if (!this.subscribed) {
this.subscribed = true; this.subscribed = true;
this.subscribeEvent.emit({ this.subscribeEvent.emit({
value: "ok" value: "ok"
}); });
this.subs.push(this._emailService.notifyForNewManagers(this.properties, this.communityId, Composer.composeEmailToInformManagers(this.community.title, this.communityId, this.community.managers, this.subs.push(this._emailService.notifyManagers(this.communityId, 'subscriber',
email, this.properties.adminPortalURL)).subscribe( Composer.composeEmailToInformManagers(this.community.title, this.communityId, this.user.fullname)).subscribe(
res => { res => {
//console.log("The email has been sent successfully!") //console.log("The email has been sent successfully!")
}, },
@ -195,7 +200,7 @@ export class SubscribeComponent {
this.userManagementService.updateUserInfo(); this.userManagementService.updateUserInfo();
this.subscribeService.setMembers(this.members + 1); this.subscribeService.setMembers(this.members + 1);
this.subscribeService.setLoading(false); this.subscribeService.setLoading(false);
this.successfulSubscribe(this.user.email); this.successfulSubscribe();
}, error => { }, error => {
this.subscribeService.setLoading(false); this.subscribeService.setLoading(false);
UIkit.notification({ UIkit.notification({