diff options
Diffstat (limited to 'frontend/src/app/_modals')
7 files changed, 74 insertions, 5 deletions
diff --git a/frontend/src/app/_modals/alert-dialog/alert-dialog.component.css b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.css new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.css diff --git a/frontend/src/app/_modals/alert-dialog/alert-dialog.component.html b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.html new file mode 100644 index 00000000..82365193 --- /dev/null +++ b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.html @@ -0,0 +1,7 @@ +<h2 mat-dialog-title class="text-muted">{{data.title}}</h2> +<div mat-dialog-content class="mt-4" style="color: rgb(81, 76, 76);"> +  {{data.message}} +</div> +<div mat-dialog-actions class="d-flex justify-content-center mt-4"> +  <button mat-button cdkFocusInitial (click)="onOkClick()" style="background-color: lightgray;">OK</button> +</div>
\ No newline at end of file diff --git a/frontend/src/app/_modals/alert-dialog/alert-dialog.component.spec.ts b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.spec.ts new file mode 100644 index 00000000..a93fc493 --- /dev/null +++ b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AlertDialogComponent } from './alert-dialog.component'; + +describe('AlertDialogComponent', () => { +  let component: AlertDialogComponent; +  let fixture: ComponentFixture<AlertDialogComponent>; + +  beforeEach(async () => { +    await TestBed.configureTestingModule({ +      declarations: [ AlertDialogComponent ] +    }) +    .compileComponents(); +  }); + +  beforeEach(() => { +    fixture = TestBed.createComponent(AlertDialogComponent); +    component = fixture.componentInstance; +    fixture.detectChanges(); +  }); + +  it('should create', () => { +    expect(component).toBeTruthy(); +  }); +}); diff --git a/frontend/src/app/_modals/alert-dialog/alert-dialog.component.ts b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.ts new file mode 100644 index 00000000..e15f3c6f --- /dev/null +++ b/frontend/src/app/_modals/alert-dialog/alert-dialog.component.ts @@ -0,0 +1,28 @@ +import { Component, OnInit } from '@angular/core'; +import { Inject} from '@angular/core'; +import { MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; + +interface DialogData { +  title: string; +  message: string; +} + +@Component({ +  selector: 'app-alert-dialog', +  templateUrl: './alert-dialog.component.html', +  styleUrls: ['./alert-dialog.component.css'] +}) +export class AlertDialogComponent { + +  constructor( +    public dialogRef: MatDialogRef<AlertDialogComponent>, +    @Inject(MAT_DIALOG_DATA) public data: DialogData, +    //public dialog: MatDialog +  ) {} + +  onOkClick(): void { +    this.dialogRef.close(); +  } + + +} diff --git a/frontend/src/app/_modals/login-modal/login-modal.component.html b/frontend/src/app/_modals/login-modal/login-modal.component.html index d7836848..03048155 100644 --- a/frontend/src/app/_modals/login-modal/login-modal.component.html +++ b/frontend/src/app/_modals/login-modal/login-modal.component.html @@ -3,7 +3,7 @@    <div class="modal-dialog modal-dialog-centered">      <div class="modal-content">        <div class="modal-header" style="background-color: #003459;"> -        <button id="closeButton" type="button" class="btn-close" style="background-color:white;" data-bs-dismiss="modal" aria-label="Close" (click)="resetData()"></button> +        <button #closeButton type="button" class="btn-close" style="background-color:white;" data-bs-dismiss="modal" aria-label="Close" (click)="resetData()"></button>        </div>        <div class="modal-body px-5" style="color:#003459">            <h1 class="text-center mt-2 mb-4">Prijavite se</h1> diff --git a/frontend/src/app/_modals/login-modal/login-modal.component.ts b/frontend/src/app/_modals/login-modal/login-modal.component.ts index c86c269a..e1535a25 100644 --- a/frontend/src/app/_modals/login-modal/login-modal.component.ts +++ b/frontend/src/app/_modals/login-modal/login-modal.component.ts @@ -4,6 +4,7 @@ import { CookieService } from 'ngx-cookie-service';  import { AuthService } from 'src/app/_services/auth.service';  import { UserInfoService } from 'src/app/_services/user-info.service';  import shared from '../../Shared'; +import {AfterViewInit, ElementRef} from '@angular/core';  @Component({    selector: 'app-login-modal', @@ -12,6 +13,8 @@ import shared from '../../Shared';  })  export class LoginModalComponent implements OnInit { +  @ViewChild('closeButton') closeButton?: ElementRef; +    username: string = '';    password: string = ''; @@ -38,7 +41,7 @@ export class LoginModalComponent implements OnInit {          }          else {            this.authService.authenticate(response); -          (<HTMLSelectElement>document.getElementById('closeButton')).click(); +          (<HTMLSelectElement>this.closeButton?.nativeElement).click();            this.userInfoService.getUserInfo().subscribe((response) => {              shared.photoId = response.photoId;            }); diff --git a/frontend/src/app/_modals/register-modal/register-modal.component.ts b/frontend/src/app/_modals/register-modal/register-modal.component.ts index 13ef7eba..05888589 100644 --- a/frontend/src/app/_modals/register-modal/register-modal.component.ts +++ b/frontend/src/app/_modals/register-modal/register-modal.component.ts @@ -1,6 +1,9 @@  import { Component, OnInit } from '@angular/core';  import { AuthService } from 'src/app/_services/auth.service';  import User from 'src/app/_data/User'; +import { DOCUMENT } from '@angular/common'; +import { Inject }  from '@angular/core'; +import shared from 'src/app/Shared';  @Component({    selector: 'app-register-modal', @@ -29,8 +32,11 @@ export class RegisterModalComponent implements OnInit {    pattEmail: RegExp = /^[a-zA-Z0-9]+([\.\-\+][a-zA-Z0-9]+)*\@([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}$/;    pattPassword: RegExp = /.{6,30}$/; +  shared = shared; +    constructor( -    private authService: AuthService +    private authService: AuthService, +    @Inject(DOCUMENT) document: Document    ) { }    ngOnInit(): void { @@ -149,11 +155,11 @@ export class RegisterModalComponent implements OnInit {                }, (error) => console.warn(error));                           }              else if (response == 'Email Already Exists') { -              alert('Nalog sa unetim email-om već postoji!'); +              shared.openDialog("Greška!", "Nalog sa unetim email-om već postoji!");                (<HTMLSelectElement>document.getElementById('email')).focus();              }              else if (response == 'Username Already Exists') { -              alert('Nalog sa unetim korisničkim imenom već postoji!'); +              shared.openDialog("Greška!", "Nalog sa unetim korisničkim imenom već postoji!");                (<HTMLSelectElement>document.getElementById('username-register')).focus();              }            }  | 
