incyclist-services 1.7.76 → 1.7.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/activities/list/service.js +1 -1
- package/lib/cjs/activities/ride/service.js +2 -1
- package/lib/cjs/workouts/base/graph/index.js +18 -0
- package/lib/cjs/workouts/base/graph/series.js +205 -0
- package/lib/cjs/workouts/base/graph/types.js +2 -0
- package/lib/cjs/workouts/base/model/index.js +0 -1
- package/lib/cjs/workouts/calendar/service.js +14 -0
- package/lib/cjs/workouts/index.js +2 -0
- package/lib/cjs/workouts/list/cards/index.js +0 -1
- package/lib/cjs/workouts/list/index.js +0 -1
- package/lib/cjs/workouts/list/pageService.js +362 -5
- package/lib/cjs/workouts/list/service.js +39 -12
- package/lib/cjs/workouts/page/index.js +17 -0
- package/lib/cjs/workouts/page/service.js +455 -0
- package/lib/cjs/workouts/page/types.js +2 -0
- package/lib/cjs/workouts/ride/index.js +1 -0
- package/lib/cjs/workouts/ride/page/index.js +18 -0
- package/lib/cjs/workouts/ride/page/service.js +498 -0
- package/lib/cjs/workouts/ride/page/types.js +2 -0
- package/lib/cjs/workouts/ride/service.js +1 -1
- package/lib/cjs/workouts/types.js +2 -0
- package/lib/esm/activities/list/service.js +1 -1
- package/lib/esm/activities/ride/service.js +2 -1
- package/lib/esm/workouts/base/graph/index.js +2 -0
- package/lib/esm/workouts/base/graph/series.js +197 -0
- package/lib/esm/workouts/base/graph/types.js +1 -0
- package/lib/esm/workouts/base/model/index.js +0 -1
- package/lib/esm/workouts/calendar/service.js +14 -0
- package/lib/esm/workouts/index.js +2 -0
- package/lib/esm/workouts/list/cards/index.js +0 -1
- package/lib/esm/workouts/list/index.js +0 -1
- package/lib/esm/workouts/list/pageService.js +362 -5
- package/lib/esm/workouts/list/service.js +39 -12
- package/lib/esm/workouts/page/index.js +1 -0
- package/lib/esm/workouts/page/service.js +451 -0
- package/lib/esm/workouts/page/types.js +1 -0
- package/lib/esm/workouts/ride/index.js +1 -0
- package/lib/esm/workouts/ride/page/index.js +2 -0
- package/lib/esm/workouts/ride/page/service.js +494 -0
- package/lib/esm/workouts/ride/page/types.js +1 -0
- package/lib/esm/workouts/ride/service.js +1 -1
- package/lib/esm/workouts/types.js +1 -0
- package/lib/types/types.d.ts +1 -0
- package/lib/types/workouts/base/graph/index.d.ts +2 -0
- package/lib/types/workouts/base/graph/series.d.ts +18 -0
- package/lib/types/workouts/base/graph/types.d.ts +11 -0
- package/lib/types/workouts/base/model/index.d.ts +0 -1
- package/lib/types/workouts/base/parsers/intervals/parser.d.ts +2 -1
- package/lib/types/workouts/calendar/service.d.ts +1 -0
- package/lib/types/workouts/index.d.ts +2 -0
- package/lib/types/workouts/list/cards/index.d.ts +0 -1
- package/lib/types/workouts/list/index.d.ts +0 -1
- package/lib/types/workouts/list/pageService.d.ts +136 -4
- package/lib/types/workouts/list/service.d.ts +4 -0
- package/lib/types/workouts/list/types.d.ts +1 -1
- package/lib/types/workouts/page/index.d.ts +1 -0
- package/lib/types/workouts/page/service.d.ts +57 -0
- package/lib/types/workouts/page/types.d.ts +95 -0
- package/lib/types/workouts/ride/index.d.ts +1 -0
- package/lib/types/workouts/ride/page/index.d.ts +2 -0
- package/lib/types/workouts/ride/page/service.d.ts +70 -0
- package/lib/types/workouts/ride/page/types.d.ts +71 -0
- package/lib/types/workouts/ride/service.d.ts +2 -1
- package/lib/types/workouts/ride/types.d.ts +3 -0
- package/lib/types/workouts/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.getWorkoutListPageService = exports.WorkoutListPageService = void 0;
|
|
38
|
+
const types_1 = require("../../base/types");
|
|
39
|
+
const pages_1 = require("../../base/pages");
|
|
40
|
+
const decorators_1 = require("../../base/decorators");
|
|
41
|
+
const appstate_1 = require("../../appstate");
|
|
42
|
+
const observer_1 = require("../../base/types/observer");
|
|
43
|
+
const settings_1 = require("../../settings");
|
|
44
|
+
const calendar_1 = require("../calendar");
|
|
45
|
+
const service_1 = require("../list/service");
|
|
46
|
+
const DEFAULT_IMPORT_GROUP = 'My Workouts';
|
|
47
|
+
const UPCOMING_COLLAPSED_COUNT = 3;
|
|
48
|
+
let WorkoutListPageService = (() => {
|
|
49
|
+
let _classDecorators = [types_1.Singleton];
|
|
50
|
+
let _classDescriptor;
|
|
51
|
+
let _classExtraInitializers = [];
|
|
52
|
+
let _classThis;
|
|
53
|
+
let _classSuper = pages_1.IncyclistPageService;
|
|
54
|
+
let _instanceExtraInitializers = [];
|
|
55
|
+
let _getWorkoutList_decorators;
|
|
56
|
+
let _getWorkoutCalendar_decorators;
|
|
57
|
+
let _getUserSettings_decorators;
|
|
58
|
+
let _getAppState_decorators;
|
|
59
|
+
var WorkoutListPageService = class extends _classSuper {
|
|
60
|
+
static { _classThis = this; }
|
|
61
|
+
static {
|
|
62
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
63
|
+
_getWorkoutList_decorators = [decorators_1.Injectable];
|
|
64
|
+
_getWorkoutCalendar_decorators = [decorators_1.Injectable];
|
|
65
|
+
_getUserSettings_decorators = [decorators_1.Injectable];
|
|
66
|
+
_getAppState_decorators = [decorators_1.Injectable];
|
|
67
|
+
__esDecorate(this, null, _getWorkoutList_decorators, { kind: "method", name: "getWorkoutList", static: false, private: false, access: { has: obj => "getWorkoutList" in obj, get: obj => obj.getWorkoutList }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
68
|
+
__esDecorate(this, null, _getWorkoutCalendar_decorators, { kind: "method", name: "getWorkoutCalendar", static: false, private: false, access: { has: obj => "getWorkoutCalendar" in obj, get: obj => obj.getWorkoutCalendar }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
69
|
+
__esDecorate(this, null, _getUserSettings_decorators, { kind: "method", name: "getUserSettings", static: false, private: false, access: { has: obj => "getUserSettings" in obj, get: obj => obj.getUserSettings }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
70
|
+
__esDecorate(this, null, _getAppState_decorators, { kind: "method", name: "getAppState", static: false, private: false, access: { has: obj => "getAppState" in obj, get: obj => obj.getAppState }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
71
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
72
|
+
WorkoutListPageService = _classThis = _classDescriptor.value;
|
|
73
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
74
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
75
|
+
}
|
|
76
|
+
groupFilter = (__runInitializers(this, _instanceExtraInitializers), null);
|
|
77
|
+
importPhase;
|
|
78
|
+
importGroup;
|
|
79
|
+
importingFileName;
|
|
80
|
+
importResult;
|
|
81
|
+
importError;
|
|
82
|
+
listObserver;
|
|
83
|
+
listUpdateHandler = this.emitPageUpdate.bind(this);
|
|
84
|
+
calendarUpdateHandler = this.emitPageUpdate.bind(this);
|
|
85
|
+
constructor() {
|
|
86
|
+
super('WorkoutListPage');
|
|
87
|
+
}
|
|
88
|
+
openPage() {
|
|
89
|
+
try {
|
|
90
|
+
super.openPage();
|
|
91
|
+
this.logEvent({ message: 'page shown', page: 'Workouts' });
|
|
92
|
+
const { observer } = this.getWorkoutList().open();
|
|
93
|
+
this.listObserver = observer;
|
|
94
|
+
this.listObserver?.on('started', this.listUpdateHandler);
|
|
95
|
+
this.listObserver?.on('loading', this.listUpdateHandler);
|
|
96
|
+
this.listObserver?.on('loaded', this.listUpdateHandler);
|
|
97
|
+
this.listObserver?.on('updated', this.listUpdateHandler);
|
|
98
|
+
this.getWorkoutCalendar().on('updated', this.calendarUpdateHandler);
|
|
99
|
+
this.emitPageUpdate();
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
this.logError(err, 'openPage');
|
|
103
|
+
}
|
|
104
|
+
return this.getPageObserver();
|
|
105
|
+
}
|
|
106
|
+
closePage() {
|
|
107
|
+
try {
|
|
108
|
+
this.getWorkoutList().close();
|
|
109
|
+
this.listObserver?.off('started', this.listUpdateHandler);
|
|
110
|
+
this.listObserver?.off('loading', this.listUpdateHandler);
|
|
111
|
+
this.listObserver?.off('loaded', this.listUpdateHandler);
|
|
112
|
+
this.listObserver?.off('updated', this.listUpdateHandler);
|
|
113
|
+
this.getWorkoutCalendar().off('updated', this.calendarUpdateHandler);
|
|
114
|
+
delete this.listObserver;
|
|
115
|
+
this.logEvent({ message: 'page closed', page: 'Workouts' });
|
|
116
|
+
super.closePage();
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
this.logError(err, 'closePage');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
getPageDisplayProps() {
|
|
123
|
+
try {
|
|
124
|
+
if (!this.getAppState().hasFeature('MOBILE_WORKOUTS')) {
|
|
125
|
+
return { pageType: 'placeholder' };
|
|
126
|
+
}
|
|
127
|
+
const service = this.getWorkoutList();
|
|
128
|
+
const loading = service.isStillLoading();
|
|
129
|
+
const upcoming = this.getUpcomingTrainingProps();
|
|
130
|
+
const allWorkouts = this.getAllWorkoutItems();
|
|
131
|
+
const groups = this.getGroupFilterProps();
|
|
132
|
+
const workouts = groups.selected ? allWorkouts.filter(w => w.group === groups.selected) : allWorkouts;
|
|
133
|
+
const selectedId = service.getSelected()?.id ?? null;
|
|
134
|
+
const isEmpty = allWorkouts.length === 0;
|
|
135
|
+
return { pageType: 'list', loading, upcoming, groups, workouts, selectedId, isEmpty };
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
this.logError(err, 'getPageDisplayProps');
|
|
139
|
+
return {};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
getWorkoutDetailsProps(id) {
|
|
143
|
+
try {
|
|
144
|
+
const card = this.findWorkoutCard(id);
|
|
145
|
+
if (!card)
|
|
146
|
+
return null;
|
|
147
|
+
const workout = card.getData();
|
|
148
|
+
const settingsProps = card.openSettings();
|
|
149
|
+
const isScheduled = card.getCardType() === 'ScheduledWorkout';
|
|
150
|
+
return {
|
|
151
|
+
id,
|
|
152
|
+
title: card.getTitle(),
|
|
153
|
+
description: workout?.description,
|
|
154
|
+
duration: settingsProps.duration,
|
|
155
|
+
workout,
|
|
156
|
+
ftp: settingsProps.settings?.ftp,
|
|
157
|
+
ftpRequired: settingsProps.ftpRequired,
|
|
158
|
+
useErgMode: settingsProps.settings?.useErgMode,
|
|
159
|
+
canStart: settingsProps.canStart,
|
|
160
|
+
canStartWorkoutOnly: settingsProps.canStartWorkoutOnly,
|
|
161
|
+
groups: settingsProps.categories,
|
|
162
|
+
group: settingsProps.category,
|
|
163
|
+
canDelete: card.canDelete(),
|
|
164
|
+
isScheduled,
|
|
165
|
+
date: isScheduled ? settingsProps.date : undefined
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
this.logError(err, 'getWorkoutDetailsProps');
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
getImportDisplayProps() {
|
|
174
|
+
try {
|
|
175
|
+
const phase = this.importPhase ?? 'landing';
|
|
176
|
+
const knownGroups = this.getKnownGroups();
|
|
177
|
+
const group = this.importGroup ?? this.getLastUsedImportGroup();
|
|
178
|
+
const props = { phase, group, knownGroups };
|
|
179
|
+
if (phase === 'importing')
|
|
180
|
+
props.importing = { fileName: this.importingFileName };
|
|
181
|
+
if (phase === 'result')
|
|
182
|
+
props.result = this.importResult;
|
|
183
|
+
if (phase === 'error')
|
|
184
|
+
props.error = this.importError;
|
|
185
|
+
return props;
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
this.logError(err, 'getImportDisplayProps');
|
|
189
|
+
return { phase: 'landing', group: DEFAULT_IMPORT_GROUP, knownGroups: [] };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
onSelectGroup(group) {
|
|
193
|
+
try {
|
|
194
|
+
this.groupFilter = group;
|
|
195
|
+
this.emitPageUpdate();
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
this.logError(err, 'onSelectGroup');
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
onOpenDetails(id) {
|
|
202
|
+
this.logEvent({ message: 'details opened', id });
|
|
203
|
+
}
|
|
204
|
+
onCloseDetails() {
|
|
205
|
+
this.logEvent({ message: 'details closed' });
|
|
206
|
+
}
|
|
207
|
+
onSetFtp(ftp) {
|
|
208
|
+
try {
|
|
209
|
+
const current = this.getWorkoutList().getStartSettings();
|
|
210
|
+
this.getWorkoutList().setStartSettings({ ...current, ftp });
|
|
211
|
+
this.emitPageUpdate();
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
this.logError(err, 'onSetFtp');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
onSetErgMode(enabled) {
|
|
218
|
+
try {
|
|
219
|
+
const current = this.getWorkoutList().getStartSettings();
|
|
220
|
+
this.getWorkoutList().setStartSettings({ ...current, useErgMode: enabled });
|
|
221
|
+
this.emitPageUpdate();
|
|
222
|
+
}
|
|
223
|
+
catch (err) {
|
|
224
|
+
this.logError(err, 'onSetErgMode');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
onChangeGroup(id, group) {
|
|
228
|
+
try {
|
|
229
|
+
const card = this.findWorkoutCard(id);
|
|
230
|
+
card?.move(group);
|
|
231
|
+
this.emitPageUpdate();
|
|
232
|
+
}
|
|
233
|
+
catch (err) {
|
|
234
|
+
this.logError(err, 'onChangeGroup');
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async onDelete(id) {
|
|
238
|
+
try {
|
|
239
|
+
const observer = this.getWorkoutList().deleteWorkout(id);
|
|
240
|
+
const deleted = await observer.wait();
|
|
241
|
+
this.emitPageUpdate();
|
|
242
|
+
return !!deleted;
|
|
243
|
+
}
|
|
244
|
+
catch (err) {
|
|
245
|
+
this.logError(err, 'onDelete');
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
onStart(id, opts) {
|
|
250
|
+
try {
|
|
251
|
+
const card = this.findWorkoutCard(id);
|
|
252
|
+
if (!card)
|
|
253
|
+
return;
|
|
254
|
+
const settings = this.getWorkoutList().getStartSettings();
|
|
255
|
+
card.select({ ...settings, noRoute: opts?.noRoute });
|
|
256
|
+
this.getPageObserver()?.emit('start-ride', { id, noRoute: opts?.noRoute });
|
|
257
|
+
}
|
|
258
|
+
catch (err) {
|
|
259
|
+
this.logError(err, 'onStart');
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
onMarkForRoute(id) {
|
|
263
|
+
try {
|
|
264
|
+
const card = this.findWorkoutCard(id);
|
|
265
|
+
if (!card)
|
|
266
|
+
return;
|
|
267
|
+
const settings = this.getWorkoutList().getStartSettings();
|
|
268
|
+
card.select({ ...settings, noRoute: false });
|
|
269
|
+
this.emitPageUpdate();
|
|
270
|
+
}
|
|
271
|
+
catch (err) {
|
|
272
|
+
this.logError(err, 'onMarkForRoute');
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
onClearSelection() {
|
|
276
|
+
try {
|
|
277
|
+
this.getWorkoutList().unselect();
|
|
278
|
+
this.emitPageUpdate();
|
|
279
|
+
}
|
|
280
|
+
catch (err) {
|
|
281
|
+
this.logError(err, 'onClearSelection');
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
onImportOpen() {
|
|
285
|
+
try {
|
|
286
|
+
this.importPhase = 'landing';
|
|
287
|
+
this.importGroup = this.getLastUsedImportGroup();
|
|
288
|
+
delete this.importError;
|
|
289
|
+
delete this.importResult;
|
|
290
|
+
this.emitImportUpdate();
|
|
291
|
+
}
|
|
292
|
+
catch (err) {
|
|
293
|
+
this.logError(err, 'onImportOpen');
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
onImportGroupChange(name) {
|
|
297
|
+
try {
|
|
298
|
+
this.importGroup = name;
|
|
299
|
+
this.emitImportUpdate();
|
|
300
|
+
}
|
|
301
|
+
catch (err) {
|
|
302
|
+
this.logError(err, 'onImportGroupChange');
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
onImportFile(file) {
|
|
306
|
+
const observer = new observer_1.Observer();
|
|
307
|
+
try {
|
|
308
|
+
const group = this.importGroup;
|
|
309
|
+
this.importPhase = 'importing';
|
|
310
|
+
this.importingFileName = file?.name;
|
|
311
|
+
this.emitImportUpdate();
|
|
312
|
+
this.getWorkoutList().import(file, { showImportCards: false })
|
|
313
|
+
.then(([card]) => {
|
|
314
|
+
if (group && group !== DEFAULT_IMPORT_GROUP)
|
|
315
|
+
card.move(group);
|
|
316
|
+
this.persistLastUsedImportGroup(group);
|
|
317
|
+
this.importPhase = 'result';
|
|
318
|
+
this.importResult = { workoutName: card.getTitle(), group };
|
|
319
|
+
observer.emit('success');
|
|
320
|
+
this.emitImportUpdate();
|
|
321
|
+
})
|
|
322
|
+
.catch((err) => {
|
|
323
|
+
this.importPhase = 'error';
|
|
324
|
+
this.importError = err?.message;
|
|
325
|
+
observer.emit('error', err);
|
|
326
|
+
this.emitImportUpdate();
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
catch (err) {
|
|
330
|
+
this.logError(err, 'onImportFile');
|
|
331
|
+
}
|
|
332
|
+
return observer;
|
|
333
|
+
}
|
|
334
|
+
onImportClose() {
|
|
335
|
+
try {
|
|
336
|
+
delete this.importPhase;
|
|
337
|
+
delete this.importingFileName;
|
|
338
|
+
delete this.importResult;
|
|
339
|
+
delete this.importError;
|
|
340
|
+
this.emitImportUpdate();
|
|
341
|
+
}
|
|
342
|
+
catch (err) {
|
|
343
|
+
this.logError(err, 'onImportClose');
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
getUpcomingTrainingProps() {
|
|
347
|
+
const calendar = this.getWorkoutCalendar();
|
|
348
|
+
const scheduled = calendar.getScheduledWorkouts();
|
|
349
|
+
if (!scheduled || scheduled.length === 0)
|
|
350
|
+
return null;
|
|
351
|
+
const todayId = calendar.getScheduledToday()?.id ?? null;
|
|
352
|
+
const selectedWorkout = this.getWorkoutList().getSelected();
|
|
353
|
+
const items = scheduled.map(w => ({
|
|
354
|
+
id: w.id,
|
|
355
|
+
title: w.workout?.name,
|
|
356
|
+
date: w.day,
|
|
357
|
+
duration: this.formatDuration(w.workout?.duration),
|
|
358
|
+
isToday: todayId !== null && w.id === todayId,
|
|
359
|
+
selected: selectedWorkout?.id !== undefined && selectedWorkout.id === w.workout?.id,
|
|
360
|
+
workout: w.workout
|
|
361
|
+
}));
|
|
362
|
+
return { items, collapsedCount: UPCOMING_COLLAPSED_COUNT, todayId };
|
|
363
|
+
}
|
|
364
|
+
getGroupFilterProps() {
|
|
365
|
+
const available = this.getKnownGroups();
|
|
366
|
+
return { available, selected: this.groupFilter };
|
|
367
|
+
}
|
|
368
|
+
getKnownGroups() {
|
|
369
|
+
const lists = this.getWorkoutList().getLists(false) ?? [];
|
|
370
|
+
return lists.filter(l => l.getId() !== 'scheduled').map(l => l.getTitle());
|
|
371
|
+
}
|
|
372
|
+
getAllWorkoutItems() {
|
|
373
|
+
const lists = this.getWorkoutList().getLists(false) ?? [];
|
|
374
|
+
const items = [];
|
|
375
|
+
lists.forEach(list => {
|
|
376
|
+
if (list.getId() === 'scheduled')
|
|
377
|
+
return;
|
|
378
|
+
list.getCards().forEach(card => {
|
|
379
|
+
if (card.getCardType() !== 'Workout')
|
|
380
|
+
return;
|
|
381
|
+
const workoutCard = card;
|
|
382
|
+
const props = workoutCard.getDisplayProperties();
|
|
383
|
+
items.push({
|
|
384
|
+
id: workoutCard.getId(),
|
|
385
|
+
title: props.title,
|
|
386
|
+
group: list.getTitle(),
|
|
387
|
+
duration: props.duration,
|
|
388
|
+
selected: props.selected,
|
|
389
|
+
canDelete: props.canDelete,
|
|
390
|
+
workout: props.workout
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
return items;
|
|
395
|
+
}
|
|
396
|
+
findWorkoutCard(id) {
|
|
397
|
+
const lists = this.getWorkoutList().getLists(false) ?? [];
|
|
398
|
+
for (const list of lists) {
|
|
399
|
+
const card = list.getCards().find(c => c.getId() === id);
|
|
400
|
+
if (card)
|
|
401
|
+
return card;
|
|
402
|
+
}
|
|
403
|
+
return undefined;
|
|
404
|
+
}
|
|
405
|
+
getLastUsedImportGroup() {
|
|
406
|
+
return this.getUserSettings().get('preferences.workouts.lastImportGroup', DEFAULT_IMPORT_GROUP);
|
|
407
|
+
}
|
|
408
|
+
persistLastUsedImportGroup(group) {
|
|
409
|
+
try {
|
|
410
|
+
this.getUserSettings().set('preferences.workouts.lastImportGroup', group);
|
|
411
|
+
}
|
|
412
|
+
catch (err) {
|
|
413
|
+
this.logError(err, 'persistLastUsedImportGroup');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
formatDuration(duration) {
|
|
417
|
+
if (duration === undefined || duration === null)
|
|
418
|
+
return '';
|
|
419
|
+
if (duration < 120)
|
|
420
|
+
return `${duration.toFixed(0)}s`;
|
|
421
|
+
if (duration % 60 === 0)
|
|
422
|
+
return `${duration / 60}min`;
|
|
423
|
+
const secVal = duration % 60;
|
|
424
|
+
const minVal = (duration - secVal) / 60 % 60;
|
|
425
|
+
const h = Math.floor((duration - secVal - minVal * 60) / 3600);
|
|
426
|
+
const sec = secVal < 10 ? `0${secVal}` : secVal;
|
|
427
|
+
const min = minVal < 10 ? `0${minVal}` : minVal;
|
|
428
|
+
if (h > 0)
|
|
429
|
+
return `${h}:${min}:${sec}`;
|
|
430
|
+
return `${min}:${sec}`;
|
|
431
|
+
}
|
|
432
|
+
emitPageUpdate() {
|
|
433
|
+
this.getPageObserver()?.emit('page-update');
|
|
434
|
+
}
|
|
435
|
+
emitImportUpdate() {
|
|
436
|
+
this.getPageObserver()?.emit('import-update');
|
|
437
|
+
}
|
|
438
|
+
getWorkoutList() {
|
|
439
|
+
return (0, service_1.useWorkoutList)();
|
|
440
|
+
}
|
|
441
|
+
getWorkoutCalendar() {
|
|
442
|
+
return (0, calendar_1.useWorkoutCalendar)();
|
|
443
|
+
}
|
|
444
|
+
getUserSettings() {
|
|
445
|
+
return (0, settings_1.useUserSettings)();
|
|
446
|
+
}
|
|
447
|
+
getAppState() {
|
|
448
|
+
return (0, appstate_1.useAppState)();
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
return WorkoutListPageService = _classThis;
|
|
452
|
+
})();
|
|
453
|
+
exports.WorkoutListPageService = WorkoutListPageService;
|
|
454
|
+
const getWorkoutListPageService = () => new WorkoutListPageService();
|
|
455
|
+
exports.getWorkoutListPageService = getWorkoutListPageService;
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./service"), exports);
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./page"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./service"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|