Skip to content

Commit 956fc9f

Browse files
committed
some column renaming and hiding
1 parent 9b18979 commit 956fc9f

File tree

2 files changed

+42
-46
lines changed

2 files changed

+42
-46
lines changed

activityTable.js

+26-36
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,32 @@
22
/* eslint-disable require-jsdoc */
33
"use strict";
44

5-
const table_columns = [];
5+
const columns = [];
66

7-
table_columns.push(helper_tabulator_col_str("x_date", "Date"));
8-
table_columns.push(helper_tabulator_col_str("type", "Type"));
9-
table_columns.push(helper_tabulator_col_str("name", "Name", 120));
10-
table_columns.push(
11-
helper_tabulator_col_str("x_nearest_city_start", "City", 120)
12-
);
13-
table_columns.push(
14-
helper_tabulator_col_str("x_start_locality", "Known location start")
15-
);
16-
table_columns.push(helper_tabulator_col_str("x_end_locality", "-end"));
17-
table_columns.push(helper_tabulator_col_str("x_gear_name", "Gear", 120));
18-
table_columns.push(helper_tabulator_col_num("x_min", "Minutes"));
19-
table_columns.push(helper_tabulator_col_num("x_km", "Kilometers"));
20-
table_columns.push(helper_tabulator_col_num("km/h", "km/h"));
21-
table_columns.push(helper_tabulator_col_num("x_max_km/h", "max km/h"));
22-
table_columns.push(
23-
helper_tabulator_col_num("total_elevation_gain", "Elevation (m)")
24-
);
25-
table_columns.push(
26-
helper_tabulator_col_num("x_elev_m/km", "Elevation (m/km)")
27-
);
28-
table_columns.push(helper_tabulator_col_num("average_heartrate", "HR avg"));
29-
table_columns.push(helper_tabulator_col_num("max_heartrate", "HR max"));
30-
table_columns.push(helper_tabulator_col_num("average_cadence", "Cadence"));
31-
table_columns.push(helper_tabulator_col_num("average_watts", "Watts avg"));
32-
table_columns.push(helper_tabulator_col_num("kilojoules", "KJ"));
33-
table_columns.push(helper_tabulator_col_str("visibility", "visibility"));
34-
table_columns.push(helper_tabulator_col_num("athlete_count", "Athletes"));
35-
table_columns.push(helper_tabulator_col_num("workout_type", "W-Type"));
36-
table_columns.push(helper_tabulator_col_num("kudos_count", "Kudos"));
37-
table_columns.push(helper_tabulator_col_num("comment_count", "Comments"));
38-
table_columns.push(
39-
helper_tabulator_col_num("achievement_count", "Achievements")
40-
);
7+
columns.push(helper_tabulator_col_str("x_date", "Date"));
8+
columns.push(helper_tabulator_col_str("type", "Type"));
9+
columns.push(helper_tabulator_col_str("name", "Name", 120));
10+
columns.push(helper_tabulator_col_str("x_nearest_city_start", "City", 120));
11+
columns.push(helper_tabulator_col_str("x_start_locality", "Known location start"));
12+
columns.push(helper_tabulator_col_str("x_end_locality", "-end"));
13+
columns.push(helper_tabulator_col_str("x_gear_name", "Gear", 120));
14+
columns.push(helper_tabulator_col_num("x_min", "Minutes"));
15+
columns.push(helper_tabulator_col_num("x_km", "Kilometers"));
16+
columns.push(helper_tabulator_col_num("km/h", "km/h"));
17+
columns.push(helper_tabulator_col_num("x_max_km/h", "max km/h"));
18+
columns.push(helper_tabulator_col_num("total_elevation_gain", "Elevation (m)"));
19+
columns.push(helper_tabulator_col_num("x_elev_m/km", "Elevation (m/km)"));
20+
columns.push(helper_tabulator_col_num("average_heartrate", "HR avg"));
21+
columns.push(helper_tabulator_col_num("max_heartrate", "HR max"));
22+
columns.push(helper_tabulator_col_num("average_cadence", "Cadence"));
23+
columns.push(helper_tabulator_col_num("average_watts", "Watts avg"));
24+
columns.push(helper_tabulator_col_num("kilojoules", "KJ"));
25+
columns.push(helper_tabulator_col_str("visibility", "visibility"));
26+
columns.push(helper_tabulator_col_num("athlete_count", "Athletes"));
27+
columns.push(helper_tabulator_col_num("workout_type", "W-Type"));
28+
columns.push(helper_tabulator_col_num("kudos_count", "Kudos"));
29+
columns.push(helper_tabulator_col_num("comment_count", "Comments"));
30+
columns.push(helper_tabulator_col_num("achievement_count", "Achievements"));
4131

4232
function defineTable() {
4333
const table = new Tabulator("#table-activity-list", {
@@ -47,7 +37,7 @@ function defineTable() {
4737
layout: "fitDataStretch", // fit columns to width of table (optional)
4838
tooltipsHeader: false,
4939
selectable: false, // for row click
50-
columns: table_columns,
40+
columns: columns,
5141
initialSort: [{ column: "x_date", dir: "desc" }],
5242
});
5343
return table;

activityTop10V2.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ const measures = {
2323
x_km: "Distance",
2424
"km/h": "Speed",
2525
total_elevation_gain: "Elevation",
26-
"x_elev_m/km": "Elevation Gain per Distance",
27-
x_dist_start_end_km: "Distance Start-End",
28-
average_heartrate: "Average Heartrate",
29-
kilojoules: "Kilo Joule",
26+
"x_elev_m/km": "Elev. m/km",
27+
x_dist_start_end_km: "Dist Start-End",
28+
average_heartrate: "Heartrate avg",
29+
kilojoules: "KJ",
3030
};
3131

3232
// add options to html_sel_measure
3333
helper_populate_select(html_sel_measure, measures, null, true);
3434

35-
const table_columns = [];
35+
const columns = [];
3636

37-
table_columns.push(helper_tabulator_col_num("rank", "#"));
38-
table_columns.push(helper_tabulator_col_str("x_date", "Date"));
39-
table_columns.push(helper_tabulator_col_str("name", "Name", 300));
37+
columns.push(helper_tabulator_col_num("rank", "#"));
38+
columns.push(helper_tabulator_col_str("x_date", "Date"));
39+
columns.push(helper_tabulator_col_str("name", "Name", 300));
4040

4141
for (let i = 0; i < Object.keys(measures).length; i++) {
4242
const key = Object.keys(measures)[i];
43-
table_columns.push(helper_tabulator_col_num(key, measures[key]));
43+
columns.push(helper_tabulator_col_num(key, measures[key]));
4444
}
4545

4646
//
@@ -107,7 +107,7 @@ function defineTable() {
107107
layout: "fitDataStretch", // fit columns to width of table (optional)
108108
tooltipsHeader: false,
109109
selectable: false, // for row click
110-
columns: table_columns,
110+
columns: columns,
111111
});
112112
return table;
113113
}
@@ -168,10 +168,16 @@ function ranking() {
168168
table.getColumns().forEach(function (column) {
169169
table.showColumn(column.getField());
170170
});
171+
// hide some columns
171172
if (type === "Swim") {
172173
table.hideColumn("total_elevation_gain");
173174
table.hideColumn("x_elev_m/km");
174175
}
176+
if (type === "Ride") {
177+
table.showColumn("kilojoules");
178+
} else {
179+
table.hideColumn("kilojoules");
180+
}
175181
}
176182

177183
//

0 commit comments

Comments
 (0)