aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_modals/login-modal/login-modal.component.ts
diff options
context:
space:
mode:
authorSonja Galovic <galovicsonja@gmail.com>2022-03-13 15:59:05 +0100
committerSonja Galovic <galovicsonja@gmail.com>2022-03-13 15:59:05 +0100
commit52618d7d8dcb8e570912e9924d39bf6ba9d68d1e (patch)
tree8687220dc5f9ac4968cfb35902c8d8efd61ed938 /frontend/src/app/_modals/login-modal/login-modal.component.ts
parenta084a81779b5a38440f5d7f15e4d2beace6a32f9 (diff)
Napravljen folder _modals u projektu. Kreirana login-modal.component (stilski uredjen modal login forme).
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.ts51
1 files changed, 51 insertions, 0 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
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");
+ //(<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() {
+
+ }
+}