incyclist-services 1.3.54 → 1.3.55
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/activities/base/repo/db.js +3 -3
- package/lib/activities/base/utils/activity.d.ts +19 -2
- package/lib/activities/base/utils/activity.js +322 -157
- package/lib/activities/list/service.d.ts +20 -9
- package/lib/activities/list/service.js +160 -77
- package/lib/activities/list/types.d.ts +33 -4
- package/lib/activities/upload/strava.d.ts +7 -3
- package/lib/activities/upload/strava.js +65 -40
- package/lib/activities/upload/types.d.ts +5 -0
- package/lib/base/decorators/Injection.d.ts +2 -0
- package/lib/base/decorators/Injection.js +29 -0
- package/lib/base/types/observer.js +4 -2
- package/lib/routes/list/service.js +1 -1
- package/package.json +2 -2
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { PromiseObserver } from "../../../base/types";
|
|
1
|
+
import { Observer, PromiseObserver } from "../../../base/types";
|
|
2
2
|
import { DisplayExportInfo, DisplayUploadInfo } from "../../list";
|
|
3
3
|
import { ActivityInfo } from "../model";
|
|
4
4
|
import { ActivitiesRepository } from "../repo";
|
|
5
5
|
import { RouteCard, RouteSettings } from "../../../routes/list/cards/RouteCard";
|
|
6
6
|
import { OnlineStateMonitoringService } from "../../../monitoring";
|
|
7
|
+
import { ActivityConverter } from "../convert";
|
|
8
|
+
import { ActivityUploadFactory } from "../../upload";
|
|
9
|
+
import { EventLogger } from "gd-eventlog";
|
|
7
10
|
export declare class Activity implements ActivityInfo {
|
|
8
11
|
protected info: ActivityInfo;
|
|
9
12
|
protected loadingObserver: PromiseObserver<void>;
|
|
13
|
+
protected currentExports: Record<string, boolean>;
|
|
14
|
+
protected currentUploads: Record<string, boolean>;
|
|
15
|
+
protected logger: EventLogger;
|
|
10
16
|
constructor(info: ActivityInfo);
|
|
11
17
|
get summary(): import("../model").ActivitySummary;
|
|
12
18
|
set summary(summary: import("../model").ActivitySummary);
|
|
@@ -20,13 +26,24 @@ export declare class Activity implements ActivityInfo {
|
|
|
20
26
|
getTitle(): string;
|
|
21
27
|
getElevation(): number;
|
|
22
28
|
getExports(): Array<DisplayExportInfo>;
|
|
29
|
+
markExporting(type: string, exporting: boolean): void;
|
|
30
|
+
isExporting(type: string): boolean;
|
|
31
|
+
export(type: string, observer?: Observer): Promise<boolean>;
|
|
32
|
+
upload(connectedApp: string, observer?: Observer): Promise<boolean>;
|
|
33
|
+
markUploading(connectedApp: string, uploading: boolean): void;
|
|
34
|
+
isUploading(connectedApp: string): boolean;
|
|
23
35
|
isRouteAvailable(): boolean;
|
|
24
36
|
getUploadStatus(): Array<DisplayUploadInfo>;
|
|
25
37
|
canStart(): boolean;
|
|
26
38
|
getRouteCard(): RouteCard;
|
|
27
39
|
createStartSettings(): RouteSettings;
|
|
28
40
|
protected getOnlineMonitoring(): OnlineStateMonitoringService;
|
|
29
|
-
protected save(): Promise<void>;
|
|
41
|
+
protected save(withDetails?: boolean): Promise<void>;
|
|
42
|
+
protected logError(err: Error, fn: string): void;
|
|
30
43
|
protected getRepo(): ActivitiesRepository;
|
|
31
44
|
protected getAppsService(): import("../../../apps").AppsService;
|
|
45
|
+
protected getBindings(): import("../../../api").IncyclistBindings;
|
|
46
|
+
protected getRouteList(): import("../../../routes").RouteListService;
|
|
47
|
+
protected getActivityConverter(): typeof ActivityConverter;
|
|
48
|
+
protected getActivityUploadFactory(): ActivityUploadFactory;
|
|
32
49
|
}
|
|
@@ -1,4 +1,38 @@
|
|
|
1
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
|
+
};
|
|
2
36
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
37
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
38
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -16,163 +50,294 @@ const repo_1 = require("../repo");
|
|
|
16
50
|
const api_1 = require("../../../api");
|
|
17
51
|
const monitoring_1 = require("../../../monitoring");
|
|
18
52
|
const apps_1 = require("../../../apps");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
setLoading(loading) {
|
|
45
|
-
this.loadingObserver = loading;
|
|
46
|
-
this.loadingObserver.wait().then(() => {
|
|
47
|
-
this.loadingObserver = null;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
isLoading() {
|
|
51
|
-
return this.loadingObserver !== null;
|
|
52
|
-
}
|
|
53
|
-
load() {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
if (!this.loadingObserver)
|
|
56
|
-
return;
|
|
57
|
-
return this.loadingObserver.wait();
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
isComplete() {
|
|
61
|
-
return !!this.info.details;
|
|
62
|
-
}
|
|
63
|
-
getTitle() {
|
|
64
|
-
var _a;
|
|
65
|
-
let title = this.info.summary.title;
|
|
66
|
-
if (title === model_1.DEFAULT_ACTIVITY_TITLE) {
|
|
67
|
-
if ((_a = this.details.route) === null || _a === void 0 ? void 0 : _a.title) {
|
|
68
|
-
title = this.details.route.title;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
title = this.details.route.name;
|
|
72
|
-
const route = (0, routes_1.useRouteList)().getRouteDescription(this.details.route.id);
|
|
73
|
-
if (route) {
|
|
74
|
-
title = route.title;
|
|
53
|
+
const Injection_1 = require("../../../base/decorators/Injection");
|
|
54
|
+
const convert_1 = require("../convert");
|
|
55
|
+
const upload_1 = require("../../upload");
|
|
56
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
57
|
+
let Activity = (() => {
|
|
58
|
+
var _a;
|
|
59
|
+
let _instanceExtraInitializers = [];
|
|
60
|
+
let _getRepo_decorators;
|
|
61
|
+
let _getAppsService_decorators;
|
|
62
|
+
let _getBindings_decorators;
|
|
63
|
+
let _getRouteList_decorators;
|
|
64
|
+
let _getActivityConverter_decorators;
|
|
65
|
+
let _getActivityUploadFactory_decorators;
|
|
66
|
+
return _a = class Activity {
|
|
67
|
+
constructor(info) {
|
|
68
|
+
var _b, _c, _d;
|
|
69
|
+
this.info = (__runInitializers(this, _instanceExtraInitializers), info);
|
|
70
|
+
this.currentExports = {};
|
|
71
|
+
this.currentUploads = {};
|
|
72
|
+
this.info = info;
|
|
73
|
+
this.logger = new gd_eventlog_1.EventLogger('Activity');
|
|
74
|
+
const ver = Number((_d = (_c = (_b = this.info) === null || _b === void 0 ? void 0 : _b.details) === null || _c === void 0 ? void 0 : _c.version) !== null && _d !== void 0 ? _d : "0");
|
|
75
|
+
if (ver < Number(repo_1.DB_VERSION)) {
|
|
76
|
+
this.getRepo().migrate(this.info);
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
79
|
+
get summary() {
|
|
80
|
+
return this.info.summary;
|
|
81
|
+
}
|
|
82
|
+
set summary(summary) {
|
|
83
|
+
this.info.summary = summary;
|
|
84
|
+
}
|
|
85
|
+
get details() {
|
|
86
|
+
return this.info.details;
|
|
87
|
+
}
|
|
88
|
+
set details(details) {
|
|
89
|
+
this.info.details = details;
|
|
90
|
+
}
|
|
91
|
+
get id() {
|
|
92
|
+
return this.info.summary.id;
|
|
93
|
+
}
|
|
94
|
+
setLoading(loading) {
|
|
95
|
+
this.loadingObserver = loading;
|
|
96
|
+
this.loadingObserver.wait().then(() => {
|
|
97
|
+
this.loadingObserver = null;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
isLoading() {
|
|
101
|
+
return this.loadingObserver !== null && this.loadingObserver !== undefined;
|
|
102
|
+
}
|
|
103
|
+
load() {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
if (!this.loadingObserver)
|
|
106
|
+
return;
|
|
107
|
+
return this.loadingObserver.wait();
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
isComplete() {
|
|
111
|
+
return !!this.info.details;
|
|
112
|
+
}
|
|
113
|
+
getTitle() {
|
|
114
|
+
var _b;
|
|
115
|
+
let title = this.info.summary.title;
|
|
116
|
+
if (title === model_1.DEFAULT_ACTIVITY_TITLE) {
|
|
117
|
+
if ((_b = this.details.route) === null || _b === void 0 ? void 0 : _b.title) {
|
|
118
|
+
title = this.details.route.title;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
title = this.details.route.name;
|
|
122
|
+
const route = (0, routes_1.useRouteList)().getRouteDescription(this.details.route.id);
|
|
123
|
+
if (route) {
|
|
124
|
+
title = route.title;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return title;
|
|
129
|
+
}
|
|
130
|
+
getElevation() {
|
|
131
|
+
var _b;
|
|
132
|
+
const { version, totalElevation, logs = [] } = (_b = this.info.details) !== null && _b !== void 0 ? _b : {};
|
|
133
|
+
if (version !== undefined)
|
|
134
|
+
return totalElevation;
|
|
135
|
+
let elevation = 0;
|
|
136
|
+
let prevElevation = 0;
|
|
137
|
+
logs.forEach(log => {
|
|
138
|
+
if (log.elevation > prevElevation)
|
|
139
|
+
elevation += log.elevation - prevElevation;
|
|
140
|
+
prevElevation = log.elevation;
|
|
141
|
+
});
|
|
142
|
+
return elevation;
|
|
143
|
+
}
|
|
144
|
+
getExports() {
|
|
145
|
+
var _b;
|
|
146
|
+
const { fileName } = (_b = this.details) !== null && _b !== void 0 ? _b : {};
|
|
147
|
+
const exports = [];
|
|
148
|
+
if (fileName)
|
|
149
|
+
exports.push({ type: 'json', file: fileName });
|
|
150
|
+
const formats = ['tcx', 'fit'];
|
|
151
|
+
formats.forEach(type => {
|
|
152
|
+
var _b, _c;
|
|
153
|
+
const details = (_b = this.details) !== null && _b !== void 0 ? _b : {};
|
|
154
|
+
const file = (_c = details[`${type}FileName`]) !== null && _c !== void 0 ? _c : fileName === null || fileName === void 0 ? void 0 : fileName.replace('.json', `.${type}`);
|
|
155
|
+
const fs = this.getBindings().fs;
|
|
156
|
+
if (fs.existsSync(file))
|
|
157
|
+
exports.push({ type, file });
|
|
158
|
+
else
|
|
159
|
+
exports.push({ type, creating: this.isExporting(type) });
|
|
160
|
+
});
|
|
161
|
+
return exports;
|
|
162
|
+
}
|
|
163
|
+
markExporting(type, exporting) {
|
|
164
|
+
this.currentExports[type] = exporting;
|
|
165
|
+
}
|
|
166
|
+
isExporting(type) {
|
|
167
|
+
return this.currentExports[type];
|
|
168
|
+
}
|
|
169
|
+
export(type, observer) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const format = type.toLowerCase();
|
|
172
|
+
const fs = this.getBindings().fs;
|
|
173
|
+
let success = false;
|
|
174
|
+
let error;
|
|
175
|
+
this.markExporting(format, true);
|
|
176
|
+
if (observer) {
|
|
177
|
+
observer.emit('export', { status: 'started', format });
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
let data;
|
|
181
|
+
const converter = this.getActivityConverter();
|
|
182
|
+
data = yield converter.convert(this.details, format);
|
|
183
|
+
const fileName = this.details.fileName.replace('.json', `.${format}`);
|
|
184
|
+
yield fs.writeFile(fileName, Buffer.from(data));
|
|
185
|
+
this.details[`${format}FileName`] = fileName;
|
|
186
|
+
yield this.save(true);
|
|
187
|
+
success = true;
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
this.logError(err, 'export');
|
|
191
|
+
error = err.message;
|
|
192
|
+
}
|
|
193
|
+
this.markExporting(format, false);
|
|
194
|
+
if (observer) {
|
|
195
|
+
observer.emit('export', { status: 'done', format, success, error });
|
|
196
|
+
}
|
|
197
|
+
return success;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
upload(connectedApp, observer) {
|
|
201
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
var _b, _c;
|
|
203
|
+
let success = false;
|
|
204
|
+
let error;
|
|
205
|
+
const factory = this.getActivityUploadFactory();
|
|
206
|
+
let exports = this.getExports().filter(e => e.type !== 'json');
|
|
207
|
+
let format = (_b = exports.find(e => e.file !== undefined)) === null || _b === void 0 ? void 0 : _b.type;
|
|
208
|
+
this.markUploading(connectedApp, true);
|
|
209
|
+
if (observer) {
|
|
210
|
+
observer.emit('upload', { status: 'started', connectedApp });
|
|
211
|
+
}
|
|
212
|
+
if (!format) {
|
|
213
|
+
const exportPromises = [];
|
|
214
|
+
exports.forEach(e => {
|
|
215
|
+
exportPromises.push(this.export(e.type, observer));
|
|
216
|
+
});
|
|
217
|
+
yield Promise.allSettled(exportPromises);
|
|
218
|
+
exports = this.getExports().filter(e => e.type !== 'json');
|
|
219
|
+
format = (_c = exports.find(e => e.file !== undefined)) === null || _c === void 0 ? void 0 : _c.type;
|
|
220
|
+
}
|
|
221
|
+
if (format) {
|
|
222
|
+
try {
|
|
223
|
+
const uploader = factory.get(connectedApp);
|
|
224
|
+
success = yield uploader.upload(this.details, format.toLowerCase());
|
|
225
|
+
yield this.save(true);
|
|
226
|
+
}
|
|
227
|
+
catch (err) {
|
|
228
|
+
this.logError(err, 'upload');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
this.markUploading(connectedApp, false);
|
|
232
|
+
if (observer) {
|
|
233
|
+
observer.emit('upload', { status: 'done', connectedApp, success, error });
|
|
234
|
+
}
|
|
235
|
+
return success;
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
markUploading(connectedApp, uploading) {
|
|
239
|
+
this.currentUploads[connectedApp] = uploading;
|
|
240
|
+
}
|
|
241
|
+
isUploading(connectedApp) {
|
|
242
|
+
return this.currentUploads[connectedApp];
|
|
243
|
+
}
|
|
244
|
+
isRouteAvailable() {
|
|
245
|
+
var _b;
|
|
246
|
+
if (!((_b = this.details) === null || _b === void 0 ? void 0 : _b.route))
|
|
247
|
+
return false;
|
|
248
|
+
if (this.details.routeType === 'Free-Ride')
|
|
249
|
+
return false;
|
|
250
|
+
return this.getRouteList().getRouteDescription(this.details.route.id) !== undefined;
|
|
251
|
+
}
|
|
252
|
+
getUploadStatus() {
|
|
253
|
+
const uploads = [];
|
|
254
|
+
const services = this.getAppsService().getConnectedServices('ActivityUpload');
|
|
255
|
+
services.forEach(service => {
|
|
256
|
+
var _b, _c;
|
|
257
|
+
let status = 'unknown';
|
|
258
|
+
const info = (_c = (_b = this.details) === null || _b === void 0 ? void 0 : _b.links) === null || _c === void 0 ? void 0 : _c[service.key];
|
|
259
|
+
if (info) {
|
|
260
|
+
status = (info.error || !info.activity_id) ? 'failed' : 'success';
|
|
261
|
+
}
|
|
262
|
+
uploads.push({
|
|
263
|
+
type: service.key, status, url: info === null || info === void 0 ? void 0 : info.url, text: service.name, synchronizing: this.isUploading(service.key)
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
return uploads;
|
|
267
|
+
}
|
|
268
|
+
canStart() {
|
|
269
|
+
var _b, _c;
|
|
270
|
+
if (!((_b = this.details) === null || _b === void 0 ? void 0 : _b.route))
|
|
271
|
+
return false;
|
|
272
|
+
if (this.details.routeType === 'Free-Ride')
|
|
273
|
+
return false;
|
|
274
|
+
if (this.details.routeType === 'Video') {
|
|
275
|
+
const isOnline = this.getOnlineMonitoring().onlineStatus;
|
|
276
|
+
return (_c = this.getRouteCard()) === null || _c === void 0 ? void 0 : _c.canStart({ isOnline });
|
|
277
|
+
}
|
|
278
|
+
return (0, routes_1.useRouteList)().getRouteDescription(this.details.route.id) !== undefined;
|
|
279
|
+
}
|
|
280
|
+
getRouteCard() {
|
|
281
|
+
const routes = (0, routes_1.useRouteList)();
|
|
282
|
+
return routes.getCard(this.details.route.id);
|
|
283
|
+
}
|
|
284
|
+
createStartSettings() {
|
|
285
|
+
const { startPos, realityFactor, segment, endPos } = this.details;
|
|
286
|
+
const card = this.getRouteCard();
|
|
287
|
+
return {
|
|
288
|
+
startPos,
|
|
289
|
+
segment,
|
|
290
|
+
endPos,
|
|
291
|
+
realityFactor,
|
|
292
|
+
showPrev: true,
|
|
293
|
+
type: card.getCardType()
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
getOnlineMonitoring() {
|
|
297
|
+
return (0, monitoring_1.useOnlineStatusMonitoring)();
|
|
298
|
+
}
|
|
299
|
+
save(withDetails) {
|
|
300
|
+
console.log('~~~ SAVE REPO', this.info, withDetails);
|
|
301
|
+
return this.getRepo().save(this.info, withDetails);
|
|
302
|
+
}
|
|
303
|
+
logError(err, fn) {
|
|
304
|
+
this.logger.logEvent({ message: 'error', error: err.message, fn, stack: err.stack });
|
|
305
|
+
}
|
|
306
|
+
getRepo() {
|
|
307
|
+
return new repo_1.ActivitiesRepository();
|
|
308
|
+
}
|
|
309
|
+
getAppsService() {
|
|
310
|
+
return (0, apps_1.useAppsService)();
|
|
311
|
+
}
|
|
312
|
+
getBindings() {
|
|
313
|
+
return (0, api_1.getBindings)();
|
|
314
|
+
}
|
|
315
|
+
getRouteList() {
|
|
316
|
+
return (0, routes_1.useRouteList)();
|
|
317
|
+
}
|
|
318
|
+
getActivityConverter() {
|
|
319
|
+
return convert_1.ActivityConverter;
|
|
320
|
+
}
|
|
321
|
+
getActivityUploadFactory() {
|
|
322
|
+
return new upload_1.ActivityUploadFactory();
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
(() => {
|
|
326
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
327
|
+
_getRepo_decorators = [Injection_1.Injectable];
|
|
328
|
+
_getAppsService_decorators = [Injection_1.Injectable];
|
|
329
|
+
_getBindings_decorators = [Injection_1.Injectable];
|
|
330
|
+
_getRouteList_decorators = [Injection_1.Injectable];
|
|
331
|
+
_getActivityConverter_decorators = [Injection_1.Injectable];
|
|
332
|
+
_getActivityUploadFactory_decorators = [Injection_1.Injectable];
|
|
333
|
+
__esDecorate(_a, null, _getRepo_decorators, { kind: "method", name: "getRepo", static: false, private: false, access: { has: obj => "getRepo" in obj, get: obj => obj.getRepo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
334
|
+
__esDecorate(_a, null, _getAppsService_decorators, { kind: "method", name: "getAppsService", static: false, private: false, access: { has: obj => "getAppsService" in obj, get: obj => obj.getAppsService }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
335
|
+
__esDecorate(_a, null, _getBindings_decorators, { kind: "method", name: "getBindings", static: false, private: false, access: { has: obj => "getBindings" in obj, get: obj => obj.getBindings }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
336
|
+
__esDecorate(_a, null, _getRouteList_decorators, { kind: "method", name: "getRouteList", static: false, private: false, access: { has: obj => "getRouteList" in obj, get: obj => obj.getRouteList }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
337
|
+
__esDecorate(_a, null, _getActivityConverter_decorators, { kind: "method", name: "getActivityConverter", static: false, private: false, access: { has: obj => "getActivityConverter" in obj, get: obj => obj.getActivityConverter }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
338
|
+
__esDecorate(_a, null, _getActivityUploadFactory_decorators, { kind: "method", name: "getActivityUploadFactory", static: false, private: false, access: { has: obj => "getActivityUploadFactory" in obj, get: obj => obj.getActivityUploadFactory }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
339
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
340
|
+
})(),
|
|
341
|
+
_a;
|
|
342
|
+
})();
|
|
178
343
|
exports.Activity = Activity;
|
|
@@ -3,41 +3,52 @@ import { Observer, PromiseObserver } from "../../base/types/observer";
|
|
|
3
3
|
import { RouteCard } from "../../routes/list/cards/RouteCard";
|
|
4
4
|
import { ActivitiesRepository, Activity, ActivitySearchCriteria } from "../base";
|
|
5
5
|
import { ActivityInfo } from "../base/model";
|
|
6
|
-
import {
|
|
6
|
+
import { ActivityUploadFactory } from "../upload";
|
|
7
|
+
import { ActivityListDisplayProperties, RideAgainResponse, SelectedActivityResponse } from "./types";
|
|
7
8
|
export declare class ActivityListService extends IncyclistService {
|
|
8
|
-
protected preloadObserver: PromiseObserver<void>;
|
|
9
9
|
protected initialized: boolean;
|
|
10
10
|
protected repo: ActivitiesRepository;
|
|
11
|
-
protected
|
|
11
|
+
protected observers: Record<string, Observer>;
|
|
12
12
|
protected filter: ActivitySearchCriteria;
|
|
13
13
|
protected selected: Activity;
|
|
14
14
|
protected listTop: number;
|
|
15
|
+
protected opened?: 'list' | 'selected';
|
|
15
16
|
constructor();
|
|
16
|
-
preload(
|
|
17
|
+
preload(props?: {
|
|
18
|
+
cntDetails?: number;
|
|
19
|
+
}): PromiseObserver<void>;
|
|
17
20
|
openList(): ActivityListDisplayProperties;
|
|
18
21
|
setListTop(top: number): void;
|
|
19
22
|
getListTop(): number;
|
|
20
|
-
|
|
23
|
+
getObserver(): Observer;
|
|
21
24
|
closeList(): void;
|
|
22
25
|
isStillLoading(): boolean;
|
|
23
26
|
setFilter(filter: ActivitySearchCriteria): void;
|
|
24
|
-
protected getPastActivities(): Array<ActivityInfo>;
|
|
25
27
|
getActivityDetails(id: string): Observer;
|
|
26
28
|
delete(id: string): Promise<boolean>;
|
|
27
29
|
select(id: string): boolean;
|
|
28
30
|
getSelected(): Activity;
|
|
29
|
-
openSelected():
|
|
30
|
-
rideAgain():
|
|
31
|
+
openSelected(): SelectedActivityResponse;
|
|
32
|
+
rideAgain(): RideAgainResponse;
|
|
33
|
+
export(format: string): Promise<boolean>;
|
|
34
|
+
upload(connectedApp: string): Promise<boolean>;
|
|
31
35
|
openRoute(): RouteCard;
|
|
32
36
|
closeSelected(keepSelected?: boolean): void;
|
|
33
37
|
getPastActivitiesWithDetails(filter: ActivitySearchCriteria): Promise<Array<ActivityInfo>>;
|
|
38
|
+
protected getPastActivities(): Array<ActivityInfo>;
|
|
39
|
+
protected getListObserver(): Observer;
|
|
40
|
+
protected getPreloadObserver(): PromiseObserver<void>;
|
|
34
41
|
protected loadActivities(): Promise<void>;
|
|
35
42
|
protected loadDetails(activity: ActivityInfo): Promise<void>;
|
|
36
|
-
protected
|
|
43
|
+
protected preloadDetails(cnt?: number): Promise<void>;
|
|
37
44
|
protected get activities(): Array<ActivityInfo>;
|
|
38
45
|
protected getActivity(id: string): ActivityInfo;
|
|
39
46
|
protected getListDisplayProperties(): ActivityListDisplayProperties;
|
|
47
|
+
private getSelectedActivityDisplayProps;
|
|
48
|
+
protected emitSelected(event: 'loaded' | 'updated'): void;
|
|
40
49
|
protected emitLists(event: 'loaded' | 'updated'): void;
|
|
50
|
+
protected getRepo(): ActivitiesRepository;
|
|
51
|
+
protected getActivityUploadFactory(): ActivityUploadFactory;
|
|
41
52
|
}
|
|
42
53
|
export declare const useActivityList: () => ActivityListService;
|
|
43
54
|
export declare const getActivityList: () => ActivityListService;
|