aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_modals/login-modal
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/app/_modals/login-modal')
-rw-r--r--frontend/src/app/_modals/login-modal/login-modal.component.html15
-rw-r--r--frontend/src/app/_modals/login-modal/login-modal.component.ts20
2 files changed, 10 insertions, 25 deletions
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 22f50de2..eb6f0c53 100644
--- a/frontend/src/app/_modals/login-modal/login-modal.component.html
+++ b/frontend/src/app/_modals/login-modal/login-modal.component.html
@@ -1,14 +1,9 @@
-<!-- Button trigger modal, OVO JE U STVARI DUGME U NAVBARU -->
-<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#modalForLogin" (click)="openModal()">
- Otvori login modal
-</button>
-
<!-- Modal -->
<div class="modal fade" id="modalForLogin" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header bg-info">
- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
+ <button type="button" class="btn-close" 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>
@@ -33,17 +28,15 @@
</form>
<div class="col-md-12 d-flex justify-content-center">
<button type="button" class="btn btn-lg btn-info" style="color:white; border-color: #00a8e8; margin-right: 10px;" (click)="doLogin()">Prijavite se</button>
- <button type="button" class="btn btn-lg btn-outline-secondary" data-bs-dismiss="modal">Odustanite</button>
+ <button type="button" class="btn btn-lg btn-outline-secondary" data-bs-dismiss="modal" (click)="resetData()">Odustanite</button>
</div>
<br>
</div>
<div class="modal-footer justify-content-center">
<p class="small fw-bold">Još uvek nemate nalog?
- <a routerLink="/register" class="link-danger">Registrujte se</a>
+ <a data-bs-toggle="modal" data-bs-target="#modalForRegister" class="link-danger">Registrujte se</a>
</p>
</div>
</div>
</div>
-</div>
-
-
+</div> \ No newline at end of file
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..3ee2c7fe 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',
@@ -27,25 +23,21 @@ 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.resetData(); //dodato
this.loginModal.hide(); //dodato
this.router.navigate(['add-model']);
+ }, error => {
+ console.warn(error); //NETACNI PODACI
});
}
- sendToRegister() {
-
+ resetData() {
+ this.username = '';
+ this.password = '';
}
}