Skip to content

Commit

Permalink
refactor about the use of telemetries of the flight tracker and the s…
Browse files Browse the repository at this point in the history
…tyles
  • Loading branch information
fdelcampo committed Apr 12, 2023
1 parent 79d1fb6 commit ea1178a
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 134 deletions.
10 changes: 10 additions & 0 deletions love/src/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,16 @@ export const mtdomeMotionStateMap = {
32: 'STOPPING MOTOR COOLING',
};

export const flightTrackerStateToMap = {
0: 'DISCONNECTED',
1: 'CONNECTED',
}

export const flightTrackerStatetoStyle = {
DISCONNECTED: 'warning',
CONNECTED: 'running',
};

export const mtdomeElevationEnabledStateToMap = {
0: 'DISABLED',
1: 'ENABLED',
Expand Down
41 changes: 26 additions & 15 deletions love/src/components/FlightTracker/FlightTracker.container.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { addGroup, removeGroup } from 'redux/actions/ws';
import { getStreamData } from 'redux/selectors';
import { getFlightTracker } from 'redux/selectors';
import FlightTracker from './FlightTracker';
import SubscriptionTableContainer from 'components/GeneralPurpose/SubscriptionTable/SubscriptionTable.container';

Expand All @@ -24,36 +25,46 @@ export const schema = {
},
};

const FlightTrackerContainer = ({
...props
}) => {
if (props.isRaw) {
return <SubscriptionTableContainer subscriptions={props.subscriptions} />;
const FlightTrackerContainer = ({ isRaw, subscriptions, status, aircrafts }) => {
if (isRaw) {
return <SubscriptionTableContainer subscriptions={subscriptions} />;
}
return (
<FlightTracker/>
<FlightTracker
status={status}
aircrafts={aircrafts}
/>
);
};

const mapStateToProps = (state) => {
const data = getFlightTracker(state);
return {
status: data.status,
aircrafts: data.aircrafts,
}
}

const mapDispatchToProps = (dispatch, ownProps) => {
const subscriptions = [
'telemetry-FlightTracker-0-data',
];
return {
subscriptions,
subscribeToStreams: () => {
subscriptions.forEach((s) => dispatch(addGroup(s)));
subscriptions.forEach((stream) => dispatch(addGroup(stream)));
},
unsubscribeToStreams: () => {
subscriptions.forEach((s) => dispatch(removeGroup(s)));
subscriptions.forEach((stream) => dispatch(removeGroup(stream)));
},
};
};

const mapStateToProps = (state) => {
//const streams = getStreamsData(state, groupNames);
return {
//streams,
}
}
FlightTrackerContainer.propTypes = {
/** Wheter the component is in raw mode */
isRaw: PropTypes.bool,
/** List of the component's subscriptions */
subscriptions: PropTypes.array,
};

export default connect(mapStateToProps, mapDispatchToProps)(FlightTrackerContainer);
Loading

0 comments on commit ea1178a

Please sign in to comment.