diff --git a/README.md b/README.md index f12b06a..d9cddec 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,10 @@ Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protrac ## Further help To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). + +## Models Generation using Swagger +Copy paste result of /swagger/v1/swagger.json file + +Run `node_modules/.bin/ng-swagger-gen --gen-config -i swagger.json` once to generate the generation file + +then Run `node_modules/.bin/ng-swagger-gen` to generate models diff --git a/src/app/app.component.html b/src/app/app.component.html index 0f465a4..7dc9b11 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,17 +1,16 @@
- MyMirror + MyMirror
- + - +
@@ -19,7 +18,7 @@ - App.Login + App.Home.Login
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index eb6b5a0..994c6d0 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -5,6 +5,7 @@ import { TranslateService } from '@ngx-translate/core'; import { AuthenticationService } from './_services/authentication.service'; import { Router } from '@angular/router'; import { first } from 'rxjs/operators'; +import { UserInfo } from './_api/models'; @Component({ @@ -15,7 +16,9 @@ import { first } from 'rxjs/operators'; export class AppComponent implements OnInit { title = 'MyControlPanel'; - items: MenuItem[]; + itemsUserDropDown: MenuItem[]; + + public ConnectedUser: UserInfo; public Connected = false; public DisplayLoginModal = false; @@ -28,6 +31,10 @@ export class AppComponent implements OnInit { public birthday: Date; + // Label + public LabelDropDownLogout: string; + public LabelDropDownModifyUser: string; + constructor( private _appService: AppService, private _translateService: TranslateService, @@ -36,17 +43,30 @@ export class AppComponent implements OnInit { ) {} ngOnInit() { - this.items = [ - {label: 'Update', icon: 'pi pi-refresh'}, - {label: 'Delete', icon: 'pi pi-times'} - ]; + // To Include in a fonction of a dropdown language chose - this._translateService.setDefaultLang('fr'); + this._translateService.setDefaultLang('en'); + + // To test + this._translateService.get('App.Home.UserDropDown.ModifyUser').subscribe(modifyLabel => { + this._translateService.get('App.Home.UserDropDown.Logout').subscribe(logoutLabel => { + this.itemsUserDropDown = [ + {label: modifyLabel, icon: 'fa fa-edit', command: () => { + // route get param => navigate vers profile + this._router.navigate(['/profile/01']); + }}, + {label: logoutLabel, icon: 'fa fa-sign-out', command: () => { + this.Logout(); + }} + ]; + }); + }); const currentUser = this._authService.currentUserValue; console.log(currentUser); if (currentUser && currentUser.token) { + this.ConnectedUser = currentUser; this.Connected = true; this.DisplayLoginModal = false; this.Username = null; @@ -78,6 +98,7 @@ export class AppComponent implements OnInit { .subscribe( data => { console.log(data); + this.ConnectedUser = data; this.Connected = true; this.DisplayLoginModal = false; this.Username = null; @@ -100,7 +121,12 @@ export class AppComponent implements OnInit { this._authService.IsLoggedIn = false; this._router.navigate(['/home']); } + public SignUp() { this.DisplaySignInModal = true; } + + public GoHome() { + this._router.navigate(['/home']); + } } diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index d41db0e..760da50 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -1,5 +1,17 @@ { "App":{ - "Login":"LOGIN" + "Home": { + "Login":"LOGIN", + "UserDropDown": { + "Logout": "Logout", + "ModifyUser": "Edit profile" + } + }, + "NotFound": { + }, + "Profile": { + "Edit": { + } + } } } diff --git a/src/assets/i18n/fr.json b/src/assets/i18n/fr.json index 0990002..6021080 100644 --- a/src/assets/i18n/fr.json +++ b/src/assets/i18n/fr.json @@ -1,5 +1,17 @@ { "App":{ - "Login":"Se Connecter" + "Home": { + "Login":"Se connecter", + "UserDropDown": { + "Logout": "Se déconnecter", + "ModifyUser": "Modifier profil" + } + }, + "NotFound": { + }, + "Profile": { + "Edit": { + } + } } }