From d89b169db17c57d63b536736197e33ae520b3ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20L=C3=A1szl=C3=B3?= <rlacko99@gmail.com> Date: Tue, 11 May 2021 23:24:17 +0200 Subject: [PATCH] Document rest of files and add prod environment --- .../error-dialog/error-dialog.component.ts | 22 ++++++++++++++++--- src/app/shared/loader/loader.component.ts | 6 +++++ .../shared/must-match-validator.directive.ts | 5 +++++ src/environments/environment.prod.ts | 4 +++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/app/shared/error-dialog/error-dialog.component.ts b/src/app/shared/error-dialog/error-dialog.component.ts index 08f638f..8574cad 100644 --- a/src/app/shared/error-dialog/error-dialog.component.ts +++ b/src/app/shared/error-dialog/error-dialog.component.ts @@ -1,22 +1,32 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { ErrorModel } from '../../models/error.model'; import { ErrorService } from '../../services/error.service'; -import { ModalDismissReasons, NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { Router } from '@angular/router'; +/** + * Component that opens a new dialog if the errorService is updated + */ @Component({ selector: 'app-error-dialog', templateUrl: './error-dialog.component.html', styleUrls: ['./error-dialog.component.css'], }) export class ErrorDialogComponent implements OnInit { + /** + * Error that will be displayed + */ error: ErrorModel; + /** + * Get the modal from template + */ @ViewChild('modalData') modalData: any; - closeModal: string; - constructor(private errorService: ErrorService, private modalService: NgbModal, private router: Router) {} + /** + * Subscribe to the ErrorService and trigger the modal on change + */ ngOnInit(): void { this.errorService.errorData$.subscribe((e) => { if (e) { @@ -26,10 +36,16 @@ export class ErrorDialogComponent implements OnInit { }); } + /** + * Open the modal + */ triggerModal(): void { this.modalService.open(this.modalData, { ariaLabelledBy: 'modal-basic-title' }); } + /** + * Redirect to the given route in the error + */ redirectToHome(): void { if (this.error.navigate) { this.router.navigate(this.error.navigate); diff --git a/src/app/shared/loader/loader.component.ts b/src/app/shared/loader/loader.component.ts index 3a2839d..b01dcc4 100644 --- a/src/app/shared/loader/loader.component.ts +++ b/src/app/shared/loader/loader.component.ts @@ -1,11 +1,17 @@ import { Component, Input, OnInit } from '@angular/core'; +/** + * Basic bootstrap loader component. + */ @Component({ selector: 'app-loader', templateUrl: './loader.component.html', styleUrls: ['./loader.component.css'] }) export class LoaderComponent implements OnInit { + /** + * colorClass that can be overwritten + */ @Input() colorClass?: string; constructor() { } diff --git a/src/app/shared/must-match-validator.directive.ts b/src/app/shared/must-match-validator.directive.ts index d8a9c7c..21d20ef 100644 --- a/src/app/shared/must-match-validator.directive.ts +++ b/src/app/shared/must-match-validator.directive.ts @@ -1,5 +1,10 @@ import { AbstractControl, FormGroup, ValidationErrors, ValidatorFn } from '@angular/forms'; +/** + * A validator that can be used to specify which fields should equal in a formGroup + * @param controlName first control in formGroup + * @param matchingControlName the matching control in formGroup + */ export const mustMatchValidator = (controlName: string, matchingControlName: string): ValidatorFn => ( control: AbstractControl ): ValidationErrors | null => { diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 3612073..40ffc99 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,3 +1,5 @@ export const environment = { - production: true + production: true, + apiUrl: 'https://stat.maze.sch.bme.hu/api/v1', + jwtRefreshBeforeMinutes: 10 }; -- GitLab