From 6e1d3c3009bd34718110715a4ec08968c7cd4e4b Mon Sep 17 00:00:00 2001 From: BrandonWerbel Date: Sat, 6 Feb 2021 16:14:13 -0500 Subject: [PATCH] Start fixing connection indicator --- src/connections.js | 7 ++++--- src/ui.js | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/connections.js b/src/connections.js index 8c99b90..d3c1d8a 100644 --- a/src/connections.js +++ b/src/connections.js @@ -56,14 +56,15 @@ function onRobotConnection(connected) { function loadComponents() { loadCameras(); + // Add any future components here } function loadCameras() { let promises = cameras.map(camera => camera.loadCameraStream()); - Promise.all(promises).then(successess => { - successess = successess.map(success => !success ? connection.status = 'loading-failed' : 'success'); + Promise.all(promises).then(successes => { + successes = successes.map(success => connection.status = success ? 'success' : 'camera-failure'); - if (successess.every(elem => elem)) connection.status = 'loaded'; + if (successes.every(elem => elem)) connection.status = 'loaded'; }).catch(_ => connection.status = 'loading-failed'); // Component errored out } diff --git a/src/ui.js b/src/ui.js index e843255..b3ae545 100644 --- a/src/ui.js +++ b/src/ui.js @@ -53,10 +53,11 @@ cameras[cameraStream1].setParent(document.getElementById('camera1')); cameras[cameraStream2].setParent(document.getElementById('camera2')); const indicatorColors = { - 'disconnected': '#D32F2F', - 'connected': 'rgb(255, 217, 0)', - 'loading-failed': '#FF8300', - 'loaded': '#42C752' + 'disconnected': '#D32F2F', //red + 'connected': '#FFD900', //yellow + 'loading-failed': '#FF8300', //orange + 'loaded': '#42C752', //green + 'camera-failure': 'hotpink' //hot pink } function showPanel(elem, id) {