incyclist-services 1.7.1 → 1.7.3
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/active-rides/service.d.ts +3 -3
- package/lib/activities/base/api/active-rides/api.d.ts +1 -1
- package/lib/activities/base/api/fitconvert/fitconvert.d.ts +1 -1
- package/lib/activities/base/convert/fit/remote-fit.d.ts +1 -1
- package/lib/activities/base/convert/tcx/tcx.d.ts +2 -2
- package/lib/activities/base/model/index.d.ts +46 -22
- package/lib/activities/base/repo/db.d.ts +3 -2
- package/lib/activities/base/repo/db.js +17 -2
- package/lib/activities/base/repo/types.d.ts +3 -2
- package/lib/activities/base/utils/activity.d.ts +7 -7
- package/lib/activities/list/service.d.ts +3 -2
- package/lib/activities/list/service.js +28 -5
- package/lib/activities/list/types.d.ts +10 -8
- package/lib/activities/list/utils.d.ts +4 -0
- package/lib/activities/list/utils.js +50 -0
- package/lib/activities/ride/service.d.ts +6 -6
- package/lib/activities/ride/service.js +36 -9
- package/lib/activities/ride/types.d.ts +4 -2
- package/lib/activities/upload/intervals.d.ts +1 -1
- package/lib/activities/upload/strava.d.ts +1 -1
- package/lib/api/bindings/index.d.ts +15 -1
- package/lib/api/bindings/index.js +6 -0
- package/lib/api/logging/types.d.ts +8 -0
- package/lib/api/{bindings/secret → secret}/index.d.ts +1 -0
- package/lib/api/secret/index.js +1 -0
- package/lib/api/serial/types.d.ts +3 -0
- package/lib/api/serial/types.js +1 -0
- package/lib/apps/base/api/base.d.ts +1 -1
- package/lib/apps/base/app/index.d.ts +1 -1
- package/lib/apps/googleMaps/service.d.ts +4 -3
- package/lib/apps/googleMaps/service.js +15 -8
- package/lib/apps/intervals/IntervalsAppConnection.d.ts +1 -1
- package/lib/apps/komoot/KomootAppConnection.d.ts +1 -1
- package/lib/apps/service.d.ts +1 -1
- package/lib/apps/strava/StravaAppConnection.d.ts +1 -1
- package/lib/apps/velohero/VeloHeroAppConnection.d.ts +1 -1
- package/lib/appstate/service.d.ts +1 -1
- package/lib/appstate/types.d.ts +1 -1
- package/lib/autoupdate/api.d.ts +1 -1
- package/lib/base/service.js +0 -2
- package/lib/coaches/service.d.ts +2 -2
- package/lib/devices/access/service.d.ts +1 -1
- package/lib/devices/configuration/service.d.ts +2 -2
- package/lib/devices/pairing/service.d.ts +2 -1
- package/lib/devices/pairing/service.js +8 -2
- package/lib/devices/ride/service.d.ts +4 -4
- package/lib/i18n/localization/service.d.ts +1 -1
- package/lib/i18n/units/converter.d.ts +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/maps/MapArea/options.js +8 -3
- package/lib/ride/base/base.d.ts +3 -3
- package/lib/ride/display/service.d.ts +7 -7
- package/lib/ride/route/GpxDisplayService.d.ts +2 -2
- package/lib/ride/route/GpxDisplayService.js +0 -4
- package/lib/ride/route/RouteDisplayService.d.ts +5 -5
- package/lib/ride/workout/WorkoutDisplayService.d.ts +1 -1
- package/lib/routes/base/api/index.d.ts +1 -1
- package/lib/routes/base/parsers/geometry.d.ts +1 -1
- package/lib/routes/free-ride/service.d.ts +3 -3
- package/lib/routes/list/loaders/StravaActivityLoader.d.ts +2 -2
- package/lib/routes/list/service.d.ts +7 -7
- package/lib/routes/sync/komoot/provider.d.ts +3 -3
- package/lib/settings/bindings/types.d.ts +1 -6
- package/lib/settings/display/user/service.d.ts +3 -3
- package/lib/settings/display/user/service.js +2 -4
- package/lib/settings/service/mock.d.ts +1 -1
- package/lib/settings/service/service.d.ts +1 -1
- package/lib/ui/index.d.ts +1 -0
- package/lib/ui/index.js +1 -0
- package/lib/ui/service.d.ts +27 -0
- package/lib/ui/service.js +258 -0
- package/lib/ui/types.d.ts +1 -0
- package/lib/ui/types.js +1 -0
- package/lib/workouts/base/api/index.d.ts +1 -1
- package/lib/workouts/base/parsers/intervals/parser.d.ts +1 -1
- package/lib/workouts/calendar/service.d.ts +3 -3
- package/lib/workouts/calendar/sync/intervals/provider.d.ts +2 -2
- package/lib/workouts/list/cards/ActiveImportCard.d.ts +1 -1
- package/lib/workouts/list/cards/WorkoutCard.d.ts +4 -4
- package/lib/workouts/list/cards/WorkoutCreateCard.d.ts +1 -1
- package/lib/workouts/list/service.d.ts +3 -3
- package/lib/workouts/ride/service.d.ts +1 -1
- package/package.json +13 -11
- /package/lib/api/{bindings/secret/index.js → logging/types.js} +0 -0
|
@@ -54,7 +54,7 @@ export declare class ActiveRidesService extends IncyclistService {
|
|
|
54
54
|
protected getName(item: any): any;
|
|
55
55
|
protected randomName(id?: string): string;
|
|
56
56
|
protected addCurrentActivity(): void;
|
|
57
|
-
protected getAvatar(item: ActiveRideEntry): import("
|
|
57
|
+
protected getAvatar(item: ActiveRideEntry): import("../../avatars").Avatar;
|
|
58
58
|
protected getRelativePower(r: ActiveRideEntry): number;
|
|
59
59
|
protected getLap(r: ActiveRideEntry, overwrite?: boolean): number;
|
|
60
60
|
protected getRoutePosDistance(r: ActiveRideEntry): number;
|
|
@@ -72,7 +72,7 @@ export declare class ActiveRidesService extends IncyclistService {
|
|
|
72
72
|
};
|
|
73
73
|
protected getRideInfo(): ActiveRideRoute;
|
|
74
74
|
protected getType(type: ActivityRouteType): ActiveRideRouteType;
|
|
75
|
-
protected get activity(): import("
|
|
75
|
+
protected get activity(): import("../base").ActivityDetails;
|
|
76
76
|
protected getRouteHash(): string;
|
|
77
77
|
protected getUserName(user?: {
|
|
78
78
|
firstname?: string;
|
|
@@ -107,7 +107,7 @@ export declare class ActiveRidesService extends IncyclistService {
|
|
|
107
107
|
protected getActivityRide(): ActivityRideService;
|
|
108
108
|
protected getRouteList(): RouteListService;
|
|
109
109
|
getCoachesService(): CoachesService;
|
|
110
|
-
getUnitConverter(): import("
|
|
110
|
+
getUnitConverter(): import("../../i18n").UnitConverterService;
|
|
111
111
|
protected getUnitConversionShortcuts(): any[];
|
|
112
112
|
protected getMessageQueue(): ActiveRideListMessageQueue;
|
|
113
113
|
protected getApi(): IncyclistActiveRidesApi;
|
|
@@ -9,5 +9,5 @@ export declare class IncyclistActiveRidesApi {
|
|
|
9
9
|
getBySessionId(sessionId: string): Promise<ActiveRideEntry[]>;
|
|
10
10
|
protected getApi(): AxiosInstance;
|
|
11
11
|
protected getBaseUrl(): string;
|
|
12
|
-
getUserSettings(): import("
|
|
12
|
+
getUserSettings(): import("../../../../settings").UserSettingsService;
|
|
13
13
|
}
|
|
@@ -5,5 +5,5 @@ export declare class IncyclistFitConvertApi {
|
|
|
5
5
|
convertToFit(data: FitExportActivity): Promise<ArrayBuffer>;
|
|
6
6
|
protected getApi(): AxiosInstance;
|
|
7
7
|
protected getBaseUrl(): string;
|
|
8
|
-
getUserSettings(): import("
|
|
8
|
+
getUserSettings(): import("../../../../settings").UserSettingsService;
|
|
9
9
|
}
|
|
@@ -9,5 +9,5 @@ export declare class RemoteFitConverter {
|
|
|
9
9
|
protected getApi(): IncyclistFitConvertApi;
|
|
10
10
|
protected getFitActivity(activity: ActivityDetails): FitExportActivity;
|
|
11
11
|
protected mapLogToFit(log: ActivityLogRecord): FitLogEntry;
|
|
12
|
-
protected getUserSettings(): import("
|
|
12
|
+
protected getUserSettings(): import("../../../../settings").UserSettingsService;
|
|
13
13
|
}
|
|
@@ -8,7 +8,7 @@ export declare class IncyclistAttribution extends AbstractSource {
|
|
|
8
8
|
toXml(): string;
|
|
9
9
|
constructor();
|
|
10
10
|
protected getAppInfo(): import("../../../../api/appInfo").IAppInfo;
|
|
11
|
-
protected getBindings(): import("
|
|
11
|
+
protected getBindings(): import("../../../../api").IncyclistBindings;
|
|
12
12
|
}
|
|
13
13
|
export declare class TcxConverter implements IActivityConverter {
|
|
14
14
|
protected logger: EventLogger;
|
|
@@ -19,5 +19,5 @@ export declare class TcxConverter implements IActivityConverter {
|
|
|
19
19
|
protected getWorkoutLapMarkers(activity: ActivityDetails): Array<TcxLapMarker>;
|
|
20
20
|
protected createLapMarkerFromStep(s: Step, activityDuration: number): TcxLapMarker;
|
|
21
21
|
protected creatTrackPoints(activity: ActivityDetails, startTime: Date): TrackPoint[];
|
|
22
|
-
protected getRideService(): import("
|
|
22
|
+
protected getRideService(): import("../../../ride").ActivityRideService;
|
|
23
23
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FormattedNumber } from "../../../i18n";
|
|
1
2
|
import { RoutePoint } from "../../../routes/base/types";
|
|
2
3
|
import { Workout } from "../../../workouts";
|
|
3
4
|
export declare const DEFAULT_ACTIVITY_TITLE = "Incyclist Ride";
|
|
@@ -12,23 +13,28 @@ export type ActivityRoute = {
|
|
|
12
13
|
name: string;
|
|
13
14
|
title?: string;
|
|
14
15
|
};
|
|
15
|
-
export type ActivityStatsRecord = {
|
|
16
|
-
min:
|
|
17
|
-
max:
|
|
18
|
-
avg:
|
|
16
|
+
export type ActivityStatsRecord<T> = {
|
|
17
|
+
min: T;
|
|
18
|
+
max: T;
|
|
19
|
+
avg: T;
|
|
19
20
|
cntVal: number;
|
|
20
|
-
sum:
|
|
21
|
-
minAllowed?:
|
|
22
|
-
weighted?:
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
hrm?: ActivityStatsRecord
|
|
26
|
-
cadence?: ActivityStatsRecord
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
power: ActivityStatsRecord;
|
|
21
|
+
sum: T;
|
|
22
|
+
minAllowed?: T;
|
|
23
|
+
weighted?: T;
|
|
24
|
+
};
|
|
25
|
+
interface ActivityStatsBase {
|
|
26
|
+
hrm?: ActivityStatsRecord<number>;
|
|
27
|
+
cadence?: ActivityStatsRecord<number>;
|
|
28
|
+
slope?: ActivityStatsRecord<number>;
|
|
29
|
+
power: ActivityStatsRecord<number>;
|
|
30
30
|
powerCurve?: Record<string, number>;
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
|
+
export interface ActivityStats extends ActivityStatsBase {
|
|
33
|
+
speed: ActivityStatsRecord<number>;
|
|
34
|
+
}
|
|
35
|
+
export interface ActivityStatsUI extends ActivityStatsBase {
|
|
36
|
+
speed: ActivityStatsRecord<number | FormattedNumber>;
|
|
37
|
+
}
|
|
32
38
|
export interface ActivityAppLink {
|
|
33
39
|
error?: string;
|
|
34
40
|
activity_id?: string;
|
|
@@ -56,7 +62,7 @@ export type ActivityDB = {
|
|
|
56
62
|
activities: Array<ActivitySummary>;
|
|
57
63
|
isComplete: boolean;
|
|
58
64
|
};
|
|
59
|
-
export type
|
|
65
|
+
export type ActivitySummaryBase = {
|
|
60
66
|
id: string;
|
|
61
67
|
title: string;
|
|
62
68
|
name: string;
|
|
@@ -65,18 +71,24 @@ export type ActivitySummary = {
|
|
|
65
71
|
previewImage?: string;
|
|
66
72
|
startTime: number;
|
|
67
73
|
rideTime: number;
|
|
68
|
-
distance: number;
|
|
69
74
|
startPos: number;
|
|
70
75
|
endPos?: number;
|
|
71
76
|
segment?: string;
|
|
72
77
|
realityFactor: number;
|
|
73
|
-
totalElevation: number;
|
|
74
78
|
uploadStatus: Array<UploadInfo>;
|
|
75
79
|
isCompleted?: boolean;
|
|
76
80
|
isSaved?: boolean;
|
|
77
81
|
saveRideTime?: number;
|
|
78
82
|
laps?: Array<LapSummary>;
|
|
79
83
|
};
|
|
84
|
+
export type ActivitySummary = ActivitySummaryBase & {
|
|
85
|
+
distance: number;
|
|
86
|
+
totalElevation: number;
|
|
87
|
+
};
|
|
88
|
+
export type ActivitySummaryUI = ActivitySummaryBase & {
|
|
89
|
+
distance: number | FormattedNumber;
|
|
90
|
+
totalElevation: number | FormattedNumber;
|
|
91
|
+
};
|
|
80
92
|
export type LapSummary = {
|
|
81
93
|
num: number;
|
|
82
94
|
startPos: number;
|
|
@@ -130,7 +142,7 @@ export type FitExportActivity = {
|
|
|
130
142
|
user: FitUser;
|
|
131
143
|
screenshots: Array<FitScreenshots>;
|
|
132
144
|
};
|
|
133
|
-
|
|
145
|
+
interface ActivityDetailsBase {
|
|
134
146
|
type?: ActivityType;
|
|
135
147
|
version?: string;
|
|
136
148
|
title: string;
|
|
@@ -141,15 +153,12 @@ export interface ActivityDetails {
|
|
|
141
153
|
time: number;
|
|
142
154
|
timeTotal: number;
|
|
143
155
|
timePause: number;
|
|
144
|
-
distance: number;
|
|
145
156
|
startPos: number;
|
|
146
157
|
endPos?: number;
|
|
147
158
|
segment?: string;
|
|
148
159
|
startpos?: number;
|
|
149
160
|
endpos?: number;
|
|
150
|
-
totalElevation: number;
|
|
151
161
|
logs: Array<ActivityLogRecord>;
|
|
152
|
-
stats?: ActivityStats;
|
|
153
162
|
screenshots?: Array<ScreenShotInfo>;
|
|
154
163
|
routeType?: ActivityRouteType;
|
|
155
164
|
realityFactor: number;
|
|
@@ -162,6 +171,16 @@ export interface ActivityDetails {
|
|
|
162
171
|
links?: ActivityAppLinks;
|
|
163
172
|
workout?: Workout;
|
|
164
173
|
}
|
|
174
|
+
export interface ActivityDetails extends ActivityDetailsBase {
|
|
175
|
+
distance: number;
|
|
176
|
+
totalElevation: number;
|
|
177
|
+
stats?: ActivityStats;
|
|
178
|
+
}
|
|
179
|
+
export interface ActivityDetailsUI extends ActivityDetailsBase {
|
|
180
|
+
distance: number | FormattedNumber;
|
|
181
|
+
totalElevation: number | FormattedNumber;
|
|
182
|
+
stats?: ActivityStatsUI;
|
|
183
|
+
}
|
|
165
184
|
export type ActivityLogRecord = {
|
|
166
185
|
time: number;
|
|
167
186
|
timeDelta: number;
|
|
@@ -180,3 +199,8 @@ export type ActivityInfo = {
|
|
|
180
199
|
summary: ActivitySummary;
|
|
181
200
|
details?: ActivityDetails;
|
|
182
201
|
};
|
|
202
|
+
export type ActivityInfoUI = {
|
|
203
|
+
summary: ActivitySummaryUI;
|
|
204
|
+
details?: ActivityDetailsUI;
|
|
205
|
+
};
|
|
206
|
+
export {};
|
|
@@ -54,6 +54,7 @@ export declare class ActivitiesRepository {
|
|
|
54
54
|
protected getActivity(id: string): ActivityInfo;
|
|
55
55
|
protected logError(err: Error, fn: string, logProps?: any): void;
|
|
56
56
|
protected getRepo(): JsonRepository;
|
|
57
|
-
protected getRouteList(): import("
|
|
58
|
-
protected getBindings(): import("
|
|
57
|
+
protected getRouteList(): import("../../../routes").RouteListService;
|
|
58
|
+
protected getBindings(): import("../../../api").IncyclistBindings;
|
|
59
|
+
protected getUnitConverter(): import("../../../i18n").UnitConverterService;
|
|
59
60
|
}
|
|
@@ -41,6 +41,7 @@ import { buildSummary } from "../utils";
|
|
|
41
41
|
import { useRouteList } from "../../../routes";
|
|
42
42
|
import { ActivitiesDBMigratorFactory } from "./migration/factory";
|
|
43
43
|
import { Injectable } from "../../../base/decorators/Injection";
|
|
44
|
+
import { useUnitConverter } from "../../../i18n";
|
|
44
45
|
export const DB_VERSION = '4';
|
|
45
46
|
export const DB_NAME = 'db';
|
|
46
47
|
let ActivitiesRepository = (() => {
|
|
@@ -50,12 +51,15 @@ let ActivitiesRepository = (() => {
|
|
|
50
51
|
let _classThis;
|
|
51
52
|
let _instanceExtraInitializers = [];
|
|
52
53
|
let _getBindings_decorators;
|
|
54
|
+
let _getUnitConverter_decorators;
|
|
53
55
|
var ActivitiesRepository = class {
|
|
54
56
|
static { _classThis = this; }
|
|
55
57
|
static {
|
|
56
58
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
57
59
|
_getBindings_decorators = [Injectable];
|
|
60
|
+
_getUnitConverter_decorators = [Injectable];
|
|
58
61
|
__esDecorate(this, 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);
|
|
62
|
+
__esDecorate(this, null, _getUnitConverter_decorators, { kind: "method", name: "getUnitConverter", static: false, private: false, access: { has: obj => "getUnitConverter" in obj, get: obj => obj.getUnitConverter }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
59
63
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
60
64
|
ActivitiesRepository = _classThis = _classDescriptor.value;
|
|
61
65
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -244,12 +248,20 @@ let ActivitiesRepository = (() => {
|
|
|
244
248
|
return result;
|
|
245
249
|
}
|
|
246
250
|
checkStartPosFilter(result, criteria) {
|
|
247
|
-
|
|
248
|
-
|
|
251
|
+
let startPos = criteria?.startPos;
|
|
252
|
+
if (typeof startPos !== 'number' && startPos?.value !== undefined) {
|
|
253
|
+
startPos = this.getUnitConverter().convert(startPos.value, 'distance', { from: startPos.unit, to: 'm' });
|
|
254
|
+
}
|
|
255
|
+
if (result?.length > 0 && startPos !== undefined) {
|
|
256
|
+
result = result.filter(ai => ai.summary.startPos === startPos);
|
|
249
257
|
}
|
|
250
258
|
return result;
|
|
251
259
|
}
|
|
252
260
|
checkEndPosFilter(result, criteria) {
|
|
261
|
+
let endPos = criteria?.endPos;
|
|
262
|
+
if (typeof endPos !== 'number' && endPos?.value !== undefined) {
|
|
263
|
+
endPos = this.getUnitConverter().convert(endPos.value, 'distance', { from: endPos.unit, to: 'm' });
|
|
264
|
+
}
|
|
253
265
|
if (result?.length > 0 && criteria?.endPos !== undefined) {
|
|
254
266
|
result = result.filter(ai => ai.summary.endPos === criteria.endPos);
|
|
255
267
|
}
|
|
@@ -497,6 +509,9 @@ let ActivitiesRepository = (() => {
|
|
|
497
509
|
getBindings() {
|
|
498
510
|
return getBindings();
|
|
499
511
|
}
|
|
512
|
+
getUnitConverter() {
|
|
513
|
+
return useUnitConverter();
|
|
514
|
+
}
|
|
500
515
|
};
|
|
501
516
|
return ActivitiesRepository = _classThis;
|
|
502
517
|
})();
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { FormattedNumber } from "../../../i18n";
|
|
1
2
|
import { UploadInfo } from "../model";
|
|
2
3
|
export interface ActivitySearchCriteria {
|
|
3
4
|
routeId?: string;
|
|
4
5
|
routeHash?: string;
|
|
5
|
-
startPos?: number;
|
|
6
|
-
endPos?: number;
|
|
6
|
+
startPos?: number | FormattedNumber;
|
|
7
|
+
endPos?: number | FormattedNumber;
|
|
7
8
|
realityFactor?: number;
|
|
8
9
|
uploadStatus?: UploadInfo | Array<UploadInfo>;
|
|
9
10
|
isSaved?: boolean;
|
|
@@ -14,10 +14,10 @@ export declare class Activity implements ActivityInfo {
|
|
|
14
14
|
protected currentUploads: Record<string, boolean>;
|
|
15
15
|
protected logger: EventLogger;
|
|
16
16
|
constructor(info: ActivityInfo);
|
|
17
|
-
get summary(): import("
|
|
18
|
-
set summary(summary: import("
|
|
19
|
-
get details(): import("
|
|
20
|
-
set details(details: import("
|
|
17
|
+
get summary(): import("../model").ActivitySummary;
|
|
18
|
+
set summary(summary: import("../model").ActivitySummary);
|
|
19
|
+
get details(): import("../model").ActivityDetails;
|
|
20
|
+
set details(details: import("../model").ActivityDetails);
|
|
21
21
|
get id(): string;
|
|
22
22
|
setLoading(loading: PromiseObserver<void>): void;
|
|
23
23
|
isLoading(): boolean;
|
|
@@ -41,9 +41,9 @@ export declare class Activity implements ActivityInfo {
|
|
|
41
41
|
protected save(withDetails?: boolean): Promise<void>;
|
|
42
42
|
protected logError(err: Error, fn: string, context?: object): void;
|
|
43
43
|
protected getRepo(): ActivitiesRepository;
|
|
44
|
-
protected getAppsService(): import("
|
|
45
|
-
protected getBindings(): import("
|
|
46
|
-
protected getRouteList(): import("
|
|
44
|
+
protected getAppsService(): import("../../../apps").AppsService;
|
|
45
|
+
protected getBindings(): import("../../../api").IncyclistBindings;
|
|
46
|
+
protected getRouteList(): import("../../../routes").RouteListService;
|
|
47
47
|
protected getActivityConverter(): typeof ActivityConverter;
|
|
48
48
|
protected getActivityUploadFactory(): ActivityUploadFactory;
|
|
49
49
|
}
|
|
@@ -50,8 +50,9 @@ export declare class ActivityListService extends IncyclistService {
|
|
|
50
50
|
protected emitLists(event: 'loaded' | 'updated'): void;
|
|
51
51
|
protected getRepo(): ActivitiesRepository;
|
|
52
52
|
protected getActivityUploadFactory(): ActivityUploadFactory;
|
|
53
|
-
protected getAppState(): import("
|
|
54
|
-
protected getRouteList(): import("
|
|
53
|
+
protected getAppState(): import("../../appstate").AppStateService;
|
|
54
|
+
protected getRouteList(): import("../../routes").RouteListService;
|
|
55
|
+
protected getUnitConverter(): import("../../i18n").UnitConverterService;
|
|
55
56
|
reset(): void;
|
|
56
57
|
}
|
|
57
58
|
export declare const useActivityList: () => ActivityListService;
|
|
@@ -37,10 +37,12 @@ import { Injectable } from "../../base/decorators/Injection";
|
|
|
37
37
|
import { IncyclistService } from "../../base/service";
|
|
38
38
|
import { Singleton } from "../../base/types";
|
|
39
39
|
import { Observer, PromiseObserver } from "../../base/types/observer";
|
|
40
|
+
import { useUnitConverter } from "../../i18n";
|
|
40
41
|
import { useRouteList } from "../../routes";
|
|
41
42
|
import { waitNextTick } from "../../utils";
|
|
42
43
|
import { ActivitiesRepository, Activity } from "../base";
|
|
43
44
|
import { ActivityUploadFactory } from "../upload";
|
|
45
|
+
import { createUIActivityDetails, createUIActivityInfo } from "./utils";
|
|
44
46
|
let ActivityListService = (() => {
|
|
45
47
|
let _classDecorators = [Singleton];
|
|
46
48
|
let _classDescriptor;
|
|
@@ -52,6 +54,7 @@ let ActivityListService = (() => {
|
|
|
52
54
|
let _getActivityUploadFactory_decorators;
|
|
53
55
|
let _getAppState_decorators;
|
|
54
56
|
let _getRouteList_decorators;
|
|
57
|
+
let _getUnitConverter_decorators;
|
|
55
58
|
var ActivityListService = class extends _classSuper {
|
|
56
59
|
static { _classThis = this; }
|
|
57
60
|
static {
|
|
@@ -60,10 +63,12 @@ let ActivityListService = (() => {
|
|
|
60
63
|
_getActivityUploadFactory_decorators = [Injectable];
|
|
61
64
|
_getAppState_decorators = [Injectable];
|
|
62
65
|
_getRouteList_decorators = [Injectable];
|
|
66
|
+
_getUnitConverter_decorators = [Injectable];
|
|
63
67
|
__esDecorate(this, 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);
|
|
64
68
|
__esDecorate(this, 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);
|
|
65
69
|
__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);
|
|
66
70
|
__esDecorate(this, 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);
|
|
71
|
+
__esDecorate(this, null, _getUnitConverter_decorators, { kind: "method", name: "getUnitConverter", static: false, private: false, access: { has: obj => "getUnitConverter" in obj, get: obj => obj.getUnitConverter }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
67
72
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
68
73
|
ActivityListService = _classThis = _classDescriptor.value;
|
|
69
74
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -362,19 +367,33 @@ let ActivityListService = (() => {
|
|
|
362
367
|
const loading = this.isStillLoading();
|
|
363
368
|
const observer = loading ? this.getListObserver() : undefined;
|
|
364
369
|
const activities = loading ? undefined : this.getPastActivities();
|
|
370
|
+
const activitiesUI = activities === undefined ? undefined : activities.map(createUIActivityInfo);
|
|
365
371
|
const filter = this.filter;
|
|
366
|
-
return { filter, activities, loading, observer };
|
|
372
|
+
return { filter, activities: activitiesUI, loading, observer };
|
|
367
373
|
}
|
|
368
374
|
getSelectedActivityDisplayProps() {
|
|
369
|
-
const activity = this.selected.details;
|
|
375
|
+
const activity = createUIActivityDetails(this.selected.details);
|
|
376
|
+
const [C, U] = this.getUnitConverter().getUnitConversionShortcuts();
|
|
370
377
|
const logs = activity?.logs ?? [];
|
|
371
378
|
const points = logs.map(p => ({ lat: p.lat, lng: p.lng ?? p.lon }));
|
|
379
|
+
const getDistance = () => {
|
|
380
|
+
if (activity?.distance === undefined)
|
|
381
|
+
return undefined;
|
|
382
|
+
if (typeof activity?.distance === 'number')
|
|
383
|
+
return { value: C(activity.distance, 'distance', { digits: 1 }), unit: U('distance') };
|
|
384
|
+
return activity?.distance;
|
|
385
|
+
};
|
|
386
|
+
const distance = getDistance();
|
|
387
|
+
const startPosVal = activity?.segment ? undefined : activity?.startPos;
|
|
388
|
+
const startPos = startPosVal === undefined ? undefined : { value: C(startPosVal, 'distance', { digits: 1 }), unit: U('distance') };
|
|
389
|
+
const totalElevation = this.selected.getElevation();
|
|
390
|
+
const elevation = totalElevation === undefined ? undefined : { value: C(totalElevation, 'elevation', { digits: 0 }), unit: U('elevation') };
|
|
372
391
|
const props = {
|
|
373
392
|
title: this.selected.getTitle(),
|
|
374
|
-
distance
|
|
393
|
+
distance,
|
|
375
394
|
duration: activity?.time,
|
|
376
|
-
elevation
|
|
377
|
-
startPos
|
|
395
|
+
elevation,
|
|
396
|
+
startPos,
|
|
378
397
|
segment: activity?.segment,
|
|
379
398
|
started: activity ? new Date(activity.startTime) : undefined,
|
|
380
399
|
showMap: true,
|
|
@@ -384,6 +403,7 @@ let ActivityListService = (() => {
|
|
|
384
403
|
canStart: this.selected.canStart(),
|
|
385
404
|
canOpen: this.selected.isRouteAvailable(),
|
|
386
405
|
uploads: this.selected.getUploadStatus(),
|
|
406
|
+
units: this.getUnitConverter().getDefaultUnits()
|
|
387
407
|
};
|
|
388
408
|
return props;
|
|
389
409
|
}
|
|
@@ -416,6 +436,9 @@ let ActivityListService = (() => {
|
|
|
416
436
|
getRouteList() {
|
|
417
437
|
return useRouteList();
|
|
418
438
|
}
|
|
439
|
+
getUnitConverter() {
|
|
440
|
+
return useUnitConverter();
|
|
441
|
+
}
|
|
419
442
|
reset() {
|
|
420
443
|
const keys = Object.keys(this.observers);
|
|
421
444
|
for (const key of keys) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Avatar } from "../../avatars";
|
|
2
2
|
import { Observer } from "../../base/types";
|
|
3
|
+
import { Dimension, FormattedNumber, Unit } from "../../i18n";
|
|
3
4
|
import { RouteInfo } from "../../routes/base/types";
|
|
4
|
-
import { ActivityDetails,
|
|
5
|
+
import { ActivityDetails, ActivityDetailsUI, ActivityInfoUI, ActivitySearchCriteria, ActivityStats } from "../base";
|
|
5
6
|
export type PastActivityLogEntry = {
|
|
6
7
|
routeHash?: string;
|
|
7
8
|
routeId?: string;
|
|
@@ -10,12 +11,12 @@ export type PastActivityLogEntry = {
|
|
|
10
11
|
time?: number;
|
|
11
12
|
power?: number;
|
|
12
13
|
heartrate?: number;
|
|
13
|
-
speed?: number;
|
|
14
|
+
speed?: number | FormattedNumber;
|
|
14
15
|
distance?: number;
|
|
15
16
|
routeDistance?: number;
|
|
16
17
|
lap?: number;
|
|
17
18
|
timeGap: string;
|
|
18
|
-
distanceGap: string;
|
|
19
|
+
distanceGap: string | FormattedNumber;
|
|
19
20
|
lat?: number;
|
|
20
21
|
lng?: number;
|
|
21
22
|
};
|
|
@@ -25,7 +26,7 @@ export interface PrevRidesListDisplayProps extends PastActivityLogEntry {
|
|
|
25
26
|
avatar?: Avatar;
|
|
26
27
|
}
|
|
27
28
|
export type ActivityListDisplayProperties = {
|
|
28
|
-
activities?: Array<
|
|
29
|
+
activities?: Array<ActivityInfoUI>;
|
|
29
30
|
filter?: ActivitySearchCriteria;
|
|
30
31
|
loading?: boolean;
|
|
31
32
|
observer?: Observer;
|
|
@@ -37,10 +38,10 @@ export interface ActivityErrorDisplayProperties extends SelectedActivityResponse
|
|
|
37
38
|
error: string;
|
|
38
39
|
}
|
|
39
40
|
export interface SelectedActivityDisplayProperties extends SelectedActivityResponse {
|
|
40
|
-
distance: number;
|
|
41
|
+
distance: number | FormattedNumber;
|
|
41
42
|
duration: number;
|
|
42
|
-
elevation: number;
|
|
43
|
-
startPos?: number;
|
|
43
|
+
elevation: number | FormattedNumber;
|
|
44
|
+
startPos?: number | FormattedNumber;
|
|
44
45
|
segment?: string;
|
|
45
46
|
started: Date;
|
|
46
47
|
showMap: boolean;
|
|
@@ -48,11 +49,12 @@ export interface SelectedActivityDisplayProperties extends SelectedActivityRespo
|
|
|
48
49
|
lat: number;
|
|
49
50
|
lng: number;
|
|
50
51
|
}>;
|
|
51
|
-
activity:
|
|
52
|
+
activity: ActivityDetailsUI;
|
|
52
53
|
exports: Array<DisplayExportInfo>;
|
|
53
54
|
canStart: boolean;
|
|
54
55
|
canOpen: boolean;
|
|
55
56
|
uploads: Array<DisplayUploadInfo>;
|
|
57
|
+
units: Record<Dimension, Unit>;
|
|
56
58
|
}
|
|
57
59
|
export type DisplayExportInfo = {
|
|
58
60
|
type: string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ActivityDetails, ActivityDetailsUI, ActivityInfo, ActivityInfoUI, ActivitySummary, ActivitySummaryUI } from "../base";
|
|
2
|
+
export declare const createUIActivityInfo: (a: ActivityInfo) => ActivityInfoUI;
|
|
3
|
+
export declare const createUIActivitySummary: (summary: ActivitySummary) => ActivitySummaryUI;
|
|
4
|
+
export declare const createUIActivityDetails: (details: ActivityDetails) => ActivityDetailsUI;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getUnitConversionShortcuts } from "../../i18n";
|
|
2
|
+
export const createUIActivityInfo = (a) => {
|
|
3
|
+
if (!a)
|
|
4
|
+
return a;
|
|
5
|
+
const { summary, details } = a;
|
|
6
|
+
return {
|
|
7
|
+
summary: createUIActivitySummary(summary),
|
|
8
|
+
details: createUIActivityDetails(details)
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export const createUIActivitySummary = (summary) => {
|
|
12
|
+
if (!summary)
|
|
13
|
+
return summary;
|
|
14
|
+
const ui = { ...summary };
|
|
15
|
+
const [C, U] = getUnitConversionShortcuts();
|
|
16
|
+
ui.distance = { value: C(summary.distance, 'distance', { digits: 1 }), unit: U('distance') };
|
|
17
|
+
if (ui.distance.value > 100)
|
|
18
|
+
ui.distance.value = Math.round(ui.distance.value);
|
|
19
|
+
ui.totalElevation = { value: C(summary.totalElevation, 'elevation', { digits: 0 }), unit: U('elevation') };
|
|
20
|
+
return ui;
|
|
21
|
+
};
|
|
22
|
+
export const createUIActivityDetails = (details) => {
|
|
23
|
+
if (!details)
|
|
24
|
+
return details;
|
|
25
|
+
const ui = { ...details };
|
|
26
|
+
const [C, U] = getUnitConversionShortcuts();
|
|
27
|
+
ui.distance = { value: C(details.distance, 'distance', { digits: 1 }), unit: U('distance') };
|
|
28
|
+
if (ui.distance.value > 100)
|
|
29
|
+
ui.distance.value = Math.round(ui.distance.value);
|
|
30
|
+
ui.totalElevation = { value: C(details.totalElevation, 'elevation', { digits: 0 }), unit: U('elevation') };
|
|
31
|
+
const formatSpeed = (v) => {
|
|
32
|
+
return { value: C(v, 'speed', { digits: 1 }), unit: U('speed') };
|
|
33
|
+
};
|
|
34
|
+
if (ui.stats?.speed) {
|
|
35
|
+
const fields = ['min', 'max', 'avg'];
|
|
36
|
+
for (const field of fields) {
|
|
37
|
+
ui.stats.speed[field] = formatSpeed(ui.stats.speed[field]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
ui.logs = [];
|
|
41
|
+
for (const log of details.logs ?? []) {
|
|
42
|
+
const { speed, distance, elevation } = log;
|
|
43
|
+
const uiLog = { ...log };
|
|
44
|
+
uiLog.speed = C(speed, 'speed', { digits: 1 });
|
|
45
|
+
uiLog.distance = C(distance, 'distance', { digits: 2 });
|
|
46
|
+
uiLog.elevation = C(elevation, 'elevation', { digits: 0 });
|
|
47
|
+
ui.logs.push(uiLog);
|
|
48
|
+
}
|
|
49
|
+
return ui;
|
|
50
|
+
};
|
|
@@ -144,7 +144,7 @@ export declare class ActivityRideService extends IncyclistService {
|
|
|
144
144
|
protected getPrevActivityLog(ai: ActivityInfo, current: ActivityLogRecord): PastActivityLogEntry | null;
|
|
145
145
|
protected getRecordWithSameOrBiggerTime(logs: any, current: any): any;
|
|
146
146
|
protected calculateDistanceGap(ai: ActivityInfo, res: any, current: any): {
|
|
147
|
-
distanceGap:
|
|
147
|
+
distanceGap: any;
|
|
148
148
|
routeDistance: any;
|
|
149
149
|
lat: any;
|
|
150
150
|
lng: any;
|
|
@@ -184,14 +184,14 @@ export declare class ActivityRideService extends IncyclistService {
|
|
|
184
184
|
protected startWorker(): void;
|
|
185
185
|
protected stopWorker(): void;
|
|
186
186
|
protected createObserver(): Observer;
|
|
187
|
-
protected getUserSettings(): import("
|
|
188
|
-
protected getRouteList(): import("
|
|
189
|
-
protected getDeviceRide(): import("
|
|
190
|
-
protected getDeviceConfiguration(): import("
|
|
187
|
+
protected getUserSettings(): import("../../settings").UserSettingsService;
|
|
188
|
+
protected getRouteList(): import("../../routes").RouteListService;
|
|
189
|
+
protected getDeviceRide(): import("../../devices").DeviceRideService;
|
|
190
|
+
protected getDeviceConfiguration(): import("../../devices").DeviceConfigurationService;
|
|
191
191
|
protected getActivityUploadFactory(): ActivityUploadFactory;
|
|
192
192
|
protected getActivityConverterfactory(): ActivityConverterFactory;
|
|
193
193
|
protected getFileSystemBinding(): import("../../api/fs").IFileSystem;
|
|
194
194
|
protected getUnitConversionShortcuts(): any[];
|
|
195
|
-
protected getUnitConverter(): import("
|
|
195
|
+
protected getUnitConverter(): import("../../i18n").UnitConverterService;
|
|
196
196
|
}
|
|
197
197
|
export declare const useActivityRide: () => ActivityRideService;
|