diff --git a/Front/skydivelogs-app/src/app/login-user/login-user.component.html b/Front/skydivelogs-app/src/app/login-user/login-user.component.html
index 3add5bb..35d6714 100644
--- a/Front/skydivelogs-app/src/app/login-user/login-user.component.html
+++ b/Front/skydivelogs-app/src/app/login-user/login-user.component.html
@@ -2,8 +2,8 @@
Username
-
+
Username is required
@@ -16,7 +16,7 @@
Password
+ [ngClass]="{ 'is-invalid': submitted && formCtrls.password.errors }">
Password is required
diff --git a/Front/skydivelogs-app/src/app/login-user/login-user.component.ts b/Front/skydivelogs-app/src/app/login-user/login-user.component.ts
index 105fe20..6bbe913 100644
--- a/Front/skydivelogs-app/src/app/login-user/login-user.component.ts
+++ b/Front/skydivelogs-app/src/app/login-user/login-user.component.ts
@@ -1,22 +1,24 @@
-import { Component, OnInit } from "@angular/core";
-import { Router, ActivatedRoute } from "@angular/router";
-import { FormBuilder, FormGroup, Validators } from "@angular/forms";
+import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core';
+import { Router, ActivatedRoute } from '@angular/router';
+import { FormBuilder, FormGroup, Validators } from '@angular/forms';
+import { MatInput } from '@angular/material/input';
-import { first } from "rxjs/operators";
+import { first } from 'rxjs/operators';
-import { AuthenticationService } from "../../services/authentication.service";
+import { AuthenticationService } from '../../services/authentication.service';
@Component({
- selector: "app-login-user",
- templateUrl: "./login-user.component.html",
- styleUrls: ["./login-user.component.css"]
+ selector: 'app-login-user',
+ templateUrl: './login-user.component.html',
+ styleUrls: ['./login-user.component.css']
})
-export class LoginUserComponent implements OnInit {
+export class LoginUserComponent implements OnInit, AfterViewInit {
loginForm: FormGroup;
loading = false;
submitted = false;
returnUrl: string;
- error = "";
+ error = '';
+ @ViewChild('username') userNameInput: MatInput;
constructor(
private formBuilder: FormBuilder,
@@ -26,26 +28,31 @@ export class LoginUserComponent implements OnInit {
) {
// redirect to home if already logged in
if (this.authenticationService.currentUserValue) {
- this.router.navigate(["/"]);
+ this.router.navigate(['/']);
}
}
+ ngAfterViewInit() {
+ this.userNameInput.focus();
+ }
+
ngOnInit() {
this.loginForm = this.formBuilder.group(
{
- username: ["", [Validators.required, Validators.minLength(3)]],
+ username: ['', [Validators.required, Validators.minLength(3)]],
password: [
- "",
+ '',
[
Validators.required /*, Validators.pattern("^[A-Za-z0-9_-]{8,15}$")*/
]
]
},
- { updateOn: "blur" }
+ { updateOn: 'blur' }
);
// get return url from route parameters or default to '/'
- this.returnUrl = this.route.snapshot.queryParams["returnUrl"] || "/";
+ this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
+
}
get formCtrls() {
diff --git a/Front/skydivelogs-app/src/assets/css/styles.css b/Front/skydivelogs-app/src/assets/css/styles.css
index 1c8e9c9..063df0b 100644
--- a/Front/skydivelogs-app/src/assets/css/styles.css
+++ b/Front/skydivelogs-app/src/assets/css/styles.css
@@ -3,7 +3,7 @@
html,
body {
min-height: 100vh;
- width: 100vw;
+ /*width: 100vw;*/
box-sizing: border-box;
overflow: auto;
}