Merge Angular 16 Irish Monitor to develop #33
|
@ -8,14 +8,7 @@ import {
|
||||||
SimpleChanges,
|
SimpleChanges,
|
||||||
ViewChild
|
ViewChild
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import {
|
import {UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, ValidatorFn, Validators} from '@angular/forms';
|
||||||
UntypedFormArray,
|
|
||||||
UntypedFormBuilder,
|
|
||||||
UntypedFormControl,
|
|
||||||
UntypedFormGroup,
|
|
||||||
ValidatorFn,
|
|
||||||
Validators
|
|
||||||
} from '@angular/forms';
|
|
||||||
import {AlertModal} from "../../../utils/modal/alert";
|
import {AlertModal} from "../../../utils/modal/alert";
|
||||||
import {UserRegistryService} from "../../../services/user-registry.service";
|
import {UserRegistryService} from "../../../services/user-registry.service";
|
||||||
import {EnvProperties} from "../../../utils/properties/env-properties";
|
import {EnvProperties} from "../../../utils/properties/env-properties";
|
||||||
|
@ -29,7 +22,6 @@ import {forkJoin, of, Subscription} from "rxjs";
|
||||||
import {NotificationHandler} from "../../../utils/notification-handler";
|
import {NotificationHandler} from "../../../utils/notification-handler";
|
||||||
import {ClearCacheService} from "../../../services/clear-cache.service";
|
import {ClearCacheService} from "../../../services/clear-cache.service";
|
||||||
import {catchError, map, tap} from "rxjs/operators";
|
import {catchError, map, tap} from "rxjs/operators";
|
||||||
import notification = CKEDITOR.plugins.notification;
|
|
||||||
import {InputComponent} from "../../../sharedComponents/input/input.component";
|
import {InputComponent} from "../../../sharedComponents/input/input.component";
|
||||||
|
|
||||||
class InvitationResponse {
|
class InvitationResponse {
|
||||||
|
|
|
@ -207,6 +207,7 @@ export class COOKIE {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Role {
|
export class Role {
|
||||||
|
public static GROUP = '';
|
||||||
public static PORTAL_ADMIN = 'PORTAL_ADMINISTRATOR';
|
public static PORTAL_ADMIN = 'PORTAL_ADMINISTRATOR';
|
||||||
public static REGISTERED_USER = 'REGISTERED_USER';
|
public static REGISTERED_USER = 'REGISTERED_USER';
|
||||||
public static ANONYMOUS_USER = 'ROLE_ANONYMOUS';
|
public static ANONYMOUS_USER = 'ROLE_ANONYMOUS';
|
||||||
|
@ -220,7 +221,7 @@ export class Role {
|
||||||
} else if (type == "organization") {
|
} else if (type == "organization") {
|
||||||
type = "institution";
|
type = "institution";
|
||||||
}
|
}
|
||||||
return type;
|
return Role.GROUP + type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {AfterViewInit, ChangeDetectorRef, 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 {Role, User} from "../login/utils/helper.class";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {UserManagementService} from "../services/user-management.service";
|
import {UserManagementService} from "../services/user-management.service";
|
||||||
import {UserRegistryService} from "../services/user-registry.service";
|
import {UserRegistryService} from "../services/user-registry.service";
|
||||||
|
@ -11,6 +11,7 @@ import {properties} from "../../../environments/environment";
|
||||||
import {EmailService} from "../utils/email/email.service";
|
import {EmailService} from "../utils/email/email.service";
|
||||||
import {Composer} from "../utils/email/composer";
|
import {Composer} from "../utils/email/composer";
|
||||||
import {ClearCacheService} from "../services/clear-cache.service";
|
import {ClearCacheService} from "../services/clear-cache.service";
|
||||||
|
import {BaseComponent} from "../sharedComponents/base/base.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'role-verification',
|
selector: 'role-verification',
|
||||||
|
@ -77,11 +78,13 @@ import {ClearCacheService} from "../services/clear-cache.service";
|
||||||
</modal-alert>
|
</modal-alert>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewInit {
|
export class RoleVerificationComponent extends BaseComponent implements OnInit, AfterViewInit {
|
||||||
@Input()
|
@Input()
|
||||||
public id: string;
|
public id: string;
|
||||||
@Input()
|
@Input()
|
||||||
public type: string;
|
set type(type: string) {
|
||||||
|
this._type = Role.GROUP + type;
|
||||||
|
}
|
||||||
@Input()
|
@Input()
|
||||||
public name: string;
|
public name: string;
|
||||||
@Input()
|
@Input()
|
||||||
|
@ -93,7 +96,7 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
|
||||||
public user: User;
|
public user: User;
|
||||||
public verification: any;
|
public verification: any;
|
||||||
public code: UntypedFormControl;
|
public code: UntypedFormControl;
|
||||||
private subscriptions: any[] = [];
|
private _type: string;
|
||||||
private paramsSubscription: Subscription;
|
private paramsSubscription: Subscription;
|
||||||
@ViewChild('managerModal') managerModal: AlertModal;
|
@ViewChild('managerModal') managerModal: AlertModal;
|
||||||
@ViewChild('memberModal') memberModal: AlertModal;
|
@ViewChild('memberModal') memberModal: AlertModal;
|
||||||
|
@ -102,14 +105,15 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
|
||||||
public loading: boolean = false;
|
public loading: boolean = false;
|
||||||
public isMember: boolean = false;
|
public isMember: boolean = false;
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(protected _route: ActivatedRoute,
|
||||||
private router: Router,
|
protected _router: Router,
|
||||||
private fb: UntypedFormBuilder,
|
private fb: UntypedFormBuilder,
|
||||||
private emailService: EmailService,
|
private emailService: EmailService,
|
||||||
private userManagementService: UserManagementService,
|
private userManagementService: UserManagementService,
|
||||||
private userRegistryService: UserRegistryService,
|
private userRegistryService: UserRegistryService,
|
||||||
private clearCacheService: ClearCacheService,
|
private clearCacheService: ClearCacheService,
|
||||||
private cdr: ChangeDetectorRef) {
|
private cdr: ChangeDetectorRef) {
|
||||||
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -119,14 +123,14 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.paramsSubscription = this.route.queryParams.subscribe(params => {
|
this.paramsSubscription = this._route.queryParams.subscribe(params => {
|
||||||
if (params) {
|
if (params) {
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
if(params['verify'] && !this.isMember) {
|
if(params['verify'] && !this.isMember) {
|
||||||
if (this.user) {
|
if (this.user) {
|
||||||
this.subscriptions.push(this.userRegistryService.getInvitation(params['verify']).subscribe(verification => {
|
this.subscriptions.push(this.userRegistryService.getInvitation(params['verify']).subscribe(verification => {
|
||||||
this.verification = verification;
|
this.verification = verification;
|
||||||
if (this.user.email === this.verification.email.toLowerCase() && this.id === this.verification.entity && this.type === this.verification.type) {
|
if (this.user.email === this.verification.email.toLowerCase() && this.id === this.verification.entity && this._type === this.verification.type) {
|
||||||
if (this.verification.verificationType === 'manager') {
|
if (this.verification.verificationType === 'manager') {
|
||||||
this.openManagerModal();
|
this.openManagerModal();
|
||||||
} else if (this.verification.verificationType === 'member') {
|
} else if (this.verification.verificationType === 'member') {
|
||||||
|
@ -141,12 +145,12 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
|
||||||
this.openErrorModal();
|
this.openErrorModal();
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate(['user-info'], {
|
this._router.navigate(['user-info'], {
|
||||||
queryParams: {
|
queryParams: {
|
||||||
'errorCode': LoginErrorCodes.NOT_LOGIN,
|
'errorCode': LoginErrorCodes.NOT_LOGIN,
|
||||||
'redirectUrl': this.router.url
|
'redirectUrl': this._router.url
|
||||||
},
|
},
|
||||||
relativeTo: this.route
|
relativeTo: this._route
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if(this.isMember) {
|
} else if(this.isMember) {
|
||||||
|
@ -161,14 +165,10 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
super.ngOnDestroy();
|
||||||
if (this.paramsSubscription instanceof Subscription) {
|
if (this.paramsSubscription instanceof Subscription) {
|
||||||
this.paramsSubscription.unsubscribe();
|
this.paramsSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
this.subscriptions.forEach(subscription => {
|
|
||||||
if (subscription instanceof Subscriber) {
|
|
||||||
subscription.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public openManagerModal() {
|
public openManagerModal() {
|
||||||
|
@ -218,7 +218,7 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
|
||||||
}
|
}
|
||||||
if (this.service === "monitor" ) {
|
if (this.service === "monitor" ) {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.router.navigate(['/admin/' + this.verification.entity]);
|
this._router.navigate(['/admin/' + this.verification.entity]);
|
||||||
} else {
|
} else {
|
||||||
this.subscriptions.push(this.emailService.notifyManagers(this.id, 'manager',
|
this.subscriptions.push(this.emailService.notifyManagers(this.id, 'manager',
|
||||||
Composer.composeEmailToInformOldManagersForTheNewOnes(this.name, this.id)).subscribe(() => {
|
Composer.composeEmailToInformOldManagersForTheNewOnes(this.name, this.id)).subscribe(() => {
|
||||||
|
@ -275,6 +275,6 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
this.isMember = false;
|
this.isMember = false;
|
||||||
this.router.navigate([]);
|
this._router.navigate([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {Observable} from 'rxjs';
|
||||||
import {properties} from '../../../environments/environment';
|
import {properties} from '../../../environments/environment';
|
||||||
import {CustomOptions} from './servicesUtils/customOptions.class';
|
import {CustomOptions} from './servicesUtils/customOptions.class';
|
||||||
import {map} from 'rxjs/operators';
|
import {map} from 'rxjs/operators';
|
||||||
|
import {Role} from "../login/utils/helper.class";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -14,7 +15,7 @@ export class UserRegistryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public createRole(type: string, id: string): Observable<any[]> {
|
public createRole(type: string, id: string): Observable<any[]> {
|
||||||
return this.http.post<any>(properties.registryUrl + 'create/' + type + '/' + id, null,
|
return this.http.post<any>(properties.registryUrl + 'create/' + Role.GROUP + type + '/' + id, null,
|
||||||
CustomOptions.registryOptions()).pipe(map((response: any) => response.response));
|
CustomOptions.registryOptions()).pipe(map((response: any) => response.response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,12 +36,12 @@ export class UserRegistryService {
|
||||||
|
|
||||||
public remove(type: string, id: string, email: string, role: "member" | "manager" = "manager"): Observable<any> {
|
public remove(type: string, id: string, email: string, role: "member" | "manager" = "manager"): Observable<any> {
|
||||||
return this.http.delete<any>(properties.registryUrl +
|
return this.http.delete<any>(properties.registryUrl +
|
||||||
type + '/' + id + '/' + role + '/' + encodeURIComponent(email), CustomOptions.registryOptions());
|
Role.GROUP + type + '/' + id + '/' + role + '/' + encodeURIComponent(email), CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
public invite(type: string, id: string, details: any, role: "member" | "manager" = "manager"): Observable<any[]> {
|
public invite(type: string, id: string, details: any, role: "member" | "manager" = "manager"): Observable<any[]> {
|
||||||
return this.http.post<any>(properties.registryUrl + 'invite/' +
|
return this.http.post<any>(properties.registryUrl + 'invite/' +
|
||||||
type + '/' + id + '/' + role, details,
|
Role.GROUP + type + '/' + id + '/' + role, details,
|
||||||
CustomOptions.registryOptions()).pipe(map((response: any) => response.response));
|
CustomOptions.registryOptions()).pipe(map((response: any) => response.response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ export class UserRegistryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getActive(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {
|
public getActive(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {
|
||||||
let url = properties.registryUrl + type + '/' + id + "/" + role + 's';
|
let url = properties.registryUrl + Role.GROUP + type + '/' + id + "/" + role + 's';
|
||||||
return this.http.get<any>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url,
|
return this.http.get<any>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url,
|
||||||
CustomOptions.registryOptions()).pipe(map((response:any) => response.response), map(users => {
|
CustomOptions.registryOptions()).pipe(map((response:any) => response.response), map(users => {
|
||||||
if(users.length > 0 && !users[0].email) {
|
if(users.length > 0 && !users[0].email) {
|
||||||
|
@ -70,7 +71,7 @@ export class UserRegistryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPending(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {
|
public getPending(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {
|
||||||
let url = properties.registryUrl + 'invite/' +type + '/' +id + "/" + role + 's/';
|
let url = properties.registryUrl + 'invite/' + Role.GROUP + type + '/' +id + "/" + role + 's/';
|
||||||
return this.http.get<any>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url,
|
return this.http.get<any>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url,
|
||||||
CustomOptions.registryOptions()).pipe(map((response: any) => response.response));
|
CustomOptions.registryOptions()).pipe(map((response: any) => response.response));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue