source: OpenWorkouts-current/ow/templates/dashboard.pt @ 5bdfbfb

currentfeature/docs
Last change on this file since 5bdfbfb was 5bdfbfb, checked in by borja <borja@…>, 5 years ago

(#7) Show year/month/weekly stats in the dashboard for the user,

including a bar chart for activity during the current week

  • Property mode set to 100644
File size: 9.6 KB
Line 
1<html xmlns="http://www.w3.org/1999/xhtml"
2      xml:lang="en"
3      xmlns:tal="http://xml.zope.org/namespaces/tal"
4      xmlns:metal="http://xml.zope.org/namespaces/metal"
5      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
6      i18n:domain="OpenWorkouts"
7      metal:use-macro="load: base.pt"
8      tal:attributes="lang request.locale_name">
9
10  <metal:head-title metal:fill-slot="head-title">
11    <tal:t i18n:translate="">My dashboard</tal:t>
12  </metal:head-title>
13
14  <!--!
15      <metal:title metal:fill-slot="title">
16        <tal:t i18n:translate="">dashboard for user</tal:t>
17        <tal:user tal:content="context.fullname"></tal:user>
18      </metal:title>
19      -->
20
21  <metal:content metal:fill-slot="content">
22
23    <div class="workout-content">
24
25      <section class="workout-list">
26
27        <h2 tal:content="context.fullname"></h2>
28
29        <h3>
30            (<tal:n tal:content="len(workouts)"></tal:n>/<tal:n tal:content="context.num_workouts"></tal:n>) <tal:t i18n:translate="">workouts</tal:t>
31        </h3>
32
33        <tal:no-workouts tal:condition="context.num_workouts == 0">
34            <div class="warning">
35                <p i18n:translate="">You haven't added any workouts yet</p>
36                <p>
37                    <a href="" i18n:translate=""
38                       tal:attributes="href request.resource_url(context, 'add-workout')">
39                        Upload one</a> |
40                    <a href="" i18n:translate=""
41                       tal:attributes="href request.resource_url(context, 'add-workout-manually')">
42                        Add one manually</a>
43                </p>
44            </div>
45        </tal:no-workouts>
46
47        <tal:r tal:repeat="workout workouts">
48
49          <article class="workout-resume">
50
51            <h2 class="workout-title">
52              <a href="" tal:content="workout.title"
53                 tal:attributes="href request.resource_url(workout)"></a>
54            </h2>
55
56            <ul class="workout-info">
57              <li>
58                <tal:c tal:content="workout.start_in_timezone(context.timezone)"></tal:c>
59              </li>
60              <li>
61                <!--! use the properly formatted duration instead of the timedelta object -->
62                <tal:c tal:content="workout._duration"></tal:c>
63              </li>
64              <li tal:condition="workout.distance">
65                <tal:c tal:content="workout.rounded_distance"></tal:c> km
66              </li>
67            </ul>
68
69            <ul class="workout-info" tal:define="hr workout.hr; cad workout.cad">
70              <li tal:condition="hr">
71                <span i18n:translate="">HR (bpm)</span>:
72                <tal:c tal:content="hr['min']"></tal:c>
73                <tal:t i18n:translate="">Min.</tal:t>,
74                <tal:c tal:content="hr['avg']"></tal:c>
75                <tal:t i18n:translate="">Avg.</tal:t>,
76                <tal:c tal:content="hr['max']"></tal:c>
77                <tal:t i18n:translate="">Max.</tal:t>
78              </li>
79              <li tal:condition="cad">
80                <span i18n:translate="">Cad</span>:
81                <tal:c tal:content="cad['min']"></tal:c>
82                <tal:t i18n:translate="">Min.</tal:t>,
83                <tal:c tal:content="cad['avg']"></tal:c>
84                <tal:t i18n:translate="">Avg.</tal:t>,
85                <tal:c tal:content="cad['max']"></tal:c>
86                <tal:t i18n:translate="">Max.</tal:t>
87              </li>
88            </ul>
89
90            <div class="workout-intro" tal:content="workout.notes"></div>
91
92            <div class="workout-map" tal:condition="workout.has_gpx">
93                <a href="" tal:attributes="href request.resource_url(workout)">
94                    <img src="" tal:attributes="src request.static_url(workout.map_screenshot);
95                              alt workout.title; title workout.title">
96                </a>
97            </div>
98
99            <ul class="workout-options">
100              <li class="owo-edit"><a href="" i18n:translate="" tal:attributes="href request.resource_url(workout, 'edit')"><span>edit</span></a></li>
101              <li class="owo-update"><a href="" i18n:translate="" tal:attributes="href request.resource_url(workout, 'update-from-file')"><span>update with tracking file</span></a></li>
102              <li class="owo-del"><a href="" i18n:translate="" tal:attributes="href request.resource_url(workout, 'delete')"><span>delete</span></a></li>
103            </ul>
104
105          </article>
106
107        </tal:r>
108
109      </section>
110
111      <aside class="workout-aside">
112          <tal:activity_tree tal:condition="context.num_workouts > 0">
113              <ul class="workout-activity-tree" tal:define="tree context.activity_dates_tree">
114                  <tal:years tal:repeat="year sorted(tree.keys(), reverse=True )">
115                      <li tal:define="is_viewing_year year == viewing_year">
116                          <a href="" tal:content="year"
117                             tal:attributes="href request.resource_url(context, query={'year': year});
118                                             class 'js-year viewing-year' if is_viewing_year  else 'js-year'">
119                          </a>
120                          <ul class="workout-activity-tree-year"
121                              tal:attributes="class 'workout-activity-tree-year' if is_viewing_year  else 'workout-activity-tree-year hidden'">
122                              <tal:months tal:repeat="month sorted(tree[year].keys())">
123                                  <li tal:define="is_viewing_month is_viewing_year and month == viewing_month">
124                                      <a href="" tal:content="month_name[month]"
125                                         tal:attributes="href request.resource_url(context, query={'year': year, 'month': month});
126                                                         class 'viewing-month' if is_viewing_month else ''">
127                                      </a>
128                                      <ul class="workout-activity-tree-month">
129                                          <tal:sports tal:repeat="sport sorted(tree[year][month].keys())">
130                                              <li>
131                                                  <a href="#">
132                                                      <tal:sport tal:content="sport"></tal:sport> (<tal:workouts tal:content="tree[year][month][sport]"></tal:workouts>)
133                                                  </a>
134                                              </li>
135                                          </tal:sports>
136                                      </ul>
137                                  </li>
138                              </tal:months>
139                          </ul>
140                      </li>
141                  </tal:years>
142              </ul>
143          </tal:activity_tree>
144
145          <tal:stats>
146
147            <div class="week-stats js-week-stats">
148              <h3><tal:t i18n:translate="">This week</tal:t></h3>
149              <h4 tal:define="totals context.week_totals">
150                <span class="week_totals_left">
151                  <tal:d tal:content="round(totals['distance'])"></tal:d>
152                  <tal:t i18n:translate="">kms</tal:t>
153                </span>
154                <span class="week_totals_right">
155                  <tal:hms tal:define="hms timedelta_to_hms(totals['time'])">
156                    <tal:h tal:content="str(hms[0]).zfill(2)"></tal:h>
157                    <tal:t i18n:translate="">hours</tal:t>,
158                    <tal:h tal:content="str(hms[1]).zfill(2)"></tal:h>
159                    <tal:t i18n:translate="">min.</tal:t>
160                  </tal:hms>
161                </span>
162              </h4>
163              <svg width="300" height="200"></svg>
164              <style>
165
166              </style>
167            </div>
168
169            <div class="user-stats">
170              <tal:year-stats tal:repeat="year context.activity_years">
171                <h3><a href="" tal:content="year"></a></h3>
172                <ul tal:define="stats context.stats(year)">
173                  <li>
174                    <span i18n:translate="">Workouts:</span>
175                    <span tal:content="stats['workouts']"></span>
176                  </li>
177                  <li>
178                    <span i18n:translate="">Distance:</span>
179                    <span tal:content="round(stats['distance'])"></span> kms
180                  </li>
181                  <li>
182                    <span i18n:translate="">Time:</span>
183                    <tal:hms tal:define="hms timedelta_to_hms(stats['time'])">
184                      <span>
185                        <tal:h tal:content="str(hms[0]).zfill(2)"></tal:h>
186                        <tal:t i18n:translate="">hours</tal:t>,
187                        <tal:h tal:content="str(hms[1]).zfill(2)"></tal:h>
188                        <tal:t i18n:translate="">min.</tal:t>
189                      </span>
190                    </tal:hms>
191                  </li>
192                  <li>
193                    <span i18n:translate="">Elevation:</span>
194                    <span tal:content="stats['elevation']"></span> m
195                  </li>
196                </ul>
197              </tal:year-stats>
198            </div>
199          </tal:stats>
200
201      </aside>
202
203    </div>
204
205  </metal:content>
206
207  <metal:body-js metal:fill-slot="body-js">
208    <script src="${request.static_url('ow:static/components/d3/d3.min.js')}"></script>
209    <script src="${request.static_url('ow:static/js/ow.js')}"></script>
210
211    <script type="text/javascript">
212     var week_chart = owjs.week_chart({
213         chart_selector: 'div.js-week-stats',
214         url: "${request.resource_url(context, 'week')}",
215         current_day_name: "${current_day_name}"
216     });
217     week_chart.render();
218    </script>
219
220  </metal:body-js>
221
222</html>
Note: See TracBrowser for help on using the repository browser.