From 52618d7d8dcb8e570912e9924d39bf6ba9d68d1e Mon Sep 17 00:00:00 2001 From: Sonja Galovic Date: Sun, 13 Mar 2022 15:59:05 +0100 Subject: Napravljen folder _modals u projektu. Kreirana login-modal.component (stilski uredjen modal login forme). --- .../_modals/login-modal/login-modal.component.css | 0 .../_modals/login-modal/login-modal.component.html | 49 +++++++++++++++++++++ .../login-modal/login-modal.component.spec.ts | 25 +++++++++++ .../_modals/login-modal/login-modal.component.ts | 51 ++++++++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 frontend/src/app/_modals/login-modal/login-modal.component.css create mode 100644 frontend/src/app/_modals/login-modal/login-modal.component.html create mode 100644 frontend/src/app/_modals/login-modal/login-modal.component.spec.ts create mode 100644 frontend/src/app/_modals/login-modal/login-modal.component.ts (limited to 'frontend/src/app/_modals') diff --git a/frontend/src/app/_modals/login-modal/login-modal.component.css b/frontend/src/app/_modals/login-modal/login-modal.component.css new file mode 100644 index 00000000..e69de29b diff --git a/frontend/src/app/_modals/login-modal/login-modal.component.html b/frontend/src/app/_modals/login-modal/login-modal.component.html new file mode 100644 index 00000000..22f50de2 --- /dev/null +++ b/frontend/src/app/_modals/login-modal/login-modal.component.html @@ -0,0 +1,49 @@ + + + + + + + diff --git a/frontend/src/app/_modals/login-modal/login-modal.component.spec.ts b/frontend/src/app/_modals/login-modal/login-modal.component.spec.ts new file mode 100644 index 00000000..7d0d526a --- /dev/null +++ b/frontend/src/app/_modals/login-modal/login-modal.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LoginModalComponent } from './login-modal.component'; + +describe('LoginModalComponent', () => { + let component: LoginModalComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ LoginModalComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(LoginModalComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/_modals/login-modal/login-modal.component.ts b/frontend/src/app/_modals/login-modal/login-modal.component.ts new file mode 100644 index 00000000..3a6fd8f1 --- /dev/null +++ b/frontend/src/app/_modals/login-modal/login-modal.component.ts @@ -0,0 +1,51 @@ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { FormControl, FormGroup } from '@angular/forms'; +import { Router } from '@angular/router'; +import { CookieService } from 'ngx-cookie-service'; +import { AuthService } from 'src/app/_services/auth.service'; +import { ElementRef } from '@angular/core'; + +declare var window: any; + +@Component({ + selector: 'app-login-modal', + templateUrl: './login-modal.component.html', + styleUrls: ['./login-modal.component.css'] +}) +export class LoginModalComponent implements OnInit { + + loginModal: any; + username: string = ''; + password: string = ''; + + public wrongCreds: boolean = false; //RAZMOTRITI + + constructor( + private authService: AuthService, + private cookie: CookieService, + private router: Router + ) { } + + ngOnInit(): void { + this.loginModal = new window.bootstrap.Modal( + document.getElementById("modalForLogin") + ); + } + + openModal() { + this.loginModal.show(); + //console.log("ok"); + //(document.getElementById("exampleModal")).style.display = "block"; + } + doLogin() { + this.authService.login(this.username, this.password).subscribe((response) => { //ako nisu ok podaci, ne ide hide nego mora opet da ukucava!!!!podesi + console.log(response); + this.cookie.set('token', response); + this.loginModal.hide(); //dodato + this.router.navigate(['add-model']); + }); + } + sendToRegister() { + + } +} -- cgit v1.2.3