Skip to content

Commit b294097

Browse files
committed
Profil utilisateur
1 parent 65d99b9 commit b294097

File tree

14 files changed

+204
-278
lines changed

14 files changed

+204
-278
lines changed

src/app/app.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { GarageService } from './services/garage.service';
1818
import { TerrainService } from './services/terrain.service';
1919
import { VisiteService } from './services/visite.service';
2020
import { AppService } from './app.service';
21+
import { MatMenuModule } from '@angular/material/menu';
22+
import { MatIconModule } from '@angular/material/icon';
2123

2224
@NgModule({
2325
imports: [
@@ -27,7 +29,9 @@ import { AppService } from './app.service';
2729
ReactiveFormsModule,
2830
RouterModule,
2931
AppRoutingModule,
30-
ComponentsModule
32+
ComponentsModule,
33+
MatMenuModule,
34+
MatIconModule
3135
],
3236
declarations: [
3337
AppComponent,

src/app/app.routing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import { QuestionComponent } from './components/question/question.component';
1313
import { RoleComponent } from './components/role/role.component';
1414
import { TerrainComponent } from './components/terrain/terrain.component';
1515
import { UtilisateurComponent } from './components/utilisateur/utilisateur.component';
16-
import { VisiteComponent } from './components/visite/visite.component';
16+
import { VisiteComponent } from './components/utilisateur/visite/visite.component';
1717
import { LoginComponent } from './components/login/login.component';
1818
import { DashboardComponent } from './dashboard/dashboard.component';
1919

20-
const routes: Routes =[
20+
const routes: Routes = [
2121
{
2222
path: '',
2323
redirectTo: 'login',

src/app/app.service.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,45 @@ import { Router } from '@angular/router';
55
@Injectable({
66
providedIn: 'root'
77
})
8+
89
export class AppService {
910
// Authentification
10-
authenticated=false;
11+
authenticated = false;
1112
responseAll: any;
1213
// Autorisation :
1314
isAdmin = false;
1415
isGerant = false;
1516
isClient = false;
16-
constructor(private httpClient:HttpClient, private router:Router) { }
17+
// Step 1
18+
idUser: any;
19+
constructor(private httpClient: HttpClient, private router: Router) { }
1720

18-
authenticate(credentials:any,callback:any){
21+
authenticate(credentials: any, callback: any) {
1922
const headersAgency = new HttpHeaders(
2023
credentials ? {
21-
authorization : 'Basic ' + btoa(credentials.username+ ':' +credentials.password)
24+
authorization: 'Basic ' + btoa(credentials.username + ':' + credentials.password)
2225
} : {}
2326
);
24-
this.httpClient.get('http://localhost:8080/login/user',{headers:headersAgency}).subscribe(response => {
27+
this.httpClient.get('http://localhost:8080/login/user', { headers: headersAgency }).subscribe(response => {
2528
this.responseAll = response; // objet = utilisateur
26-
console.log("responseAll="+this.responseAll);
27-
if(this.responseAll['username']){
29+
console.log("responseAll=" + this.responseAll);
30+
// Step 2
31+
this.idUser = this.responseAll['idUtilisateur'];
32+
if (this.responseAll['username']) {
2833
this.authenticated = true;
2934
// vérification des profils :
30-
for(let i=0;i<this.responseAll['roles'].length;i++){
31-
if(this.responseAll['roles'][i]['idRole']==1){
35+
for (let i = 0; i < this.responseAll['roles'].length; i++) {
36+
if (this.responseAll['roles'][i]['idRole'] == 1) {
3237
this.isAdmin = true;
3338
}
34-
if(this.responseAll['roles'][i]['idRole']==2){
39+
if (this.responseAll['roles'][i]['idRole'] == 2) {
3540
this.isGerant = true;
3641
}
37-
if(this.responseAll['roles'][i]['idRole']==3){
42+
if (this.responseAll['roles'][i]['idRole'] == 3) {
3843
this.isClient = true;
3944
}
4045
}
41-
}else{
46+
} else {
4247
this.authenticated = false;
4348
}
4449
return callback && callback();

src/app/components/components.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { OffreComponent } from './offre/offre.component';
1414
import { QuestionComponent } from './question/question.component';
1515
import { RoleComponent } from './role/role.component';
1616
import { TerrainComponent } from './terrain/terrain.component';
17-
import { VisiteComponent } from './visite/visite.component';
17+
import { VisiteComponent } from './utilisateur/visite/visite.component';
1818
import { LoginComponent } from 'app/components/login/login.component';
1919
import { FormsModule } from '@angular/forms';
2020

src/app/dashboard/dashboard.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<br>
77
<br>
88
<br>
9+
<h1>Hello {{user.prenomUtilisateur}}</h1>
910
<div style="position: relative; left: 10px; background-color: white; border-color: black; border-width: thick;">
1011
<table>
1112
<th>

0 commit comments

Comments
 (0)