@robotical/webapp-types 1.1.1 → 3.7.2

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.
@@ -42,17 +42,21 @@ export default class ApplicationManager {
42
42
  * This method is called from various environments (connection button, blocksjr, blocks etc.)
43
43
  * Known issue: connecting to a raft from within a platform won't add the newly connected raft to the connectedRafts hook
44
44
  */
45
- connectGeneric(afterRaftConnectedCb: (raft: RAFT) => void, uuids: string[]): Promise<void>;
45
+ connectGeneric(afterRaftConnectedCb: (raft: RAFT) => void, uuids?: string[]): Promise<void>;
46
46
  /**
47
47
  * Disconnect from RAFT generic
48
48
  * This method is called from various environments (connection button, blocksjr, blocks etc.)
49
49
  */
50
- disconnectGeneric(raft: RAFT, afterRaftDisconnectedCb?: () => void): Promise<void>;
50
+ disconnectGeneric(raft: RAFT, afterRaftDisconnectedCb?: () => void, skipConfirmation?: boolean): Promise<void>;
51
51
  /**
52
52
  * Selects a RAFT in Phone's verification modal
53
53
  */
54
54
  selectRaft(ricToConnectTo: FOUND_RAFT_ON_DISCOVERY_RESPONSE['foundRIC'], method: RaftConnectionMethod): Promise<RAFT | null>;
55
- connectToRIC(method: RaftConnectionMethod, uuids: string[]): Promise<RAFT | null>;
55
+ connectToRIC(method: RaftConnectionMethod, uuids: string[], withoutVerification?: boolean): Promise<RAFT | null>;
56
+ /**
57
+ * Toggles the Sensors Dashboard modal
58
+ */
59
+ toggleSensorsDashboard(): void;
56
60
  /**
57
61
  * Disconnect from RAFT
58
62
  */
@@ -67,6 +71,11 @@ export default class ApplicationManager {
67
71
  * This is used from the Phone App only
68
72
  */
69
73
  startDiscovery(ricSelectedCb: (raft: RAFT) => void, uuids: string[]): Promise<void>;
74
+ /**
75
+ * Start discovery without verification
76
+ * This is used from the Phone App only, when the user wants to connect to a RAFT with qr code
77
+ */
78
+ startDiscoveryWithoutVerification(uuids: string[], afterRaftConnectedCb: (raft: RAFT) => void): Promise<void>;
70
79
  /**
71
80
  * Stοp discovery
72
81
  * When the user cancels the discovery process without having first connected to a robot
@@ -52,6 +52,9 @@ import Toaster from "../../utils/Toaster";
52
52
  import { AnalyticsManager } from "../../analytics/AnalyticsManager";
53
53
  import { ConnManager } from "@robotical/roboticaljs";
54
54
  import ConnectingLoadingSpinnerModal from "../../components/modals/ConnectingLoadingSpinnerModal";
55
+ import draggableModalState from "../../state-observables/modal/DraggableModalState";
56
+ import SensorsDashboardModal from "../../components/modals/ SensorsDashboardModal";
57
+ import LEDLightsOrQRVerificationModal from "../../components/modals/LEDLightsOrQRVerificationModal";
55
58
  var SHOW_LOGS = true;
56
59
  var TAG = "ApplicationManager";
57
60
  var ApplicationManager = /** @class */ (function () {
@@ -132,48 +135,69 @@ var ApplicationManager = /** @class */ (function () {
132
135
  */
133
136
  ApplicationManager.prototype.connectGeneric = function (afterRaftConnectedCb, uuids) {
134
137
  return __awaiter(this, void 0, void 0, function () {
135
- var e_1, newRaft, e_2;
138
+ var specificUUIDs, isQRVerification, e_1, newRaft, e_2;
136
139
  var _this = this;
137
140
  return __generator(this, function (_a) {
138
141
  switch (_a.label) {
139
- case 0:
140
- if (!isPhoneApp()) return [3 /*break*/, 5];
141
- _a.label = 1;
142
+ case 0: return [4 /*yield*/, modalState.setModal(createElement(LEDLightsOrQRVerificationModal), "Verification Method")];
142
143
  case 1:
143
- _a.trys.push([1, 3, , 4]);
144
- return [4 /*yield*/, window.applicationManager.startDiscovery(function (newRaft) {
145
- _this.connectedRaftContextMethods.addConnectedRaft({ id: newRaft.id, type: newRaft.type, name: newRaft.getFriendlyName() || "", isSelected: true });
146
- afterRaftConnectedCb(newRaft);
147
- }, uuids)];
144
+ specificUUIDs = _a.sent();
145
+ isQRVerification = false;
146
+ if (specificUUIDs === false) {
147
+ return [2 /*return*/];
148
+ }
149
+ if (specificUUIDs.length > 0) {
150
+ uuids = specificUUIDs;
151
+ isQRVerification = true;
152
+ }
153
+ else {
154
+ if (!uuids) {
155
+ uuids = [ConnManager.COGUUID, ConnManager.RICUUID];
156
+ }
157
+ }
158
+ if (!isPhoneApp()) return [3 /*break*/, 9];
159
+ _a.label = 2;
148
160
  case 2:
149
- _a.sent();
150
- return [3 /*break*/, 4];
161
+ _a.trys.push([2, 7, , 8]);
162
+ if (!isQRVerification) return [3 /*break*/, 4];
163
+ return [4 /*yield*/, window.applicationManager.startDiscoveryWithoutVerification(uuids, afterRaftConnectedCb)];
151
164
  case 3:
152
- e_1 = _a.sent();
153
- Logger.error(SHOW_LOGS, TAG, "Failed to start discovery: ".concat(e_1));
154
- return [3 /*break*/, 4];
155
- case 4: return [3 /*break*/, 10];
165
+ _a.sent();
166
+ return [3 /*break*/, 6];
167
+ case 4: return [4 /*yield*/, window.applicationManager.startDiscovery(function (newRaft) {
168
+ _this.connectedRaftContextMethods.addConnectedRaft({ id: newRaft.id, type: newRaft.type, name: newRaft.getFriendlyName() || "", isSelected: true });
169
+ afterRaftConnectedCb(newRaft);
170
+ }, uuids)];
156
171
  case 5:
157
- secondaryModalState.setModal(createElement(ConnectingLoadingSpinnerModal, {}), "Connecting...", false);
172
+ _a.sent();
158
173
  _a.label = 6;
159
- case 6:
160
- _a.trys.push([6, 8, , 9]);
161
- return [4 /*yield*/, window.applicationManager.connectToRIC(RaftConnectionMethod.WEB_BLE, uuids)];
174
+ case 6: return [3 /*break*/, 8];
162
175
  case 7:
176
+ e_1 = _a.sent();
177
+ Logger.error(SHOW_LOGS, TAG, "Failed to start discovery: ".concat(e_1));
178
+ return [3 /*break*/, 8];
179
+ case 8: return [3 /*break*/, 14];
180
+ case 9:
181
+ secondaryModalState.setModal(createElement(ConnectingLoadingSpinnerModal, {}), "Connecting...", false);
182
+ _a.label = 10;
183
+ case 10:
184
+ _a.trys.push([10, 12, , 13]);
185
+ return [4 /*yield*/, window.applicationManager.connectToRIC(RaftConnectionMethod.WEB_BLE, uuids, isQRVerification)];
186
+ case 11:
163
187
  newRaft = _a.sent();
164
188
  if (newRaft) {
165
189
  this.connectedRaftContextMethods.addConnectedRaft({ id: newRaft.id, type: newRaft.type, name: newRaft.getFriendlyName() || "", isSelected: true });
166
190
  afterRaftConnectedCb(newRaft);
167
191
  }
168
- return [3 /*break*/, 9];
169
- case 8:
192
+ return [3 /*break*/, 13];
193
+ case 12:
170
194
  e_2 = _a.sent();
171
195
  Logger.error(SHOW_LOGS, TAG, "Failed to connect to new robot: ".concat(e_2));
172
- return [3 /*break*/, 9];
173
- case 9:
196
+ return [3 /*break*/, 13];
197
+ case 13:
174
198
  secondaryModalState.closeModal();
175
- _a.label = 10;
176
- case 10: return [2 /*return*/];
199
+ _a.label = 14;
200
+ case 14: return [2 /*return*/];
177
201
  }
178
202
  });
179
203
  });
@@ -182,31 +206,34 @@ var ApplicationManager = /** @class */ (function () {
182
206
  * Disconnect from RAFT generic
183
207
  * This method is called from various environments (connection button, blocksjr, blocks etc.)
184
208
  */
185
- ApplicationManager.prototype.disconnectGeneric = function (raft, afterRaftDisconnectedCb) {
209
+ ApplicationManager.prototype.disconnectGeneric = function (raft, afterRaftDisconnectedCb, skipConfirmation) {
210
+ if (skipConfirmation === void 0) { skipConfirmation = false; }
186
211
  return __awaiter(this, void 0, void 0, function () {
187
212
  var confirmDisconnect, e_3;
188
213
  return __generator(this, function (_a) {
189
214
  switch (_a.label) {
190
215
  case 0:
191
- _a.trys.push([0, 3, , 4]);
216
+ _a.trys.push([0, 4, , 5]);
217
+ if (!!skipConfirmation) return [3 /*break*/, 2];
192
218
  return [4 /*yield*/, modalState.setModal(createElement(DisconnectConfirmationModal), "Are you sure you want to disconnect from your ".concat(raft.getFriendlyName(), "?"))];
193
219
  case 1:
194
220
  confirmDisconnect = _a.sent();
195
221
  if (!confirmDisconnect) {
196
222
  return [2 /*return*/];
197
223
  }
198
- return [4 /*yield*/, window.applicationManager.disconnectFromRaft(raft.id)];
199
- case 2:
224
+ _a.label = 2;
225
+ case 2: return [4 /*yield*/, window.applicationManager.disconnectFromRaft(raft.id)];
226
+ case 3:
200
227
  _a.sent();
201
228
  if (afterRaftDisconnectedCb) {
202
229
  afterRaftDisconnectedCb();
203
230
  }
204
- return [3 /*break*/, 4];
205
- case 3:
231
+ return [3 /*break*/, 5];
232
+ case 4:
206
233
  e_3 = _a.sent();
207
234
  Logger.error(SHOW_LOGS, TAG, "Failed to disconnect from robot: ".concat(e_3));
208
- return [3 /*break*/, 4];
209
- case 4: return [2 /*return*/];
235
+ return [3 /*break*/, 5];
236
+ case 5: return [2 /*return*/];
210
237
  }
211
238
  });
212
239
  });
@@ -260,7 +287,7 @@ var ApplicationManager = /** @class */ (function () {
260
287
  });
261
288
  });
262
289
  };
263
- ApplicationManager.prototype.connectToRIC = function (method, uuids) {
290
+ ApplicationManager.prototype.connectToRIC = function (method, uuids, withoutVerification) {
264
291
  var _a, _b;
265
292
  return __awaiter(this, void 0, void 0, function () {
266
293
  var wasConnectedObj, raftId, raftType, raft;
@@ -293,13 +320,27 @@ var ApplicationManager = /** @class */ (function () {
293
320
  case 2:
294
321
  _c.sent();
295
322
  // start verification process
296
- modalState.setModal(createElement(VerificationModal, { connectedRAFT_: raft }), "Looking for ".concat(raft.type));
323
+ if (!withoutVerification) {
324
+ modalState.setModal(createElement(VerificationModal, { connectedRAFT_: raft }), "Looking for ".concat(raft.type));
325
+ }
326
+ else {
327
+ raft.stopVerifyingRaft(true);
328
+ }
297
329
  return [2 /*return*/, raft];
298
330
  case 3: return [2 /*return*/, null];
299
331
  }
300
332
  });
301
333
  });
302
334
  };
335
+ /**
336
+ * Toggles the Sensors Dashboard modal
337
+ */
338
+ ApplicationManager.prototype.toggleSensorsDashboard = function () {
339
+ if (draggableModalState.modalContent) {
340
+ return draggableModalState.closeModal();
341
+ }
342
+ return draggableModalState.setModal(createElement(SensorsDashboardModal), "Sensor Insights Hub (βETA)", "sensors-dashboard");
343
+ };
303
344
  /**
304
345
  * Disconnect from RAFT
305
346
  */
@@ -375,6 +416,57 @@ var ApplicationManager = /** @class */ (function () {
375
416
  });
376
417
  });
377
418
  };
419
+ /**
420
+ * Start discovery without verification
421
+ * This is used from the Phone App only, when the user wants to connect to a RAFT with qr code
422
+ */
423
+ ApplicationManager.prototype.startDiscoveryWithoutVerification = function (uuids, afterRaftConnectedCb) {
424
+ return __awaiter(this, void 0, void 0, function () {
425
+ var foundRICs, wasDiscoveryStarted;
426
+ var _this = this;
427
+ return __generator(this, function (_a) {
428
+ switch (_a.label) {
429
+ case 0:
430
+ foundRICs = [];
431
+ raftFoundSubscriptionHelper().subscribe(function (_a) {
432
+ var discoveredDevice = _a.discoveredDevice;
433
+ return __awaiter(_this, void 0, void 0, function () {
434
+ var newRaft;
435
+ return __generator(this, function (_b) {
436
+ switch (_b.label) {
437
+ case 0:
438
+ // connect to the first device found, block the rest
439
+ if (foundRICs.length > 0) {
440
+ return [2 /*return*/];
441
+ }
442
+ foundRICs.push(discoveredDevice);
443
+ return [4 /*yield*/, this.selectRaft(discoveredDevice, RaftConnectionMethod.PHONE_BLE)];
444
+ case 1:
445
+ newRaft = _b.sent();
446
+ if (newRaft) {
447
+ this.connectedRaftContextMethods.addConnectedRaft({ id: newRaft.id, type: newRaft.type, name: newRaft.getFriendlyName() || "", isSelected: true });
448
+ afterRaftConnectedCb(newRaft);
449
+ }
450
+ else {
451
+ foundRICs = [];
452
+ }
453
+ return [2 /*return*/];
454
+ }
455
+ });
456
+ });
457
+ });
458
+ return [4 /*yield*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.RAFT_START_DISCOVERY, { uuids: uuids })];
459
+ case 1:
460
+ wasDiscoveryStarted = _a.sent();
461
+ if (!wasDiscoveryStarted) {
462
+ return [2 /*return*/, raftFoundSubscriptionHelper().unsubscribe()];
463
+ }
464
+ raftFoundSubscriptionHelper().unsubscribe();
465
+ return [2 /*return*/];
466
+ }
467
+ });
468
+ });
469
+ };
378
470
  /**
379
471
  * Stοp discovery
380
472
  * When the user cancels the discovery process without having first connected to a robot
@@ -208,7 +208,7 @@ var Cog = /** @class */ (function (_super) {
208
208
  return __generator(this, function (_a) {
209
209
  switch (eventEnum) {
210
210
  case RaftInfoEvents.STATE_INFO:
211
- this.raftStateInfo = data;
211
+ this.raftStateInfo = data.stateInfo;
212
212
  break;
213
213
  default:
214
214
  break;
@@ -119,7 +119,7 @@ var PublishedDataAnalyser = /** @class */ (function (_super) {
119
119
  var _this = this;
120
120
  this.pubSub = raftPubSubscriptionHelper(this.cog);
121
121
  this.pubSub.subscribe(function (data) {
122
- _this.analyse(data);
122
+ _this.analyse(data.stateInfo);
123
123
  });
124
124
  };
125
125
  PublishedDataAnalyser.prototype.unsubscribeFromPublishedData = function () {
@@ -317,7 +317,7 @@ var ShakeDetector = /** @class */ (function () {
317
317
  this.gravityVector = [xAcc, yAcc, zAcc];
318
318
  if (this.moveInProgress) {
319
319
  // console.log("move detected");
320
- analyser.setMovementType("move");
320
+ // analyser.setMovementType("move");
321
321
  }
322
322
  else {
323
323
  // console.log("no move detected");
@@ -326,7 +326,7 @@ var ShakeDetector = /** @class */ (function () {
326
326
  this.moveInProgress = false;
327
327
  this.shakeInProgress = false;
328
328
  this.sensorBundles = [];
329
- return this.moveInProgress;
329
+ return this.shakeInProgress;
330
330
  }
331
331
  else {
332
332
  //console.log("move in progrss. prev state: ", this.moveInProgress);
@@ -351,7 +351,7 @@ var ShakeDetector = /** @class */ (function () {
351
351
  if (this.sensorBundles.length > this.thresholdShakeNumber) {
352
352
  // console.log("Shake detected!");
353
353
  this.sensorBundles = [];
354
- this.shakeInProgress = false;
354
+ this.shakeInProgress = true;
355
355
  analyser.setMovementType("shake");
356
356
  }
357
357
  }
@@ -363,11 +363,11 @@ var ShakeDetector = /** @class */ (function () {
363
363
  this.sensorBundles = [];
364
364
  // console.log("resetting shake detector. Move detected");
365
365
  // fire move detector
366
- analyser.setMovementType("move");
366
+ analyser.setMovementType("none");
367
367
  }
368
368
  }
369
369
  }
370
- return this.moveInProgress;
370
+ return this.shakeInProgress;
371
371
  /*
372
372
  if (this.sensorBundles.length === 0 || timestamp - this.lastTime > this.interval) {
373
373
  // Check if we should reset based on time since last recorded shake
@@ -284,7 +284,8 @@ var RAFT = /** @class */ (function () {
284
284
  case RaftConnEvent.CONN_VERIFIED_CORRECT:
285
285
  window.applicationManager.analyticsManager.logEvent("connection", { raftType: this.type, systemInfo: this.systemInfo });
286
286
  break;
287
- case RaftConnEvent.CONN_DISCONNECTED:
287
+ case RaftConnEvent.CONN_DISCONNECTED: // this runs when the RAFT is disconnected on its own (due to a timeout or other reasons)
288
+ window.applicationManager.disconnectGeneric(this, function () { }, true); // disconnects the RAFT and removes it from the connectedRafts list
288
289
  window.applicationManager.analyticsManager.logEvent("disconnection", { raftType: this.type });
289
290
  break;
290
291
  case RaftConnEvent.CONN_ISSUE_DETECTED:
@@ -324,7 +325,7 @@ var RAFT = /** @class */ (function () {
324
325
  return __generator(this, function (_a) {
325
326
  switch (eventEnum) {
326
327
  case RaftInfoEvents.STATE_INFO:
327
- this.raftStateInfo = data;
328
+ this.raftStateInfo = data.stateInfo;
328
329
  break;
329
330
  case RaftInfoEvents.SYSTEM_INFO:
330
331
  this.systemInfo = data.systemInfo;
@@ -0,0 +1,2 @@
1
+ declare function SensorsDashboardModal(): import("react/jsx-runtime").JSX.Element;
2
+ export default SensorsDashboardModal;
@@ -0,0 +1,61 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { createElement, useEffect, useRef, useState } from 'react';
14
+ import SensorsDashboard from '@robotical/sensors-dashboard/dist/App';
15
+ import { ReactComponent as BetaSignSVG } from "../../../assets/beta-sign.svg";
16
+ import modalState from "../../../state-observables/modal/ModalState";
17
+ import DetailedFeedbackModal from '../DetailedFeedbackModal';
18
+ import styles from './styles.module.css';
19
+ function SensorsDashboardModal() {
20
+ var _a = useState(true), showBetaSign = _a[0], setShowBetaSign = _a[1];
21
+ var betaSignRef = useRef(null);
22
+ // if (window.mv2Dashboard) {
23
+ // window.mv2Dashboard.setIsModal(true);
24
+ // }
25
+ var updateBetaSignVisibility = function () {
26
+ if (!betaSignRef.current) {
27
+ return;
28
+ }
29
+ var parent = betaSignRef.current.parentElement;
30
+ if (!parent) {
31
+ return;
32
+ }
33
+ var parentHeight = parent.clientHeight;
34
+ if (parentHeight > 100) {
35
+ setShowBetaSign(true);
36
+ }
37
+ else {
38
+ setShowBetaSign(false);
39
+ }
40
+ };
41
+ useEffect(function () {
42
+ updateBetaSignVisibility();
43
+ if (!betaSignRef.current) {
44
+ return;
45
+ }
46
+ var resizeObserver = new ResizeObserver(function () {
47
+ updateBetaSignVisibility();
48
+ });
49
+ if (!betaSignRef.current.parentElement) {
50
+ return;
51
+ }
52
+ resizeObserver.observe(betaSignRef.current.parentElement);
53
+ return function () {
54
+ resizeObserver.disconnect();
55
+ };
56
+ }, [betaSignRef]);
57
+ return (_jsxs(_Fragment, { children: [_jsx("div", __assign({ style: { visibility: showBetaSign ? "visible" : "hidden" }, className: styles.betaSign, onClick: function () {
58
+ return modalState.setModal(createElement(DetailedFeedbackModal), "Anonymous Bug Report");
59
+ }, ref: betaSignRef }, { children: _jsx(BetaSignSVG, {}) })), _jsx(SensorsDashboard, { isInModal: true })] }));
60
+ }
61
+ export default SensorsDashboardModal;
@@ -0,0 +1,5 @@
1
+ type Props = {
2
+ otherInfoObject?: object;
3
+ };
4
+ export default function DetailedFeedbackModal({ otherInfoObject }: Props): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,37 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { useState } from "react";
14
+ import modalState from "../../../state-observables/modal/ModalState";
15
+ import styles from "./styles.module.css";
16
+ import SimpleButton from "../../disposables/buttons/SimpleButton";
17
+ export default function DetailedFeedbackModal(_a) {
18
+ var otherInfoObject = _a.otherInfoObject;
19
+ var _b = useState(""), report = _b[0], setReport = _b[1];
20
+ var _c = useState(""), email = _c[0], setEmail = _c[1];
21
+ var _d = useState(false), reportSent = _d[0], setReportSent = _d[1];
22
+ var onReport = function () {
23
+ if (!report)
24
+ return;
25
+ if (!email) {
26
+ var confirm_1 = window.confirm("We noticed you didn't leave your email. Without it we won't be able to reach out and help you. If you want to leave your email, press cancel and fill in the email field, otherwise press OK to send the report without your email.");
27
+ if (!confirm_1)
28
+ return;
29
+ }
30
+ var reportWithContact = { text: "".concat(email ? email : "Anonymous", ": ").concat(report) };
31
+ window.applicationManager.analyticsManager.logEvent("textfeedback", __assign(__assign({}, reportWithContact), otherInfoObject));
32
+ setReportSent(true);
33
+ modalState.updateModalProps({ modalTitle: "🚀" });
34
+ setTimeout(function () { return modalState.closeModal(); }, 1500);
35
+ };
36
+ return (_jsx("div", __assign({ className: styles.bugReportModalContainer }, { children: reportSent ? ("Thank you for your feedback!") : (_jsxs(_Fragment, { children: [_jsxs("div", __assign({ className: styles.bugReportModalInfo }, { children: ["Please help up improve Marty! Please let us know if you spot any irregularities/bugs. ", _jsx("strong", __assign({ className: styles.bugReportModalInfoStrong }, { children: "You can optionally leave your contact details so we can reach out and help you" })), ". Thank you!"] })), _jsxs("div", __assign({ className: styles.bugReportModalForm }, { children: [_jsx("textarea", { className: styles.bugReportModalTextInput, placeholder: "Your report...", onChange: function (e) { return setReport(e.target.value); }, value: report }), _jsx("label", __assign({ className: styles.bugReportModalEmailLabel }, { children: "Provide your email if you want us to get back to you with a solution!" })), _jsx("input", { type: "email", className: styles.bugReportModalEmailInput, placeholder: "Email (optional)", onChange: function (e) { return setEmail(e.target.value); }, value: email })] })), _jsxs("div", __assign({ className: styles.bugReportModalButtons }, { children: [_jsx(SimpleButton, { onClick: function () { return modalState.closeModal(); }, title: "Cancel" }), _jsx(SimpleButton, { onClick: onReport, title: "Report" })] }))] })) })));
37
+ }
@@ -0,0 +1 @@
1
+ export default function LEDLightsOrQRVerificationModal(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,141 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
49
+ import { useEffect, useState } from "react";
50
+ import modalState from "../../../state-observables/modal/ModalState";
51
+ import styles from "./styles.module.css";
52
+ import { HiOutlineLightBulb } from "react-icons/hi";
53
+ import { MdQrCode } from "react-icons/md";
54
+ //@ts-ignore
55
+ import { Scanner, centerText } from '@yudiel/react-qr-scanner';
56
+ import { ConnManager } from "@robotical/roboticaljs";
57
+ var options = [
58
+ {
59
+ id: "qr",
60
+ title: "QR Code Verification",
61
+ subtitle: "Scan a QR code to verify.",
62
+ icon: _jsx(MdQrCode, { size: 32 }),
63
+ },
64
+ {
65
+ id: "led",
66
+ title: "LED Lights Verification",
67
+ subtitle: "Check LED signals for verification.",
68
+ icon: _jsx(HiOutlineLightBulb, { size: 32 }),
69
+ },
70
+ ];
71
+ export default function LEDLightsOrQRVerificationModal() {
72
+ var _a = useState(true), qrSelected = _a[0], setQRSelected = _a[1];
73
+ var _b = useState(undefined), serialNoFromQR = _b[0], setSerialNoFromQR = _b[1];
74
+ useEffect(function () {
75
+ if (serialNoFromQR) {
76
+ modalState.closeModal([ConnManager.generateServiceFilterUUID(serialNoFromQR)]);
77
+ // modalState.closeModal([ConnManager.generateServiceFilterUUID('00000000202302111d28b4dc5f0d46d5')]);
78
+ }
79
+ }, [serialNoFromQR]);
80
+ var handleSelect = function (id) {
81
+ if (id === 'qr') {
82
+ setQRSelected(function (prev) { return !prev; });
83
+ }
84
+ else {
85
+ modalState.closeModal([]);
86
+ }
87
+ };
88
+ return (_jsxs("div", __assign({ className: styles.container }, { children: [_jsx("div", __assign({ className: styles.cards }, { children: options.map(function (_a) {
89
+ var id = _a.id, title = _a.title, subtitle = _a.subtitle, icon = _a.icon;
90
+ return (_jsxs("div", __assign({ className: qrSelected && id === 'qr' ? [styles.card, styles.qrselected].join(" ") : styles.card, onClick: function () { return handleSelect(id); } }, { children: [_jsx("div", __assign({ className: styles.icon }, { children: icon })), _jsx("h3", __assign({ className: styles.title }, { children: title })), _jsx("p", __assign({ className: styles.subtitle }, { children: subtitle }))] }), id));
91
+ }) })), qrSelected && _jsx(QRContent, { setSerialNo: setSerialNoFromQR }), _jsx("button", __assign({ className: styles.cancelButton, onClick: function () { return modalState.closeModal(false); } }, { children: "Cancel" }))] })));
92
+ }
93
+ function QRContent(_a) {
94
+ var _this = this;
95
+ var setSerialNo = _a.setSerialNo;
96
+ var onQrCodeFound = function (result) { return __awaiter(_this, void 0, void 0, function () {
97
+ var rawValue, today, serialNo;
98
+ var _a;
99
+ return __generator(this, function (_b) {
100
+ rawValue = (_a = result[0]) === null || _a === void 0 ? void 0 : _a.rawValue;
101
+ if (!rawValue || !rawValue.includes("CV1-")) {
102
+ window.applicationManager.toaster.error("No Valid QR Code Found");
103
+ return [2 /*return*/];
104
+ }
105
+ today = new Date();
106
+ serialNo = "00000000" + today.toISOString().split("T")[0].replaceAll("-", "") + rawValue.split("-").slice(-1)[0].padStart(16, "0");
107
+ setSerialNo(serialNo);
108
+ return [2 /*return*/];
109
+ });
110
+ }); };
111
+ return (_jsx("div", __assign({ className: styles.QRcontainer }, { children: _jsx("div", __assign({ className: styles.QRscannerContainer }, { children: _jsx(Scanner, { formats: [
112
+ "qr_code",
113
+ "micro_qr_code",
114
+ "rm_qr_code",
115
+ "maxi_code",
116
+ "pdf417",
117
+ "aztec",
118
+ "data_matrix",
119
+ "matrix_codes",
120
+ "dx_film_edge",
121
+ "databar",
122
+ "databar_expanded",
123
+ "codabar",
124
+ "code_39",
125
+ "code_93",
126
+ "code_128",
127
+ "ean_8",
128
+ "ean_13",
129
+ "itf",
130
+ "linear_codes",
131
+ "upc_a",
132
+ "upc_e",
133
+ ], allowMultiple: false, scanDelay: 2000, onScan: onQrCodeFound, components: {
134
+ audio: true,
135
+ onOff: false,
136
+ torch: true,
137
+ zoom: true,
138
+ finder: true,
139
+ tracker: centerText, // boundingBox // outline //
140
+ } }) })) })));
141
+ }
@@ -0,0 +1,16 @@
1
+ import { ModalContentType, ModalEventTopics, ModalObservable, ModalObserver, ModalStateData } from "./ModalObserver";
2
+ declare class DraggableModalState implements ModalObservable {
3
+ modalContent: ModalContentType | null;
4
+ modalTitle: string;
5
+ modalNewWindowLink: string | undefined;
6
+ private _observers;
7
+ private onClose?;
8
+ constructor();
9
+ setModal(modalContent: ModalContentType, modalTitle: string, newWindowLink?: string, onClose?: () => void): void;
10
+ closeModal(): void;
11
+ subscribe(observer: ModalObserver, topics: Array<ModalEventTopics>): void;
12
+ unsubscribe(observer: ModalObserver): void;
13
+ publish(eventTopic: ModalEventTopics, eventData?: ModalStateData): void;
14
+ }
15
+ declare const draggableModalState: DraggableModalState;
16
+ export default draggableModalState;
@@ -0,0 +1,52 @@
1
+ var DraggableModalState = /** @class */ (function () {
2
+ function DraggableModalState() {
3
+ this._observers = {};
4
+ }
5
+ DraggableModalState.prototype.setModal = function (modalContent, modalTitle, newWindowLink, onClose) {
6
+ this.modalContent = modalContent;
7
+ this.modalTitle = modalTitle;
8
+ this.modalNewWindowLink = newWindowLink;
9
+ this.publish("SetModal", { modalContent: modalContent, modalTitle: modalTitle, newWindowLink: newWindowLink });
10
+ this.onClose = onClose;
11
+ };
12
+ DraggableModalState.prototype.closeModal = function () {
13
+ var _a;
14
+ this.modalContent = null;
15
+ this.modalTitle = "";
16
+ this.modalNewWindowLink = undefined;
17
+ this.publish("CloseModal");
18
+ (_a = this.onClose) === null || _a === void 0 ? void 0 : _a.call(this);
19
+ };
20
+ DraggableModalState.prototype.subscribe = function (observer, topics) {
21
+ for (var _i = 0, topics_1 = topics; _i < topics_1.length; _i++) {
22
+ var topic = topics_1[_i];
23
+ if (!this._observers[topic]) {
24
+ this._observers[topic] = [];
25
+ }
26
+ if (this._observers[topic].indexOf(observer) === -1) {
27
+ this._observers[topic].push(observer);
28
+ }
29
+ }
30
+ };
31
+ DraggableModalState.prototype.unsubscribe = function (observer) {
32
+ for (var topic in this._observers) {
33
+ if (this._observers.hasOwnProperty(topic)) {
34
+ var index = this._observers[topic].indexOf(observer);
35
+ if (index !== -1) {
36
+ this._observers[topic].splice(index, 1);
37
+ }
38
+ }
39
+ }
40
+ };
41
+ DraggableModalState.prototype.publish = function (eventTopic, eventData) {
42
+ if (this._observers.hasOwnProperty(eventTopic)) {
43
+ for (var _i = 0, _a = this._observers[eventTopic]; _i < _a.length; _i++) {
44
+ var observer = _a[_i];
45
+ observer.notify(eventTopic, eventData);
46
+ }
47
+ }
48
+ };
49
+ return DraggableModalState;
50
+ }());
51
+ var draggableModalState = new DraggableModalState();
52
+ export default draggableModalState;
@@ -193,7 +193,7 @@ var CogConnector = /** @class */ (function (_super) {
193
193
  light: CogPublishedDataGetter.getLightData(stateInfo.deviceManager),
194
194
  gyroscope: CogPublishedDataGetter.getGyroscopeData(stateInfo.deviceManager)
195
195
  };
196
- this.publish("raftinfo", RaftInfoEvents.STATE_INFO, "StateInfo", simplifiedInfo);
196
+ this.publish("raftinfo", RaftInfoEvents.STATE_INFO, "StateInfo", { stateInfo: simplifiedInfo });
197
197
  }
198
198
  }
199
199
  break;
@@ -77,7 +77,7 @@ var ConnectorFactory = /** @class */ (function () {
77
77
  };
78
78
  ConnectorFactory.createConnector = function (raftType, connManager) {
79
79
  var systemInfo = connManager.getConnector().getRaftSystemUtils().getCachedSystemInfo();
80
- var serialNo = systemInfo === null || systemInfo === void 0 ? void 0 : systemInfo.SerialNo;
80
+ var serialNo = (systemInfo === null || systemInfo === void 0 ? void 0 : systemInfo.MAC) || (systemInfo === null || systemInfo === void 0 ? void 0 : systemInfo.SerialNo);
81
81
  var connector;
82
82
  var randomId = serialNo || randomHashGenerator();
83
83
  switch (raftType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robotical/webapp-types",
3
- "version": "1.1.1",
3
+ "version": "3.7.2",
4
4
  "description": "Type definitions for the Application Manager",
5
5
  "main": "dist/application-manager.d.ts",
6
6
  "types": "dist/application-manager.d.ts",
@@ -1,23 +0,0 @@
1
- import { DeviceManager } from "@robotical/raftjs/dist/web/RaftDeviceManager";
2
- export default class PublishedDataGetter {
3
- static getPowerData(deviceManager: DeviceManager): {
4
- battV: number;
5
- usb: "yes" | "no";
6
- } | undefined;
7
- static getAccelerometerData(deviceManager: DeviceManager): {
8
- ax: number;
9
- ay: number;
10
- az: number;
11
- } | undefined;
12
- static getGyroscopeData(deviceManager: DeviceManager): {
13
- gx: number;
14
- gy: number;
15
- gz: number;
16
- } | undefined;
17
- static getLightData(deviceManager: DeviceManager): {
18
- amb0: number;
19
- ir0: number;
20
- ir1: number;
21
- ir2: number;
22
- } | undefined;
23
- }
@@ -1,65 +0,0 @@
1
- import { deviceAttrGetLatestFormatted } from "@robotical/raftjs";
2
- /* LIGHT ATTRIBUTES */
3
- var COG_LIGHT_ATTR_KEY = 'RoboCogLightV1_0';
4
- var AMB0_KEY = 'amb0';
5
- var IR0_KEY = 'ir0';
6
- var IR1_KEY = 'ir1';
7
- var IR2_KEY = 'ir2';
8
- /* POWER ATTRIBUTES */
9
- var COG_POWER_ATTR_KEY = 'RoboCogPowerV1_00';
10
- var BATTV_KEY = 'battV';
11
- var USB_KEY = 'UST';
12
- /* I2CA ATTRIBUTES */
13
- var COG_I2CA_ATTR_KEY = 'I2CA_6a';
14
- var AX_KEY = 'ax';
15
- var AY_KEY = 'ay';
16
- var AZ_KEY = 'az';
17
- var GX_KEY = 'gx';
18
- var GY_KEY = 'gy';
19
- var GZ_KEY = 'gz';
20
- var PublishedDataGetter = /** @class */ (function () {
21
- function PublishedDataGetter() {
22
- }
23
- PublishedDataGetter.getPowerData = function (deviceManager) {
24
- var powerAttr = deviceManager.getDeviceState(COG_POWER_ATTR_KEY);
25
- var battV = deviceAttrGetLatestFormatted(powerAttr === null || powerAttr === void 0 ? void 0 : powerAttr.deviceAttributes[BATTV_KEY]);
26
- var usb = deviceAttrGetLatestFormatted(powerAttr === null || powerAttr === void 0 ? void 0 : powerAttr.deviceAttributes[USB_KEY]);
27
- return { battV: convertStringToNumber(battV), usb: usb };
28
- };
29
- PublishedDataGetter.getAccelerometerData = function (deviceManager) {
30
- var i2caAttr = deviceManager.getDeviceState(COG_I2CA_ATTR_KEY);
31
- if (!i2caAttr)
32
- return;
33
- var i2ca = i2caAttr.deviceAttributes;
34
- var ax = deviceAttrGetLatestFormatted(i2ca[AX_KEY]);
35
- var ay = deviceAttrGetLatestFormatted(i2ca[AY_KEY]);
36
- var az = deviceAttrGetLatestFormatted(i2ca[AZ_KEY]);
37
- return { ax: convertStringToNumber(ax), ay: convertStringToNumber(ay), az: convertStringToNumber(az) };
38
- };
39
- PublishedDataGetter.getGyroscopeData = function (deviceManager) {
40
- var i2caAttr = deviceManager.getDeviceState(COG_I2CA_ATTR_KEY);
41
- if (!i2caAttr)
42
- return;
43
- var i2ca = i2caAttr.deviceAttributes;
44
- var gx = deviceAttrGetLatestFormatted(i2ca[GX_KEY]);
45
- var gy = deviceAttrGetLatestFormatted(i2ca[GY_KEY]);
46
- var gz = deviceAttrGetLatestFormatted(i2ca[GZ_KEY]);
47
- return { gx: convertStringToNumber(gx), gy: convertStringToNumber(gy), gz: convertStringToNumber(gz) };
48
- };
49
- PublishedDataGetter.getLightData = function (deviceManager) {
50
- var lightAttr = deviceManager.getDeviceState(COG_LIGHT_ATTR_KEY);
51
- if (!lightAttr)
52
- return;
53
- var light = lightAttr.deviceAttributes;
54
- var amb0 = deviceAttrGetLatestFormatted(light[AMB0_KEY]);
55
- var ir0 = deviceAttrGetLatestFormatted(light[IR0_KEY]);
56
- var ir1 = deviceAttrGetLatestFormatted(light[IR1_KEY]);
57
- var ir2 = deviceAttrGetLatestFormatted(light[IR2_KEY]);
58
- return { amb0: convertStringToNumber(amb0), ir0: convertStringToNumber(ir0), ir1: convertStringToNumber(ir1), ir2: convertStringToNumber(ir2) };
59
- };
60
- return PublishedDataGetter;
61
- }());
62
- export default PublishedDataGetter;
63
- var convertStringToNumber = function (str) {
64
- return isNaN(+str) ? 0 : +str;
65
- };