Style du login
This commit is contained in:
@@ -30,12 +30,10 @@
|
|||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
"budgets": [
|
"budgets": [{
|
||||||
{
|
|
||||||
"type": "anyComponentStyle",
|
"type": "anyComponentStyle",
|
||||||
"maximumWarning": "6kb"
|
"maximumWarning": "6kb"
|
||||||
}
|
}],
|
||||||
],
|
|
||||||
"optimization": true,
|
"optimization": true,
|
||||||
"outputHashing": "all",
|
"outputHashing": "all",
|
||||||
"sourceMap": false,
|
"sourceMap": false,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div>
|
<div>
|
||||||
<header>
|
<header *ngIf="this.show()">
|
||||||
<svg (click)="toggleMenu()" class="hamburger__icon" viewBox="31.5 30 49.9 32">
|
<svg (click)="toggleMenu()" class="hamburger__icon" viewBox="31.5 30 49.9 32">
|
||||||
<rect id="Rectangle_9" width="49.9" height="4" class="hamburger__icon__fill" data-name="Rectangle 9" rx="2"
|
<rect id="Rectangle_9" width="49.9" height="4" class="hamburger__icon__fill" data-name="Rectangle 9" rx="2"
|
||||||
transform="translate(31.5 58)"></rect>
|
transform="translate(31.5 58)"></rect>
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { ServiceComm } from '../services/service-comm.service';
|
import { Router } from "@angular/router";
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { AuthenticationService } from '../services/authentication.service';
|
import { User } from "../models/user";
|
||||||
import { User } from '../models/user';
|
|
||||||
|
import { AuthenticationService } from "../services/authentication.service";
|
||||||
|
import { ServiceComm } from "../services/service-comm.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: "app-root",
|
||||||
templateUrl: './app.component.html',
|
templateUrl: "./app.component.html",
|
||||||
styleUrls: ['./app.component.css']
|
styleUrls: ["./app.component.css"]
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit {
|
||||||
title = 'app';
|
title = "app";
|
||||||
showMenu = false;
|
showMenu = false;
|
||||||
currentUser: User;
|
currentUser: User;
|
||||||
|
|
||||||
@@ -19,7 +21,9 @@ export class AppComponent implements OnInit {
|
|||||||
private authenticationService: AuthenticationService,
|
private authenticationService: AuthenticationService,
|
||||||
private serviceComm: ServiceComm
|
private serviceComm: ServiceComm
|
||||||
) {
|
) {
|
||||||
this.authenticationService.currentUser.subscribe(x => this.currentUser = x);
|
this.authenticationService.currentUser.subscribe(
|
||||||
|
x => (this.currentUser = x)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -30,9 +34,13 @@ export class AppComponent implements OnInit {
|
|||||||
this.showMenu = !this.showMenu;
|
this.showMenu = !this.showMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
show() {
|
||||||
|
return this.authenticationService.currentUserValue != undefined;
|
||||||
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
this.authenticationService.logout();
|
this.authenticationService.logout();
|
||||||
this.showMenu = !this.showMenu;
|
this.showMenu = !this.showMenu;
|
||||||
this.router.navigate(['/login']);
|
this.router.navigate(["/login"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,22 @@
|
|||||||
<div class="col-md-6 offset-md-3 mt-5">
|
<div class="col-md-6 offset-md-3 mt-5">
|
||||||
<div class="alert alert-info">
|
|
||||||
Username: test<br />
|
|
||||||
Password: test
|
|
||||||
</div>
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h4 class="card-header">Angular 8 Basic Auth Login Example</h4>
|
<h4 class="card-header">Login to the Skydive log</h4>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form [formGroup]="loginForm" (ngSubmit)="onSubmit()">
|
<form [formGroup]="loginForm" (ngSubmit)="onLoginSubmit()">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username">Username</label>
|
<label for="username">Username</label>
|
||||||
<input type="text" formControlName="username" class="form-control"
|
<input type="text" formControlName="username" class="form-control"
|
||||||
[ngClass]="{ 'is-invalid': submitted && f.username.errors }" />
|
[ngClass]="{ 'is-invalid': submitted && loginCtrls.username.errors }" />
|
||||||
<div *ngIf="submitted && f.username.errors" class="invalid-feedback">
|
<div *ngIf="submitted && loginCtrls.username.errors" class="invalid-feedback">
|
||||||
<div *ngIf="f.username.errors.required">Username is required</div>
|
<div *ngIf="loginCtrls.username.errors.required">Username is required</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password">Password</label>
|
<label for="password">Password</label>
|
||||||
<input type="password" formControlName="password" class="form-control"
|
<input type="password" formControlName="password" class="form-control"
|
||||||
[ngClass]="{ 'is-invalid': submitted && f.password.errors }" />
|
[ngClass]="{ 'is-invalid': submitted && loginCtrls.password.errors }" />
|
||||||
<div *ngIf="submitted && f.password.errors" class="invalid-feedback">
|
<div *ngIf="submitted && loginCtrls.password.errors" class="invalid-feedback">
|
||||||
<div *ngIf="f.password.errors.required">Password is required</div>
|
<div *ngIf="loginCtrls.password.errors.required">Password is required</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button [disabled]="loading" class="btn btn-primary">
|
<button [disabled]="loading" class="btn btn-primary">
|
||||||
@@ -29,6 +25,30 @@
|
|||||||
</button>
|
</button>
|
||||||
<div *ngIf="error" class="alert alert-danger mt-3 mb-0">{{error}}</div>
|
<div *ngIf="error" class="alert alert-danger mt-3 mb-0">{{error}}</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<form [formGroup]="createForm" (ngSubmit)="onCreateSubmit()">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="username">Username</label>
|
||||||
|
<input type="text" formControlName="username" class="form-control"
|
||||||
|
[ngClass]="{ 'is-invalid': submitted && createCtrls.username.errors }" />
|
||||||
|
<div *ngIf="submitted && createCtrls.username.errors" class="invalid-feedback">
|
||||||
|
<div *ngIf="createCtrls.username.errors.required">Username 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 && createCtrls.password.errors }" />
|
||||||
|
<div *ngIf="submitted && createCtrls.password.errors" class="invalid-feedback">
|
||||||
|
<div *ngIf="createCtrls.password.errors.required">Password is required</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button [disabled]="loading" class="btn btn-primary">
|
||||||
|
<span *ngIf="loading" class="spinner-border spinner-border-sm mr-1"></span>
|
||||||
|
Create user and login
|
||||||
|
</button>
|
||||||
|
<div *ngIf="error" class="alert alert-danger mt-3 mb-0">{{error}}</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { Router, ActivatedRoute } from '@angular/router';
|
import { Router, ActivatedRoute } from "@angular/router";
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||||
|
|
||||||
import { first } from 'rxjs/operators';
|
import { first } from "rxjs/operators";
|
||||||
|
|
||||||
import { AuthenticationService } from '../../services/authentication.service';
|
|
||||||
|
|
||||||
|
import { AuthenticationService } from "../../services/authentication.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: "app-login",
|
||||||
templateUrl: './login.component.html',
|
templateUrl: "./login.component.html",
|
||||||
styleUrls: ['./login.component.css']
|
styleUrls: ["./login.component.css"]
|
||||||
})
|
})
|
||||||
export class LoginComponent implements OnInit {
|
export class LoginComponent implements OnInit {
|
||||||
loginForm: FormGroup;
|
loginForm: FormGroup;
|
||||||
|
createForm: FormGroup;
|
||||||
loading = false;
|
loading = false;
|
||||||
submitted = false;
|
submitted = false;
|
||||||
returnUrl: string;
|
returnUrl: string;
|
||||||
error = '';
|
error = "";
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
@@ -27,24 +27,33 @@ export class LoginComponent implements OnInit {
|
|||||||
) {
|
) {
|
||||||
// redirect to home if already logged in
|
// redirect to home if already logged in
|
||||||
if (this.authenticationService.currentUserValue) {
|
if (this.authenticationService.currentUserValue) {
|
||||||
this.router.navigate(['/']);
|
this.router.navigate(["/"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.loginForm = this.formBuilder.group({
|
this.loginForm = this.formBuilder.group({
|
||||||
username: ['', Validators.required],
|
username: ["", Validators.required],
|
||||||
password: ['', Validators.required]
|
password: ["", Validators.required]
|
||||||
|
});
|
||||||
|
this.createForm = this.formBuilder.group({
|
||||||
|
username: ["", Validators.required],
|
||||||
|
password: ["", Validators.required]
|
||||||
});
|
});
|
||||||
|
|
||||||
// get return url from route parameters or default to '/'
|
// get return url from route parameters or default to '/'
|
||||||
this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
|
this.returnUrl = this.route.snapshot.queryParams["returnUrl"] || "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
// convenience getter for easy access to form fields
|
get loginCtrls() {
|
||||||
get f() { return this.loginForm.controls; }
|
return this.loginForm.controls;
|
||||||
|
}
|
||||||
|
|
||||||
onSubmit() {
|
get createCtrls() {
|
||||||
|
return this.loginForm.controls;
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoginSubmit() {
|
||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
|
|
||||||
// stop here if form is invalid
|
// stop here if form is invalid
|
||||||
@@ -53,7 +62,8 @@ export class LoginComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.authenticationService.login(this.f.username.value, this.f.password.value)
|
this.authenticationService
|
||||||
|
.login(this.loginCtrls.username.value, this.loginCtrls.password.value)
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
data => {
|
data => {
|
||||||
@@ -62,6 +72,30 @@ export class LoginComponent implements OnInit {
|
|||||||
error => {
|
error => {
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCreateSubmit() {
|
||||||
|
this.submitted = true;
|
||||||
|
|
||||||
|
// stop here if form is invalid
|
||||||
|
if (this.createForm.invalid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.loading = true;
|
||||||
|
this.authenticationService
|
||||||
|
.login(this.createCtrls.username.value, this.createCtrls.password.value)
|
||||||
|
.pipe(first())
|
||||||
|
.subscribe(
|
||||||
|
data => {
|
||||||
|
this.router.navigate([this.returnUrl]);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.error = error;
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,16 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label style="float: left; width: 130px;">Total cutaways</label>
|
<label style="clear: both; float: left; width: 130px;">Total cutaways</label>
|
||||||
<span>: {{ totalCutaways }}</span>
|
<span>: {{ totalCutaways }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label style="float: left; width: 130px;">Last jump</label>
|
<label style="clear: both; float: left; width: 130px;">Last jump</label>
|
||||||
<span>: {{ lastJump }}</span>
|
<span>: {{ lastJump }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="display: flex; flex-direction: row; flex-wrap: wrap; margin-top: 15px;">
|
<div style="clear: both; display: flex; flex-direction: row; flex-wrap: wrap; margin-top: 15px;">
|
||||||
<label (click)="showStats(1)" [ngClass]="statsToShow(1) ? 'labelTab selected': 'labelTab'">Jumps in the last
|
<label (click)="showStats(1)" [ngClass]="statsToShow(1) ? 'labelTab selected': 'labelTab'">Jumps in the last
|
||||||
month</label>
|
month</label>
|
||||||
<label (click)="showStats(2)" [ngClass]="statsToShow(2) ? 'labelTab selected': 'labelTab'">Jumps in the last
|
<label (click)="showStats(2)" [ngClass]="statsToShow(2) ? 'labelTab selected': 'labelTab'">Jumps in the last
|
||||||
|
|||||||
7
Front/skydivelogs-app/src/assets/css/bootstrap-4.3.1.min.css
vendored
Normal file
7
Front/skydivelogs-app/src/assets/css/bootstrap-4.3.1.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,3 +1,5 @@
|
|||||||
|
@import 'bootstrap-4.3.1.min.css';
|
||||||
|
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|||||||
Reference in New Issue
Block a user