incyclist-services 1.4.6 → 1.4.8
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/devices/pairing/service.js +26 -21
- package/lib/workouts/list/cards/WorkoutCreateCard.d.ts +21 -0
- package/lib/workouts/list/cards/WorkoutCreateCard.js +102 -0
- package/lib/workouts/list/cards/WorkoutImportCard copy.d.ts +19 -0
- package/lib/workouts/list/cards/WorkoutImportCard copy.js +41 -0
- package/lib/workouts/list/cards/index.d.ts +2 -1
- package/lib/workouts/list/cards/index.js +2 -1
- package/lib/workouts/list/cards/types.d.ts +7 -1
- package/lib/workouts/list/service.d.ts +1 -0
- package/lib/workouts/list/service.js +7 -3
- package/package.json +1 -1
|
@@ -713,31 +713,36 @@ class DevicePairingService extends service_2.IncyclistService {
|
|
|
713
713
|
this.emitStateChange({ capabilities });
|
|
714
714
|
}
|
|
715
715
|
onDeviceDetected(deviceSettings) {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
adapter
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
if (this.state.scan.adapters
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
716
|
+
try {
|
|
717
|
+
const udid = this.configuration.add(deviceSettings, { legacy: false });
|
|
718
|
+
this.logEvent({ message: 'device detected', device: deviceSettings, udid });
|
|
719
|
+
if (!udid) {
|
|
720
|
+
this.logEvent({ message: 'device could not be added', reason: 'add() failed' });
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
const adapter = this.configuration.getAdapter(udid);
|
|
724
|
+
if (adapter) {
|
|
725
|
+
adapter.onScanStart();
|
|
726
|
+
this.markConnected(adapter, udid);
|
|
727
|
+
if (this.isScanning() && this.state.scan.adapters) {
|
|
728
|
+
if (this.state.scan.adapters.find(a => a.udid === udid) === undefined) {
|
|
729
|
+
const handler = (deviceSettings, data) => {
|
|
730
|
+
this.onDeviceData(data, udid);
|
|
731
|
+
};
|
|
732
|
+
adapter.on('data', handler);
|
|
733
|
+
this.state.scan.adapters.push({ udid, adapter, handler });
|
|
734
|
+
}
|
|
733
735
|
}
|
|
736
|
+
this.checkCanStart();
|
|
734
737
|
}
|
|
735
|
-
|
|
738
|
+
else {
|
|
739
|
+
this.logEvent({ message: 'Could not get adapter', deviceSettings });
|
|
740
|
+
}
|
|
741
|
+
this.onPairingSuccess(udid);
|
|
736
742
|
}
|
|
737
|
-
|
|
738
|
-
this.
|
|
743
|
+
catch (err) {
|
|
744
|
+
this.logError(err, 'onDeviceDetected');
|
|
739
745
|
}
|
|
740
|
-
this.onPairingSuccess(udid);
|
|
741
746
|
}
|
|
742
747
|
markConnected(adapter, udid) {
|
|
743
748
|
const capabilites = adapter.getCapabilities();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Card } from "../../../base/cardlist";
|
|
2
|
+
import { ImportFilter } from "../../../base/cardlist/types";
|
|
3
|
+
import { PromiseObserver } from "../../../base/types/observer";
|
|
4
|
+
import { AppStatus } from "../../../routes/base/types";
|
|
5
|
+
import { Workout } from "../../base/model/Workout";
|
|
6
|
+
import { BaseCard } from "./base";
|
|
7
|
+
import { WorkoutCardType, WorkoutCreateProps } from "./types";
|
|
8
|
+
export declare class WorkoutCreateCard extends BaseCard implements Card<Workout> {
|
|
9
|
+
setVisible(): void;
|
|
10
|
+
canDelete(): boolean;
|
|
11
|
+
canStart(status: AppStatus): boolean;
|
|
12
|
+
delete(): PromiseObserver<boolean>;
|
|
13
|
+
getData(): any;
|
|
14
|
+
getCardType(): WorkoutCardType;
|
|
15
|
+
getId(): string;
|
|
16
|
+
getFilters(): Array<ImportFilter>;
|
|
17
|
+
getTitle(): string;
|
|
18
|
+
getDisplayProperties(): WorkoutCreateProps;
|
|
19
|
+
markAsSeen(): void;
|
|
20
|
+
getUserSettings(): import("../../../settings").UserSettingsService;
|
|
21
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
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.WorkoutCreateCard = void 0;
|
|
38
|
+
const decorators_1 = require("../../../base/decorators");
|
|
39
|
+
const observer_1 = require("../../../base/types/observer");
|
|
40
|
+
const settings_1 = require("../../../settings");
|
|
41
|
+
const base_1 = require("./base");
|
|
42
|
+
const DEFAULT_TITLE = "Create Workout";
|
|
43
|
+
const DEFAULT_LINK = 'https://zwofactory.com/';
|
|
44
|
+
let WorkoutCreateCard = (() => {
|
|
45
|
+
var _a;
|
|
46
|
+
let _classSuper = base_1.BaseCard;
|
|
47
|
+
let _instanceExtraInitializers = [];
|
|
48
|
+
let _getUserSettings_decorators;
|
|
49
|
+
return _a = class WorkoutCreateCard extends _classSuper {
|
|
50
|
+
setVisible() {
|
|
51
|
+
this.visible = true;
|
|
52
|
+
}
|
|
53
|
+
canDelete() {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
canStart(status) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
delete() {
|
|
60
|
+
return observer_1.PromiseObserver.alwaysReturning(false);
|
|
61
|
+
}
|
|
62
|
+
getData() {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
getCardType() {
|
|
66
|
+
return 'WorkoutCreate';
|
|
67
|
+
}
|
|
68
|
+
getId() {
|
|
69
|
+
return 'Create';
|
|
70
|
+
}
|
|
71
|
+
getFilters() {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
getTitle() {
|
|
75
|
+
return DEFAULT_TITLE;
|
|
76
|
+
}
|
|
77
|
+
getDisplayProperties() {
|
|
78
|
+
const title = this.getTitle();
|
|
79
|
+
const firstTime = this.getUserSettings().get('state.createWorkoutSeen', false) === false;
|
|
80
|
+
return { title, visible: true, link: DEFAULT_LINK, firstTime };
|
|
81
|
+
}
|
|
82
|
+
markAsSeen() {
|
|
83
|
+
this.getUserSettings().set('state.createWorkoutSeen', true);
|
|
84
|
+
}
|
|
85
|
+
getUserSettings() {
|
|
86
|
+
return (0, settings_1.useUserSettings)();
|
|
87
|
+
}
|
|
88
|
+
constructor() {
|
|
89
|
+
super(...arguments);
|
|
90
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
(() => {
|
|
94
|
+
var _b;
|
|
95
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
|
|
96
|
+
_getUserSettings_decorators = [decorators_1.Injectable];
|
|
97
|
+
__esDecorate(_a, 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);
|
|
98
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
99
|
+
})(),
|
|
100
|
+
_a;
|
|
101
|
+
})();
|
|
102
|
+
exports.WorkoutCreateCard = WorkoutCreateCard;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Card } from "../../../base/cardlist";
|
|
2
|
+
import { ImportFilter } from "../../../base/cardlist/types";
|
|
3
|
+
import { PromiseObserver } from "../../../base/types/observer";
|
|
4
|
+
import { AppStatus } from "../../../routes/base/types";
|
|
5
|
+
import { Workout } from "../../base/model/Workout";
|
|
6
|
+
import { BaseCard } from "./base";
|
|
7
|
+
import { WorkoutCardType, WorkoutImportProps } from "./types";
|
|
8
|
+
export declare class WorkoutImportCard extends BaseCard implements Card<Workout> {
|
|
9
|
+
setVisible(): void;
|
|
10
|
+
canDelete(): boolean;
|
|
11
|
+
canStart(status: AppStatus): boolean;
|
|
12
|
+
delete(): PromiseObserver<boolean>;
|
|
13
|
+
getData(): any;
|
|
14
|
+
getCardType(): WorkoutCardType;
|
|
15
|
+
getId(): string;
|
|
16
|
+
getFilters(): Array<ImportFilter>;
|
|
17
|
+
getTitle(): string;
|
|
18
|
+
getDisplayProperties(): WorkoutImportProps;
|
|
19
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkoutImportCard = void 0;
|
|
4
|
+
const observer_1 = require("../../../base/types/observer");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
const types_1 = require("./types");
|
|
7
|
+
class WorkoutImportCard extends base_1.BaseCard {
|
|
8
|
+
setVisible() {
|
|
9
|
+
this.visible = true;
|
|
10
|
+
}
|
|
11
|
+
canDelete() {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
canStart(status) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
delete() {
|
|
18
|
+
return observer_1.PromiseObserver.alwaysReturning(false);
|
|
19
|
+
}
|
|
20
|
+
getData() {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
getCardType() {
|
|
24
|
+
return 'WorkoutImport';
|
|
25
|
+
}
|
|
26
|
+
getId() {
|
|
27
|
+
return 'Import';
|
|
28
|
+
}
|
|
29
|
+
getFilters() {
|
|
30
|
+
return types_1.DEFAULT_FILTERS;
|
|
31
|
+
}
|
|
32
|
+
getTitle() {
|
|
33
|
+
return types_1.DEFAULT_TITLE;
|
|
34
|
+
}
|
|
35
|
+
getDisplayProperties() {
|
|
36
|
+
const title = this.getTitle();
|
|
37
|
+
const filters = this.getFilters();
|
|
38
|
+
return { title, filters, visible: true };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.WorkoutImportCard = WorkoutImportCard;
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./WorkoutCreateCard"), exports);
|
|
18
18
|
__exportStar(require("./WorkoutImportCard"), exports);
|
|
19
|
+
__exportStar(require("./WorkoutCard"), exports);
|
|
19
20
|
__exportStar(require("./types"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ImportFilter } from "../../../base/cardlist/types";
|
|
2
2
|
import { Observer } from "../../../base/types/observer";
|
|
3
3
|
import { Workout } from "../../base/model";
|
|
4
|
-
export type WorkoutCardType = 'WorkoutImport' | 'Workout' | 'ActiveWorkoutImport';
|
|
4
|
+
export type WorkoutCardType = 'WorkoutImport' | 'Workout' | 'ActiveWorkoutImport' | 'WorkoutCreate';
|
|
5
5
|
export declare const DEFAULT_TITLE = "Import Workout";
|
|
6
6
|
export declare const DEFAULT_FILTERS: {
|
|
7
7
|
name: string;
|
|
@@ -12,6 +12,12 @@ export interface WorkoutImportProps {
|
|
|
12
12
|
filters: Array<ImportFilter>;
|
|
13
13
|
visible: boolean;
|
|
14
14
|
}
|
|
15
|
+
export interface WorkoutCreateProps {
|
|
16
|
+
title: string;
|
|
17
|
+
visible: boolean;
|
|
18
|
+
link?: string;
|
|
19
|
+
firstTime?: boolean;
|
|
20
|
+
}
|
|
15
21
|
export interface ActiveImportProps {
|
|
16
22
|
name: string;
|
|
17
23
|
error?: Error;
|
|
@@ -37,6 +37,7 @@ export declare class WorkoutListService extends IncyclistService implements ILis
|
|
|
37
37
|
onCarouselInitialized(list: CardList<WP>, item: any, itemsInSlide: any): void;
|
|
38
38
|
onCarouselUpdated(list: any, item: any, itemsInSlide: any): void;
|
|
39
39
|
preload(): PromiseObserver<void>;
|
|
40
|
+
isStillLoading(): boolean;
|
|
40
41
|
import(info: FileInfo | Array<FileInfo>, props: {
|
|
41
42
|
card?: ActiveImportCard;
|
|
42
43
|
showImportCards?: boolean;
|
|
@@ -59,7 +59,7 @@ const valid_1 = require("../../utils/valid");
|
|
|
59
59
|
const parsers_1 = require("../base/parsers");
|
|
60
60
|
const ActiveImportCard_1 = require("./cards/ActiveImportCard");
|
|
61
61
|
const WorkoutCard_1 = require("./cards/WorkoutCard");
|
|
62
|
-
const
|
|
62
|
+
const cards_1 = require("./cards");
|
|
63
63
|
const db_1 = require("./loaders/db");
|
|
64
64
|
let WorkoutListService = (() => {
|
|
65
65
|
let _classDecorators = [types_1.Singleton];
|
|
@@ -75,7 +75,8 @@ let WorkoutListService = (() => {
|
|
|
75
75
|
this.lists = [this.myWorkouts];
|
|
76
76
|
this.items = [];
|
|
77
77
|
this.language = 'en';
|
|
78
|
-
this.myWorkouts.add(new
|
|
78
|
+
this.myWorkouts.add(new cards_1.WorkoutImportCard());
|
|
79
|
+
this.myWorkouts.add(new cards_1.WorkoutCreateCard());
|
|
79
80
|
this.registerUserChangeHandler();
|
|
80
81
|
}
|
|
81
82
|
getSelected() { return this.selectedWorkout; }
|
|
@@ -224,6 +225,9 @@ let WorkoutListService = (() => {
|
|
|
224
225
|
}
|
|
225
226
|
return this.preloadObserver;
|
|
226
227
|
}
|
|
228
|
+
isStillLoading() {
|
|
229
|
+
return this.preloadObserver !== undefined && !this.initialized;
|
|
230
|
+
}
|
|
227
231
|
import(info, props) {
|
|
228
232
|
return __awaiter(this, void 0, void 0, function* () {
|
|
229
233
|
try {
|
|
@@ -342,7 +346,7 @@ let WorkoutListService = (() => {
|
|
|
342
346
|
}
|
|
343
347
|
createSettingsList() {
|
|
344
348
|
const list = new cardlist_1.CardList('settings', 'Workouts');
|
|
345
|
-
list.add(new
|
|
349
|
+
list.add(new cards_1.WorkoutImportCard());
|
|
346
350
|
this.items
|
|
347
351
|
.sort((a, b) => a.name > b.name ? 1 : -1);
|
|
348
352
|
this.items.forEach(i => {
|