diff options
author | Nevena Bojovic <nenabojov@gmail.com> | 2022-03-16 20:15:27 +0100 |
---|---|---|
committer | Nevena Bojovic <nenabojov@gmail.com> | 2022-03-16 20:15:27 +0100 |
commit | 8ac9eb2404ac00397be35fce4aee7adc1f261875 (patch) | |
tree | 979fc626207a2911a54ac18a2859c0a81e57918f /frontend/src/app/_modals/login-modal/login-modal.component.ts | |
parent | 39228ed08db5aa56e6a1c02ddbfc6691e1d0eef0 (diff) | |
parent | 0f06229fa6a112b5299ac5182d938adb7ef39bde (diff) |
Merge branch 'dev' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into dev
Diffstat (limited to 'frontend/src/app/_modals/login-modal/login-modal.component.ts')
-rw-r--r-- | frontend/src/app/_modals/login-modal/login-modal.component.ts | 34 |
1 files changed, 13 insertions, 21 deletions
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 3a6fd8f1..d17d7017 100644 --- a/frontend/src/app/_modals/login-modal/login-modal.component.ts +++ b/frontend/src/app/_modals/login-modal/login-modal.component.ts @@ -1,11 +1,7 @@ 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', @@ -14,7 +10,6 @@ declare var window: any; }) export class LoginModalComponent implements OnInit { - loginModal: any; username: string = ''; password: string = ''; @@ -27,25 +22,22 @@ export class LoginModalComponent implements OnInit { ) { } ngOnInit(): void { - this.loginModal = new window.bootstrap.Modal( - document.getElementById("modalForLogin") - ); } - openModal() { - this.loginModal.show(); - //console.log("ok"); - //(<HTMLInputElement>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() { + if (this.username.length > 0 && this.password.length > 0) { + 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.authService.authenticate(response); + (<HTMLSelectElement>document.getElementById('closeButton')).click(); + }, error => { + console.warn(error); //NETACNI PODACI + }); + } } + resetData() { + this.username = ''; + this.password = ''; + } } |