[frontend] Finish login design
This commit is contained in:
parent
f497b52d83
commit
99a74ba927
|
@ -1,47 +1,49 @@
|
|||
<div *ngIf="error" class="error">{{ error }}</div>
|
||||
<div *ngIf="info" class="success">{{ info }}</div>
|
||||
<h2>Login</h2>
|
||||
<form [formGroup]="loginForm" (ngSubmit)="onSubmit()">
|
||||
<div class="form-group">
|
||||
<label for="email">E-Mail</label>
|
||||
<input
|
||||
type="text"
|
||||
formControlName="email"
|
||||
class="form-control"
|
||||
[ngClass]="{ 'is-invalid': submitted && loginForm.controls.email.errors }"
|
||||
/>
|
||||
<div
|
||||
*ngIf="submitted && loginForm.controls.email.errors"
|
||||
class="invalid-feedback"
|
||||
>
|
||||
<div *ngIf="loginForm.controls.email.errors.required">
|
||||
Email is required
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input
|
||||
type="password"
|
||||
formControlName="password"
|
||||
class="form-control"
|
||||
[ngClass]="{
|
||||
'is-invalid': submitted && loginForm.controls.password.errors
|
||||
}"
|
||||
/>
|
||||
<div
|
||||
*ngIf="submitted && loginForm.controls.password.errors"
|
||||
class="invalid-feedback"
|
||||
>
|
||||
<div *ngIf="loginForm.controls.password.errors.required">
|
||||
Password is required
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button [disabled]="loading" class="btn btn-primary">
|
||||
Login
|
||||
</button>
|
||||
<a routerLink="/register">Register</a>
|
||||
</div>
|
||||
</form>
|
||||
<div class="container">
|
||||
<mat-card class="login-form">
|
||||
<mat-card-header>
|
||||
<h2>Log in as hood admin!</h2>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="loginForm" (ngSubmit)="onSubmit()">
|
||||
<div class="input-container">
|
||||
<mat-form-field appearance="fill">
|
||||
<mat-label>E-Mail</mat-label>
|
||||
<input type="text" formControlName="email" matInput />
|
||||
<mat-error
|
||||
*ngIf="
|
||||
loginForm.controls.email.errors &&
|
||||
loginForm.controls.email.errors.required
|
||||
"
|
||||
>
|
||||
Email is required
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="fill">
|
||||
<mat-label>Password</mat-label>
|
||||
<input
|
||||
type="password"
|
||||
formControlName="password"
|
||||
matInput
|
||||
[type]="'password'"
|
||||
/>
|
||||
<mat-error
|
||||
*ngIf="
|
||||
loginForm.controls.password.errors &&
|
||||
loginForm.controls.password.errors.required
|
||||
"
|
||||
>
|
||||
Password is required
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button mat-raised-button color="primary" [disabled]="loading">
|
||||
Log In
|
||||
</button>
|
||||
<a mat-button routerLink="/register">Register</a>
|
||||
</div>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
<div class="banner"></div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
.input-container {
|
||||
display: grid;
|
||||
grid-template-rows: 1fr 1fr;
|
||||
margin-left: 5%;
|
||||
margin-right: 5%;
|
||||
margin-bottom: 5%;
|
||||
margin-top: 3%;
|
||||
}
|
||||
|
||||
.mat-card:not([class*="mat-elevation-z"]) {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
margin-left: 10%;
|
||||
margin-right: 10%;
|
||||
margin-top: 5%;
|
||||
@media (max-width: 600px) {
|
||||
grid-template-columns: 1fr;
|
||||
margin-top: 10%;
|
||||
margin-left: 5%;
|
||||
margin-right: 5%;
|
||||
}
|
||||
}
|
||||
|
||||
.banner {
|
||||
background: url("../../../assets/hoods1.jpg");
|
||||
background-size: 100%;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
margin-top: 10%;
|
||||
margin-bottom: 10%;
|
||||
}
|
|
@ -3,6 +3,7 @@ import { LoginService } from '../../core/auth/login.service';
|
|||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { Validators, FormGroup, FormBuilder } from '@angular/forms';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
|
@ -12,16 +13,16 @@ import { first } from 'rxjs/operators';
|
|||
export class LoginComponent implements OnInit {
|
||||
loginForm: FormGroup;
|
||||
returnUrl: string;
|
||||
error: string;
|
||||
loading = false;
|
||||
submitted = false;
|
||||
info: string;
|
||||
hide = true;
|
||||
|
||||
constructor(
|
||||
private loginService: LoginService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
private formBuilder: FormBuilder
|
||||
private formBuilder: FormBuilder,
|
||||
private snackBar: MatSnackBar
|
||||
) {
|
||||
if (this.loginService.currentHoodAdminValue) {
|
||||
this.router.navigate(['/dashboard']);
|
||||
|
@ -37,7 +38,9 @@ export class LoginComponent implements OnInit {
|
|||
this.route.snapshot.queryParams['returnUrl'] || '/dashboard';
|
||||
|
||||
if (this.route.snapshot.queryParams['registered'] === true) {
|
||||
this.info = 'Registration successful';
|
||||
this.snackBar.open('Registration successful', 'Close', {
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +62,9 @@ export class LoginComponent implements OnInit {
|
|||
this.router.navigate([this.returnUrl]);
|
||||
},
|
||||
(error) => {
|
||||
this.error = 'Wrong credentials! Try again.';
|
||||
this.snackBar.open('Wrong credentials! Try again.', 'Close', {
|
||||
duration: 2000,
|
||||
});
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
|
|
|
@ -8,6 +8,8 @@ import { MatCardModule } from '@angular/material/card';
|
|||
import { MatExpansionModule } from '@angular/material/expansion';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
|
@ -21,6 +23,8 @@ import { MatInputModule } from '@angular/material/input';
|
|||
MatExpansionModule,
|
||||
MatListModule,
|
||||
MatInputModule,
|
||||
MatDialogModule,
|
||||
MatSnackBarModule,
|
||||
],
|
||||
exports: [
|
||||
MatButtonModule,
|
||||
|
@ -32,6 +36,8 @@ import { MatInputModule } from '@angular/material/input';
|
|||
MatExpansionModule,
|
||||
MatListModule,
|
||||
MatInputModule,
|
||||
MatDialogModule,
|
||||
MatSnackBarModule,
|
||||
],
|
||||
})
|
||||
export class MaterialModule {}
|
||||
|
|
BIN
kibicara-frontend/src/assets/hoods1.jpg
Normal file
BIN
kibicara-frontend/src/assets/hoods1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 MiB |
Loading…
Reference in a new issue