[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;
@ -100,11 +98,7 @@ 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.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;
@ -113,8 +107,6 @@ export class CuratorsComponent {
HelperFunctions.scroll();
}));
}
}));
}
private getPageContents() {
this.subs.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {

View File

@ -41,7 +41,7 @@ declare var UIkit: any;
</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>
@ -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({