@robotical/webapp-types 3.7.32 → 3.7.34
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.
|
@@ -11,6 +11,7 @@ import { ConnectedRaftItem } from "../../store/SelectedRaftContext";
|
|
|
11
11
|
import Toaster from "../../utils/Toaster";
|
|
12
12
|
import AnalyticsFacade from "@robotical/appv2-analytics-gatherer";
|
|
13
13
|
import { CarouselNavigatorManager } from "../../utils/CarouselNavigatorManager";
|
|
14
|
+
import { UserDeviceInfo } from "../../types/userDeviceInfo";
|
|
14
15
|
export default class ApplicationManager {
|
|
15
16
|
AnalyticsFacade: typeof AnalyticsFacade;
|
|
16
17
|
analyticsSessionId: string | undefined;
|
|
@@ -22,6 +23,7 @@ export default class ApplicationManager {
|
|
|
22
23
|
connectedRaftsContext: ConnectedRaftItem[];
|
|
23
24
|
returnToMainApp: () => void;
|
|
24
25
|
carouselNavigatorManager: CarouselNavigatorManager;
|
|
26
|
+
deviceInfo: UserDeviceInfo | undefined;
|
|
25
27
|
private _router;
|
|
26
28
|
setRouter(router: any): void;
|
|
27
29
|
navigateTo(path: string): void;
|
|
@@ -37,6 +39,7 @@ export default class ApplicationManager {
|
|
|
37
39
|
};
|
|
38
40
|
isPhoneApp: () => boolean;
|
|
39
41
|
constructor();
|
|
42
|
+
getDeviceInfo(): Promise<void>;
|
|
40
43
|
updateRaftNameInAllStates(raftId: string, name: string): Promise<boolean>;
|
|
41
44
|
pauseWifiConnectionMarty(raftId: string, pause: boolean): Promise<boolean>;
|
|
42
45
|
getCachedWifiStatusMarty(martyId: string): RaftWifiConnStatus | undefined;
|
|
@@ -70,6 +70,8 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
70
70
|
this.returnToMainApp = function () { };
|
|
71
71
|
// Carousel navigators
|
|
72
72
|
this.carouselNavigatorManager = new CarouselNavigatorManager();
|
|
73
|
+
// Device info
|
|
74
|
+
this.deviceInfo = undefined;
|
|
73
75
|
// Callback to call when a RAFT is selected (Phone App only)
|
|
74
76
|
// We need that to make sure the connection button gets the selected RAFT once the user selects one
|
|
75
77
|
this.ricSelectedCb = null;
|
|
@@ -112,6 +114,21 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
112
114
|
Logger.error(SHOW_LOGS, TAG, "Router is not set");
|
|
113
115
|
}
|
|
114
116
|
};
|
|
117
|
+
ApplicationManager.prototype.getDeviceInfo = function () {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
+
var _a;
|
|
120
|
+
return __generator(this, function (_b) {
|
|
121
|
+
switch (_b.label) {
|
|
122
|
+
case 0:
|
|
123
|
+
_a = this;
|
|
124
|
+
return [4 /*yield*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.GET_DEVICE_INFO, {})];
|
|
125
|
+
case 1:
|
|
126
|
+
_a.deviceInfo = _b.sent();
|
|
127
|
+
return [2 /*return*/];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
115
132
|
ApplicationManager.prototype.updateRaftNameInAllStates = function (raftId, name) {
|
|
116
133
|
return __awaiter(this, void 0, void 0, function () {
|
|
117
134
|
var wasSuccessful;
|
|
@@ -380,55 +397,51 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
380
397
|
uuids = [ConnManager.COGUUID, ConnManager.RICUUID];
|
|
381
398
|
}
|
|
382
399
|
}
|
|
383
|
-
if (!isPhoneApp()) return [3 /*break*/,
|
|
400
|
+
if (!isPhoneApp()) return [3 /*break*/, 9];
|
|
384
401
|
_a.label = 2;
|
|
385
402
|
case 2:
|
|
386
|
-
_a.trys.push([2,
|
|
387
|
-
if (!isQRVerification) return [3 /*break*/,
|
|
403
|
+
_a.trys.push([2, 7, , 8]);
|
|
404
|
+
if (!isQRVerification) return [3 /*break*/, 4];
|
|
388
405
|
secondaryModalState.setModal(createElement(ConnectingLoadingSpinnerModal, {}), "Connecting...", false);
|
|
389
406
|
this.ricSelectedCb = null;
|
|
390
407
|
return [4 /*yield*/, window.applicationManager.startDiscoveryWithoutVerification(uuids, afterRaftConnectedCb)];
|
|
391
408
|
case 3:
|
|
392
409
|
_a.sent();
|
|
393
|
-
return [
|
|
394
|
-
case 4:
|
|
395
|
-
_a.sent(); // make sure the device has shown up in the connection area
|
|
396
|
-
secondaryModalState.closeModal();
|
|
397
|
-
return [3 /*break*/, 7];
|
|
398
|
-
case 5: return [4 /*yield*/, window.applicationManager.startDiscovery(function (newRaft) {
|
|
410
|
+
return [3 /*break*/, 6];
|
|
411
|
+
case 4: return [4 /*yield*/, window.applicationManager.startDiscovery(function (newRaft) {
|
|
399
412
|
_this.connectedRaftContextMethods.addConnectedRaft({ id: newRaft.id, type: newRaft.type, name: newRaft.getFriendlyName() || "", isSelected: true });
|
|
400
413
|
afterRaftConnectedCb(newRaft);
|
|
401
414
|
}, uuids)];
|
|
402
|
-
case
|
|
415
|
+
case 5:
|
|
403
416
|
_a.sent();
|
|
404
|
-
_a.label =
|
|
405
|
-
case
|
|
406
|
-
case
|
|
417
|
+
_a.label = 6;
|
|
418
|
+
case 6: return [3 /*break*/, 8];
|
|
419
|
+
case 7:
|
|
407
420
|
e_1 = _a.sent();
|
|
408
421
|
Logger.error(SHOW_LOGS, TAG, "Failed to start discovery: ".concat(e_1));
|
|
409
|
-
return [3 /*break*/,
|
|
410
|
-
case
|
|
411
|
-
case
|
|
422
|
+
return [3 /*break*/, 8];
|
|
423
|
+
case 8: return [3 /*break*/, 14];
|
|
424
|
+
case 9:
|
|
412
425
|
secondaryModalState.setModal(createElement(ConnectingLoadingSpinnerModal, {}), "Connecting...", false);
|
|
413
|
-
_a.label =
|
|
414
|
-
case
|
|
415
|
-
_a.trys.push([
|
|
426
|
+
_a.label = 10;
|
|
427
|
+
case 10:
|
|
428
|
+
_a.trys.push([10, 12, , 13]);
|
|
416
429
|
return [4 /*yield*/, window.applicationManager.connectToRIC(RaftConnectionMethod.WEB_BLE, uuids, isQRVerification)];
|
|
417
|
-
case
|
|
430
|
+
case 11:
|
|
418
431
|
newRaft = _a.sent();
|
|
419
432
|
if (newRaft) {
|
|
420
433
|
this.connectedRaftContextMethods.addConnectedRaft({ id: newRaft.id, type: newRaft.type, name: newRaft.getFriendlyName() || "", isSelected: true });
|
|
421
434
|
afterRaftConnectedCb(newRaft);
|
|
422
435
|
}
|
|
423
|
-
return [3 /*break*/,
|
|
424
|
-
case
|
|
436
|
+
return [3 /*break*/, 13];
|
|
437
|
+
case 12:
|
|
425
438
|
e_2 = _a.sent();
|
|
426
439
|
Logger.error(SHOW_LOGS, TAG, "Failed to connect to new robot: ".concat(e_2));
|
|
427
|
-
return [3 /*break*/,
|
|
428
|
-
case
|
|
440
|
+
return [3 /*break*/, 13];
|
|
441
|
+
case 13:
|
|
429
442
|
secondaryModalState.closeModal();
|
|
430
|
-
_a.label =
|
|
431
|
-
case
|
|
443
|
+
_a.label = 14;
|
|
444
|
+
case 14: return [2 /*return*/];
|
|
432
445
|
}
|
|
433
446
|
});
|
|
434
447
|
});
|
|
@@ -643,12 +656,21 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
643
656
|
*/
|
|
644
657
|
ApplicationManager.prototype.startDiscoveryWithoutVerification = function (uuids, afterRaftConnectedCb) {
|
|
645
658
|
return __awaiter(this, void 0, void 0, function () {
|
|
646
|
-
var foundRICs, wasDiscoveryStarted;
|
|
659
|
+
var foundRICs, notFoundTimeout, wasDiscoveryStarted;
|
|
647
660
|
var _this = this;
|
|
648
661
|
return __generator(this, function (_a) {
|
|
649
662
|
switch (_a.label) {
|
|
650
663
|
case 0:
|
|
651
664
|
foundRICs = [];
|
|
665
|
+
notFoundTimeout = setTimeout(function () {
|
|
666
|
+
if (foundRICs.length === 0) {
|
|
667
|
+
_this.toaster.error("Make sure the robot is powered on and in range!");
|
|
668
|
+
}
|
|
669
|
+
window.applicationManager.stopDiscovery();
|
|
670
|
+
secondaryModalState.closeModal();
|
|
671
|
+
clearTimeout(notFoundTimeout);
|
|
672
|
+
}, 7000);
|
|
673
|
+
Logger.phoneAppLog(SHOW_LOGS, TAG, "before raftFoundSubscriptionHelper");
|
|
652
674
|
raftFoundSubscriptionHelper().subscribe(function (_a) {
|
|
653
675
|
var discoveredDevice = _a.discoveredDevice;
|
|
654
676
|
return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -666,6 +688,7 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
666
688
|
case 1:
|
|
667
689
|
newRaft = _b.sent();
|
|
668
690
|
if (!newRaft) return [3 /*break*/, 3];
|
|
691
|
+
secondaryModalState.closeModal();
|
|
669
692
|
this.connectedRaftContextMethods.addConnectedRaft({ id: newRaft.id, type: newRaft.type, name: newRaft.getFriendlyName() || "", isSelected: true });
|
|
670
693
|
afterRaftConnectedCb(newRaft);
|
|
671
694
|
oldColours = newRaft._ledLcdColours;
|
|
@@ -101,6 +101,10 @@ export default function LEDLightsOrQRVerificationModal() {
|
|
|
101
101
|
if (serialNoFromQR) {
|
|
102
102
|
modalState.closeModalWithoutAnimation([ConnManager.generateServiceFilterUUID(serialNoFromQR)]);
|
|
103
103
|
}
|
|
104
|
+
else {
|
|
105
|
+
// // testing
|
|
106
|
+
// modalState.closeModalWithoutAnimation([ConnManager.generateServiceFilterUUID('00000000000000000000000000000079')]);
|
|
107
|
+
}
|
|
104
108
|
return [2 /*return*/];
|
|
105
109
|
});
|
|
106
110
|
}); };
|
|
@@ -111,6 +115,7 @@ export default function LEDLightsOrQRVerificationModal() {
|
|
|
111
115
|
}
|
|
112
116
|
function QRContent(_a) {
|
|
113
117
|
var _this = this;
|
|
118
|
+
var _b;
|
|
114
119
|
var setSerialNo = _a.setSerialNo;
|
|
115
120
|
var onQrCodeFound = function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
116
121
|
var rawValue, serialNo;
|
|
@@ -126,7 +131,8 @@ function QRContent(_a) {
|
|
|
126
131
|
return [2 /*return*/];
|
|
127
132
|
});
|
|
128
133
|
}); };
|
|
129
|
-
|
|
134
|
+
var isWebapp = ((_b = window.applicationManager.deviceInfo) === null || _b === void 0 ? void 0 : _b.manufacturer) === "Webapp";
|
|
135
|
+
return (_jsx("div", __assign({ className: styles.QRcontainer }, { children: _jsx("div", __assign({ className: styles.QRscannerContainer }, { children: _jsx(Scanner, { styles: { container: { transform: isWebapp ? 'scaleX(-1)' : 'none' } }, onError: function (err) { return console.error(err); }, formats: [
|
|
130
136
|
"qr_code",
|
|
131
137
|
"micro_qr_code",
|
|
132
138
|
"rm_qr_code",
|