Skip to content

Commit feea12a

Browse files
authored
Merge pull request #12 from AdonisVienet/localBapt
Hello Adonis
2 parents 9396cca + c9fc082 commit feea12a

File tree

3 files changed

+161
-142
lines changed

3 files changed

+161
-142
lines changed

src/app/app.service.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,42 @@ import { Router } from '@angular/router';
77
})
88
export class AppService {
99
// Authentification
10-
authenticated=false;
10+
authenticated = false;
1111
responseAll: any;
1212
// Autorisation :
1313
isAdmin = false;
1414
isGerant = false;
1515
isClient = false;
16-
constructor(private httpClient:HttpClient, private router:Router) { }
16+
// Step 1
17+
idUser: any;
18+
constructor(private httpClient: HttpClient, private router: Router) { }
1719

18-
authenticate(credentials:any,callback:any){
20+
authenticate(credentials: any, callback: any) {
1921
const headersAgency = new HttpHeaders(
2022
credentials ? {
21-
authorization : 'Basic ' + btoa(credentials.username+ ':' +credentials.password)
23+
authorization: 'Basic ' + btoa(credentials.username + ':' + credentials.password)
2224
} : {}
2325
);
24-
this.httpClient.get('http://localhost:8080/login/user',{headers:headersAgency}).subscribe(response => {
26+
this.httpClient.get('http://localhost:8080/login/user', { headers: headersAgency }).subscribe(response => {
2527
this.responseAll = response; // objet = utilisateur
26-
console.log("responseAll="+this.responseAll);
27-
if(this.responseAll['username']){
28+
console.log("responseAll=" + this.responseAll);
29+
// Step 2
30+
this.idUser = this.responseAll['idUtilisateur'];
31+
if (this.responseAll['username']) {
2832
this.authenticated = true;
2933
// vérification des profils :
30-
for(let i=0;i<this.responseAll['roles'].length;i++){
31-
if(this.responseAll['roles'][i]['idRole']==1){
34+
for (let i = 0; i < this.responseAll['roles'].length; i++) {
35+
if (this.responseAll['roles'][i]['idRole'] == 1) {
3236
this.isAdmin = true;
3337
}
34-
if(this.responseAll['roles'][i]['idRole']==2){
38+
if (this.responseAll['roles'][i]['idRole'] == 2) {
3539
this.isGerant = true;
3640
}
37-
if(this.responseAll['roles'][i]['idRole']==3){
41+
if (this.responseAll['roles'][i]['idRole'] == 3) {
3842
this.isClient = true;
3943
}
4044
}
41-
}else{
45+
} else {
4246
this.authenticated = false;
4347
}
4448
return callback && callback();

src/app/dashboard/dashboard.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<br>
66
<br>
7+
<h1>Hello {{user.prenomUtilisateur}}</h1>
78
<br>
89
<br>
910
<div style="position: relative; left: 10px; background-color: white; border-color: black; border-width: thick;">
Lines changed: 144 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { AppService } from 'app/app.service';
3+
import { Utilisateur } from 'app/model/utilisateur';
4+
import { UtilisateurService } from 'app/services/utilisateur.service';
25
import * as Chartist from 'chartist';
36

47
@Component({
@@ -7,144 +10,155 @@ import * as Chartist from 'chartist';
710
styleUrls: ['./dashboard.component.css']
811
})
912
export class DashboardComponent implements OnInit {
10-
11-
constructor() { }
12-
startAnimationForLineChart(chart){
13-
let seq: any, delays: any, durations: any;
14-
seq = 0;
15-
delays = 80;
16-
durations = 500;
17-
18-
chart.on('draw', function(data) {
19-
if(data.type === 'line' || data.type === 'area') {
20-
data.element.animate({
21-
d: {
22-
begin: 600,
23-
dur: 700,
24-
from: data.path.clone().scale(1, 0).translate(0, data.chartRect.height()).stringify(),
25-
to: data.path.clone().stringify(),
26-
easing: Chartist.Svg.Easing.easeOutQuint
27-
}
28-
});
29-
} else if(data.type === 'point') {
30-
seq++;
31-
data.element.animate({
32-
opacity: {
33-
begin: seq * delays,
34-
dur: durations,
35-
from: 0,
36-
to: 1,
37-
easing: 'ease'
38-
}
39-
});
13+
// Step 3
14+
idUser: any;
15+
user: Utilisateur = new Utilisateur();
16+
// Step 4
17+
constructor(private utilisateurService: UtilisateurService, private appService: AppService) { }
18+
startAnimationForLineChart(chart) {
19+
let seq: any, delays: any, durations: any;
20+
seq = 0;
21+
delays = 80;
22+
durations = 500;
23+
24+
chart.on('draw', function (data) {
25+
if (data.type === 'line' || data.type === 'area') {
26+
data.element.animate({
27+
d: {
28+
begin: 600,
29+
dur: 700,
30+
from: data.path.clone().scale(1, 0).translate(0, data.chartRect.height()).stringify(),
31+
to: data.path.clone().stringify(),
32+
easing: Chartist.Svg.Easing.easeOutQuint
33+
}
34+
});
35+
} else if (data.type === 'point') {
36+
seq++;
37+
data.element.animate({
38+
opacity: {
39+
begin: seq * delays,
40+
dur: durations,
41+
from: 0,
42+
to: 1,
43+
easing: 'ease'
4044
}
41-
});
45+
});
46+
}
47+
});
4248

43-
seq = 0;
49+
seq = 0;
4450
};
45-
startAnimationForBarChart(chart){
46-
let seq2: any, delays2: any, durations2: any;
47-
48-
seq2 = 0;
49-
delays2 = 80;
50-
durations2 = 500;
51-
chart.on('draw', function(data) {
52-
if(data.type === 'bar'){
53-
seq2++;
54-
data.element.animate({
55-
opacity: {
56-
begin: seq2 * delays2,
57-
dur: durations2,
58-
from: 0,
59-
to: 1,
60-
easing: 'ease'
61-
}
62-
});
63-
}
64-
});
51+
startAnimationForBarChart(chart) {
52+
let seq2: any, delays2: any, durations2: any;
53+
54+
seq2 = 0;
55+
delays2 = 80;
56+
durations2 = 500;
57+
chart.on('draw', function (data) {
58+
if (data.type === 'bar') {
59+
seq2++;
60+
data.element.animate({
61+
opacity: {
62+
begin: seq2 * delays2,
63+
dur: durations2,
64+
from: 0,
65+
to: 1,
66+
easing: 'ease'
67+
}
68+
});
69+
}
70+
});
6571

66-
seq2 = 0;
72+
seq2 = 0;
6773
};
74+
// Step 5
75+
findOne(id: number) {
76+
this.utilisateurService.findOne(id).subscribe(data => { this.user = data; });
77+
}
6878
ngOnInit() {
69-
/* ----------========== Daily Sales Chart initialization For Documentation ==========---------- */
70-
71-
const dataDailySalesChart: any = {
72-
labels: ['M', 'T', 'W', 'T', 'F', 'S', 'S'],
73-
series: [
74-
[12, 17, 7, 17, 23, 18, 38]
75-
]
76-
};
77-
78-
const optionsDailySalesChart: any = {
79-
lineSmooth: Chartist.Interpolation.cardinal({
80-
tension: 0
81-
}),
82-
low: 0,
83-
high: 50, // creative tim: we recommend you to set the high sa the biggest value + something for a better look
84-
chartPadding: { top: 0, right: 0, bottom: 0, left: 0},
85-
}
86-
87-
var dailySalesChart = new Chartist.Line('#dailySalesChart', dataDailySalesChart, optionsDailySalesChart);
88-
89-
this.startAnimationForLineChart(dailySalesChart);
90-
91-
92-
/* ----------========== Completed Tasks Chart initialization ==========---------- */
93-
94-
const dataCompletedTasksChart: any = {
95-
labels: ['12p', '3p', '6p', '9p', '12p', '3a', '6a', '9a'],
96-
series: [
97-
[230, 750, 450, 300, 280, 240, 200, 190]
98-
]
99-
};
100-
101-
const optionsCompletedTasksChart: any = {
102-
lineSmooth: Chartist.Interpolation.cardinal({
103-
tension: 0
104-
}),
105-
low: 0,
106-
high: 1000, // creative tim: we recommend you to set the high sa the biggest value + something for a better look
107-
chartPadding: { top: 0, right: 0, bottom: 0, left: 0}
108-
}
109-
110-
var completedTasksChart = new Chartist.Line('#completedTasksChart', dataCompletedTasksChart, optionsCompletedTasksChart);
111-
112-
// start animation for the Completed Tasks Chart - Line Chart
113-
this.startAnimationForLineChart(completedTasksChart);
114-
115-
116-
117-
/* ----------========== Emails Subscription Chart initialization ==========---------- */
118-
119-
var datawebsiteViewsChart = {
120-
labels: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
121-
series: [
122-
[542, 443, 320, 780, 553, 453, 326, 434, 568, 610, 756, 895]
123-
124-
]
125-
};
126-
var optionswebsiteViewsChart = {
127-
axisX: {
128-
showGrid: false
129-
},
130-
low: 0,
131-
high: 1000,
132-
chartPadding: { top: 0, right: 5, bottom: 0, left: 0}
133-
};
134-
var responsiveOptions: any[] = [
135-
['screen and (max-width: 640px)', {
136-
seriesBarDistance: 5,
137-
axisX: {
138-
labelInterpolationFnc: function (value) {
139-
return value[0];
140-
}
79+
// Step 6
80+
this.idUser = this.appService.idUser;
81+
console.log("user profile " + this.idUser);
82+
this.findOne(this.idUser);
83+
/* ----------========== Daily Sales Chart initialization For Documentation ==========---------- */
84+
85+
const dataDailySalesChart: any = {
86+
labels: ['M', 'T', 'W', 'T', 'F', 'S', 'S'],
87+
series: [
88+
[12, 17, 7, 17, 23, 18, 38]
89+
]
90+
};
91+
92+
const optionsDailySalesChart: any = {
93+
lineSmooth: Chartist.Interpolation.cardinal({
94+
tension: 0
95+
}),
96+
low: 0,
97+
high: 50, // creative tim: we recommend you to set the high sa the biggest value + something for a better look
98+
chartPadding: { top: 0, right: 0, bottom: 0, left: 0 },
99+
}
100+
101+
var dailySalesChart = new Chartist.Line('#dailySalesChart', dataDailySalesChart, optionsDailySalesChart);
102+
103+
this.startAnimationForLineChart(dailySalesChart);
104+
105+
106+
/* ----------========== Completed Tasks Chart initialization ==========---------- */
107+
108+
const dataCompletedTasksChart: any = {
109+
labels: ['12p', '3p', '6p', '9p', '12p', '3a', '6a', '9a'],
110+
series: [
111+
[230, 750, 450, 300, 280, 240, 200, 190]
112+
]
113+
};
114+
115+
const optionsCompletedTasksChart: any = {
116+
lineSmooth: Chartist.Interpolation.cardinal({
117+
tension: 0
118+
}),
119+
low: 0,
120+
high: 1000, // creative tim: we recommend you to set the high sa the biggest value + something for a better look
121+
chartPadding: { top: 0, right: 0, bottom: 0, left: 0 }
122+
}
123+
124+
var completedTasksChart = new Chartist.Line('#completedTasksChart', dataCompletedTasksChart, optionsCompletedTasksChart);
125+
126+
// start animation for the Completed Tasks Chart - Line Chart
127+
this.startAnimationForLineChart(completedTasksChart);
128+
129+
130+
131+
/* ----------========== Emails Subscription Chart initialization ==========---------- */
132+
133+
var datawebsiteViewsChart = {
134+
labels: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
135+
series: [
136+
[542, 443, 320, 780, 553, 453, 326, 434, 568, 610, 756, 895]
137+
138+
]
139+
};
140+
var optionswebsiteViewsChart = {
141+
axisX: {
142+
showGrid: false
143+
},
144+
low: 0,
145+
high: 1000,
146+
chartPadding: { top: 0, right: 5, bottom: 0, left: 0 }
147+
};
148+
var responsiveOptions: any[] = [
149+
['screen and (max-width: 640px)', {
150+
seriesBarDistance: 5,
151+
axisX: {
152+
labelInterpolationFnc: function (value) {
153+
return value[0];
141154
}
142-
}]
143-
];
144-
var websiteViewsChart = new Chartist.Bar('#websiteViewsChart', datawebsiteViewsChart, optionswebsiteViewsChart, responsiveOptions);
155+
}
156+
}]
157+
];
158+
var websiteViewsChart = new Chartist.Bar('#websiteViewsChart', datawebsiteViewsChart, optionswebsiteViewsChart, responsiveOptions);
145159

146-
//start animation for the Emails Subscription Chart
147-
this.startAnimationForBarChart(websiteViewsChart);
160+
//start animation for the Emails Subscription Chart
161+
this.startAnimationForBarChart(websiteViewsChart);
148162
}
149163

150164
}

0 commit comments

Comments
 (0)