1. Fix a bug with get stakeholder promise. 2. Fix a bug with infinity loop in user-info page. 3. Fix a bug with verify member error modal open on success.

This commit is contained in:
Konstantinos Triantafyllou 2023-03-21 14:02:59 +02:00
parent 8d3a83821b
commit ed19051fc0
4 changed files with 53 additions and 36 deletions

View File

@ -1,4 +1,4 @@
import {Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, ViewChild} from '@angular/core';
import {Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild} from '@angular/core';
import {UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators} from '@angular/forms';
import {AlertModal} from "../../../utils/modal/alert";
import {UserRegistryService} from "../../../services/user-registry.service";
@ -278,7 +278,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
}
public isMe(userId: string) {
return userId.includes(this.user.id) && !this.isCurator;
return userId && userId.includes(this.user.id) && !this.isCurator;
}
public get isManager(): boolean {

View File

@ -43,8 +43,8 @@ export class UserComponent {
this.loginUrl = this.properties.loginUrl;
if (typeof document !== 'undefined') {
this.server = false;
this.userManagementsService.updateUserInfo(() => {
this.user = this.userManagementsService.user;
this.userManagementsService.getUserInfo().subscribe( user => {
this.user = user;
this.loggedIn = !!this.user;
this.errorMessage = "";
this.loading = true;

View File

@ -58,7 +58,10 @@ export class StakeholderService {
}
async getStakeholderAsync() {
await this.promise;
if(this.promise) {
await this.promise;
this.promise = null;
}
this.clearSubscriptions();
return this.stakeholderSubject.getValue();
}

View File

@ -1,4 +1,4 @@
import {AfterViewInit, Component, Input, OnDestroy, OnInit, ViewChild} from "@angular/core";
import {AfterViewInit, ChangeDetectorRef, Component, Input, OnDestroy, OnInit, ViewChild} from "@angular/core";
import {User} from "../login/utils/helper.class";
import {ActivatedRoute, Router} from "@angular/router";
import {UserManagementService} from "../services/user-management.service";
@ -35,7 +35,7 @@ import {ClearCacheService} from "../services/clear-cache.service";
</div>
</modal-alert>
<modal-alert #memberModal [overflowBody]="false" *ngIf="service == 'monitor'" (cancelOutput)="cancel()"
(alertOutput)="verifyMember()" [okDisabled]="code.invalid || loading">
(alertOutput)="verifyMember()" [okDisabled]="(code.invalid || loading) && !isMember">
<div *ngIf="!isMember">
<div>
You have been invited to join <span class="uk-text-bold">{{name}}</span> Monitor Dashboard as a member.
@ -108,7 +108,8 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
private emailService: EmailService,
private userManagementService: UserManagementService,
private userRegistryService: UserRegistryService,
private clearCacheService: ClearCacheService) {
private clearCacheService: ClearCacheService,
private cdr: ChangeDetectorRef) {
}
ngOnInit() {
@ -122,33 +123,42 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
this.paramsSubscription.unsubscribe();
}
this.paramsSubscription = this.route.queryParams.subscribe(params => {
if (params && params['verify']) {
if (this.user) {
this.subscriptions.push(this.userRegistryService.getInvitation(params['verify']).subscribe(verification => {
this.verification = verification;
if (this.user.email === this.verification.email.toLowerCase() && this.id === this.verification.entity && this.type === this.verification.type) {
if (this.verification.verificationType === 'manager') {
this.openManagerModal();
} else if (this.verification.verificationType === 'member' && this.service === "monitor") {
this.openMemberModal();
if (params) {
this.isMember = !!params['isMember'];
this.cdr.detectChanges();
if(params['verify'] && !this.isMember) {
if (this.user) {
this.subscriptions.push(this.userRegistryService.getInvitation(params['verify']).subscribe(verification => {
this.verification = verification;
if (this.user.email === this.verification.email.toLowerCase() && this.id === this.verification.entity && this.type === this.verification.type) {
if (this.verification.verificationType === 'manager') {
this.openManagerModal();
} else if (this.verification.verificationType === 'member' && this.service === "monitor") {
this.openMemberModal();
} else {
this.openErrorModal();
}
} else {
this.openErrorModal();
}
} else {
}, error => {
this.openErrorModal();
}
}, error => {
this.openErrorModal();
}));
} else {
this.router.navigate(['user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_LOGIN,
'redirectUrl': this.router.url
},
relativeTo: this.route
});
}));
} else {
this.router.navigate(['user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_LOGIN,
'redirectUrl': this.router.url
},
relativeTo: this.route
});
}
} else if(this.isMember) {
this.openMemberModal();
}
} else {
this.isMember = false;
this.cdr.detectChanges();
}
});
}));
@ -177,12 +187,18 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
public openMemberModal() {
this.error = null;
this.isMember = false;
if(this.isMember) {
this.memberModal.cancelButton = false;
this.memberModal.okButtonText = 'Close';
} else {
this.memberModal.cancelButton = true;
this.memberModal.okButtonText = 'Accept';
}
this.memberModal.okButtonLeft = false;
this.memberModal.okButtonText = 'Accept';
this.memberModal.stayOpen = true;
this.memberModal.cancelButtonText = 'Cancel';
this.memberModal.alertTitle = 'Member Invitation';
this.cdr.detectChanges();
this.memberModal.open();
}
@ -239,9 +255,7 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
this.loading = false;
this.error = null;
this.userManagementService.updateUserInfo(() => {
this.memberModal.cancelButton = false;
this.memberModal.okButtonText = 'Close';
this.isMember = true;
this.router.navigate([], {queryParams: {'verify': null, 'isMember': true}});
});
}, error => {
this.loading = false;
@ -257,6 +271,6 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
}
cancel() {
this.router.navigate([this.router.url.split('?')[0]]);
this.router.navigate([], {queryParams: {'verify': null, 'isMember': null}});
}
}