[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'
})
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();
}));
}

View File

@ -23,8 +23,8 @@ declare var UIkit: any;
template: `
<span *ngIf="subscribed != null && !showNumbers && showTemplate">
<div *ngIf="!subscribed && showLoginAlert" class="uk-alert-warning uk-animation-slide-bottom" uk-alert="">
<a class="uk-alert-close" uk-close></a>
<p>Please login first to subscribe</p>
<a class="uk-alert-close" uk-close></a>
<p>Please login first to subscribe</p>
</div>
<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>
@ -37,18 +37,18 @@ declare var UIkit: any;
<path
d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"></path>
</svg>
<span class="space">Subscribe</span>
<span class="space">Subscribe</span>
</span>
</button>
<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">
<svg height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"></path>
<path
d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"></path>
</svg>
<span class="space">Subscribed</span>
<span class="space">Subscribed</span>
</span>
</button>
</span>
@ -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({