[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 class="container">
|
||||||
<div *ngIf="info" class="success">{{ info }}</div>
|
<mat-card class="login-form">
|
||||||
<h2>Login</h2>
|
<mat-card-header>
|
||||||
|
<h2>Log in as hood admin!</h2>
|
||||||
|
</mat-card-header>
|
||||||
|
<mat-card-content>
|
||||||
<form [formGroup]="loginForm" (ngSubmit)="onSubmit()">
|
<form [formGroup]="loginForm" (ngSubmit)="onSubmit()">
|
||||||
<div class="form-group">
|
<div class="input-container">
|
||||||
<label for="email">E-Mail</label>
|
<mat-form-field appearance="fill">
|
||||||
<input
|
<mat-label>E-Mail</mat-label>
|
||||||
type="text"
|
<input type="text" formControlName="email" matInput />
|
||||||
formControlName="email"
|
<mat-error
|
||||||
class="form-control"
|
*ngIf="
|
||||||
[ngClass]="{ 'is-invalid': submitted && loginForm.controls.email.errors }"
|
loginForm.controls.email.errors &&
|
||||||
/>
|
loginForm.controls.email.errors.required
|
||||||
<div
|
"
|
||||||
*ngIf="submitted && loginForm.controls.email.errors"
|
|
||||||
class="invalid-feedback"
|
|
||||||
>
|
>
|
||||||
<div *ngIf="loginForm.controls.email.errors.required">
|
|
||||||
Email is required
|
Email is required
|
||||||
</div>
|
</mat-error>
|
||||||
</div>
|
</mat-form-field>
|
||||||
</div>
|
<mat-form-field appearance="fill">
|
||||||
<div class="form-group">
|
<mat-label>Password</mat-label>
|
||||||
<label for="password">Password</label>
|
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
formControlName="password"
|
formControlName="password"
|
||||||
class="form-control"
|
matInput
|
||||||
[ngClass]="{
|
[type]="'password'"
|
||||||
'is-invalid': submitted && loginForm.controls.password.errors
|
|
||||||
}"
|
|
||||||
/>
|
/>
|
||||||
<div
|
<mat-error
|
||||||
*ngIf="submitted && loginForm.controls.password.errors"
|
*ngIf="
|
||||||
class="invalid-feedback"
|
loginForm.controls.password.errors &&
|
||||||
|
loginForm.controls.password.errors.required
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<div *ngIf="loginForm.controls.password.errors.required">
|
|
||||||
Password is required
|
Password is required
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="buttons">
|
||||||
</div>
|
<button mat-raised-button color="primary" [disabled]="loading">
|
||||||
<div class="form-group">
|
Log In
|
||||||
<button [disabled]="loading" class="btn btn-primary">
|
|
||||||
Login
|
|
||||||
</button>
|
</button>
|
||||||
<a routerLink="/register">Register</a>
|
<a mat-button routerLink="/register">Register</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</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 { Router, ActivatedRoute } from '@angular/router';
|
||||||
import { Validators, FormGroup, FormBuilder } from '@angular/forms';
|
import { Validators, FormGroup, FormBuilder } from '@angular/forms';
|
||||||
import { first } from 'rxjs/operators';
|
import { first } from 'rxjs/operators';
|
||||||
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
|
@ -12,16 +13,16 @@ import { first } from 'rxjs/operators';
|
||||||
export class LoginComponent implements OnInit {
|
export class LoginComponent implements OnInit {
|
||||||
loginForm: FormGroup;
|
loginForm: FormGroup;
|
||||||
returnUrl: string;
|
returnUrl: string;
|
||||||
error: string;
|
|
||||||
loading = false;
|
loading = false;
|
||||||
submitted = false;
|
submitted = false;
|
||||||
info: string;
|
hide = true;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private loginService: LoginService,
|
private loginService: LoginService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private formBuilder: FormBuilder
|
private formBuilder: FormBuilder,
|
||||||
|
private snackBar: MatSnackBar
|
||||||
) {
|
) {
|
||||||
if (this.loginService.currentHoodAdminValue) {
|
if (this.loginService.currentHoodAdminValue) {
|
||||||
this.router.navigate(['/dashboard']);
|
this.router.navigate(['/dashboard']);
|
||||||
|
@ -37,7 +38,9 @@ export class LoginComponent implements OnInit {
|
||||||
this.route.snapshot.queryParams['returnUrl'] || '/dashboard';
|
this.route.snapshot.queryParams['returnUrl'] || '/dashboard';
|
||||||
|
|
||||||
if (this.route.snapshot.queryParams['registered'] === true) {
|
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]);
|
this.router.navigate([this.returnUrl]);
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this.error = 'Wrong credentials! Try again.';
|
this.snackBar.open('Wrong credentials! Try again.', 'Close', {
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -8,6 +8,8 @@ import { MatCardModule } from '@angular/material/card';
|
||||||
import { MatExpansionModule } from '@angular/material/expansion';
|
import { MatExpansionModule } from '@angular/material/expansion';
|
||||||
import { MatListModule } from '@angular/material/list';
|
import { MatListModule } from '@angular/material/list';
|
||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
|
import { MatDialogModule } from '@angular/material/dialog';
|
||||||
|
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [],
|
declarations: [],
|
||||||
|
@ -21,6 +23,8 @@ import { MatInputModule } from '@angular/material/input';
|
||||||
MatExpansionModule,
|
MatExpansionModule,
|
||||||
MatListModule,
|
MatListModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
|
MatDialogModule,
|
||||||
|
MatSnackBarModule,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
|
@ -32,6 +36,8 @@ import { MatInputModule } from '@angular/material/input';
|
||||||
MatExpansionModule,
|
MatExpansionModule,
|
||||||
MatListModule,
|
MatListModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
|
MatDialogModule,
|
||||||
|
MatSnackBarModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class MaterialModule {}
|
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