design-system #7
@@ -92,7 +92,7 @@
|
|||||||
</mat-tab>
|
</mat-tab>
|
||||||
</mat-tab-group>
|
</mat-tab-group>
|
||||||
<footer>
|
<footer>
|
||||||
<app-submit-button label="Save" [requestPending]="!!(isSaving$ | async)" i18n-label></app-submit-button>
|
<app-submit-button [requestPending]="!!(isSaving$ | async)" i18n>Save</app-submit-button>
|
||||||
<button type="button" class="secondary" (click)="goPreviousLocation()" i18n>
|
<button type="button" class="secondary" (click)="goPreviousLocation()" i18n>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<button type="submit" [class]="color" [disabled]="disabled || requestPending" (click)="click.emit()">
|
<button type="submit"
|
||||||
|
class="cod-button {{color}}"
|
||||||
|
[disabled]="disabled || requestPending"
|
||||||
|
(click)="click.emit()">
|
||||||
@if (requestPending) {
|
@if (requestPending) {
|
||||||
<mat-spinner class="spinner {{color}}" [diameter]="25"></mat-spinner>
|
<mat-spinner class="spinner {{color}}" [diameter]="25"></mat-spinner>
|
||||||
}
|
}
|
||||||
<span>
|
<span>
|
||||||
{{ label }}
|
<ng-content/>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<form [formGroup]="loginForm" (submit)="performLogin()" ngNativeValidate>
|
<form [formGroup]="loginForm" (submit)="performLogin()" class="cod-form card" ngNativeValidate>
|
||||||
<h1 i18n>Login</h1>
|
<h1 i18n>Login</h1>
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<mat-icon>mail</mat-icon>
|
<mat-icon>mail</mat-icon>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<input type="password" id="password" formControlName="password" required />
|
<input type="password" id="password" formControlName="password" required />
|
||||||
</div>
|
</div>
|
||||||
<div class="actions reversed">
|
<div class="actions reversed">
|
||||||
<button type="submit" i18n>Send</button>
|
<app-submit-button [requestPending]="false" [disabled]="false" i18n>Send</app-submit-button>
|
||||||
<a [routerLink]="['/signin']" class="button secondary" i18n>Create an account</a>
|
<a [routerLink]="['/signin']" class="cod-button secondary" i18n>Create an account</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -4,17 +4,4 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
|
|
||||||
form {
|
|
||||||
width: 80%;
|
|
||||||
max-width: 20em;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 1em;
|
|
||||||
box-shadow: 0 2px 5px 0 rgba(0,0,0,.16),0 2px 10px 0 rgba(0,0,0,.12);
|
|
||||||
border-radius: .5em;
|
|
||||||
padding: 1em 1.5em;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,13 +5,14 @@ import { Subscription, debounceTime, map } from 'rxjs';
|
|||||||
import { LoginService } from './login.service';
|
import { LoginService } from './login.service';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
|
import { SubmitButtonComponent } from "../../components/submit-button/submit-button.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: './login.component.html',
|
templateUrl: './login.component.html',
|
||||||
styleUrl: './login.component.scss',
|
styleUrl: './login.component.scss',
|
||||||
imports: [ReactiveFormsModule, MatIconModule, RouterModule],
|
imports: [ReactiveFormsModule, MatIconModule, RouterModule, SubmitButtonComponent],
|
||||||
providers: [LoginService, MatSnackBarModule]
|
providers: [LoginService, MatSnackBarModule]
|
||||||
})
|
})
|
||||||
export class LoginComponent implements OnInit, OnDestroy {
|
export class LoginComponent implements OnInit, OnDestroy {
|
||||||
|
|||||||
@@ -60,18 +60,24 @@ export class LoginService {
|
|||||||
performLogin(): void {
|
performLogin(): void {
|
||||||
const state = this.state;
|
const state = this.state;
|
||||||
|
|
||||||
// Check state is valid
|
if (this.isStateValid(state)) {
|
||||||
|
this.userRestService
|
||||||
|
.login(state.request)
|
||||||
|
.then((response) => {
|
||||||
|
this.authenticationService.authenticate(response.accessToken, response.refreshToken);
|
||||||
|
this.snackBar.open($localize`Authentication succeeded!`, $localize`Close`, { duration: 5000 });
|
||||||
|
this.router.navigate(['/home']);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
this.snackBar.open($localize`Authentication failed.`, $localize`Close`, { duration: 5000 });
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.snackBar.open($localize`Please, fill the inputs before send.`, $localize`Close`, { duration: 5000 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.userRestService
|
isStateValid(state: LoginState): boolean {
|
||||||
.login(state.request)
|
return !!state.request.email?.trim().length && !!state.request.password?.length;
|
||||||
.then((response) => {
|
|
||||||
this.authenticationService.authenticate(response.accessToken, response.refreshToken);
|
|
||||||
this.snackBar.open($localize`Authentication succeeded!`, $localize`Close`, { duration: 5000 });
|
|
||||||
this.router.navigate(['/home']);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error(error);
|
|
||||||
this.snackBar.open($localize`Authentication failed.`, $localize`Close`, { duration: 5000 });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<form [formGroup]="signinForm" (submit)="performSignin()" ngNativeValidate>
|
<form [formGroup]="signinForm" (submit)="performSignin()" class="cod-form card" ngNativeValidate>
|
||||||
<h1 i18n>Signin</h1>
|
<h1 i18n>Signin</h1>
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<mat-icon>person</mat-icon>
|
<mat-icon>person</mat-icon>
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
<input type="password" id="confirm-password" formControlName="confirmPassword" required />
|
<input type="password" id="confirm-password" formControlName="confirmPassword" required />
|
||||||
</div>
|
</div>
|
||||||
<div class="actions reversed">
|
<div class="actions reversed">
|
||||||
<button type="submit" i18n>Send</button>
|
<app-submit-button [requestPending]="false" [disabled]="false" i18n>Send</app-submit-button>
|
||||||
<a [routerLink]="['/login']" class="button secondary" i18n>I already have an account</a>
|
<a [routerLink]="['/login']" class="cod-button secondary" i18n>I already have an account</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -4,17 +4,4 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
|
|
||||||
form {
|
|
||||||
width: 80%;
|
|
||||||
max-width: 20em;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 1em;
|
|
||||||
box-shadow: 0 2px 5px 0 rgba(0,0,0,.16),0 2px 10px 0 rgba(0,0,0,.12);
|
|
||||||
border-radius: .5em;
|
|
||||||
padding: 1em 1.5em;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,12 @@ import { Subscription, debounceTime, distinctUntilChanged, map } from 'rxjs';
|
|||||||
import { SigninService } from './signin.service';
|
import { SigninService } from './signin.service';
|
||||||
import { LoginService } from '../login/login.service';
|
import { LoginService } from '../login/login.service';
|
||||||
import { FormError } from '../../core/model/FormError';
|
import { FormError } from '../../core/model/FormError';
|
||||||
|
import { SubmitButtonComponent } from "../../components/submit-button/submit-button.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-signin',
|
selector: 'app-signin',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [ReactiveFormsModule, MatIconModule, RouterModule],
|
imports: [ReactiveFormsModule, MatIconModule, RouterModule, SubmitButtonComponent],
|
||||||
templateUrl: './signin.component.html',
|
templateUrl: './signin.component.html',
|
||||||
styleUrl: './signin.component.scss',
|
styleUrl: './signin.component.scss',
|
||||||
providers: [SigninService, LoginService]
|
providers: [SigninService, LoginService]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
button, a.button {
|
button.cod-btn, a.cod-button {
|
||||||
padding: .8em 1.2em;
|
padding: .8em 1.2em;
|
||||||
border-radius: 10em;
|
border-radius: 10em;
|
||||||
border: none;
|
border: none;
|
||||||
@@ -21,6 +21,6 @@ button, a.button {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a.button {
|
a.cod-button {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,17 @@
|
|||||||
form {
|
form.cod-form {
|
||||||
|
&.card {
|
||||||
|
width: 80%;
|
||||||
|
max-width: 20em;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 1em;
|
||||||
|
box-shadow: 0 2px 5px 0 rgba(0,0,0,.16),0 2px 10px 0 rgba(0,0,0,.12);
|
||||||
|
border-radius: .5em;
|
||||||
|
padding: 1em 1.5em;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
@use './button.scss';
|
@use './button.scss';
|
||||||
@use './input.scss';
|
@use './form.scss';
|
||||||
@@ -60,6 +60,7 @@
|
|||||||
"2308975396733519902": "Créer un compte",
|
"2308975396733519902": "Créer un compte",
|
||||||
"1037765878727976611": "Connexion réussie",
|
"1037765878727976611": "Connexion réussie",
|
||||||
"6034686865111167926": "Une erreur est survenue lors de la connexion.",
|
"6034686865111167926": "Une erreur est survenue lors de la connexion.",
|
||||||
|
"5304730975301536612": "Veuillez renseigner tous les champs avant de valider.",
|
||||||
"1041423751558601074": "Vos publications",
|
"1041423751558601074": "Vos publications",
|
||||||
"5463894166935799864": "Rédiger une nouvelle publication",
|
"5463894166935799864": "Rédiger une nouvelle publication",
|
||||||
"1519054954638405159": "Chargement de la liste de vos publications...",
|
"1519054954638405159": "Chargement de la liste de vos publications...",
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
"2308975396733519902": "Create an account",
|
"2308975396733519902": "Create an account",
|
||||||
"1037765878727976611": "Authentication succeeded!",
|
"1037765878727976611": "Authentication succeeded!",
|
||||||
"6034686865111167926": "Authentication failed.",
|
"6034686865111167926": "Authentication failed.",
|
||||||
|
"5304730975301536612": "Please, fill the inputs before send.",
|
||||||
"1041423751558601074": "Your publications",
|
"1041423751558601074": "Your publications",
|
||||||
"5463894166935799864": "Add a new publication",
|
"5463894166935799864": "Add a new publication",
|
||||||
"1519054954638405159": "Publication loading...",
|
"1519054954638405159": "Publication loading...",
|
||||||
|
|||||||
Reference in New Issue
Block a user