| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -49,9 +49,9 @@ import { CreateOrUpdateAccessDialogParams } from './interfaces/interfaces'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  styleUrls: ['./create-or-update-access-dialog.scss'], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  templateUrl: 'create-or-update-access-dialog.html' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					export class GfCreateOrUpdateAccessDialog implements OnInit, OnDestroy { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					export class GfCreateOrUpdateAccessDialog implements OnDestroy, OnInit { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  public accessForm: FormGroup; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  public isEditMode: boolean; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  public mode: 'create' | 'update'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  private unsubscribeSubject = new Subject<void>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -63,44 +63,11 @@ export class GfCreateOrUpdateAccessDialog implements OnInit, OnDestroy { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private formBuilder: FormBuilder, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    private notificationService: NotificationService | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  ) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    this.isEditMode = !!data.accessId; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    this.mode = this.data.access?.id ? 'update' : 'create'; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  private async createAccess() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    console.log('Creating access...'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const access: CreateAccessDto = { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      alias: this.accessForm.get('alias').value, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      granteeUserId: this.accessForm.get('granteeUserId').value, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      permissions: [this.accessForm.get('permissions').value] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      await validateObjectForForm({ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        classDto: CreateAccessDto, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        form: this.accessForm, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        object: access | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      this.dataService | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        .postAccess(access) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        .pipe( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          catchError((error) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (error.status === StatusCodes.BAD_REQUEST) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					              this.notificationService.alert({ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                title: $localize`Oops! Could not grant access.` | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					              }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return EMPTY; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          }), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          takeUntil(this.unsubscribeSubject) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        .subscribe(() => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          this.dialogRef.close(access); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } catch (error) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      console.error(error); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  public onCancel() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    this.dialogRef.close(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  public ngOnDestroy() { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -114,7 +81,7 @@ export class GfCreateOrUpdateAccessDialog implements OnInit, OnDestroy { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      granteeUserId: [this.data.access.grantee, Validators.required], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      permissions: [this.data.access.permissions[0], Validators.required], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      type: [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        { value: this.data.access.type, disabled: this.isEditMode }, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        { value: this.data.access.type, disabled: this.mode === 'update' }, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Validators.required | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      ] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -145,34 +112,58 @@ export class GfCreateOrUpdateAccessDialog implements OnInit, OnDestroy { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  public onCancel() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    this.dialogRef.close(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  public async onSubmit() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    if (!this.accessForm.valid) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      console.error('Form is invalid:', this.accessForm.errors); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    if (this.isEditMode) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    if (this.mode === 'update') { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      await this.updateAccess(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      await this.createAccess(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  private async createAccess() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const access: CreateAccessDto = { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      alias: this.accessForm.get('alias').value, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      granteeUserId: this.accessForm.get('granteeUserId').value, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      permissions: [this.accessForm.get('permissions').value] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      await validateObjectForForm({ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        classDto: CreateAccessDto, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        form: this.accessForm, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        object: access | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      this.dataService | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        .postAccess(access) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        .pipe( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          catchError((error) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (error.status === StatusCodes.BAD_REQUEST) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					              this.notificationService.alert({ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                title: $localize`Oops! Could not grant access.` | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					              }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return EMPTY; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          }), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          takeUntil(this.unsubscribeSubject) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        .subscribe(() => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          this.dialogRef.close(access); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } catch (error) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      console.error(error); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  private async updateAccess() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    console.log('Updating access...'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const access: UpdateAccessDto = { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      id: this.data.access.id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      alias: this.accessForm.get('alias').value, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      granteeUserId: this.accessForm.get('granteeUserId').value, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      permissions: [this.accessForm.get('permissions').value] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    console.log('Access data:', access); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    console.log('Access ID:', this.data.accessId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      await validateObjectForForm({ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        classDto: UpdateAccessDto, | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -181,7 +172,7 @@ export class GfCreateOrUpdateAccessDialog implements OnInit, OnDestroy { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      this.dataService | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        .putAccess(this.data.accessId, access) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        .putAccess(access) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        .pipe( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          catchError((error) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (error.status === StatusCodes.BAD_REQUEST) { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |