Ajout de la traduction sur la page d'accueil
This commit is contained in:
@@ -7,33 +7,33 @@
|
||||
<mat-sidenav #snav mode="over" style="padding: 0 20px 0 10px;">
|
||||
<mat-nav-list>
|
||||
<mat-icon aria-hidden="false" aria-label="Summary">timeline</mat-icon>
|
||||
<a routerLink="/summary" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>Summary</a>
|
||||
<a routerLink="/summary" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>{{ 'App_Nav_Summary' | translate }}</a>
|
||||
<hr class="splitter">
|
||||
</mat-nav-list>
|
||||
<mat-nav-list>
|
||||
<mat-icon aria-hidden="false" aria-label="List of jumps">list_alt</mat-icon>
|
||||
<a routerLink="/jumps" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>List of jumps</a>
|
||||
<a routerLink="/jumps" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>{{ 'App_Nav_Jumps' | translate }}</a>
|
||||
</mat-nav-list>
|
||||
<mat-nav-list>
|
||||
<mat-icon aria-hidden="false" aria-label="Add jumps">add_circle</mat-icon>
|
||||
<a routerLink="/newjump" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>Add a new jump</a>
|
||||
<a routerLink="/newjump" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>{{ 'App_Nav_NewJump' | translate }}</a>
|
||||
<hr class="splitter">
|
||||
</mat-nav-list>
|
||||
<mat-nav-list>
|
||||
<mat-icon aria-hidden="false" aria-label="Dropzones">store</mat-icon>
|
||||
<a routerLink="/dzs" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>List of DZs</a>
|
||||
<a routerLink="/dzs" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>{{ 'App_Nav_Dzs' | translate }}</a>
|
||||
</mat-nav-list>
|
||||
<mat-nav-list>
|
||||
<mat-icon aria-hidden="false" aria-label="Aircrafts">airplanemode_active</mat-icon>
|
||||
<a routerLink="/aircrafts" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>List of aircrafts</a>
|
||||
<a routerLink="/aircrafts" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>{{ 'App_Nav_Aircrafts' | translate }}</a>
|
||||
</mat-nav-list>
|
||||
<mat-nav-list>
|
||||
<mat-icon aria-hidden="false" aria-label="List of jump types">flight_land</mat-icon>
|
||||
<a routerLink="/jumpTypes" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>List of jump types</a>
|
||||
<a routerLink="/jumpTypes" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>{{ 'App_Nav_JumpTypes' | translate }}</a>
|
||||
</mat-nav-list>
|
||||
<mat-nav-list>
|
||||
<mat-icon aria-hidden="false" aria-label="List of gears">settings_input_antenna</mat-icon>
|
||||
<a routerLink="/gears" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>List of gears</a>
|
||||
<a routerLink="/gears" routerLinkActive="active" (click)="snav.toggle()" skipLocationChange>{{ 'App_Nav_Gears' | translate }}</a>
|
||||
</mat-nav-list>
|
||||
<mat-nav-list *ngIf="currentUser">
|
||||
<hr class="splitter">
|
||||
@@ -44,12 +44,12 @@
|
||||
</mat-nav-list>
|
||||
<mat-nav-list *ngIf="currentUser">
|
||||
<mat-icon aria-hidden="false" aria-label="To logout">logout</mat-icon>
|
||||
<span (click)="snav.toggle(); logout()" style="cursor: pointer;">Logout</span>
|
||||
<span (click)="snav.toggle(); logout()" style="cursor: pointer;">sdfsdfsf {{ 'App_Nav_Logout' | translate }}</span>
|
||||
</mat-nav-list>
|
||||
</mat-sidenav>
|
||||
|
||||
<mat-sidenav-content>
|
||||
<router-outlet></router-outlet>
|
||||
<footer style="text-align: right;">Web software to log your skydive jumps - v{{ version }} - @Séb</footer>
|
||||
<footer style="text-align: right;">{{ 'App_Footer' | translate }}{{ version }} - @Séb</footer>
|
||||
</mat-sidenav-content>
|
||||
</mat-sidenav-container>
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
|
||||
import { User } from "../models/user";
|
||||
import { CacheApiKey } from "../models/cache-api-key.enum";
|
||||
@@ -22,9 +23,13 @@ export class AppComponent implements OnInit {
|
||||
constructor(private router: Router,
|
||||
private authenticationService: AuthenticationService,
|
||||
private serviceComm: ServiceComm,
|
||||
private serviceCacheApi : ServiceCacheApi)
|
||||
private serviceCacheApi : ServiceCacheApi,
|
||||
private translateService: TranslateService)
|
||||
{
|
||||
this.authenticationService.currentUser.subscribe(user => { this.currentUser = user; });
|
||||
this.authenticationService.currentUser.subscribe(user => {
|
||||
this.currentUser = user;
|
||||
this.translateService.use(user.language);
|
||||
});
|
||||
|
||||
ConfigurationHelper.settings.subscribe(settings =>
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Router, ActivatedRoute } from "@angular/router";
|
||||
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
|
||||
import { first } from "rxjs/operators";
|
||||
|
||||
@@ -19,12 +20,11 @@ export class CreateUserComponent implements OnInit {
|
||||
returnUrl: string;
|
||||
error = "";
|
||||
|
||||
constructor(
|
||||
private formBuilder: FormBuilder,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private authenticationService: AuthenticationService
|
||||
) {
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private authenticationService: AuthenticationService,
|
||||
private translateService: TranslateService) {
|
||||
// redirect to home if already logged in
|
||||
if (this.authenticationService.currentUserValue) {
|
||||
this.router.navigate(["/"]);
|
||||
@@ -69,6 +69,7 @@ export class CreateUserComponent implements OnInit {
|
||||
createUser.firstName = this.formCtrls.firstname.value;
|
||||
createUser.lastName = this.formCtrls.lastname.value;
|
||||
createUser.email = this.formCtrls.email.value;
|
||||
createUser.language = this.translateService.currentLang;
|
||||
|
||||
this.authenticationService.create(createUser)
|
||||
.pipe(first())
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { AuthenticationService } from "../../services/authentication.service";
|
||||
import { ServiceComm } from "../../services/service-comm.service";
|
||||
|
||||
@@ -9,10 +10,13 @@ import { ServiceComm } from "../../services/service-comm.service";
|
||||
})
|
||||
export class DefaultComponent implements OnInit {
|
||||
constructor(private serviceComm: ServiceComm,
|
||||
private authenticationService: AuthenticationService) {}
|
||||
private authenticationService: AuthenticationService,
|
||||
private translateService: TranslateService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.serviceComm.UpdatedComponentTitle("Home");
|
||||
this.translateService.get("Home").subscribe(
|
||||
data => { this.serviceComm.UpdatedComponentTitle(data); }
|
||||
)
|
||||
this.authenticationService.alwaysLogin();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ 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 { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { first } from 'rxjs/operators';
|
||||
|
||||
@@ -31,7 +32,8 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
|
||||
private serviceApiAircraft : AircraftService,
|
||||
private serviceApiJumpType : JumpTypeService,
|
||||
private serviceApiDropzone : DropzoneService,
|
||||
private serviceApiGear : GearService) {
|
||||
private serviceApiGear : GearService,
|
||||
private translateService: TranslateService) {
|
||||
if (this.authenticationService.currentUserValue) {
|
||||
this.router.navigate(['/']);
|
||||
}
|
||||
@@ -71,7 +73,7 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
|
||||
this.authenticationService.login(this.formCtrls.username.value, this.formCtrls.password.value)
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
() => {
|
||||
data => {
|
||||
this.serviceApiAircraft.getListOfAircrafts(false).subscribe();
|
||||
this.serviceApiJumpType.getListOfJumpTypes().subscribe();
|
||||
this.serviceApiDropzone.getListOfDropZones(false).subscribe();
|
||||
|
||||
@@ -26,5 +26,16 @@
|
||||
"LoginCreateUser_Password" : "Password",
|
||||
"LoginCreateUser_PasswordRequired" : "Password is required",
|
||||
"LoginCreateUser_PasswordPattern" : "The pattern of the password ([A-Za-z0-9_-|/]{{ '{' }}8,15{{ '}' }})",
|
||||
"LoginCreateUser_BtnLogin" : "Create user and login"
|
||||
"LoginCreateUser_BtnLogin" : "Create user and login",
|
||||
|
||||
"Default_Title" : "Home",
|
||||
"App_Footer" : "Web software to log your skydive jumps - v",
|
||||
"App_Nav_Summary" : "Summary",
|
||||
"App_Nav_Jumps" : "List of jumps",
|
||||
"App_Nav_NewJump" : "Add a new jump",
|
||||
"App_Nav_Dzs" : "List of DZs",
|
||||
"App_Nav_Aircrafts" : "List of aircrafts",
|
||||
"App_Nav_JumpTypes" : "List of jump types",
|
||||
"App_Nav_Gears" : "List of gears",
|
||||
"App_Nav_Logout" : "Logout"
|
||||
}
|
||||
@@ -26,5 +26,16 @@
|
||||
"LoginCreateUser_Password" : "Mot de passe",
|
||||
"LoginCreateUser_PasswordRequired" : "Le mot de passe est obligatoire",
|
||||
"LoginCreateUser_PasswordPattern" : "Le mot de passe doit contenir lettres minuscule/majuscule et entre 8 et 15 caractères.",
|
||||
"LoginCreateUser_BtnLogin" : "Créer et se connecter"
|
||||
"LoginCreateUser_BtnLogin" : "Créer et se connecter",
|
||||
|
||||
"Default_Title" : "Accueil",
|
||||
"App_Footer" : "Application pour enregistrer ses sauts de parachutisme - v",
|
||||
"App_Nav_Summary" : "Résumé",
|
||||
"App_Nav_Jumps" : "Les sauts",
|
||||
"App_Nav_NewJump" : "Ajouter un saut",
|
||||
"App_Nav_Dzs" : "Centre de parachutisme",
|
||||
"App_Nav_Aircrafts" : "Avions",
|
||||
"App_Nav_JumpTypes" : "Type de saut",
|
||||
"App_Nav_Gears" : "Pièges",
|
||||
"App_Nav_Logout" : "Se Déconneter"
|
||||
}
|
||||
@@ -8,6 +8,7 @@ export class User {
|
||||
roles: string;
|
||||
authdata?: string;
|
||||
token?: string;
|
||||
language: string;
|
||||
|
||||
public get isAdmin(): boolean {
|
||||
return this.roles === "admin";
|
||||
|
||||
@@ -64,6 +64,10 @@ export class AuthenticationService extends BaseService {
|
||||
private pushToken(login: string, password: string, user: User){
|
||||
if (user && user.token) {
|
||||
user.authdata = window.btoa(login + ":" + password);
|
||||
|
||||
if (!user.language) {
|
||||
user.language = 'en';
|
||||
}
|
||||
localStorage.setItem("currentUser", JSON.stringify(user));
|
||||
this.currentUserSubject.next(user);
|
||||
}
|
||||
@@ -72,7 +76,7 @@ export class AuthenticationService extends BaseService {
|
||||
public alwaysLogin() {
|
||||
this.http.get(`${this.apiUrl}/User/AlwaysLogin`,
|
||||
{ headers: this.headers })
|
||||
.subscribe(data => { console.log(data); });
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
public logout() {
|
||||
|
||||
Reference in New Issue
Block a user