[Pharo] Personal fitness tracker web app.
1
Class {
2
#name : 'MFTHomePage',
3
#superclass : 'MFTPage',
4
#category : 'MyFitnessTracker-Web-Components',
5
#package : 'MyFitnessTracker-Web',
6
#tag : 'Components'
7
}
8
9
{ #category : 'rendering' }
10
MFTHomePage >> renderContentOn: html [
11
12
html heading
13
level: 1;
14
with: self session user trainee currentRoutine canonicalName capitalized.
15
self
16
renderStatusOn: html;
17
renderNextWorkoutPrescriptionOn: html;
18
renderMainActionsOn: html.
19
self session user trainee logBook workoutLogs ifNotEmpty: [
20
self renderWorkoutLogBookOn: html ]
21
]
22
23
{ #category : 'rendering' }
24
MFTHomePage >> renderMainActionsOn: html [
25
26
| trainee |
27
trainee := self session user trainee.
28
29
html div: [
30
html anchor
31
callback: [
32
| workoutLog |
33
workoutLog := self call:
34
(MFTWorkoutLogEditorPage forWorkoutPrescription:
35
trainee nextWorkoutPrescription).
36
workoutLog ifNotNil: [ trainee logWorkout: workoutLog ] ];
37
with: 'Log workout' ]
38
]
39
40
{ #category : 'rendering' }
41
MFTHomePage >> renderNextWorkoutPrescriptionOn: html [
42
43
| workoutPrescription |
44
workoutPrescription := self session user trainee
45
nextWorkoutPrescription.
46
47
html heading
48
level: 2;
49
with: 'Next workout'.
50
html heading
51
level: 3;
52
with: workoutPrescription canonicalName.
53
html render:
54
(MFTWorkoutPrescriptionTable forPrescription: workoutPrescription)
55
]
56
57
{ #category : 'rendering' }
58
MFTHomePage >> renderStatusOn: html [
59
60
| trainee |
61
trainee := self session user trainee.
62
63
html definitionList: [
64
trainee logBook durationSinceLastWorkout ifNotNil: [
65
html
66
definitionTerm: 'Hours since last workout';
67
definitionData:
68
trainee logBook durationSinceLastWorkout asHours rounded asString ].
69
html
70
definitionTerm: 'Recovery status';
71
definitionData: (trainee isRecovered
72
ifTrue: [ 'Fully recovered' ]
73
ifFalse: [ 'Not recovered yet' ]) ]
74
]
75
76
{ #category : 'rendering' }
77
MFTHomePage >> renderWorkoutLogBookOn: html [
78
79
html heading
80
level: 2;
81
with: 'Previous workouts'.
82
html table
83
style: 'max-width: 30rem';
84
with: [
85
html
86
tableHead: [
87
html tableRow: [
88
html
89
tableData: 'Date';
90
tableData: 'Name';
91
tableData: 'Volume';
92
tableData: 'Intensity' ] ];
93
tableBody: [
94
self session user trainee logBook workoutLogs reverseDo: [
95
:workoutLog |
96
html tableRow: [
97
html
98
tableData: workoutLog start asDate yyyymmdd;
99
tableData: workoutLog canonicalName;
100
tableData: workoutLog volume;
101
tableData: workoutLog intensityFactor asString , '%' ] ] ] ]
102
]
103
104
{ #category : 'accessing' }
105
MFTHomePage >> title [
106
107
^ 'Home'
108
]
109