| 
						
						
						
					 | 
					@ -1,5 +1,6 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { | 
					 | 
					 | 
					import { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  ChangeDetectionStrategy, | 
					 | 
					 | 
					  ChangeDetectionStrategy, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  ChangeDetectorRef, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  Component, | 
					 | 
					 | 
					  Component, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  Inject, | 
					 | 
					 | 
					  Inject, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  OnDestroy | 
					 | 
					 | 
					  OnDestroy | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -7,7 +8,9 @@ import { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | 
					 | 
					 | 
					import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; | 
					 | 
					 | 
					import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { CreateAccessDto } from '@ghostfolio/api/app/access/create-access.dto'; | 
					 | 
					 | 
					import { CreateAccessDto } from '@ghostfolio/api/app/access/create-access.dto'; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					import { Subject } from 'rxjs'; | 
					 | 
					 | 
					import { DataService } from '@ghostfolio/client/services/data.service'; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import { StatusCodes } from 'http-status-codes'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import { EMPTY, Subject, catchError, takeUntil } from 'rxjs'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { CreateOrUpdateAccessDialogParams } from './interfaces/interfaces'; | 
					 | 
					 | 
					import { CreateOrUpdateAccessDialogParams } from './interfaces/interfaces'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -24,15 +27,32 @@ export class CreateOrUpdateAccessDialog implements OnDestroy { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  private unsubscribeSubject = new Subject<void>(); | 
					 | 
					 | 
					  private unsubscribeSubject = new Subject<void>(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public constructor( | 
					 | 
					 | 
					  public constructor( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    private changeDetectorRef: ChangeDetectorRef, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Inject(MAT_DIALOG_DATA) public data: CreateOrUpdateAccessDialogParams, | 
					 | 
					 | 
					    @Inject(MAT_DIALOG_DATA) public data: CreateOrUpdateAccessDialogParams, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    public dialogRef: MatDialogRef<CreateOrUpdateAccessDialog>, | 
					 | 
					 | 
					    public dialogRef: MatDialogRef<CreateOrUpdateAccessDialog>, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    private dataService: DataService, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private formBuilder: FormBuilder | 
					 | 
					 | 
					    private formBuilder: FormBuilder | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  ) {} | 
					 | 
					 | 
					  ) {} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  ngOnInit() { | 
					 | 
					 | 
					  ngOnInit() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    this.accessForm = this.formBuilder.group({ | 
					 | 
					 | 
					    this.accessForm = this.formBuilder.group({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      alias: [this.data.access.alias], | 
					 | 
					 | 
					      alias: [this.data.access.alias], | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      type: [this.data.access.type, Validators.required] | 
					 | 
					 | 
					      type: [this.data.access.type, Validators.required], | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      userId: [this.data.access.grantee, Validators.required] | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    this.accessForm.get('type').valueChanges.subscribe((value) => { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      const userIdControl = this.accessForm.get('userId'); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      if (value === 'PRIVATE') { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        userIdControl.setValidators(Validators.required); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        userIdControl.clearValidators(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      userIdControl.updateValueAndValidity(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      this.changeDetectorRef.markForCheck(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    }); | 
					 | 
					 | 
					    }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -43,10 +63,25 @@ export class CreateOrUpdateAccessDialog implements OnDestroy { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public onSubmit() { | 
					 | 
					 | 
					  public onSubmit() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const access: CreateAccessDto = { | 
					 | 
					 | 
					    const access: CreateAccessDto = { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      alias: this.accessForm.controls['alias'].value, | 
					 | 
					 | 
					      alias: this.accessForm.controls['alias'].value, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      granteeUserId: this.accessForm.controls['userId'].value, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      type: this.accessForm.controls['type'].value | 
					 | 
					 | 
					      type: this.accessForm.controls['type'].value | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    }; | 
					 | 
					 | 
					    }; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    this.dataService | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      .postAccess(access) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      .pipe( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        catchError((error) => { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          if (error.status === StatusCodes.BAD_REQUEST) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            alert($localize`Oops! Could not grant access.`); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          return EMPTY; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        }), | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        takeUntil(this.unsubscribeSubject) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      ) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      .subscribe(() => { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        this.dialogRef.close({ access }); | 
					 | 
					 | 
					        this.dialogRef.close({ access }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public ngOnDestroy() { | 
					 | 
					 | 
					  public ngOnDestroy() { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |