incyclist-services 1.3.36 → 1.3.37
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/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/monitoring/index.d.ts +1 -0
- package/lib/monitoring/index.js +17 -0
- package/lib/monitoring/online/index.d.ts +1 -0
- package/lib/monitoring/online/index.js +17 -0
- package/lib/monitoring/online/service.d.ts +15 -0
- package/lib/monitoring/online/service.js +104 -0
- package/lib/routes/list/cards/RouteCard.d.ts +7 -0
- package/lib/routes/list/cards/RouteCard.js +59 -4
- package/lib/routes/list/service.js +2 -2
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -29,3 +29,4 @@ Object.defineProperty(exports, "initUserSettings", { enumerable: true, get: func
|
|
|
29
29
|
Object.defineProperty(exports, "UserSettingsService", { enumerable: true, get: function () { return settings_1.UserSettingsService; } });
|
|
30
30
|
Object.defineProperty(exports, "UserSettingsBinding", { enumerable: true, get: function () { return settings_1.UserSettingsBinding; } });
|
|
31
31
|
__exportStar(require("./autoupdate"), exports);
|
|
32
|
+
__exportStar(require("./monitoring"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './online';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./online"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './service';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./service"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IncyclistService } from "../../base/service";
|
|
2
|
+
import { Observer } from "../../base/types/observer";
|
|
3
|
+
export declare class OnlineStateMonitoringService extends IncyclistService {
|
|
4
|
+
protected isOnline: boolean;
|
|
5
|
+
protected _observer: Observer;
|
|
6
|
+
protected contextHandlers: Record<string, (online: boolean) => void>;
|
|
7
|
+
constructor();
|
|
8
|
+
setOnline(isOnline: boolean): void;
|
|
9
|
+
get onlineStatus(): boolean;
|
|
10
|
+
get observer(): Observer;
|
|
11
|
+
start(context: string, onlineStatusChanged: (online: boolean) => void): Observer;
|
|
12
|
+
stop(context: string): void;
|
|
13
|
+
emit<K>(eventName: string | symbol, ...args: any[]): boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const useOnlineStatusMonitoring: () => OnlineStateMonitoringService;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.useOnlineStatusMonitoring = exports.OnlineStateMonitoringService = void 0;
|
|
42
|
+
const service_1 = require("../../base/service");
|
|
43
|
+
const types_1 = require("../../base/types");
|
|
44
|
+
const observer_1 = require("../../base/types/observer");
|
|
45
|
+
let OnlineStateMonitoringService = (() => {
|
|
46
|
+
let _classDecorators = [types_1.Singleton];
|
|
47
|
+
let _classDescriptor;
|
|
48
|
+
let _classExtraInitializers = [];
|
|
49
|
+
let _classThis;
|
|
50
|
+
let _classSuper = service_1.IncyclistService;
|
|
51
|
+
var OnlineStateMonitoringService = _classThis = class extends _classSuper {
|
|
52
|
+
constructor() {
|
|
53
|
+
super('OnlineStatee');
|
|
54
|
+
this.contextHandlers = {};
|
|
55
|
+
this._observer = new observer_1.Observer();
|
|
56
|
+
}
|
|
57
|
+
setOnline(isOnline) {
|
|
58
|
+
if (this.isOnline === undefined || this.isOnline !== isOnline) {
|
|
59
|
+
this.isOnline = isOnline;
|
|
60
|
+
this.emit('onlineStatus', isOnline);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
get onlineStatus() {
|
|
64
|
+
return this.isOnline;
|
|
65
|
+
}
|
|
66
|
+
get observer() {
|
|
67
|
+
return this._observer;
|
|
68
|
+
}
|
|
69
|
+
start(context, onlineStatusChanged) {
|
|
70
|
+
if (this.contextHandlers[context])
|
|
71
|
+
this.stop(context);
|
|
72
|
+
this.contextHandlers[context] = onlineStatusChanged;
|
|
73
|
+
this._observer.on('onlineStatus', onlineStatusChanged);
|
|
74
|
+
return this._observer;
|
|
75
|
+
}
|
|
76
|
+
stop(context) {
|
|
77
|
+
const onlineStatusChanged = this.contextHandlers[context];
|
|
78
|
+
if (onlineStatusChanged === undefined)
|
|
79
|
+
return;
|
|
80
|
+
this._observer.off('onlineStatus', onlineStatusChanged);
|
|
81
|
+
delete this.contextHandlers[context];
|
|
82
|
+
}
|
|
83
|
+
emit(eventName, ...args) {
|
|
84
|
+
if (this._observer) {
|
|
85
|
+
this._observer.emit(eventName, ...args);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
__setFunctionName(_classThis, "OnlineStateMonitoringService");
|
|
92
|
+
(() => {
|
|
93
|
+
var _a;
|
|
94
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
95
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
96
|
+
OnlineStateMonitoringService = _classThis = _classDescriptor.value;
|
|
97
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
98
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
99
|
+
})();
|
|
100
|
+
return OnlineStateMonitoringService = _classThis;
|
|
101
|
+
})();
|
|
102
|
+
exports.OnlineStateMonitoringService = OnlineStateMonitoringService;
|
|
103
|
+
const useOnlineStatusMonitoring = () => new OnlineStateMonitoringService();
|
|
104
|
+
exports.useOnlineStatusMonitoring = useOnlineStatusMonitoring;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FileInfo } from "../../../api";
|
|
1
2
|
import { Card, CardList } from "../../../base/cardlist";
|
|
2
3
|
import { Observer, PromiseObserver } from "../../../base/types/observer";
|
|
3
4
|
import { RouteApiDetail } from "../../base/api/types";
|
|
@@ -19,6 +20,7 @@ export interface SummaryCardDisplayProps extends RouteInfo {
|
|
|
19
20
|
initialized: boolean;
|
|
20
21
|
loading?: boolean;
|
|
21
22
|
isNew?: boolean;
|
|
23
|
+
videoMissing?: boolean;
|
|
22
24
|
}
|
|
23
25
|
export interface DetailCardDisplayProps {
|
|
24
26
|
}
|
|
@@ -39,6 +41,8 @@ export type RouteCardProps = {
|
|
|
39
41
|
showLoopOverwrite: boolean;
|
|
40
42
|
showNextOverwrite: boolean;
|
|
41
43
|
hasWorkout?: boolean;
|
|
44
|
+
canStart?: boolean;
|
|
45
|
+
videoMissing?: boolean;
|
|
42
46
|
};
|
|
43
47
|
declare class ConvertObserver extends Observer {
|
|
44
48
|
protected conversion: Observer;
|
|
@@ -64,6 +68,8 @@ export declare class RouteCard extends BaseCard implements Card<Route> {
|
|
|
64
68
|
getRepo(): RoutesDbLoader;
|
|
65
69
|
setList(list: CardList<Route>): void;
|
|
66
70
|
verify(): void;
|
|
71
|
+
videoExists(): boolean;
|
|
72
|
+
protected fileExists(path: any): boolean;
|
|
67
73
|
previewMissing(): boolean;
|
|
68
74
|
setInitialized(init: boolean): void;
|
|
69
75
|
setVisible(visible: boolean): void;
|
|
@@ -91,6 +97,7 @@ export declare class RouteCard extends BaseCard implements Card<Route> {
|
|
|
91
97
|
getCurrentDownload(): Observer;
|
|
92
98
|
getVideoDir(): string;
|
|
93
99
|
setVideoDir(dir: string): void;
|
|
100
|
+
onVideoSelected(info: FileInfo): "Could not open file" | "Unsupported video format - Please select MP4 or AVI";
|
|
94
101
|
download(): Observer;
|
|
95
102
|
stopDownload(): void;
|
|
96
103
|
protected onDownloadCompleted(url: string): Promise<void>;
|
|
@@ -25,6 +25,7 @@ const gd_eventlog_1 = require("gd-eventlog");
|
|
|
25
25
|
const route_1 = require("../../base/utils/route");
|
|
26
26
|
const workouts_1 = require("../../../workouts");
|
|
27
27
|
const utils_2 = require("../utils");
|
|
28
|
+
const monitoring_1 = require("../../../monitoring");
|
|
28
29
|
class ConvertObserver extends observer_1.Observer {
|
|
29
30
|
constructor() {
|
|
30
31
|
super();
|
|
@@ -54,10 +55,12 @@ class RouteCard extends base_1.BaseCard {
|
|
|
54
55
|
try {
|
|
55
56
|
const { isOnline } = status;
|
|
56
57
|
const route = this.route.description;
|
|
57
|
-
if (!route.hasVideo || !route.isLocal || route.videoUrl.startsWith('http'))
|
|
58
|
+
if (!route.hasVideo || !(route.isLocal || route.isDownloaded) || route.videoUrl.startsWith('http'))
|
|
58
59
|
return isOnline;
|
|
59
60
|
if (route.requiresDownload)
|
|
60
|
-
return
|
|
61
|
+
return isOnline;
|
|
62
|
+
if (route.hasVideo)
|
|
63
|
+
return this.videoExists();
|
|
61
64
|
return true;
|
|
62
65
|
}
|
|
63
66
|
catch (err) {
|
|
@@ -80,6 +83,26 @@ class RouteCard extends base_1.BaseCard {
|
|
|
80
83
|
this.logError(err, 'verify');
|
|
81
84
|
}
|
|
82
85
|
}
|
|
86
|
+
videoExists() {
|
|
87
|
+
const descr = this.getRouteDescription();
|
|
88
|
+
if (!(descr === null || descr === void 0 ? void 0 : descr.hasVideo) || (descr === null || descr === void 0 ? void 0 : descr.videoUrl) === undefined)
|
|
89
|
+
return false;
|
|
90
|
+
const videoUrl = descr.videoUrl;
|
|
91
|
+
let path = undefined;
|
|
92
|
+
if (videoUrl.startsWith('file:///'))
|
|
93
|
+
path = videoUrl.replace('file:///', '');
|
|
94
|
+
if (videoUrl.startsWith('video:///'))
|
|
95
|
+
path = videoUrl.replace('video:///', '');
|
|
96
|
+
if (path) {
|
|
97
|
+
return this.fileExists(path);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
fileExists(path) {
|
|
101
|
+
const fs = (0, api_1.getBindings)().fs;
|
|
102
|
+
if (!fs)
|
|
103
|
+
return true;
|
|
104
|
+
return fs.existsSync(path);
|
|
105
|
+
}
|
|
83
106
|
previewMissing() {
|
|
84
107
|
try {
|
|
85
108
|
const descr = this.getRouteDescription();
|
|
@@ -163,8 +186,12 @@ class RouteCard extends base_1.BaseCard {
|
|
|
163
186
|
points = undefined;
|
|
164
187
|
}
|
|
165
188
|
let isNew = (0, utils_2.checkIsNew)(descr);
|
|
189
|
+
let videoMissing = undefined;
|
|
190
|
+
if (descr.hasVideo && descr.isLocal && !this.videoExists()) {
|
|
191
|
+
videoMissing = true;
|
|
192
|
+
}
|
|
166
193
|
const loading = this.deleteObserver !== undefined;
|
|
167
|
-
return Object.assign(Object.assign({}, descr), { initialized: this.initialized, loaded: true, ready: true, state: 'loaded', visible: this.visible, isNew, canDelete: this.canDelete(), points, loading, title: this.getTitle(), observer: this.cardObserver });
|
|
194
|
+
return Object.assign(Object.assign({}, descr), { initialized: this.initialized, loaded: true, ready: true, state: 'loaded', visible: this.visible, isNew, canDelete: this.canDelete(), points, loading, title: this.getTitle(), videoMissing, observer: this.cardObserver });
|
|
168
195
|
}
|
|
169
196
|
catch (err) {
|
|
170
197
|
this.logError(err, 'getDisplayProperties');
|
|
@@ -197,6 +224,13 @@ class RouteCard extends base_1.BaseCard {
|
|
|
197
224
|
var _a, _b, _c, _d, _e, _f;
|
|
198
225
|
const settings = this.getSettings();
|
|
199
226
|
const workouts = (0, workouts_1.getWorkoutList)();
|
|
227
|
+
const isOnline = (0, monitoring_1.useOnlineStatusMonitoring)().onlineStatus;
|
|
228
|
+
const canStart = this.canStart({ isOnline });
|
|
229
|
+
const descr = this.getRouteDescription();
|
|
230
|
+
let videoMissing;
|
|
231
|
+
if ((descr === null || descr === void 0 ? void 0 : descr.hasVideo) && ((descr === null || descr === void 0 ? void 0 : descr.isLocal) || (descr === null || descr === void 0 ? void 0 : descr.isDownloaded)) && !this.videoExists()) {
|
|
232
|
+
videoMissing = true;
|
|
233
|
+
}
|
|
200
234
|
let showLoopOverwrite, showNextOverwrite;
|
|
201
235
|
let hasWorkout = true;
|
|
202
236
|
this.adjustStartPosAvi(settings);
|
|
@@ -215,7 +249,7 @@ class RouteCard extends base_1.BaseCard {
|
|
|
215
249
|
catch (err) {
|
|
216
250
|
this.logError(err, 'openSettings');
|
|
217
251
|
}
|
|
218
|
-
return { settings, showLoopOverwrite, showNextOverwrite, hasWorkout };
|
|
252
|
+
return { settings, showLoopOverwrite, showNextOverwrite, hasWorkout, canStart, videoMissing };
|
|
219
253
|
}
|
|
220
254
|
changeSettings(props) {
|
|
221
255
|
try {
|
|
@@ -359,6 +393,27 @@ class RouteCard extends base_1.BaseCard {
|
|
|
359
393
|
this.logError(err, 'setVideoDir');
|
|
360
394
|
}
|
|
361
395
|
}
|
|
396
|
+
onVideoSelected(info) {
|
|
397
|
+
const dropped = Array.isArray(info) ? info[0] : info;
|
|
398
|
+
const ext = dropped.ext.toLowerCase();
|
|
399
|
+
if (ext !== 'mp4' && ext !== 'avi') {
|
|
400
|
+
return 'Unsupported video format - Please select MP4 or AVI';
|
|
401
|
+
}
|
|
402
|
+
const path = dropped.url.replace('file:///', '');
|
|
403
|
+
const exists = this.fileExists(path);
|
|
404
|
+
if (!exists) {
|
|
405
|
+
return 'Could not open file';
|
|
406
|
+
}
|
|
407
|
+
const descr = this.getRouteDescription();
|
|
408
|
+
const details = this.getRouteData();
|
|
409
|
+
descr.videoUrl = dropped.url;
|
|
410
|
+
descr.videoFormat = ext;
|
|
411
|
+
details.video.file = undefined;
|
|
412
|
+
details.video.url = dropped.url;
|
|
413
|
+
details.video.format = ext;
|
|
414
|
+
this.save();
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
362
417
|
download() {
|
|
363
418
|
var _a;
|
|
364
419
|
try {
|
|
@@ -170,7 +170,7 @@ let RouteListService = (() => {
|
|
|
170
170
|
if (!filters) {
|
|
171
171
|
return { routes, filters, observer: this.observer };
|
|
172
172
|
}
|
|
173
|
-
routes = routes.filter(r => !r.isDeleted);
|
|
173
|
+
routes = routes.filter(r => !(r === null || r === void 0 ? void 0 : r.isDeleted));
|
|
174
174
|
routes = this.applyTitleFilter(filters, routes);
|
|
175
175
|
routes = this.applyDistanceFilter(filters, routes);
|
|
176
176
|
routes = this.applyElevationFilter(filters, routes);
|
|
@@ -294,8 +294,8 @@ let RouteListService = (() => {
|
|
|
294
294
|
this.preloadObserver = new observer_1.PromiseObserver(promise);
|
|
295
295
|
this.preloadObserver.start()
|
|
296
296
|
.then(() => {
|
|
297
|
-
this.logEvent({ message: 'preload route list completed' });
|
|
298
297
|
this.initialized = true;
|
|
298
|
+
this.logEvent({ message: 'preload route list completed' });
|
|
299
299
|
(0, utils_1.updateRepoStats)();
|
|
300
300
|
this.emitLists('loaded', true);
|
|
301
301
|
process.nextTick(() => { delete this.preloadObserver; });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-services",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.37",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"gd-eventlog": "^0.1.26"
|
|
6
6
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"axios": "^1.7.7",
|
|
45
|
-
"incyclist-devices": "^2.2.
|
|
45
|
+
"incyclist-devices": "^2.2.8",
|
|
46
46
|
"promise.any": "^2.0.6",
|
|
47
47
|
"semver": "^7.6.3",
|
|
48
48
|
"tcx-builder": "^1.1.1",
|