Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 86a9285

Browse files
CLIC EPFLs314cy
CLIC EPFL
andauthoredDec 2, 2021
tweak coaching page #150 (#222)
Co-authored-by: s314cy <hugo.elguedj@epfl.ch>
1 parent 1d619c0 commit 86a9285

File tree

5 files changed

+92
-84
lines changed

5 files changed

+92
-84
lines changed
 
-13.8 KB
Loading

‎src/pages/coaching/coaching-list.json

+41-23
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,52 @@
11
{
2-
"supercoaches": [
2+
"specialCoaches": [
33
{
44
"name": "Hugues Devimeux",
55
"imageURL": "/coaching/hugues_devimeux.jpg",
6-
"websiteURL": "https://people.epfl.ch/hugues.devimeux"
6+
"websiteURL": "https://people.epfl.ch/hugues.devimeux",
7+
"role": "Supercoach"
78
},
89
{
910
"name": "Paul Madelénat",
1011
"imageURL": "/coaching/paul_madelenat.jpg",
11-
"websiteURL": "https://people.epfl.ch/paul.madelenat"
12+
"websiteURL": "https://people.epfl.ch/paul.madelenat",
13+
"role": "Supercoach"
14+
},
15+
{
16+
"name": "Maxime Lestiboudois",
17+
"imageURL": "/coaching/maxime_lestiboudois.jpg",
18+
"websiteURL": "https://people.epfl.ch/maxime.lestiboudois",
19+
"role": "Trésorier"
20+
},
21+
{
22+
"name": "Théo Ducrey",
23+
"imageURL": "/coaching/theo_ducrey.jpg",
24+
"websiteURL": "https://people.epfl.ch/theo.ducrey",
25+
"role": "Logistique"
26+
},
27+
{
28+
"name": "Tancredi Cogne",
29+
"imageURL": "/coaching/tancredi_cogne.jpg",
30+
"websiteURL": "https://people.epfl.ch/tancredi.cogne",
31+
"role": "Intendance"
32+
},
33+
{
34+
"name": "Alexandra Lagutova",
35+
"imageURL": "/coaching/alexandra_lagutova.jpg",
36+
"websiteURL": "https://people.epfl.ch/alexandra.lagutova",
37+
"role": "Sponsoring"
38+
},
39+
{
40+
"name": "Khadija Tagemouati",
41+
"imageURL": "/coaching/khadija_tagemouati.jpg",
42+
"websiteURL": "https://people.epfl.ch/khadija.tagemouati",
43+
"role": "Communication"
44+
},
45+
{
46+
"name": "Sylvain Nérisson",
47+
"imageURL": "/coaching/sylvain_nerisson.jpg",
48+
"websiteURL": "https://people.epfl.ch/sylvain.nerisson",
49+
"role": "IT"
1250
}
1351
],
1452
"coaches": [
@@ -17,11 +55,6 @@
1755
"imageURL": "/coaching/ahmed_elalamy.jpg",
1856
"websiteURL": "https://people.epfl.ch/ahmed.elalamy"
1957
},
20-
{
21-
"name": "Alexandra",
22-
"imageURL": "/coaching/alexandra_lagutova.jpg",
23-
"websiteURL": "https://people.epfl.ch/alexandra.lagutova"
24-
},
2558
{
2659
"name": "Christelle",
2760
"imageURL": "/coaching/christelle_lam.jpg",
@@ -67,11 +100,6 @@
67100
"imageURL": "/coaching/jeremy_barghorn.jpg",
68101
"websiteURL": "https://people.epfl.ch/jeremy.barghorn"
69102
},
70-
{
71-
"name": "Khadija",
72-
"imageURL": "/coaching/khadija_tagemouati.jpg",
73-
"websiteURL": "https://people.epfl.ch/khadija.tagemouati"
74-
},
75103
{
76104
"name": "Leïla",
77105
"imageURL": "/coaching/leila_hammi.jpg",
@@ -92,11 +120,6 @@
92120
"imageURL": "/coaching/maxime_hilbig.jpg",
93121
"websiteURL": "https://people.epfl.ch/maxime.hilbig"
94122
},
95-
{
96-
"name": "Maxime L.",
97-
"imageURL": "/coaching/maxime_lestiboudois.jpg",
98-
"websiteURL": "https://people.epfl.ch/maxime.lestiboudois"
99-
},
100123
{
101124
"name": "Menelik",
102125
"imageURL": "/coaching/menelik_nouvellon.jpg",
@@ -162,11 +185,6 @@
162185
"imageURL": "/coaching/tamara_paris.jpg",
163186
"websiteURL": "https://people.epfl.ch/tamara.paris"
164187
},
165-
{
166-
"name": "Tancredi",
167-
"imageURL": "/coaching/tancredi_cogne.jpg",
168-
"websiteURL": "https://people.epfl.ch/theo.ducrey"
169-
},
170188
{
171189
"name": "Timo",
172190
"imageURL": "/coaching/timo_achard.jpg",

‎src/pages/coaching/coaching-page-view.njk

+20-22
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,31 @@
6969
<div class="center">
7070
<div class="content padded-40">
7171
<h1>Team</h1>
72-
<h3>Vos coachs dévoués</h3>
73-
74-
<div class="pole">
75-
{% for supercoach in supercoachingList %}
76-
<a href="{{supercoach.websiteURL}}" target="_blank">
77-
<div class="member">
78-
<img src="{{supercoach.imageURL}}" alt="{{supercoach.name}}"/>
79-
<div class="desc">
80-
<p class="name">{{supercoach.name}}</p>
81-
<p class="role">Supercoach</p>
82-
</div>
83-
</div>
84-
</a>
85-
{% endfor %}
86-
</div>
87-
88-
{% for coach in coachingList %}
89-
<a href="{{coach.websiteURL}}" target="_blank">
90-
<div class="coaching">
91-
<img src="{{coach.imageURL}}" alt="{{coach.name}}"/>
72+
<h3>Le comité</h3>
73+
<div class="pole">
74+
{% for specialCoach in specialCoachingList %}
75+
<a href="{{specialCoach.websiteURL}}" target="_blank">
76+
<div class="member">
77+
<img src="{{specialCoach.imageURL}}" alt="{{specialCoach.name}}"/>
9278
<div class="desc">
93-
<p class="name">{{coach.name}}</p>
79+
<p class="name">{{specialCoach.name}}</p>
80+
<p class="role">{{specialCoach.role}}</p>
9481
</div>
9582
</div>
9683
</a>
9784
{% endfor %}
98-
85+
</div>
86+
<h3 style="padding-top: 40px;">Les coachs IC</h3>
87+
{% for coach in coachingList %}
88+
<a href="{{coach.websiteURL}}" target="_blank">
89+
<div class="coaching">
90+
<img src="{{coach.imageURL}}" alt="{{coach.name}}"/>
91+
<div class="desc">
92+
<p class="name">{{coach.name}}</p>
93+
</div>
94+
</div>
95+
</a>
96+
{% endfor %}
9997
</div>
10098
</div>
10199
</div>

‎src/pages/coaching/coaching-page.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
import { Page } from '../page'
88
import { Request, Response } from 'express'
9-
import { Coach, coachingComponent } from './coaching'
9+
import { Coach, SpecialCoach, coachingComponent } from './coaching'
1010

1111
/**
1212
* View model that binds the data to the template for the coaching page
@@ -15,7 +15,7 @@ import { Coach, coachingComponent } from './coaching'
1515
*/
1616
class CoachingPageViewModel {
1717
coachingList: Coach[] = coachingComponent.getCoachingList()
18-
supercoachingList: Coach[] = coachingComponent.getSupercoachingList()
18+
specialCoachingList: SpecialCoach[] = coachingComponent.getSpecialCoachingList()
1919
}
2020

2121
/**

‎src/pages/coaching/coaching.ts

+29-37
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
1-
/**
2-
* This module defines committee members logic, datatypes and storage
3-
* CLIC website software
4-
*
5-
* @author Alexandre CHAU
6-
*/
71
import data from './coaching-list.json'
82
import { logger } from '../../logger'
93

10-
/**
11-
* This class represents a coach
12-
*
13-
* @member name The name of the coach
14-
* @member imageURL The exposed URL of the coach's profile picture ex: /coaching/jonhdoe.png
15-
* @member websiteURL The optional website of the coach
16-
*/
174
class Coach {
185
name: string
196
imageURL: string
@@ -25,29 +12,16 @@ class Coach {
2512
this.websiteURL = websiteURL
2613
}
2714

28-
/**
29-
* Builds a Coach from any Object that has the correct shape
30-
*
31-
* @param data Object to convert to Coach
32-
* @throws errors if input data is not of the correct shape
33-
* @warning Modify this method if the properties of the class are changed!
34-
*/
3515
static fromAny(data: any): Coach {
3616
if (!Coach.is(data)) {
37-
const message = `Cannot cast data to type Coach : wrong shape ${JSON.stringify(data)}`
17+
const message = `Cannot cast data to type Coach: wrong shape ${JSON.stringify(data)}`
3818
logger.log(message)
3919
throw new Error(message)
4020
} else {
4121
return new Coach(data.name, data.imageURL, data.websiteURL)
4222
}
4323
}
4424

45-
/**
46-
* Check type of object to test if it is a valid coach
47-
*
48-
* @param data Object to check if of type Coach
49-
* @warning Modify this method if the properties of the class are changed!
50-
*/
5125
static is(data: any): boolean {
5226
return (
5327
// check existence of object
@@ -62,15 +36,33 @@ class Coach {
6236
}
6337
}
6438

65-
/**
66-
* This is not really a component (yet?), but behaves like one. It handles coaching list logic such as storage, serialization and
67-
* querying
68-
*
69-
* @member coachingList The list of all coaches defined in {@link coaching-list.json}
70-
*/
39+
40+
class SpecialCoach extends Coach {
41+
role: string
42+
43+
constructor(name: string, imageURL: string, websiteURL: string, role: string) {
44+
super(name, imageURL, websiteURL)
45+
this.role = role
46+
}
47+
48+
static fromAny(data: any) {
49+
if (!SpecialCoach.is(data)) {
50+
const message = `Cannot cast data to type SpecialCoach: wrong shape ${JSON.stringify(data)}`
51+
logger.log(message)
52+
throw new Error(message)
53+
} else {
54+
return new SpecialCoach(data.name, data.imageURL, data.websiteURL, data.role)
55+
}
56+
}
57+
58+
static is(data: any) {
59+
return Coach.is(data) && data.role !== undefined && typeof data.role === "string"
60+
}
61+
}
62+
7163
class CoachingComponent {
7264
private readonly coachingList: Coach[] = data.coaches.map(Coach.fromAny)
73-
private readonly supercoachingList: Coach[] = data.supercoaches.map(Coach.fromAny)
65+
private readonly specialCoachingList: SpecialCoach[] = data.specialCoaches.map(SpecialCoach.fromAny)
7466

7567
/**
7668
* Returns all coaches in a fresh array
@@ -79,13 +71,13 @@ class CoachingComponent {
7971
return Object.assign([], this.coachingList)
8072
}
8173

82-
getSupercoachingList(): Coach[] {
83-
return Object.assign([], this.supercoachingList)
74+
getSpecialCoachingList(): SpecialCoach[] {
75+
return Object.assign([], this.specialCoachingList)
8476
}
8577
}
8678

8779
/**
8880
* Export a single instance of the coaching component
8981
*/
9082
const coachingComponent = new CoachingComponent()
91-
export { Coach, coachingComponent }
83+
export { Coach, SpecialCoach, coachingComponent }

0 commit comments

Comments
 (0)
This repository has been archived.