incyclist-services 1.9.21 → 1.9.23
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/base/repo/db.js +8 -2
- package/lib/cjs/activities/base/utils/helpers.js +26 -11
- package/lib/cjs/activities/upload/index.js +1 -0
- package/lib/cjs/activities/upload/komoot.js +166 -0
- package/lib/cjs/apps/base/api/komoot/api.js +35 -0
- package/lib/cjs/apps/komoot/KomootAppConnection.js +6 -4
- package/lib/cjs/apps/service.js +1 -1
- package/lib/cjs/devices/page/base/guidance/guidance.js +277 -16
- package/lib/cjs/devices/page/base/service.js +245 -16
- package/lib/cjs/devices/page/desktop/matrix.js +2 -1
- package/lib/cjs/devices/page/desktop/service.js +4 -11
- package/lib/cjs/devices/page/mobile/service.js +1 -0
- package/lib/cjs/devices/pairing/conflict.js +47 -0
- package/lib/cjs/devices/pairing/guidance.js +40 -4
- package/lib/cjs/devices/pairing/helper.js +3 -1
- package/lib/cjs/devices/pairing/index.js +1 -0
- package/lib/cjs/devices/pairing/service.js +228 -35
- package/lib/cjs/devices/pairing/status.js +1 -0
- package/lib/cjs/devices/ride/service.js +20 -4
- package/lib/cjs/devices/ride/timeouts.js +9 -0
- package/lib/cjs/ride/display/service.js +2 -2
- package/lib/cjs/routes/base/api/api.js +1 -0
- package/lib/esm/activities/base/repo/db.js +8 -2
- package/lib/esm/activities/base/utils/helpers.js +24 -10
- package/lib/esm/activities/upload/index.js +1 -0
- package/lib/esm/activities/upload/komoot.js +163 -0
- package/lib/esm/apps/base/api/komoot/api.js +35 -0
- package/lib/esm/apps/komoot/KomootAppConnection.js +6 -4
- package/lib/esm/apps/service.js +1 -1
- package/lib/esm/devices/page/base/guidance/guidance.js +276 -15
- package/lib/esm/devices/page/base/service.js +246 -17
- package/lib/esm/devices/page/desktop/matrix.js +2 -1
- package/lib/esm/devices/page/desktop/service.js +4 -11
- package/lib/esm/devices/page/mobile/service.js +1 -0
- package/lib/esm/devices/pairing/conflict.js +9 -4
- package/lib/esm/devices/pairing/guidance.js +40 -4
- package/lib/esm/devices/pairing/helper.js +1 -0
- package/lib/esm/devices/pairing/index.js +1 -0
- package/lib/esm/devices/pairing/service.js +228 -35
- package/lib/esm/devices/pairing/status.js +1 -0
- package/lib/esm/devices/ride/service.js +20 -4
- package/lib/esm/ride/display/service.js +2 -2
- package/lib/esm/routes/base/api/api.js +1 -0
- package/lib/types/activities/base/model/index.d.ts +1 -5
- package/lib/types/activities/base/repo/db.d.ts +2 -1
- package/lib/types/activities/base/utils/helpers.d.ts +2 -1
- package/lib/types/activities/upload/index.d.ts +1 -0
- package/lib/types/activities/upload/komoot.d.ts +20 -0
- package/lib/types/apps/base/api/komoot/api.d.ts +2 -1
- package/lib/types/apps/base/api/komoot/types.d.ts +1 -0
- package/lib/types/apps/komoot/KomootAppConnection.d.ts +1 -1
- package/lib/types/devices/page/base/guidance/guidance.d.ts +49 -2
- package/lib/types/devices/page/base/guidance/types.d.ts +20 -2
- package/lib/types/devices/page/base/service.d.ts +36 -2
- package/lib/types/devices/page/base/types.d.ts +31 -0
- package/lib/types/devices/page/desktop/service.d.ts +1 -2
- package/lib/types/devices/pairing/conflict.d.ts +4 -1
- package/lib/types/devices/pairing/guidance.d.ts +9 -4
- package/lib/types/devices/pairing/helper.d.ts +1 -0
- package/lib/types/devices/pairing/index.d.ts +1 -0
- package/lib/types/devices/pairing/model.d.ts +1 -0
- package/lib/types/devices/pairing/service.d.ts +43 -4
- package/lib/types/devices/pairing/status.d.ts +2 -1
- package/lib/types/devices/ride/service.d.ts +1 -0
- package/package.json +2 -2
|
@@ -35,7 +35,7 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
35
35
|
import { EventLogger } from 'gd-eventlog';
|
|
36
36
|
import { Injectable } from '../../../base/decorators';
|
|
37
37
|
import { IncyclistPageService } from '../../../base/pages';
|
|
38
|
-
import { useDevicePairing, PAIRING_CAPABILITY_ROLES, getCapabilityHelpText, getEmptyTileFooterText, getPairingGuidanceText, getPairingRowLabelId, getPairingStatusDisplay, getPairingTileState, isCapabilityActive, getPairingHelperFooter, getPairingHelperReasonLabel, getPairingHelperTip, getPairingHelperTitle, hasContinueWithoutDeviceAction, PAIRING_HELPER_RESOLVED_TEXT, PAIRING_HELPER_SUBLINE } from '../../pairing';
|
|
38
|
+
import { useDevicePairing, PAIRING_CAPABILITY_ROLES, getCapabilityHelpText, getEmptyTileFooterText, getPairingGuidanceText, getPairingRowLabelId, getPairingStatusDisplay, getPairingTileState, isCapabilityActive, getFallbackActionLabel, getPairingHelperFooter, getPairingHelperReasonLabel, getPairingHelperTip, getPairingHelperTitle, hasContinueWithoutDeviceAction, PAIRING_HELPER_RESOLVED_TEXT, PAIRING_HELPER_SUBLINE, getCapabilityTitle, getConflictKeepLabel, getConflictQueuedText, getConflictReplaceLabel, getConflictStepSubline, getConflictStepTitle } from '../../pairing';
|
|
39
39
|
import { PageLogObserver } from './logobserver';
|
|
40
40
|
import { IncyclistCapability } from 'incyclist-devices';
|
|
41
41
|
import { useDeviceConfiguration } from '../../configuration';
|
|
@@ -67,6 +67,10 @@ let PairingPageService = (() => {
|
|
|
67
67
|
handingOffToRide = false;
|
|
68
68
|
guidance;
|
|
69
69
|
onPairingStateHandler = this.onPairingState.bind(this);
|
|
70
|
+
onExclusionRevertedHandler = this.onExclusionReverted.bind(this);
|
|
71
|
+
onSelectionConflictHandler = this.updatePage.bind(this);
|
|
72
|
+
conflictStep;
|
|
73
|
+
cardChoices;
|
|
70
74
|
constructor() {
|
|
71
75
|
super('pairing');
|
|
72
76
|
this.stateMachine = this.createOrchestrator();
|
|
@@ -74,6 +78,7 @@ let PairingPageService = (() => {
|
|
|
74
78
|
this.guidance = new PairingGuidance({
|
|
75
79
|
log: (message, fields) => { this.logEvent({ message, ...fields }); },
|
|
76
80
|
onChange: () => { this.updatePage(); },
|
|
81
|
+
configuration: () => this.getDeviceConfiguration(),
|
|
77
82
|
});
|
|
78
83
|
}
|
|
79
84
|
get openedCapability() {
|
|
@@ -171,40 +176,44 @@ let PairingPageService = (() => {
|
|
|
171
176
|
const { capability: cap, deviceName, connectState, value, unit, disabled } = data;
|
|
172
177
|
const capability = this.getTCapability(cap);
|
|
173
178
|
const title = this.getDisplayCapability(cap);
|
|
174
|
-
const
|
|
179
|
+
const openList = () => { this.openDeviceSelection(cap); };
|
|
175
180
|
const role = PAIRING_CAPABILITY_ROLES.find(r => r.capability === cap)?.role;
|
|
176
181
|
const helpText = {
|
|
177
182
|
full: getCapabilityHelpText(capability, 'full') ?? '',
|
|
178
183
|
short: getCapabilityHelpText(capability, 'short') ?? '',
|
|
179
184
|
};
|
|
180
185
|
if (disabled) {
|
|
181
|
-
return this.getDisabledCapabilityDisplayProps(data, { title, capability, role, helpText, onClick });
|
|
186
|
+
return this.getDisabledCapabilityDisplayProps(data, { title, capability, role, helpText, onClick: openList });
|
|
182
187
|
}
|
|
183
188
|
const adapaters = this.state.adapters ?? [];
|
|
184
189
|
const adapter = adapaters.find(ai => data.selected && ai.udid === data.selected);
|
|
185
190
|
const ifName = adapter?.adapter?.getInterface();
|
|
186
|
-
const
|
|
191
|
+
const tileState = this.getTileState(data, role, noSearch);
|
|
192
|
+
const onUnselect = data.selected && !tileState.dimmed ? () => { this.onCapabilityUnselect(cap); } : undefined;
|
|
193
|
+
const useTrainerAgain = tileState.dimmed && cap === IncyclistCapability.Control;
|
|
194
|
+
const onClick = useTrainerAgain ? () => { this.onUseTrainerAgain(); } : openList;
|
|
187
195
|
const emptyFooter = this.getActiveCapabilityEmptyFooter(cap, role, noSearch);
|
|
188
196
|
const found = Boolean(data.selected) && this.getSearchStatus()?.running === true && adapter?.adapter?.isStarted() !== true;
|
|
189
197
|
const stateText = found ? 'Found' : undefined;
|
|
190
198
|
return {
|
|
191
199
|
title, capability, deviceName, disabled: false, connectState, value: value?.toString(), unit, interface: ifName,
|
|
192
200
|
role, helpText, emptyFooter, stateText,
|
|
193
|
-
...
|
|
201
|
+
...tileState,
|
|
194
202
|
onClick, onUnselect
|
|
195
203
|
};
|
|
196
204
|
}
|
|
197
205
|
getTileState(data, role, noSearch) {
|
|
198
206
|
try {
|
|
199
207
|
const control = (this.state.capabilities ?? []).find(c => c.capability === IncyclistCapability.Control);
|
|
200
|
-
const { trainerPhase } = this.guidance.getState();
|
|
208
|
+
const { trainerPhase, trainerRetry, fallback } = this.guidance.getState();
|
|
201
209
|
const { selectedReason, separateSensor } = this.guidance.getHelper();
|
|
202
210
|
return getPairingTileState({
|
|
203
211
|
capability: data.capability, role, disabled: data.disabled, selected: data.selected, connectState: data.connectState,
|
|
204
212
|
noSearch, canStartRide: this.canStartRide(),
|
|
205
|
-
trainerPhase, trainerUdid: control?.selected,
|
|
213
|
+
trainerPhase, trainerRetry, trainerUdid: control?.selected,
|
|
206
214
|
trainerUnavailablePicked: selectedReason === 'trainer_unavailable',
|
|
207
215
|
separateSensor: separateSensor !== undefined,
|
|
216
|
+
fallbackActive: fallback !== undefined,
|
|
208
217
|
});
|
|
209
218
|
}
|
|
210
219
|
catch (err) {
|
|
@@ -252,7 +261,7 @@ let PairingPageService = (() => {
|
|
|
252
261
|
onDelete: () => { this.onDeviceDelete(d); }
|
|
253
262
|
}));
|
|
254
263
|
const disabled = devices.length > 0 && !devices.some(d => d.isSelected);
|
|
255
|
-
|
|
264
|
+
const props = {
|
|
256
265
|
capability: this.openedCapability,
|
|
257
266
|
devices,
|
|
258
267
|
isScanning: this.stateMachine.selectState === 'Active',
|
|
@@ -261,6 +270,101 @@ let PairingPageService = (() => {
|
|
|
261
270
|
disabled,
|
|
262
271
|
onClose: () => { this.closeDeviceSelection(); },
|
|
263
272
|
};
|
|
273
|
+
return this.withConflictStep(props);
|
|
274
|
+
}
|
|
275
|
+
withConflictStep(props) {
|
|
276
|
+
const step = this.conflictStep;
|
|
277
|
+
if (step) {
|
|
278
|
+
props.conflictStep = this.getConflictStepProps(step.conflict, step.choices, 0, {
|
|
279
|
+
onDone: () => { this.closeConflictStep('done'); },
|
|
280
|
+
onDismiss: () => { this.closeConflictStep('dismissed'); },
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return props;
|
|
284
|
+
}
|
|
285
|
+
getPendingConflictDisplayProps() {
|
|
286
|
+
try {
|
|
287
|
+
if (!this.isVisitOpen || this.isPanelSlotTaken())
|
|
288
|
+
return undefined;
|
|
289
|
+
const pending = this.getDevicePairing().getPendingConflicts?.() ?? [];
|
|
290
|
+
const [head] = pending;
|
|
291
|
+
if (!head) {
|
|
292
|
+
delete this.cardChoices;
|
|
293
|
+
return undefined;
|
|
294
|
+
}
|
|
295
|
+
if (this.cardChoices?.id !== head.id)
|
|
296
|
+
this.cardChoices = { id: head.id, choices: new Map() };
|
|
297
|
+
return this.getConflictStepProps(head, this.cardChoices.choices, pending.length - 1, {
|
|
298
|
+
onDone: () => { this.onConflictCardDone(head.id); },
|
|
299
|
+
onDismiss: () => { this.onConflictCardDismissed(head.id); },
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
this.logError(err, 'getPendingConflictDisplayProps');
|
|
304
|
+
return undefined;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
isPanelSlotTaken() {
|
|
308
|
+
if (this.openedCapability !== undefined)
|
|
309
|
+
return true;
|
|
310
|
+
try {
|
|
311
|
+
return this.guidance.getHelper().phase !== 'hidden';
|
|
312
|
+
}
|
|
313
|
+
catch (err) {
|
|
314
|
+
this.logError(err, 'isPanelSlotTaken');
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
getConflictStepProps(conflict, choices, queued, handlers) {
|
|
319
|
+
const { id, origin, deviceName, filled } = conflict;
|
|
320
|
+
const props = {
|
|
321
|
+
id, origin, deviceName,
|
|
322
|
+
title: getConflictStepTitle(deviceName),
|
|
323
|
+
subline: getConflictStepSubline(origin, deviceName, filled),
|
|
324
|
+
rows: conflict.conflicts.map(c => ({
|
|
325
|
+
capability: this.getTCapability(c.capability),
|
|
326
|
+
capabilityTitle: getCapabilityTitle(c.capability),
|
|
327
|
+
currentName: c.currentName,
|
|
328
|
+
choice: choices.get(c.capability) ?? 'keep',
|
|
329
|
+
keepLabel: getConflictKeepLabel(c.currentName),
|
|
330
|
+
replaceLabel: getConflictReplaceLabel(deviceName),
|
|
331
|
+
})),
|
|
332
|
+
queued,
|
|
333
|
+
onChoice: (capability, choice) => {
|
|
334
|
+
choices.set(capability, choice);
|
|
335
|
+
this.updatePage();
|
|
336
|
+
},
|
|
337
|
+
...handlers,
|
|
338
|
+
};
|
|
339
|
+
const queuedText = getConflictQueuedText(queued);
|
|
340
|
+
if (queuedText)
|
|
341
|
+
props.queuedText = queuedText;
|
|
342
|
+
return props;
|
|
343
|
+
}
|
|
344
|
+
getReplacedCapabilities(choices) {
|
|
345
|
+
return [...choices].filter(([, choice]) => choice === 'replace').map(([capability]) => capability);
|
|
346
|
+
}
|
|
347
|
+
onConflictCardDone(id) {
|
|
348
|
+
const replace = this.getReplacedCapabilities(this.cardChoices?.choices ?? new Map());
|
|
349
|
+
delete this.cardChoices;
|
|
350
|
+
this.getDevicePairing().resolveConflict(id, replace)
|
|
351
|
+
.catch(err => { this.logError(err, 'onConflictCardDone'); });
|
|
352
|
+
this.updatePage();
|
|
353
|
+
}
|
|
354
|
+
onConflictCardDismissed(id) {
|
|
355
|
+
const replace = this.getReplacedCapabilities(this.cardChoices?.choices ?? new Map());
|
|
356
|
+
delete this.cardChoices;
|
|
357
|
+
this.getDevicePairing().resolveConflict(id, replace, 'dismissed')
|
|
358
|
+
.catch(err => { this.logError(err, 'onConflictCardDismissed'); });
|
|
359
|
+
this.updatePage();
|
|
360
|
+
}
|
|
361
|
+
reevaluateConflicts(changed) {
|
|
362
|
+
try {
|
|
363
|
+
this.getDevicePairing().reevaluatePendingConflicts?.(changed);
|
|
364
|
+
}
|
|
365
|
+
catch (err) {
|
|
366
|
+
this.logError(err, 'reevaluateConflicts');
|
|
367
|
+
}
|
|
264
368
|
}
|
|
265
369
|
updatePage() {
|
|
266
370
|
this.getPageObserver()?.emit('page-update');
|
|
@@ -280,20 +384,80 @@ let PairingPageService = (() => {
|
|
|
280
384
|
onDeviceSelected(d, addAll) {
|
|
281
385
|
const capability = this.openedCapability;
|
|
282
386
|
this.logEvent({ message: 'device selected', capability, device: d.name });
|
|
387
|
+
if (capability === IncyclistCapability.Control && addAll === undefined) {
|
|
388
|
+
this.onResistanceDevicePicked(d);
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
283
391
|
this.closeDeviceSelection();
|
|
284
|
-
this.
|
|
392
|
+
this.selectDevice(capability, d.udid, addAll ?? false);
|
|
393
|
+
this.updatePage();
|
|
394
|
+
}
|
|
395
|
+
onResistanceDevicePicked(d) {
|
|
396
|
+
const conflict = this.startManualConflict(d.udid);
|
|
397
|
+
if (conflict) {
|
|
398
|
+
this.conflictStep = { conflict, choices: new Map() };
|
|
399
|
+
this.updatePage();
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
this.closeDeviceSelection();
|
|
403
|
+
this.selectDevice(IncyclistCapability.Control, d.udid, { others: 'fill-empty', replace: [] });
|
|
404
|
+
this.updatePage();
|
|
405
|
+
}
|
|
406
|
+
startManualConflict(udid) {
|
|
407
|
+
try {
|
|
408
|
+
return this.getDevicePairing().startManualConflict?.(IncyclistCapability.Control, udid);
|
|
409
|
+
}
|
|
410
|
+
catch (err) {
|
|
411
|
+
this.logError(err, 'startManualConflict');
|
|
412
|
+
return undefined;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
selectDevice(capability, udid, mode) {
|
|
416
|
+
this.getDevicePairing().selectDevice(capability, udid, mode)
|
|
285
417
|
.catch(err => { this.logError(err, 'onDeviceSelected'); });
|
|
418
|
+
this.reevaluateConflicts(mode === false ? [capability] : undefined);
|
|
419
|
+
}
|
|
420
|
+
closeConflictStep(via) {
|
|
421
|
+
if (!this.commitConflictStep(via))
|
|
422
|
+
return;
|
|
423
|
+
this.closeDeviceSelection();
|
|
286
424
|
this.updatePage();
|
|
287
425
|
}
|
|
426
|
+
commitConflictStep(via) {
|
|
427
|
+
const step = this.conflictStep;
|
|
428
|
+
if (!step)
|
|
429
|
+
return false;
|
|
430
|
+
delete this.conflictStep;
|
|
431
|
+
this.getDevicePairing().commitManualConflict(step.conflict.id, this.getReplacedCapabilities(step.choices), via)
|
|
432
|
+
.catch(err => { this.logError(err, 'commitConflictStep'); });
|
|
433
|
+
this.reevaluateConflicts();
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
288
436
|
onCapabilityUnselect(cap) {
|
|
289
437
|
this.logEvent({ message: 'capability unselect clicked', capability: cap, eventSource: 'user' });
|
|
438
|
+
if (cap === IncyclistCapability.Control && this.getResistanceUnselectAction() === 'open-helper') {
|
|
439
|
+
this.withGuidance(g => g.openHelperForUnavailableTrainer('tile_unselect'), 'onCapabilityUnselect');
|
|
440
|
+
this.updatePage();
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
290
443
|
this.getDevicePairing().unselectDevices(cap)
|
|
291
444
|
.catch(err => { this.logError(err, 'onCapabilityUnselect'); });
|
|
445
|
+
this.reevaluateConflicts([cap]);
|
|
292
446
|
this.updatePage();
|
|
293
447
|
}
|
|
448
|
+
getResistanceUnselectAction() {
|
|
449
|
+
try {
|
|
450
|
+
return this.guidance.getResistanceUnselectAction();
|
|
451
|
+
}
|
|
452
|
+
catch (err) {
|
|
453
|
+
this.logError(err, 'getResistanceUnselectAction');
|
|
454
|
+
return 'unselect';
|
|
455
|
+
}
|
|
456
|
+
}
|
|
294
457
|
onCapabilityUse(cap) {
|
|
295
458
|
this.logEvent({ message: 'capability use clicked', capability: cap, eventSource: 'user' });
|
|
296
459
|
this.getDevicePairing().useCapability(cap);
|
|
460
|
+
this.reevaluateConflicts([cap]);
|
|
297
461
|
this.updatePage();
|
|
298
462
|
}
|
|
299
463
|
onDeviceDelete(d) {
|
|
@@ -301,10 +465,12 @@ let PairingPageService = (() => {
|
|
|
301
465
|
this.logEvent({ message: 'device delete requested', capability, device: d.name });
|
|
302
466
|
this.getDevicePairing().deleteDevice(capability, d.udid)
|
|
303
467
|
.catch(err => { this.logError(err, 'onDeviceDelete'); });
|
|
468
|
+
this.reevaluateConflicts([capability]);
|
|
304
469
|
this.updatePage();
|
|
305
470
|
}
|
|
306
471
|
closeDeviceSelection() {
|
|
307
472
|
this.logEvent({ message: 'capability closed', capability: this.openedCapability, caller: new Error().stack });
|
|
473
|
+
this.commitConflictStep('dismissed');
|
|
308
474
|
this.openedCapability = undefined;
|
|
309
475
|
Promise.resolve(this.stateMachine.onDeviceSelectionClosed())
|
|
310
476
|
.catch(err => { this.logError(err, 'closeDeviceSelection'); });
|
|
@@ -384,6 +550,8 @@ let PairingPageService = (() => {
|
|
|
384
550
|
this.isVisitOpen = true;
|
|
385
551
|
}
|
|
386
552
|
closeVisit(via) {
|
|
553
|
+
this.commitConflictStep('left_page');
|
|
554
|
+
delete this.cardChoices;
|
|
387
555
|
this.trackVisit(t => t.closeVisit(via, { canStartRide: this.canStartRide() }), 'closeVisit');
|
|
388
556
|
this.trackVisit(t => t.setExitFields(undefined), 'closeVisit');
|
|
389
557
|
this.withGuidance(g => g.closeVisit(), 'closeVisit');
|
|
@@ -402,8 +570,13 @@ let PairingPageService = (() => {
|
|
|
402
570
|
try {
|
|
403
571
|
const pairing = this.getDevicePairing();
|
|
404
572
|
pairing.off?.('pairing-state', this.onPairingStateHandler);
|
|
405
|
-
|
|
573
|
+
pairing.off?.('exclusion-reverted', this.onExclusionRevertedHandler);
|
|
574
|
+
pairing.off?.('selection-conflict', this.onSelectionConflictHandler);
|
|
575
|
+
if (listen) {
|
|
406
576
|
pairing.on?.('pairing-state', this.onPairingStateHandler);
|
|
577
|
+
pairing.on?.('exclusion-reverted', this.onExclusionRevertedHandler);
|
|
578
|
+
pairing.on?.('selection-conflict', this.onSelectionConflictHandler);
|
|
579
|
+
}
|
|
407
580
|
}
|
|
408
581
|
catch (err) {
|
|
409
582
|
this.logError(err, 'listenToPairingState');
|
|
@@ -412,6 +585,10 @@ let PairingPageService = (() => {
|
|
|
412
585
|
onPairingState(state) {
|
|
413
586
|
this.withGuidance(g => g.onPairingState(state), 'onPairingState');
|
|
414
587
|
}
|
|
588
|
+
onExclusionReverted(event) {
|
|
589
|
+
this.withGuidance(g => g.onFallbackReverted(event?.udid), 'onExclusionReverted');
|
|
590
|
+
this.updatePage();
|
|
591
|
+
}
|
|
415
592
|
getStatusDisplayProps(interfaces) {
|
|
416
593
|
const src = {
|
|
417
594
|
platform: this.getPlatform(),
|
|
@@ -438,15 +615,25 @@ let PairingPageService = (() => {
|
|
|
438
615
|
.map(r => capProps.find(c => c.capability === this.getTCapability(r.capability)))
|
|
439
616
|
.filter(c => c !== undefined);
|
|
440
617
|
const trainerSelected = isCapabilityActive(caps.find(c => c.capability === IncyclistCapability.Control));
|
|
618
|
+
const fallbackReady = this.isFallbackActive() && this.canStartRide();
|
|
441
619
|
return {
|
|
442
620
|
top: row('required'),
|
|
443
621
|
bottom: row('optional'),
|
|
444
622
|
rowLabels: {
|
|
445
|
-
top: getPairingGuidanceText(getPairingRowLabelId(trainerSelected, this.isStillLooking(), this.getTrainerPhase())),
|
|
623
|
+
top: getPairingGuidanceText(getPairingRowLabelId(trainerSelected, this.isStillLooking(), this.getTrainerPhase(), fallbackReady)),
|
|
446
624
|
bottom: getPairingGuidanceText('row-optional'),
|
|
447
625
|
},
|
|
448
626
|
};
|
|
449
627
|
}
|
|
628
|
+
isFallbackActive() {
|
|
629
|
+
try {
|
|
630
|
+
return this.guidance.getState().fallback !== undefined;
|
|
631
|
+
}
|
|
632
|
+
catch (err) {
|
|
633
|
+
this.logError(err, 'isFallbackActive');
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
450
637
|
getTrainerPhase() {
|
|
451
638
|
try {
|
|
452
639
|
return this.guidance.getState().trainerPhase;
|
|
@@ -492,18 +679,60 @@ let PairingPageService = (() => {
|
|
|
492
679
|
return props;
|
|
493
680
|
}
|
|
494
681
|
props.tip = getPairingHelperTip(selectedReason, { platform, separateSensor });
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
props.action =
|
|
498
|
-
if (note)
|
|
499
|
-
props.action.note = note;
|
|
500
|
-
}
|
|
682
|
+
const action = this.getHelperActionProps(selectedReason, helper);
|
|
683
|
+
if (action)
|
|
684
|
+
props.action = action;
|
|
501
685
|
return props;
|
|
502
686
|
}
|
|
687
|
+
getHelperActionProps(reason, helper) {
|
|
688
|
+
const { fallbackCandidate, separateSensor } = helper;
|
|
689
|
+
if (reason === 'trainer_unavailable' && fallbackCandidate)
|
|
690
|
+
return { label: getFallbackActionLabel(fallbackCandidate), onClick: () => { this.onChooseFallback(); } };
|
|
691
|
+
if (!hasContinueWithoutDeviceAction(reason, separateSensor))
|
|
692
|
+
return undefined;
|
|
693
|
+
const { label, note } = this.guidance.getContinueWithoutDeviceAction();
|
|
694
|
+
const action = { label, onClick: () => { this.onContinueWithoutDevice(); } };
|
|
695
|
+
if (note)
|
|
696
|
+
action.note = note;
|
|
697
|
+
return action;
|
|
698
|
+
}
|
|
699
|
+
onChooseFallback() {
|
|
700
|
+
this.withGuidance(g => { g.chooseFallback(); }, 'onChooseFallback');
|
|
701
|
+
this.updatePage();
|
|
702
|
+
}
|
|
703
|
+
onUseTrainerAgain() {
|
|
704
|
+
this.logEvent({ message: 'use trainer again clicked', eventSource: 'user' });
|
|
705
|
+
let started = false;
|
|
706
|
+
this.withGuidance(g => {
|
|
707
|
+
g.cancelFallback();
|
|
708
|
+
started = g.startRiderRetry({ trigger: 'tile' });
|
|
709
|
+
}, 'onUseTrainerAgain');
|
|
710
|
+
const covered = this.reconnectNow();
|
|
711
|
+
if (started)
|
|
712
|
+
this.withGuidance(g => g.logRiderRetry(covered), 'onUseTrainerAgain');
|
|
713
|
+
this.updatePage();
|
|
714
|
+
}
|
|
715
|
+
reconnectNow() {
|
|
716
|
+
try {
|
|
717
|
+
return this.getDevicePairing().reconnectNow() ?? [];
|
|
718
|
+
}
|
|
719
|
+
catch (err) {
|
|
720
|
+
this.logError(err, 'reconnectNow');
|
|
721
|
+
return [];
|
|
722
|
+
}
|
|
723
|
+
}
|
|
503
724
|
onHelperOpen() {
|
|
725
|
+
if (this.getTrainerPhase() === 'unavailable') {
|
|
726
|
+
this.onTrainerUnavailable();
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
504
729
|
this.withGuidance(g => g.openHelper(), 'onHelperOpen');
|
|
505
730
|
this.updatePage();
|
|
506
731
|
}
|
|
732
|
+
onTrainerUnavailable() {
|
|
733
|
+
this.withGuidance(g => g.openHelperForUnavailableTrainer('trainer_unavailable_link'), 'onTrainerUnavailable');
|
|
734
|
+
this.updatePage();
|
|
735
|
+
}
|
|
507
736
|
onHelperDismissed() {
|
|
508
737
|
this.withGuidance(g => g.dismissHelper(), 'onHelperDismissed');
|
|
509
738
|
this.updatePage();
|
|
@@ -13,7 +13,8 @@ export const DESKTOP_MATRIX = [
|
|
|
13
13
|
{ area: 'simulator', name: 'Shift+S adds the simulator', given: 'Shift+S pressed', expected: 'deviceConfig.add({name:"Simulator", interface:"simulator"}); the key is disabled afterwards' },
|
|
14
14
|
{ area: 'tiles', name: 'Tile ✕ unselects the capability', given: 'a selected tile', expected: 'devicePairing.unselectDevices(capability)' },
|
|
15
15
|
{ area: 'device-list', name: 'Opening a tile opens its device list', given: 'tile clicked', expected: 'DeviceSelector opens for that capability' },
|
|
16
|
-
{ area: 'device-list', name: 'Select
|
|
16
|
+
{ area: 'device-list', name: 'Select for Resistance', given: 'capability=control, device clicked without a "for all" value', expected: 'free slots are filled; slots held by another device are asked about in the list (conflictStep) before selectDevice(control, udid, {others:"fill-empty", replace}); the dialog closes once answered' },
|
|
17
|
+
{ area: 'device-list', name: 'Select for Resistance with the deprecated "for all" value', given: 'capability=control, device clicked with addAll', expected: 'selectDevice(control, udid, addAll); the dialog closes' },
|
|
17
18
|
{ area: 'device-list', name: 'Select with changeForAll default for other capabilities', given: 'capability!=control, device clicked', expected: 'selectDevice(capability, udid, false); the dialog closes' },
|
|
18
19
|
{ area: 'device-list', name: 'Select-all is offered for Resistance only', given: 'capability=control', expected: 'canSelectAll true; other capabilities false' },
|
|
19
20
|
{ area: 'device-list', name: 'Delete a device in the list', given: 'delete clicked on a device', expected: 'devicePairing.deleteDevice(capability, udid); the list stays open' },
|
|
@@ -92,6 +92,7 @@ let DesktopPairingPageService = (() => {
|
|
|
92
92
|
buttons: this.getButtonsDisplayProps(noSearch),
|
|
93
93
|
showInterfaceSettings: this.getInterfaceSettingsDisplayProps(),
|
|
94
94
|
...this.getGuidanceDisplayProps(),
|
|
95
|
+
pendingConflict: this.getPendingConflictDisplayProps(),
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
catch (err) {
|
|
@@ -114,17 +115,9 @@ let DesktopPairingPageService = (() => {
|
|
|
114
115
|
});
|
|
115
116
|
this.updatePage();
|
|
116
117
|
}
|
|
117
|
-
onDeviceSelected(d, addAll) {
|
|
118
|
-
const capability = this.openedCapability;
|
|
119
|
-
this.logEvent({ message: 'device selected', capability, device: d.name });
|
|
120
|
-
const changeForAll = addAll ?? (capability === IncyclistCapability.Control);
|
|
121
|
-
this.closeDeviceSelection();
|
|
122
|
-
this.getDevicePairing().selectDevice(capability, d.udid, changeForAll)
|
|
123
|
-
.catch(err => { this.logError(err, 'onDeviceSelected'); });
|
|
124
|
-
this.updatePage();
|
|
125
|
-
}
|
|
126
118
|
closeDeviceSelection() {
|
|
127
119
|
this.logEvent({ message: 'capability closed', capability: this.openedCapability });
|
|
120
|
+
this.commitConflictStep('dismissed');
|
|
128
121
|
this.getDevicePairing().stopDeviceSelection()
|
|
129
122
|
.catch(err => { this.logError(err, 'closeDeviceSelection'); });
|
|
130
123
|
this.openedCapability = undefined;
|
|
@@ -146,7 +139,7 @@ let DesktopPairingPageService = (() => {
|
|
|
146
139
|
}));
|
|
147
140
|
const disabled = devices.length > 0 && !devices.some(d => d.isSelected);
|
|
148
141
|
const canSelectAll = this.openedCapability === IncyclistCapability.Control;
|
|
149
|
-
return {
|
|
142
|
+
return this.withConflictStep({
|
|
150
143
|
capability: this.openedCapability,
|
|
151
144
|
devices,
|
|
152
145
|
isScanning: Boolean(this.deviceSelectState?.isScanning),
|
|
@@ -154,7 +147,7 @@ let DesktopPairingPageService = (() => {
|
|
|
154
147
|
canSelectAll,
|
|
155
148
|
disabled,
|
|
156
149
|
onClose: () => { this.closeDeviceSelection(); },
|
|
157
|
-
};
|
|
150
|
+
});
|
|
158
151
|
}
|
|
159
152
|
getInterfaceDisplayProps(info) {
|
|
160
153
|
const { name, state, isScanning, enabled, protocol, port } = info;
|
|
@@ -22,12 +22,17 @@ export const getConflictStepSubline = (origin, deviceName, filled) => {
|
|
|
22
22
|
: 'Choose which device to use for each.';
|
|
23
23
|
return { full, short: 'Choose which device to use for each.' };
|
|
24
24
|
}
|
|
25
|
-
const short =
|
|
25
|
+
const short = `Just found ${deviceName}. Nothing changes until you choose.`;
|
|
26
26
|
const full = names.length > 0
|
|
27
|
-
?
|
|
28
|
-
:
|
|
27
|
+
? `We just found your ${deviceName}. Nothing changes until you choose. ${freed} ${deviceName}.`
|
|
28
|
+
: `We just found your ${deviceName}. Nothing changes until you choose.`;
|
|
29
29
|
return { full, short };
|
|
30
30
|
};
|
|
31
31
|
export const getConflictKeepLabel = (currentName) => `Keep ${currentName}`;
|
|
32
32
|
export const getConflictReplaceLabel = (deviceName) => `Use ${deviceName}`;
|
|
33
|
-
export const getConflictQueuedText = (queued) =>
|
|
33
|
+
export const getConflictQueuedText = (queued) => {
|
|
34
|
+
if (queued <= 0)
|
|
35
|
+
return undefined;
|
|
36
|
+
const device = queued === 1 ? 'device' : 'devices';
|
|
37
|
+
return { full: `${queued} more ${device} to check`, short: `${queued} more to check` };
|
|
38
|
+
};
|
|
@@ -56,11 +56,12 @@ const isPartialOutageShown = (input) => {
|
|
|
56
56
|
const now = input.now ?? Date.now();
|
|
57
57
|
return now - input.partialOutageSince >= PARTIAL_OUTAGE_DEBOUNCE_MS;
|
|
58
58
|
};
|
|
59
|
+
const UNAVAILABLE_STATUS_BY_RETRY = { running: 'S7a', failed: 'S7b' };
|
|
59
60
|
const getTrainerStatus = (input) => {
|
|
60
61
|
if (input.trainerPhase === 'connecting')
|
|
61
62
|
return 'S3';
|
|
62
63
|
if (input.trainerPhase === 'unavailable')
|
|
63
|
-
return 'S7';
|
|
64
|
+
return input.trainerRetry ? UNAVAILABLE_STATUS_BY_RETRY[input.trainerRetry] : 'S7';
|
|
64
65
|
if (input.connectingDeviceName)
|
|
65
66
|
return 'S3';
|
|
66
67
|
return undefined;
|
|
@@ -179,6 +180,16 @@ const getTrainerUnreachableText = (trainer, isShort) => isShort
|
|
|
179
180
|
link: 'Not available today?',
|
|
180
181
|
stateOnlyText: `Can't reach your trainer ${trainer}.`,
|
|
181
182
|
};
|
|
183
|
+
const getTrainerRetryRunningText = (trainer, isShort) => isShort
|
|
184
|
+
? { text: `Trying to reach ${trainer}…`, link: 'Not available?' }
|
|
185
|
+
: { text: `Trying to reach your trainer ${trainer}…`, link: 'Not available today?' };
|
|
186
|
+
const getTrainerRetryFailedText = (trainer, isShort) => isShort
|
|
187
|
+
? { text: `Still can't reach ${trainer}`, link: 'Not available?' }
|
|
188
|
+
: {
|
|
189
|
+
text: `Still can't reach your trainer ${trainer}. Check it's switched on and not connected to another app.`,
|
|
190
|
+
link: 'Not available today?',
|
|
191
|
+
stateOnlyText: `Still can't reach your trainer ${trainer}.`,
|
|
192
|
+
};
|
|
182
193
|
const getAllSwitchedOffText = (canToggle, isShort) => {
|
|
183
194
|
if (isShort)
|
|
184
195
|
return { text: canToggle ? 'To ride: all switched off. Switch one on.' : 'To ride: all switched off. Tap one to choose.' };
|
|
@@ -204,6 +215,8 @@ const getRowLabelText = (id) => {
|
|
|
204
215
|
return { text: 'TO RIDE', subtext: 'waiting for your trainer' };
|
|
205
216
|
case 'row-ready':
|
|
206
217
|
return { text: '✓ READY TO RIDE' };
|
|
218
|
+
case 'row-ready-without-resistance':
|
|
219
|
+
return { text: '✓ READY TO RIDE', subtext: 'without resistance control' };
|
|
207
220
|
case 'row-optional':
|
|
208
221
|
return { text: 'OPTIONAL', subtext: 'extras, not needed' };
|
|
209
222
|
case 'row-searching-trainer':
|
|
@@ -222,6 +235,12 @@ const getTileText = (id, isShort) => {
|
|
|
222
235
|
return { text: 'via your trainer' };
|
|
223
236
|
case 'tile-trainer-waiting':
|
|
224
237
|
return { text: isShort ? 'Waiting…' : 'Waiting to connect' };
|
|
238
|
+
case 'tile-trainer-connecting':
|
|
239
|
+
return { text: 'Connecting…' };
|
|
240
|
+
case 'tile-tap-to-use-again':
|
|
241
|
+
return { text: 'Tap to use again' };
|
|
242
|
+
case 'tile-not-used':
|
|
243
|
+
return { text: 'Not used' };
|
|
225
244
|
case 'tile-waiting-for-trainer':
|
|
226
245
|
return { text: isShort ? 'Waiting…' : 'Waiting for trainer' };
|
|
227
246
|
case 'tile-optional-for-now':
|
|
@@ -268,15 +287,21 @@ export const getPairingGuidanceText = (id, params = {}, variant = 'full') => {
|
|
|
268
287
|
return getStillSearchingText(isShort);
|
|
269
288
|
case 'S7':
|
|
270
289
|
return getTrainerUnreachableText(params.trainerName ?? '', isShort);
|
|
290
|
+
case 'S7a':
|
|
291
|
+
return getTrainerRetryRunningText(params.trainerName ?? '', isShort);
|
|
292
|
+
case 'S7b':
|
|
293
|
+
return getTrainerRetryFailedText(params.trainerName ?? '', isShort);
|
|
271
294
|
case 'S8':
|
|
272
295
|
return getAllSwitchedOffText(params.switchedOffCanToggle, isShort);
|
|
273
296
|
case 'S9':
|
|
274
297
|
return getSearchEndedText(isShort);
|
|
275
298
|
}
|
|
276
299
|
};
|
|
277
|
-
export const getPairingRowLabelId = (trainerSelected, stillLooking = false, trainerPhase) => {
|
|
300
|
+
export const getPairingRowLabelId = (trainerSelected, stillLooking = false, trainerPhase, fallbackReady = false) => {
|
|
278
301
|
if (stillLooking)
|
|
279
302
|
return trainerSelected ? 'row-searching-found' : 'row-searching-trainer';
|
|
303
|
+
if (fallbackReady)
|
|
304
|
+
return 'row-ready-without-resistance';
|
|
280
305
|
if (!trainerSelected)
|
|
281
306
|
return 'row-required';
|
|
282
307
|
return trainerPhase === 'unavailable' ? 'row-required-trainer-waiting' : 'row-required-trainer';
|
|
@@ -301,10 +326,21 @@ const tileFooter = (id) => ({
|
|
|
301
326
|
short: getPairingGuidanceText(id, {}, 'short').text,
|
|
302
327
|
});
|
|
303
328
|
const tileRoleLabel = (id) => getPairingGuidanceText(id).text;
|
|
329
|
+
const getFallbackTileState = (input) => {
|
|
330
|
+
if (input.capability === 'control')
|
|
331
|
+
return { trainerRole: 'trainer', roleLabel: tileRoleLabel('tile-role-trainer'), footerText: tileFooter('tile-tap-to-use-again'), awaited: false, dimmed: true };
|
|
332
|
+
if (input.selected !== undefined && input.selected === input.trainerUdid)
|
|
333
|
+
return { trainerRole: 'via-trainer', footerText: tileFooter('tile-not-used'), awaited: false, dimmed: true };
|
|
334
|
+
return undefined;
|
|
335
|
+
};
|
|
304
336
|
const getUnavailableTrainerTileState = (input) => {
|
|
305
337
|
const { capability, selected, trainerUdid } = input;
|
|
306
|
-
if (
|
|
307
|
-
return
|
|
338
|
+
if (input.fallbackActive)
|
|
339
|
+
return getFallbackTileState(input);
|
|
340
|
+
if (capability === 'control') {
|
|
341
|
+
const footer = input.trainerRetry === 'running' ? 'tile-trainer-connecting' : 'tile-trainer-waiting';
|
|
342
|
+
return { trainerRole: 'trainer', roleLabel: tileRoleLabel('tile-role-trainer'), footerText: tileFooter(footer), awaited: true };
|
|
343
|
+
}
|
|
308
344
|
const canReplace = TRAINER_REPLACEMENTS.has(capability);
|
|
309
345
|
const needsReplacement = canReplace && input.trainerUnavailablePicked === true && !input.separateSensor;
|
|
310
346
|
if (selected !== undefined && selected === trainerUdid)
|
|
@@ -16,6 +16,7 @@ export const getContinueWithoutDeviceAction = ({ rideMode, canSimulate }) => {
|
|
|
16
16
|
};
|
|
17
17
|
export const hasContinueWithoutDeviceAction = (reason, separateSensor) => reason === 'no_device' || (reason === 'trainer_unavailable' && separateSensor === undefined);
|
|
18
18
|
const SENSOR_LABELS = { power: 'power meter', speed: 'speed sensor' };
|
|
19
|
+
export const getFallbackActionLabel = (capability) => `Ride with ${SENSOR_LABELS[capability]} only`;
|
|
19
20
|
export const getPairingHelperTitle = (trainerConfigured) => trainerConfigured ? "Can't connect to your trainer?" : "Can't find your trainer?";
|
|
20
21
|
export const PAIRING_HELPER_SUBLINE = "Pick what fits best and we'll show you what to try.";
|
|
21
22
|
export const PAIRING_HELPER_RESOLVED_TEXT = 'Found it! Ready to ride.';
|