Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Start fixing connection indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonWerbel authored and AndrewLester committed Feb 25, 2021
1 parent d9385c2 commit 6e1d3c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
9 changes: 5 additions & 4 deletions src/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6e1d3c3

Please sign in to comment.