@robotical/webapp-types 1.0.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/application-manager.ts +20 -0
- package/dist-types/src/application/ApplicationManager/ApplicationManager.d.ts +91 -0
- package/dist-types/src/application/ApplicationManager/ApplicationManager.js +448 -0
- package/dist-types/src/application/RAFTs/Cog/Cog.d.ts +39 -0
- package/dist-types/src/application/RAFTs/Cog/Cog.js +171 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.d.ts +40 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.js +179 -0
- package/dist-types/src/application/RAFTs/RAFT.d.ts +109 -0
- package/dist-types/src/application/RAFTs/RAFT.js +313 -0
- package/dist-types/src/application/RAFTs/RAFTInterface.d.ts +13 -0
- package/dist-types/src/application/RAFTs/RAFTInterface.js +6 -0
- package/dist-types/src/application/RAFTs/RaftObserver.d.ts +10 -0
- package/dist-types/src/application/RAFTs/RaftObserver.js +1 -0
- package/dist-types/src/application/RAFTs/raft-subscription-helpers.d.ts +59 -0
- package/dist-types/src/application/RAFTs/raft-subscription-helpers.js +324 -0
- package/dist-types/src/application/communicators/SelfdestructiveMessagePromise.d.ts +10 -0
- package/dist-types/src/application/communicators/SelfdestructiveMessagePromise.js +31 -0
- package/dist-types/src/application/communicators/WrapperCommunicator.d.ts +24 -0
- package/dist-types/src/application/communicators/WrapperCommunicator.js +137 -0
- package/dist-types/src/components/disposables/LoadingSpinner/index.d.ts +7 -0
- package/dist-types/src/components/disposables/LoadingSpinner/index.js +29 -0
- package/dist-types/src/components/disposables/buttons/SVGImageButton/index.d.ts +14 -0
- package/dist-types/src/components/disposables/buttons/SVGImageButton/index.js +19 -0
- package/dist-types/src/components/disposables/buttons/SimpleButton/index.d.ts +14 -0
- package/dist-types/src/components/disposables/buttons/SimpleButton/index.js +18 -0
- package/dist-types/src/components/modals/DisconnectConfirmation/index.d.ts +6 -0
- package/dist-types/src/components/modals/DisconnectConfirmation/index.js +63 -0
- package/dist-types/src/components/modals/DisconnectConfirmation/styles.d.ts +1 -0
- package/dist-types/src/components/modals/DisconnectConfirmation/styles.js +7 -0
- package/dist-types/src/components/modals/InUnplugged/index.d.ts +1 -0
- package/dist-types/src/components/modals/InUnplugged/index.js +12 -0
- package/dist-types/src/components/modals/InUnplugged/styles.d.ts +5 -0
- package/dist-types/src/components/modals/InUnplugged/styles.js +11 -0
- package/dist-types/src/components/modals/VerificationModal/index.d.ts +6 -0
- package/dist-types/src/components/modals/VerificationModal/index.js +124 -0
- package/dist-types/src/components/modals/VerificationModalPhoneApp/index.d.ts +6 -0
- package/dist-types/src/components/modals/VerificationModalPhoneApp/index.js +190 -0
- package/dist-types/src/components/oneoffs/LEDs/index.d.ts +8 -0
- package/dist-types/src/components/oneoffs/LEDs/index.js +39 -0
- package/dist-types/src/components/oneoffs/RICSignal/index.d.ts +7 -0
- package/dist-types/src/components/oneoffs/RICSignal/index.js +29 -0
- package/dist-types/src/services/logger/Logger.d.ts +7 -0
- package/dist-types/src/services/logger/Logger.js +19 -0
- package/dist-types/src/state-observables/modal/ModalObserver.d.ts +17 -0
- package/dist-types/src/state-observables/modal/ModalObserver.js +1 -0
- package/dist-types/src/state-observables/modal/ModalState.d.ts +24 -0
- package/dist-types/src/state-observables/modal/ModalState.js +69 -0
- package/dist-types/src/store/SelectedRaftContext.d.ts +17 -0
- package/dist-types/src/store/SelectedRaftContext.js +80 -0
- package/dist-types/src/styles/colors.d.ts +35 -0
- package/dist-types/src/styles/colors.js +42 -0
- package/dist-types/src/types/communication-between-apps/wrapper-communication.d.ts +45 -0
- package/dist-types/src/types/communication-between-apps/wrapper-communication.js +25 -0
- package/dist-types/src/types/events/raft-info.d.ts +10 -0
- package/dist-types/src/types/events/raft-info.js +11 -0
- package/dist-types/src/types/phone-app-communicator.d.ts +20 -0
- package/dist-types/src/types/phone-app-communicator.js +5 -0
- package/dist-types/src/types/raft.d.ts +18 -0
- package/dist-types/src/types/raft.js +14 -0
- package/dist-types/src/utils/Toaster.d.ts +13 -0
- package/dist-types/src/utils/Toaster.js +38 -0
- package/dist-types/src/utils/helpers/compare-version.d.ts +2 -0
- package/dist-types/src/utils/helpers/compare-version.js +19 -0
- package/dist-types/src/utils/helpers/randomHashGenerator.d.ts +1 -0
- package/dist-types/src/utils/helpers/randomHashGenerator.js +10 -0
- package/dist-types/src/utils/helpers/rescale-range.d.ts +2 -0
- package/dist-types/src/utils/helpers/rescale-range.js +4 -0
- package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.d.ts +3 -0
- package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.js +34 -0
- package/dist-types/src/utils/phone-app-communication/is-phone-app.d.ts +5 -0
- package/dist-types/src/utils/phone-app-communication/is-phone-app.js +7 -0
- package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +58 -0
- package/dist-types/src/wrapper-app/WrapperAppManager.js +176 -0
- package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.d.ts +24 -0
- package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.js +243 -0
- package/dist-types/src/wrapper-app/connectors/CogConnector/CogConnector.d.ts +35 -0
- package/dist-types/src/wrapper-app/connectors/CogConnector/CogConnector.js +177 -0
- package/dist-types/src/wrapper-app/connectors/Connector.d.ts +69 -0
- package/dist-types/src/wrapper-app/connectors/Connector.js +315 -0
- package/dist-types/src/wrapper-app/connectors/ConnectorFactory.d.ts +15 -0
- package/dist-types/src/wrapper-app/connectors/ConnectorFactory.js +99 -0
- package/dist-types/src/wrapper-app/connectors/ConnectorInterface.d.ts +10 -0
- package/dist-types/src/wrapper-app/connectors/ConnectorInterface.js +6 -0
- package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.d.ts +35 -0
- package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.js +219 -0
- package/dist-types/types-package/application-manager.d.ts +17 -0
- package/dist-types/types-package/application-manager.js +5 -0
- package/package.json +13 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
38
|
+
import modalState from "../../../state-observables/modal/ModalState";
|
|
39
|
+
import { useConnectedRafts } from "../../../store/SelectedRaftContext";
|
|
40
|
+
import { RED } from "../../../styles/colors";
|
|
41
|
+
import SimpleButton from "../../disposables/buttons/SimpleButton";
|
|
42
|
+
import { Container } from "./styles";
|
|
43
|
+
export default function DisconnectConfirmationModal(_a) {
|
|
44
|
+
var _this = this;
|
|
45
|
+
var connectedRaft = _a.connectedRaft;
|
|
46
|
+
var removeConnectedRaft = useConnectedRafts().removeConnectedRaft;
|
|
47
|
+
var disconnectHandler = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
switch (_a.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
if (!connectedRaft)
|
|
52
|
+
return [2 /*return*/];
|
|
53
|
+
return [4 /*yield*/, window.applicationManager.disconnectFromRaft(connectedRaft.id)];
|
|
54
|
+
case 1:
|
|
55
|
+
_a.sent();
|
|
56
|
+
removeConnectedRaft(connectedRaft.id);
|
|
57
|
+
modalState.closeModal();
|
|
58
|
+
return [2 /*return*/];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}); };
|
|
62
|
+
return (_jsxs(Container, { children: [_jsx(SimpleButton, { onClick: function () { return modalState.closeModal(); }, title: "Cancel" }), _jsx(SimpleButton, { onClick: disconnectHandler, title: "Disconnect", colour: RED })] }));
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Container: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
export var Container = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: grid;\n grid-auto-flow: column;\n column-gap: 2rem;\n"], ["\n display: grid;\n grid-auto-flow: column;\n column-gap: 2rem;\n"])));
|
|
7
|
+
var templateObject_1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function InUnpluggedModalContent(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CenteredView, StyledView, ModalText, ModalTitle, StyledImage, } from "./styles";
|
|
3
|
+
import imageAbutton from "../../../assets/marty-a-button.png";
|
|
4
|
+
import modalState from "../../../state-observables/modal/ModalState";
|
|
5
|
+
import SimpleButton from "../../disposables/buttons/SimpleButton";
|
|
6
|
+
export default function InUnpluggedModalContent() {
|
|
7
|
+
// disconnecting from marty as soon as
|
|
8
|
+
// the modal comes up because some users might
|
|
9
|
+
// try pressing A when the modal is still up.
|
|
10
|
+
// window.marty.disconnect();
|
|
11
|
+
return (_jsxs(StyledView, { children: [_jsx(ModalTitle, { children: "Couldn't connect to your Marty!" }), _jsx(ModalText, { children: "Your Marty is currently in unplugged mode. If you want to dissconect Marty from unplugged mode, please press the \"MODE\"/\"A\" button on the back of Marty and try again!" }), _jsx(StyledImage, { src: imageAbutton }), _jsx(CenteredView, { children: _jsx(SimpleButton, { title: "Got it!", onClick: function () { return modalState.closeModal(); } }) })] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const StyledView: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const ModalText: import("styled-components").StyledComponent<"p", any, {}, never>;
|
|
3
|
+
export declare const ModalTitle: import("styled-components").StyledComponent<"p", any, {}, never>;
|
|
4
|
+
export declare const CenteredView: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const StyledImage: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
export var StyledView = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: grid;\n grid-template-areas: \"modal-title modal-title\" \"modal-info marty-img\" \"button button\";\n grid-template-columns: 1fr 1fr;\n background-color: white;\n border-radius: 2rem;\n align-items: center;\n max-width: 90vw;\n max-height: 90vh;\n row-gap: 1rem;\n"], ["\n display: grid;\n grid-template-areas: \"modal-title modal-title\" \"modal-info marty-img\" \"button button\";\n grid-template-columns: 1fr 1fr;\n background-color: white;\n border-radius: 2rem;\n align-items: center;\n max-width: 90vw;\n max-height: 90vh;\n row-gap: 1rem;\n"])));
|
|
7
|
+
export var ModalText = styled.p(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n grid-area: modal-info;\n font-family: \"Lato Regular\";\n text-align: center;\n"], ["\n grid-area: modal-info;\n font-family: \"Lato Regular\";\n text-align: center;\n"])));
|
|
8
|
+
export var ModalTitle = styled.p(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n grid-area: modal-title;\n font-size: 2.2rem;\n font-family: \"Lato Regular\";\n text-align: center;\n"], ["\n grid-area: modal-title;\n font-size: 2.2rem;\n font-family: \"Lato Regular\";\n text-align: center;\n"])));
|
|
9
|
+
export var CenteredView = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n grid-area: button;\n flex-direction: row;\n"], ["\n grid-area: button;\n flex-direction: row;\n"])));
|
|
10
|
+
export var StyledImage = styled.img(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n grid-area: marty-img;\n max-height: 40vh;\n max-width: 40vw;\n justify-self: center;\n"], ["\n grid-area: marty-img;\n max-height: 40vh;\n max-width: 40vw;\n justify-self: center;\n"])));
|
|
11
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -0,0 +1,124 @@
|
|
|
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 "./styles.css";
|
|
51
|
+
import { ReactComponent as BluetoothSVG } from "../../../assets/configuration/bluetooth.svg";
|
|
52
|
+
import { MAIN_BLUE } from "../../../styles/colors";
|
|
53
|
+
import modalState from "../../../state-observables/modal/ModalState";
|
|
54
|
+
import RICSignal from "../../oneoffs/RICSignal";
|
|
55
|
+
import SimpleButton from "../../disposables/buttons/SimpleButton";
|
|
56
|
+
import LEDs from "../../oneoffs/LEDs";
|
|
57
|
+
import { raftConnectingSubscriptionHelper } from "../../../application/RAFTs/raft-subscription-helpers";
|
|
58
|
+
import { useConnectedRafts } from "../../../store/SelectedRaftContext";
|
|
59
|
+
var SHOW_LOGS = true;
|
|
60
|
+
var TAG = "VerificationModal";
|
|
61
|
+
function VerificationModal(_a) {
|
|
62
|
+
var _this = this;
|
|
63
|
+
var connectedRAFT_ = _a.connectedRAFT_;
|
|
64
|
+
var _b = useState([]), randomColours = _b[0], setRandomColours = _b[1];
|
|
65
|
+
var _c = useState(connectedRAFT_), connectedRaft = _c[0], setConnectedRaft = _c[1];
|
|
66
|
+
var _d = useState(-200), RSSI = _d[0], setRSSI = _d[1];
|
|
67
|
+
var removeConnectedRaft = useConnectedRafts().removeConnectedRaft;
|
|
68
|
+
useEffect(function () {
|
|
69
|
+
/* Subscribe to the connectedRaft's SIGNAL strength */
|
|
70
|
+
if (!connectedRaft)
|
|
71
|
+
return;
|
|
72
|
+
var signalUpdateTimout = setInterval(function () {
|
|
73
|
+
setRSSI(connectedRaft.getRSSI());
|
|
74
|
+
}, 200);
|
|
75
|
+
return function () { return clearInterval(signalUpdateTimout); };
|
|
76
|
+
}, [connectedRaft]);
|
|
77
|
+
var onCancel = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
78
|
+
return __generator(this, function (_a) {
|
|
79
|
+
switch (_a.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
// close modal, stop verification process, disconnect, scan again
|
|
82
|
+
modalState.closeModal();
|
|
83
|
+
if (!connectedRaft)
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
removeConnectedRaft(connectedRaft.id);
|
|
86
|
+
return [4 /*yield*/, window.applicationManager.stopVerifyingRaft(connectedRaft.id, false)];
|
|
87
|
+
case 1:
|
|
88
|
+
_a.sent();
|
|
89
|
+
return [4 /*yield*/, connectedRaft.disconnect()];
|
|
90
|
+
case 2:
|
|
91
|
+
_a.sent();
|
|
92
|
+
return [2 /*return*/];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}); };
|
|
96
|
+
var onYes = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
modalState.closeModal();
|
|
101
|
+
return [4 /*yield*/, (connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.stopVerifyingRaft(true))];
|
|
102
|
+
case 1:
|
|
103
|
+
_a.sent();
|
|
104
|
+
return [2 /*return*/];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}); };
|
|
108
|
+
useEffect(function () {
|
|
109
|
+
/* Subscribe to the connectedRaft's Connection state */
|
|
110
|
+
if (!connectedRaft)
|
|
111
|
+
return;
|
|
112
|
+
raftConnectingSubscriptionHelper(connectedRaft).subscribe(setRandomColours);
|
|
113
|
+
return function () {
|
|
114
|
+
raftConnectingSubscriptionHelper(connectedRaft).unsubscribe();
|
|
115
|
+
};
|
|
116
|
+
}, [connectedRaft]);
|
|
117
|
+
useEffect(function () {
|
|
118
|
+
/* Verify the connectedRaft once it's connected */
|
|
119
|
+
connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.verifyRaft();
|
|
120
|
+
}, [connectedRaft]);
|
|
121
|
+
var contentJSX = _jsxs("div", __assign({ className: "verification-modal-container" }, { children: [_jsxs("div", __assign({ className: "verification-modal-martys-container" }, { children: [_jsxs("div", __assign({ className: "verification-modal-marty-name-row-container" }, { children: [_jsx("p", __assign({ className: "verification-modal-marty-name" }, { children: connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.getFriendlyName() })), _jsx("div", __assign({ className: "verification-modal-marty-signal-container" }, { children: _jsx(RICSignal, { signalStrength: RSSI }) })), _jsx(BluetoothSVG, { fill: MAIN_BLUE })] })), _jsxs("p", __assign({ className: "verification-modal-martys-back-hint" }, { children: ["Look on ", connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.type, "'s back, is it displaying these lights?"] })), _jsxs("div", __assign({ className: "verification-modal-led-row-container" }, { children: [_jsx(LEDs, { coloursArr: randomColours, connectedRaft: connectedRaft }), _jsx(SimpleButton, { onClick: onCancel, title: "No", borderColour: "red", colour: "white", textColour: "red" }), _jsx(SimpleButton, { onClick: onYes, title: "YES" })] }))] })), _jsxs("div", __assign({ className: "verification-modal-bottom-btns-container" }, { children: [_jsx("div", { className: "dummy-gap" }), _jsx(SimpleButton, { onClick: onCancel, title: "CANCEL" })] }))] }));
|
|
122
|
+
return contentJSX;
|
|
123
|
+
}
|
|
124
|
+
export default VerificationModal;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "./styles.css";
|
|
2
|
+
import { FOUND_RAFT_ON_DISCOVERY_RESPONSE } from "../../../types/phone-app-communicator";
|
|
3
|
+
declare function VerificationModalPhoneApp({ foundRICs }: {
|
|
4
|
+
foundRICs: FOUND_RAFT_ON_DISCOVERY_RESPONSE["foundRIC"][];
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default VerificationModalPhoneApp;
|
|
@@ -0,0 +1,190 @@
|
|
|
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 { Fragment, useEffect, useState } from "react";
|
|
50
|
+
import "./styles.css";
|
|
51
|
+
import { ReactComponent as BluetoothSVG } from "../../../assets/configuration/bluetooth.svg";
|
|
52
|
+
import { ReactComponent as RefreshSVG } from "../../../assets/refresh.svg";
|
|
53
|
+
import { MAIN_BLUE, WHITE } from "../../../styles/colors";
|
|
54
|
+
import modalState from "../../../state-observables/modal/ModalState";
|
|
55
|
+
import RICSignal from "../../oneoffs/RICSignal";
|
|
56
|
+
import SimpleButton from "../../disposables/buttons/SimpleButton";
|
|
57
|
+
import LEDs from "../../oneoffs/LEDs";
|
|
58
|
+
import SVGImageButton from "../../disposables/buttons/SVGImageButton";
|
|
59
|
+
import { raftConnectingSubscriptionHelper, raftDiscoveryFinishedSubscriptionHelper, raftDiscoveryStartedSubscriptionHelper } from "../../../application/RAFTs/raft-subscription-helpers";
|
|
60
|
+
import isPhoneApp from "../../../utils/phone-app-communication/is-phone-app";
|
|
61
|
+
import LoadingSpinner from "../../disposables/LoadingSpinner";
|
|
62
|
+
import { RaftConnectionMethod } from "../../../types/raft";
|
|
63
|
+
import { useConnectedRafts } from "../../../store/SelectedRaftContext";
|
|
64
|
+
var SHOW_LOGS = true;
|
|
65
|
+
var TAG = "VerificationModalPhone";
|
|
66
|
+
function VerificationModalPhoneApp(_a) {
|
|
67
|
+
var _this = this;
|
|
68
|
+
var foundRICs = _a.foundRICs;
|
|
69
|
+
var _b = useState([]), randomColours = _b[0], setRandomColours = _b[1];
|
|
70
|
+
var _c = useState(-1), selectedRICIdx = _c[0], setSelectedRICIdx = _c[1];
|
|
71
|
+
var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
|
|
72
|
+
var _e = useState(isPhoneApp()), isScanning = _e[0], setIsScanning = _e[1];
|
|
73
|
+
var _f = useState(), connectedRaft = _f[0], setConnectedRaft = _f[1];
|
|
74
|
+
var removeConnectedRaft = useConnectedRafts().removeConnectedRaft;
|
|
75
|
+
useEffect(function () {
|
|
76
|
+
raftDiscoveryFinishedSubscriptionHelper().subscribe(function () { return setIsScanning(false); });
|
|
77
|
+
raftDiscoveryStartedSubscriptionHelper().subscribe(function () { return setIsScanning(true); });
|
|
78
|
+
return function () {
|
|
79
|
+
raftDiscoveryFinishedSubscriptionHelper().unsubscribe();
|
|
80
|
+
raftDiscoveryStartedSubscriptionHelper().unsubscribe();
|
|
81
|
+
};
|
|
82
|
+
}, []);
|
|
83
|
+
var onCancel = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
if (!connectedRaft) return [3 /*break*/, 3];
|
|
88
|
+
return [4 /*yield*/, window.applicationManager.stopVerifyingRaft(connectedRaft.id, false)];
|
|
89
|
+
case 1:
|
|
90
|
+
_a.sent();
|
|
91
|
+
return [4 /*yield*/, window.applicationManager.disconnectFromRaft(connectedRaft.id)];
|
|
92
|
+
case 2:
|
|
93
|
+
_a.sent();
|
|
94
|
+
removeConnectedRaft(connectedRaft.id);
|
|
95
|
+
_a.label = 3;
|
|
96
|
+
case 3:
|
|
97
|
+
modalState.closeModal();
|
|
98
|
+
return [2 /*return*/];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}); };
|
|
102
|
+
var onScanAgain = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
if (!connectedRaft) return [3 /*break*/, 3];
|
|
107
|
+
return [4 /*yield*/, window.applicationManager.stopVerifyingRaft(connectedRaft.id, false)];
|
|
108
|
+
case 1:
|
|
109
|
+
_a.sent();
|
|
110
|
+
return [4 /*yield*/, window.applicationManager.disconnectFromRaft(connectedRaft.id)];
|
|
111
|
+
case 2:
|
|
112
|
+
_a.sent();
|
|
113
|
+
_a.label = 3;
|
|
114
|
+
case 3:
|
|
115
|
+
setSelectedRICIdx(-1);
|
|
116
|
+
setConnectedRaft(undefined);
|
|
117
|
+
if (!window.applicationManager.ricSelectedCb) return [3 /*break*/, 5];
|
|
118
|
+
return [4 /*yield*/, window.applicationManager.startDiscovery(window.applicationManager.ricSelectedCb)];
|
|
119
|
+
case 4:
|
|
120
|
+
_a.sent();
|
|
121
|
+
_a.label = 5;
|
|
122
|
+
case 5: return [2 /*return*/];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}); };
|
|
126
|
+
var onYes = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0:
|
|
130
|
+
modalState.closeModal();
|
|
131
|
+
return [4 /*yield*/, (connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.stopVerifyingRaft(true))];
|
|
132
|
+
case 1:
|
|
133
|
+
_a.sent();
|
|
134
|
+
return [2 /*return*/];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}); };
|
|
138
|
+
useEffect(function () {
|
|
139
|
+
if (!connectedRaft)
|
|
140
|
+
return;
|
|
141
|
+
raftConnectingSubscriptionHelper(connectedRaft).subscribe(setRandomColours);
|
|
142
|
+
connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.verifyRaftPhoneApp(foundRICs[selectedRICIdx]);
|
|
143
|
+
return function () {
|
|
144
|
+
raftConnectingSubscriptionHelper(connectedRaft).unsubscribe();
|
|
145
|
+
};
|
|
146
|
+
}, [connectedRaft]);
|
|
147
|
+
var onselectRaft = function (raftIdx) { return __awaiter(_this, void 0, void 0, function () {
|
|
148
|
+
var foundRaft, newRaft;
|
|
149
|
+
return __generator(this, function (_a) {
|
|
150
|
+
switch (_a.label) {
|
|
151
|
+
case 0:
|
|
152
|
+
setIsLoading(true);
|
|
153
|
+
if (!connectedRaft) return [3 /*break*/, 3];
|
|
154
|
+
return [4 /*yield*/, window.applicationManager.stopVerifyingRaft(connectedRaft.id, false)];
|
|
155
|
+
case 1:
|
|
156
|
+
_a.sent();
|
|
157
|
+
return [4 /*yield*/, window.applicationManager.disconnectFromRaft(connectedRaft.id)];
|
|
158
|
+
case 2:
|
|
159
|
+
_a.sent();
|
|
160
|
+
removeConnectedRaft(connectedRaft.id);
|
|
161
|
+
_a.label = 3;
|
|
162
|
+
case 3:
|
|
163
|
+
setSelectedRICIdx(raftIdx);
|
|
164
|
+
if (!foundRICs) return [3 /*break*/, 5];
|
|
165
|
+
foundRaft = foundRICs[raftIdx];
|
|
166
|
+
return [4 /*yield*/, window.applicationManager.selectRaft(foundRaft, RaftConnectionMethod.PHONE_BLE)];
|
|
167
|
+
case 4:
|
|
168
|
+
newRaft = _a.sent();
|
|
169
|
+
if (!newRaft)
|
|
170
|
+
return [2 /*return*/];
|
|
171
|
+
setConnectedRaft(newRaft);
|
|
172
|
+
_a.label = 5;
|
|
173
|
+
case 5:
|
|
174
|
+
setIsLoading(false);
|
|
175
|
+
return [2 /*return*/];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}); };
|
|
179
|
+
var contentJSX = null;
|
|
180
|
+
if (foundRICs.length === 0) {
|
|
181
|
+
contentJSX = _jsxs("div", __assign({ className: "verification-modal-container" }, { children: [!isScanning && _jsx("p", __assign({ style: { alignSelf: 'center' } }, { children: "No Martys Found" })), _jsx("div", __assign({ className: "verification-modal-martys-container" }, { children: isScanning && _jsxs("div", __assign({ style: { margin: "auto", width: "50px", height: "50px" } }, { children: [" ", _jsx(LoadingSpinner, {}), " "] })) })), _jsxs("div", __assign({ className: "verification-modal-bottom-btns-container" }, { children: [_jsx(SVGImageButton, { onClick: onScanAgain, title: "SCAN AGAIN", SVGImage: RefreshSVG, backgroundColour: MAIN_BLUE, titleColour: WHITE, SVGColour: WHITE }), _jsx("div", { className: "dummy-gap" }), _jsx(SimpleButton, { onClick: onCancel, title: "CANCEL" })] }))] }));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
contentJSX = _jsxs("div", __assign({ className: "verification-modal-container" }, { children: [_jsxs("div", __assign({ className: "verification-modal-martys-container" }, { children: [isScanning && _jsxs("div", __assign({ style: { margin: "auto", width: "50px", height: "50px" } }, { children: [" ", _jsx(LoadingSpinner, {}), " "] })), foundRICs.map(function (raftObj, raftIdx) {
|
|
185
|
+
return _jsxs(Fragment, { children: [_jsxs("div", __assign({ className: "verification-modal-marty-name-row-container", onClick: function () { return onselectRaft(raftIdx); } }, { children: [_jsx("p", __assign({ className: "verification-modal-marty-name" }, { children: raftObj._localName })), _jsx("div", __assign({ className: "verification-modal-marty-signal-container" }, { children: _jsx(RICSignal, { signalStrength: raftObj._rssi }) })), _jsx(BluetoothSVG, { fill: MAIN_BLUE })] })), selectedRICIdx === raftIdx && _jsxs("div", { children: [_jsx("p", __assign({ className: "verification-modal-martys-back-hint" }, { children: isLoading ? "Loading..." : "Look on ".concat(connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.type, "'s back, is it displaying these lights?") })), _jsxs("div", __assign({ className: "verification-modal-led-row-container" }, { children: [_jsx(LEDs, { coloursArr: randomColours, connectedRaft: connectedRaft }), !isLoading && _jsx(SimpleButton, { onClick: onCancel, title: "No", borderColour: "red", colour: "white", textColour: "red" }), !isLoading && _jsx(SimpleButton, { onClick: onYes, title: "YES" })] }))] })] }, raftIdx);
|
|
186
|
+
})] })), _jsxs("div", __assign({ className: "verification-modal-bottom-btns-container" }, { children: [_jsx(SVGImageButton, { onClick: onScanAgain, title: "SCAN AGAIN", SVGImage: RefreshSVG, backgroundColour: MAIN_BLUE, titleColour: WHITE, SVGColour: WHITE, disabled: isScanning }), _jsx("div", { className: "dummy-gap" }), _jsx(SimpleButton, { onClick: onCancel, title: "CANCEL" })] }))] }));
|
|
187
|
+
}
|
|
188
|
+
return contentJSX;
|
|
189
|
+
}
|
|
190
|
+
export default VerificationModalPhoneApp;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "./styles.css";
|
|
2
|
+
import RAFT from "../../../application/RAFTs/RAFT";
|
|
3
|
+
type LEDsProps = {
|
|
4
|
+
coloursArr: string[];
|
|
5
|
+
connectedRaft: RAFT | undefined;
|
|
6
|
+
};
|
|
7
|
+
export default function LEDs({ coloursArr, connectedRaft }: LEDsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
13
|
+
import { RaftUtils } from "@robdobsn/raftjs";
|
|
14
|
+
import "./styles.css";
|
|
15
|
+
import { RaftTypeE } from "../../../types/raft";
|
|
16
|
+
export default function LEDs(_a) {
|
|
17
|
+
var coloursArr = _a.coloursArr, connectedRaft = _a.connectedRaft;
|
|
18
|
+
var LEDContentJSX = null;
|
|
19
|
+
if ((connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.type) === RaftTypeE.MARTY) {
|
|
20
|
+
LEDContentJSX = _jsxs("div", __assign({ className: "leds-colours-container" }, { children: [_jsx("div", { className: "leds-colour-1", style: { backgroundColor: coloursArr[0] } }), _jsx("div", { className: "leds-colour-2", style: { backgroundColor: coloursArr[1] } }), _jsx("div", { className: "leds-colour-3", style: { backgroundColor: coloursArr[2] } })] }));
|
|
21
|
+
}
|
|
22
|
+
else if ((connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.type) === RaftTypeE.COG) {
|
|
23
|
+
LEDContentJSX = _jsx("div", { className: "leds-colours-container-phone", dangerouslySetInnerHTML: { __html: (coloursArr && connectedRaft) ? cogSvg(coloursArr, connectedRaft) : "Please wait..." } });
|
|
24
|
+
}
|
|
25
|
+
return LEDContentJSX;
|
|
26
|
+
}
|
|
27
|
+
var cogSvg = function (lights, connectedRaft) {
|
|
28
|
+
// pushing the index by 5 for all of them, to align the lights with the correct orientation of p3
|
|
29
|
+
// pushing the index by 5 for all of them, to align the lights with the correct orientation of p3
|
|
30
|
+
var correctedIdxFactorForOlderP3 = 5;
|
|
31
|
+
var correctedIdxFactorForNewerP3 = 12;
|
|
32
|
+
var LEDAndAccelerometerVersionCutOff = "1.2.0";
|
|
33
|
+
var correctedIdxFactor = correctedIdxFactorForOlderP3;
|
|
34
|
+
if (RaftUtils.isVersionGreater(connectedRaft.getRaftVersion(), LEDAndAccelerometerVersionCutOff)) {
|
|
35
|
+
correctedIdxFactor = correctedIdxFactorForNewerP3;
|
|
36
|
+
}
|
|
37
|
+
var lightsReIndexed = lights.map(function (light, index) { return lights[(index + (correctedIdxFactor)) % 12]; });
|
|
38
|
+
return "\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<svg id=\"Layer_2\" data-name=\"Layer 2\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 76 66\">\n <defs>\n <style>\n .cls-cog-svg-1 {\n fill: #040406;\n }\n\n .cls-cog-svg-1, .cls-cog-svg-2, .cls-cog-svg-3, .cls-cog-svg-4, .cls-cog-svg-5, .cls-cog-svg-6 {\n stroke-width: 0px;\n }\n\n .cls-cog-svg-2 {\n\n }\n\n .cls-cog-svg-3 {\n fill: #ab55a1;\n }\n\n .cls-cog-svg-4 {\n fill: #fff;\n }\n\n .cls-cog-svg-5 {\n fill: #969692;\n }\n\n .cls-cog-svg-6 {\n fill: #fcee21;\n }\n </style>\n </defs>\n <path class=\"cls-cog-svg-3\" d=\"M22.1,42.18l15.9,9.18,15.9-9.18v-18.36l-15.9-9.18-15.9,9.18v18.36ZM38,49.56l-14.34-8.28v-16.56l14.34-8.28,14.34,8.28v16.56l-14.34,8.28ZM25.66,40.13l12.34,7.12,12.34-7.12v-14.25l-12.34-7.13-12.34,7.13v14.25Z\"/>\n <polygon class=\"cls-cog-svg-3\" points=\"55.9 22.67 55.9 43.34 38 53.67 20.1 43.34 20.1 22.67 38 12.33 55.9 22.67\"/>\n <g>\n <polygon class=\"cls-cog-svg-4\" points=\"53.12 41.73 53.12 24.27 38 15.54 22.88 24.27 22.88 41.73 38 50.46 53.12 41.73\"/>\n <polygon class=\"cls-cog-svg-4\" points=\"54.62 23.41 54.62 42.6 38 52.2 21.38 42.6 21.38 23.41 38 13.81 54.62 23.41\"/>\n </g>\n <g>\n <g>\n <circle id=\"circle--1\" class=\"cls-cog-svg-2\" cx=\"38.1\" cy=\"33.1\" r=\"4.27\"/>\n <path class=\"cls-cog-svg-5\" d=\"M34.72,36.47c-1.86-1.86-1.86-4.89,0-6.75s4.89-1.86,6.75,0,1.86,4.89,0,6.75-4.89,1.86-6.75,0ZM40.77,30.43c-1.47-1.47-3.86-1.47-5.34,0s-1.47,3.86,0,5.33,3.86,1.47,5.33,0,1.47-3.86,0-5.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--2\" class=\"cls-cog-svg-2\" cx=\"47.83\" cy=\"27.44\" r=\"2.48\" fill=\"".concat(lightsReIndexed[2], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M45.98,29.28c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM49.49,25.77c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--3\" class=\"cls-cog-svg-2\" cx=\"28.37\" cy=\"38.75\" r=\"2.48\" fill=\"").concat(lightsReIndexed[8], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M26.53,40.6c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM30.04,37.09c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--4\" class=\"cls-cog-svg-2\" cx=\"32.44\" cy=\"23.37\" r=\"2.48\" fill=\"").concat(lightsReIndexed[11], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M30.6,25.21c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM34.11,21.7c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--5\" class=\"cls-cog-svg-2\" cx=\"43.75\" cy=\"42.82\" r=\"2.48\" fill=\"").concat(lightsReIndexed[5], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M41.91,44.67c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM45.42,41.16c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--6\" class=\"cls-cog-svg-2\" cx=\"28.46\" cy=\"27.46\" r=\"2.48\" fill=\"").concat(lightsReIndexed[10], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M26.62,29.3c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM30.13,25.79c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--7\" class=\"cls-cog-svg-2\" cx=\"26.99\" cy=\"33.14\" r=\"2.48\" fill=\"").concat(lightsReIndexed[9], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M25.15,34.98c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM28.66,31.47c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--8\" class=\"cls-cog-svg-2\" cx=\"37.89\" cy=\"21.81\" r=\"2.48\" fill=\"").concat(lightsReIndexed[0], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M36.05,23.66c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM39.56,20.15c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--13\" class=\"cls-cog-svg-2\" cx=\"43.85\" cy=\"23.34\" r=\"2.48\" fill=\"").concat(lightsReIndexed[1], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M42,25.18c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM45.51,21.67c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--9\" class=\"cls-cog-svg-2\" cx=\"47.77\" cy=\"38.8\" r=\"2.48\" fill=\"").concat(lightsReIndexed[4], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M45.93,40.64c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM49.44,37.13c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--10\" class=\"cls-cog-svg-2\" cx=\"49.23\" cy=\"33.21\" r=\"2.48\" fill=\"").concat(lightsReIndexed[3], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M47.39,35.05c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM50.9,31.54c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--11\" class=\"cls-cog-svg-2\" cx=\"32.51\" cy=\"42.93\" r=\"2.48\" fill=\"").concat(lightsReIndexed[7], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M30.66,44.77c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM34.17,41.26c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n <g>\n <circle id=\"circle--12\" class=\"cls-cog-svg-2\" cx=\"38.27\" cy=\"44.32\" r=\"2.48\" fill=\"").concat(lightsReIndexed[6], "\"/>\n <path class=\"cls-cog-svg-1\" d=\"M36.43,46.17c-1.02-1.02-1.02-2.67,0-3.69s2.67-1.02,3.69,0,1.02,2.67,0,3.69-2.67,1.02-3.69,0ZM39.93,42.66c-.92-.92-2.41-.92-3.33,0s-.92,2.41,0,3.33,2.41.92,3.33,0,.92-2.41,0-3.33Z\"/>\n </g>\n </g>\n <polygon class=\"cls-cog-svg-6\" points=\"29.44 18.75 46.56 18.75 38 13.81 29.44 18.75\"/>\n <path class=\"cls-cog-svg-3\" d=\"M47.53,19h-19.07c-.14,0-.25-.11-.25-.25s.11-.25.25-.25h19.07c.14,0,.25.11.25.25s-.11.25-.25.25Z\"/>\n</svg>\n");
|
|
39
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import RAFT from "../../../application/RAFTs/RAFT";
|
|
2
|
+
type RICSignlaProps = {
|
|
3
|
+
signalStrength: number;
|
|
4
|
+
connectedRaft?: RAFT;
|
|
5
|
+
};
|
|
6
|
+
export default function RICSignal({ signalStrength, connectedRaft }: RICSignlaProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { ReactComponent as EmptySignalSVG } from "../../../assets/connect-button/empty-signal.svg";
|
|
4
|
+
import rescale from "../../../utils/helpers/rescale-range";
|
|
5
|
+
import { SCREENFREE_GREEN, SCREENFREE_YELLOW } from "../../../styles/colors";
|
|
6
|
+
import isVersionGreater from "../../../utils/helpers/compare-version";
|
|
7
|
+
import { FW_VERSION_RSSI_WIFI } from "../../../utils/helpers/wifi-configuration-subtitle-gen";
|
|
8
|
+
export default function RICSignal(_a) {
|
|
9
|
+
var signalStrength = _a.signalStrength, connectedRaft = _a.connectedRaft;
|
|
10
|
+
var signalRef = useRef(null);
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
if (signalRef.current) {
|
|
13
|
+
var signalRaw = (-50 / signalStrength) * 100;
|
|
14
|
+
var signalScaled = rescale(signalRaw, 50, 100, 0, 100);
|
|
15
|
+
var signalBars = signalScaled / 20;
|
|
16
|
+
var colour = signalBars <= 3 ? SCREENFREE_YELLOW : SCREENFREE_GREEN;
|
|
17
|
+
var svgStartPath = 9;
|
|
18
|
+
for (var i = 0; i < 5; i++) {
|
|
19
|
+
if (i < signalBars) {
|
|
20
|
+
signalRef.current.children[svgStartPath - i].setAttribute("fill", colour);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
signalRef.current.children[svgStartPath - i].setAttribute("fill", "white");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, [signalStrength]);
|
|
28
|
+
return _jsx(EmptySignalSVG, { ref: signalRef, width: "80%", opacity: !isVersionGreater((connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.getRaftVersion()) || "100.0.0", FW_VERSION_RSSI_WIFI) ? 0.5 : 1 });
|
|
29
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare class Logger {
|
|
2
|
+
static info(SHOW_LOGS: boolean, tag: string, message: string): void;
|
|
3
|
+
static error(SHOW_LOGS: boolean, tag: string, message: string): void;
|
|
4
|
+
static debug(SHOW_LOGS: boolean, tag: string, message: string): void;
|
|
5
|
+
static warn(SHOW_LOGS: boolean, tag: string, message: string): void;
|
|
6
|
+
}
|
|
7
|
+
export default Logger;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var Logger = /** @class */ (function () {
|
|
2
|
+
function Logger() {
|
|
3
|
+
}
|
|
4
|
+
Logger.info = function (SHOW_LOGS, tag, message) {
|
|
5
|
+
SHOW_LOGS && console.log('\x1b[34m%s\x1b[0m', "INFO: ".concat(tag), message); // Blue color for info logs
|
|
6
|
+
};
|
|
7
|
+
Logger.error = function (SHOW_LOGS, tag, message) {
|
|
8
|
+
SHOW_LOGS && console.error('\x1b[31m%s\x1b[0m', "ERROR: ".concat(tag), message); // Red color for error logs
|
|
9
|
+
};
|
|
10
|
+
Logger.debug = function (SHOW_LOGS, tag, message) {
|
|
11
|
+
SHOW_LOGS && console.debug('\x1b[35m%s\x1b[0m', "DEBUG: ".concat(tag), message); // Magenta color for debug logs
|
|
12
|
+
};
|
|
13
|
+
Logger.warn = function (SHOW_LOGS, tag, message) {
|
|
14
|
+
SHOW_LOGS && console.warn('\x1b[33m%s\x1b[0m', "WARN: ".concat(tag), message); // Yellow color for warning logs
|
|
15
|
+
};
|
|
16
|
+
return Logger;
|
|
17
|
+
}());
|
|
18
|
+
window.Logger = Logger;
|
|
19
|
+
export default Logger;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export type ModalContentType = ReactNode;
|
|
3
|
+
export type ModalEventTopics = "SetModal" | "CloseModal" | "UpdateModalProps";
|
|
4
|
+
export type ModalStateData = {
|
|
5
|
+
modalContent?: ModalContentType;
|
|
6
|
+
modalTitle?: string;
|
|
7
|
+
newWindowLink?: string;
|
|
8
|
+
withCloseButton?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export interface ModalObservable {
|
|
11
|
+
subscribe(observer: ModalObserver, topics: Array<ModalEventTopics>): void;
|
|
12
|
+
unsubscribe(observer: ModalObserver): void;
|
|
13
|
+
publish(eventTopic: ModalEventTopics, eventData?: ModalStateData): void;
|
|
14
|
+
}
|
|
15
|
+
export interface ModalObserver {
|
|
16
|
+
notify(eventTopic: ModalEventTopics, eventData?: ModalStateData): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ModalContentType, ModalEventTopics, ModalObservable, ModalObserver, ModalStateData } from "./ModalObserver";
|
|
2
|
+
type ModalReturnValue = any;
|
|
3
|
+
declare class ModalState implements ModalObservable {
|
|
4
|
+
modalContent: ModalContentType | null;
|
|
5
|
+
modalTitle: string;
|
|
6
|
+
private _observers;
|
|
7
|
+
private _modalPromise;
|
|
8
|
+
private _modalResolve;
|
|
9
|
+
private _modalReject;
|
|
10
|
+
constructor();
|
|
11
|
+
setModal(modalContent: ModalContentType, modalTitle: string): Promise<ModalReturnValue>;
|
|
12
|
+
closeModal(modalReturnValue?: ModalReturnValue, onCloseCb?: () => void): void;
|
|
13
|
+
updateModalProps(updatedProps: {
|
|
14
|
+
modalTitle?: string;
|
|
15
|
+
withCloseButton?: boolean;
|
|
16
|
+
}): void;
|
|
17
|
+
clearPromise(): void;
|
|
18
|
+
subscribe(observer: ModalObserver, topics: Array<ModalEventTopics>): void;
|
|
19
|
+
unsubscribe(observer: ModalObserver): void;
|
|
20
|
+
publish(eventTopic: ModalEventTopics, eventData?: ModalStateData): void;
|
|
21
|
+
}
|
|
22
|
+
declare const modalState: ModalState;
|
|
23
|
+
export default modalState;
|
|
24
|
+
export declare const secondaryModalState: ModalState;
|