@robotical/webapp-types 3.10.3 → 3.11.0
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/dist-types/src/application/ApplicationManager/ApplicationManager.d.ts +12 -1
- package/dist-types/src/application/ApplicationManager/ApplicationManager.js +21 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.d.ts +14 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.js +77 -1
- package/dist-types/src/application/RAFTs/Marty/notifications-manager/RICNotificationsManager.d.ts +15 -0
- package/dist-types/src/application/RAFTs/Marty/notifications-manager/RICNotificationsManager.js +498 -0
- package/dist-types/src/application/RAFTs/Marty/notifications-manager/ReportedWarningsState.d.ts +59 -0
- package/dist-types/src/application/RAFTs/Marty/notifications-manager/ReportedWarningsState.js +145 -0
- package/dist-types/src/application/RAFTs/RAFT.js +11 -1
- package/dist-types/src/components/modals/InBtButAPressed/index.d.ts +2 -0
- package/dist-types/src/components/modals/InBtButAPressed/index.js +21 -0
- package/dist-types/src/components/modals/InBtButAPressed/styles.d.ts +5 -0
- package/dist-types/src/components/modals/InBtButAPressed/styles.js +11 -0
- package/dist-types/src/services/logger/Logger.d.ts +5 -5
- package/dist-types/src/services/logger/Logger.js +40 -11
- package/dist-types/src/store/user-role-context.d.ts +12 -0
- package/dist-types/src/store/user-role-context.js +33 -0
- package/dist-types/src/types/communication-between-apps/wrapper-communication.d.ts +3 -1
- package/dist-types/src/types/communication-between-apps/wrapper-communication.js +2 -0
- package/dist-types/src/types/userDeviceInfo.d.ts +6 -0
- package/dist-types/src/utils/warranty-service/cookies.d.ts +19 -0
- package/dist-types/src/utils/warranty-service/cookies.js +76 -0
- package/dist-types/src/utils/warranty-service/warranty-service-utils.d.ts +10 -0
- package/dist-types/src/utils/warranty-service/warranty-service-utils.js +232 -0
- package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +13 -1
- package/dist-types/src/wrapper-app/WrapperAppManager.js +109 -0
- package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.js +48 -21
- package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.d.ts +4 -0
- package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.js +13 -0
- package/package.json +1 -1
|
@@ -11,7 +11,8 @@ 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
|
+
import { CustomBluetoothItem, UserDeviceInfo } from "../../types/userDeviceInfo";
|
|
15
|
+
import { UserRoleContextTypes } from "../../store/user-role-context";
|
|
15
16
|
export default class ApplicationManager {
|
|
16
17
|
AnalyticsFacade: typeof AnalyticsFacade;
|
|
17
18
|
analyticsSessionId: string | undefined;
|
|
@@ -24,6 +25,8 @@ export default class ApplicationManager {
|
|
|
24
25
|
returnToMainApp: () => void;
|
|
25
26
|
carouselNavigatorManager: CarouselNavigatorManager;
|
|
26
27
|
deviceInfo: UserDeviceInfo | undefined;
|
|
28
|
+
userRoleCtx: UserRoleContextTypes | null;
|
|
29
|
+
setUserRoleCtx(userRoleCtx: UserRoleContextTypes): void;
|
|
27
30
|
private _router;
|
|
28
31
|
setRouter(router: any): void;
|
|
29
32
|
navigateTo(path: string): void;
|
|
@@ -82,6 +85,14 @@ export default class ApplicationManager {
|
|
|
82
85
|
*/
|
|
83
86
|
selectRaft(ricToConnectTo: FOUND_RAFT_ON_DISCOVERY_RESPONSE['foundRIC'], method: RaftConnectionMethod): Promise<RAFT | null>;
|
|
84
87
|
connectToRIC(method: RaftConnectionMethod, uuids: string[], withoutVerification?: boolean): Promise<RAFT | null>;
|
|
88
|
+
/**
|
|
89
|
+
* Warranty Service bluetooth scan for device
|
|
90
|
+
* It scans for a device and gets the device object
|
|
91
|
+
* Then it checks if the device is already in the given devices array having CustomBluetoothItem[] type
|
|
92
|
+
* if not, it gets its serial number and adds it to the devices array
|
|
93
|
+
* @returns {Promise<CustomBluetoothItem[]>}
|
|
94
|
+
*/
|
|
95
|
+
scanForPotentialWarrantyDevice(existingDevices: CustomBluetoothItem[]): Promise<CustomBluetoothItem[]>;
|
|
85
96
|
/**
|
|
86
97
|
* Toggles the Sensors Dashboard modal
|
|
87
98
|
*/
|
|
@@ -72,6 +72,8 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
72
72
|
this.carouselNavigatorManager = new CarouselNavigatorManager();
|
|
73
73
|
// Device info
|
|
74
74
|
this.deviceInfo = undefined;
|
|
75
|
+
// User role context
|
|
76
|
+
this.userRoleCtx = null;
|
|
75
77
|
// Callback to call when a RAFT is selected (Phone App only)
|
|
76
78
|
// We need that to make sure the connection button gets the selected RAFT once the user selects one
|
|
77
79
|
this.ricSelectedCb = null;
|
|
@@ -103,6 +105,11 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
103
105
|
this.connectGenericMarty = this.connectGenericMarty.bind(this);
|
|
104
106
|
this.connectGenericCog = this.connectGenericCog.bind(this);
|
|
105
107
|
}
|
|
108
|
+
ApplicationManager.prototype.setUserRoleCtx = function (userRoleCtx) {
|
|
109
|
+
if (this.userRoleCtx) {
|
|
110
|
+
this.userRoleCtx = userRoleCtx;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
106
113
|
ApplicationManager.prototype.setRouter = function (router) {
|
|
107
114
|
this._router = router;
|
|
108
115
|
};
|
|
@@ -589,6 +596,20 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
589
596
|
});
|
|
590
597
|
});
|
|
591
598
|
};
|
|
599
|
+
/**
|
|
600
|
+
* Warranty Service bluetooth scan for device
|
|
601
|
+
* It scans for a device and gets the device object
|
|
602
|
+
* Then it checks if the device is already in the given devices array having CustomBluetoothItem[] type
|
|
603
|
+
* if not, it gets its serial number and adds it to the devices array
|
|
604
|
+
* @returns {Promise<CustomBluetoothItem[]>}
|
|
605
|
+
*/
|
|
606
|
+
ApplicationManager.prototype.scanForPotentialWarrantyDevice = function (existingDevices) {
|
|
607
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
608
|
+
return __generator(this, function (_a) {
|
|
609
|
+
return [2 /*return*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.SCAN_FOR_POTENTIAL_WARRANTY_DEVICE, { existingDevices: existingDevices })];
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
};
|
|
592
613
|
/**
|
|
593
614
|
* Toggles the Sensors Dashboard modal
|
|
594
615
|
*/
|
|
@@ -7,6 +7,7 @@ import { RICLedLcdColours, RICStateInfo } from "@robotical/roboticaljs";
|
|
|
7
7
|
import { MartyWifiManager } from "./MartyWifiManager";
|
|
8
8
|
import MartyAddonsManager from "./MartyAddonsManager";
|
|
9
9
|
import CalibrationManager from "./CalibrationManager";
|
|
10
|
+
import { RICNotificationsManager } from "./notifications-manager/RICNotificationsManager";
|
|
10
11
|
export declare class Marty extends RAFT implements RICInterface {
|
|
11
12
|
id: string;
|
|
12
13
|
type: RaftTypeE;
|
|
@@ -15,6 +16,7 @@ export declare class Marty extends RAFT implements RICInterface {
|
|
|
15
16
|
wifiManager: MartyWifiManager;
|
|
16
17
|
addonsManager: MartyAddonsManager;
|
|
17
18
|
calibrationManager: CalibrationManager;
|
|
19
|
+
ricNotificationManager: RICNotificationsManager;
|
|
18
20
|
_ledLcdColours: RICLedLcdColours;
|
|
19
21
|
private rssiValues;
|
|
20
22
|
private MAX_RSSI_VALUES_N;
|
|
@@ -32,10 +34,18 @@ export declare class Marty extends RAFT implements RICInterface {
|
|
|
32
34
|
* Highlights Marty by flashing the LED and playing a tune
|
|
33
35
|
*/
|
|
34
36
|
highlight(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Sends atomic read operation to Marty
|
|
39
|
+
*/
|
|
40
|
+
sendAtomicReadOperation(): Promise<boolean>;
|
|
35
41
|
/**
|
|
36
42
|
* This methods handles RAFT events coming from the RICConnector of the wrapper
|
|
37
43
|
*/
|
|
38
44
|
handleRaftEvent(eventType: string, eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent | RaftInfoEvents, eventName: string, eventData: any): void;
|
|
45
|
+
/**
|
|
46
|
+
* Connection Event Handler
|
|
47
|
+
*/
|
|
48
|
+
connectionEventHandler(eventEnum: RaftConnEvent, eventName: string, data: any): Promise<void>;
|
|
39
49
|
/**
|
|
40
50
|
* Pub Event Handler
|
|
41
51
|
*/
|
|
@@ -44,5 +54,9 @@ export declare class Marty extends RAFT implements RICInterface {
|
|
|
44
54
|
* Raft Info Event Handler
|
|
45
55
|
*/
|
|
46
56
|
raftInfoEventHandler(eventEnum: RaftInfoEvents, eventName: string, data: any): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Warn Event Handler
|
|
59
|
+
*/
|
|
60
|
+
msgEventHandler(eventEnum: RaftConnEvent, eventName: string, data: any): Promise<void>;
|
|
47
61
|
}
|
|
48
62
|
export default Marty;
|
|
@@ -51,10 +51,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
51
51
|
};
|
|
52
52
|
import { RaftTypeE } from "../../../types/raft";
|
|
53
53
|
import RAFT from "../RAFT";
|
|
54
|
-
import { RaftPublishEvent } from "@robotical/raftjs";
|
|
54
|
+
import { RaftConnEvent, RaftPublishEvent } from "@robotical/raftjs";
|
|
55
55
|
import { MartyWifiManager } from "./MartyWifiManager";
|
|
56
56
|
import MartyAddonsManager from "./MartyAddonsManager";
|
|
57
57
|
import CalibrationManager from "./CalibrationManager";
|
|
58
|
+
import Logger from "../../../services/logger/Logger";
|
|
59
|
+
import { AppSentMessage } from "../../../types/communication-between-apps/wrapper-communication";
|
|
60
|
+
import { RICNotificationsManager } from "./notifications-manager/RICNotificationsManager";
|
|
61
|
+
var SHOW_LOGS = true;
|
|
62
|
+
var TAG = "Marty";
|
|
58
63
|
var Marty = /** @class */ (function (_super) {
|
|
59
64
|
__extends(Marty, _super);
|
|
60
65
|
function Marty(id) {
|
|
@@ -71,6 +76,7 @@ var Marty = /** @class */ (function (_super) {
|
|
|
71
76
|
_this.addonsManager = new MartyAddonsManager(_this);
|
|
72
77
|
// Calibration Manager
|
|
73
78
|
_this.calibrationManager = new CalibrationManager(_this);
|
|
79
|
+
_this.ricNotificationManager = new RICNotificationsManager(_this);
|
|
74
80
|
// Colours to use for LED patterns
|
|
75
81
|
_this._ledLcdColours = [
|
|
76
82
|
{ led: "#202000", lcd: "#FFFF00" },
|
|
@@ -144,22 +150,81 @@ var Marty = /** @class */ (function (_super) {
|
|
|
144
150
|
});
|
|
145
151
|
});
|
|
146
152
|
};
|
|
153
|
+
/**
|
|
154
|
+
* Sends atomic read operation to Marty
|
|
155
|
+
*/
|
|
156
|
+
Marty.prototype.sendAtomicReadOperation = function () {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
+
var response, error_1;
|
|
159
|
+
return __generator(this, function (_a) {
|
|
160
|
+
switch (_a.label) {
|
|
161
|
+
case 0:
|
|
162
|
+
_a.trys.push([0, 2, , 3]);
|
|
163
|
+
return [4 /*yield*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.SEND_ATOMIC_READ_OPERATION_TO_MARTY, { raftId: this.id })];
|
|
164
|
+
case 1:
|
|
165
|
+
response = _a.sent();
|
|
166
|
+
return [2 /*return*/, !!response];
|
|
167
|
+
case 2:
|
|
168
|
+
error_1 = _a.sent();
|
|
169
|
+
Logger.error(SHOW_LOGS, TAG, "Error in sendAtomicReadOperation: ".concat(error_1));
|
|
170
|
+
return [2 /*return*/, false];
|
|
171
|
+
case 3: return [2 /*return*/];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
};
|
|
147
176
|
/**
|
|
148
177
|
* This methods handles RAFT events coming from the RICConnector of the wrapper
|
|
149
178
|
*/
|
|
150
179
|
Marty.prototype.handleRaftEvent = function (eventType, eventEnum, eventName, eventData) {
|
|
151
180
|
_super.prototype.handleRaftEvent.call(this, eventType, eventEnum, eventName, eventData);
|
|
152
181
|
switch (eventType) {
|
|
182
|
+
case "conn":
|
|
183
|
+
this.connectionEventHandler(eventEnum, eventName, eventData);
|
|
184
|
+
break;
|
|
153
185
|
case "pub":
|
|
154
186
|
this.pubEventHandler(eventEnum, eventName, eventData);
|
|
155
187
|
break;
|
|
156
188
|
case "raftinfo":
|
|
157
189
|
this.raftInfoEventHandler(eventEnum, eventName, eventData);
|
|
158
190
|
break;
|
|
191
|
+
case "msg":
|
|
192
|
+
this.msgEventHandler(eventEnum, eventName, eventData);
|
|
193
|
+
break;
|
|
159
194
|
default:
|
|
160
195
|
break;
|
|
161
196
|
}
|
|
162
197
|
};
|
|
198
|
+
/**
|
|
199
|
+
* Connection Event Handler
|
|
200
|
+
*/
|
|
201
|
+
Marty.prototype.connectionEventHandler = function (eventEnum, eventName, data) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
203
|
+
var _a, wasSent;
|
|
204
|
+
return __generator(this, function (_b) {
|
|
205
|
+
switch (_b.label) {
|
|
206
|
+
case 0:
|
|
207
|
+
_a = eventEnum;
|
|
208
|
+
switch (_a) {
|
|
209
|
+
case RaftConnEvent.CONN_VERIFIED_CORRECT: return [3 /*break*/, 1];
|
|
210
|
+
}
|
|
211
|
+
return [3 /*break*/, 3];
|
|
212
|
+
case 1: return [4 /*yield*/, this.sendAtomicReadOperation()];
|
|
213
|
+
case 2:
|
|
214
|
+
wasSent = _b.sent();
|
|
215
|
+
if (wasSent) {
|
|
216
|
+
Logger.info(SHOW_LOGS, TAG, "Atomic read operation sent to Marty");
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
Logger.warn(SHOW_LOGS, TAG, "Warn! sending atomic read operation to Marty");
|
|
220
|
+
}
|
|
221
|
+
return [3 /*break*/, 4];
|
|
222
|
+
case 3: return [3 /*break*/, 4];
|
|
223
|
+
case 4: return [2 /*return*/];
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
};
|
|
163
228
|
/**
|
|
164
229
|
* Pub Event Handler
|
|
165
230
|
*/
|
|
@@ -190,6 +255,17 @@ var Marty = /** @class */ (function (_super) {
|
|
|
190
255
|
});
|
|
191
256
|
});
|
|
192
257
|
};
|
|
258
|
+
/**
|
|
259
|
+
* Warn Event Handler
|
|
260
|
+
*/
|
|
261
|
+
Marty.prototype.msgEventHandler = function (eventEnum, eventName, data) {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
263
|
+
return __generator(this, function (_a) {
|
|
264
|
+
this.ricNotificationManager.reportNofication(data);
|
|
265
|
+
return [2 /*return*/];
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
};
|
|
193
269
|
return Marty;
|
|
194
270
|
}(RAFT));
|
|
195
271
|
export { Marty };
|
package/dist-types/src/application/RAFTs/Marty/notifications-manager/RICNotificationsManager.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RICHWElem, RICHWElemList } from "@robotical/ricjs";
|
|
2
|
+
import Marty from "../Marty";
|
|
3
|
+
export declare class RICNotificationsManager {
|
|
4
|
+
private marty;
|
|
5
|
+
constructor(marty: Marty);
|
|
6
|
+
msgBodyDecider(report: any, hwElems: RICHWElem[]): void;
|
|
7
|
+
reportNofication(report: any): Promise<void>;
|
|
8
|
+
getHwStatus(stringify?: boolean, maxRetries?: number, delayMs?: number): Promise<string | RICHWElemList["hw"]>;
|
|
9
|
+
getHWNameGivenIdNo(hwStatusArr: RICHWElemList["hw"], IDNo: number): string | number | null;
|
|
10
|
+
getHwRevAndVersion(): Promise<string>;
|
|
11
|
+
martyNameStr(): Promise<string>;
|
|
12
|
+
handleServoFaultRawMsg(report: any): Promise<void>;
|
|
13
|
+
handleElemCommsFailDet(report: any): void;
|
|
14
|
+
handleBusFailDet(report: any): void;
|
|
15
|
+
}
|