Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add M1M3Compact and M2Compact components. #673

Merged
merged 11 commits into from
Nov 12, 2024
Merged
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Version History
===============

v6.4.0
------

* Add M1M3Compact and M2Compact components `<https://github.com/lsst-ts/LOVE-frontend/pull/673>`_

v6.3.2
------

Expand Down
557 changes: 554 additions & 3 deletions love/src/Config.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions love/src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ export const IMAGE_STATES = {
END_READOUT: 'END_READOUT',
END_TELEMETRY: 'END_TELEMETRY',
};

export const VALUE_TYPES = {
BOOLEAN: 'boolean',
INTEGER: 'integer',
FLOAT: 'float',
STRING: 'string',
ARRAY: 'array',
OBJECT: 'object',
};
9 changes: 9 additions & 0 deletions love/src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2125,3 +2125,12 @@ export function formatOLETimeOfIncident(dateStart, dateEnd) {
if (dateStart === dateEnd) return truncateISODateToMinutes(dateStart);
return `${truncateISODateToMinutes(dateStart)} - ${truncateISODateToMinutes(dateEnd)}`;
}

/**
* Function to swap values per keys in a object
* @param {object} obj object to be swapped
* @returns {object} object with swapped keys and values
*/
export function swapKeysAndValues(obj) {
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [value, key]));
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ this program. If not, see <http://www.gnu.org/licenses/>.
overflow: visible;
}

svg text {
.svgElevation text {
padding: 4px;
}

Expand Down
59 changes: 13 additions & 46 deletions love/src/components/GeneralPurpose/ProgressBar/ProgressBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,12 @@ this program. If not, see <http://www.gnu.org/licenses/>.
*/

import React, { useRef } from 'react';
import PropTypes from 'prop-types';
import styles from './ProgressBar.module.css';

const ProgressBar = (props) => {
const ProgressBar = ({ targetValue, completed, hideCompleted = false, height = 20 }) => {
const ref = useRef(null);
const { targetValue, completed, hideCompleted = false, height = 20 } = props;
const padding = 4;

const parentDiv = {
display: 'flex',
};

const containerStyles = {
height: 20,
width: '100%',
backgroundColor: '#455a64',
marginBottom: '5px',
float: 'rigth',
position: 'relative',
padding: `${padding}px`,
};

const fillerStyles = {
height: '100%',
width: `${completed}%`,
backgroundColor: 'var(--second-tertiary-background-color)',
textAlign: 'right',
};

const labelStyles = {
padding: 5,
color: 'white',
fontWeight: 'bold',
};

const targetValueLine = {
stroke: 'white',
strokeWidth: 2,
strokeDasharray: 1.8,
strokeOpacity: 0.5,
};

const progressCommandedLine = {
position: 'absolute',
top: padding,
right: padding,
bottom: padding,
left: padding,
overflow: 'visible',
};

const width = ref.current?.clientWidth ?? 0;
const targetValuePixels = ((width - 2 * padding) * targetValue) / 100;
const completedValue = completed.toString().padStart(3, '0');
Expand Down Expand Up @@ -101,4 +57,15 @@ const ProgressBar = (props) => {
);
};

ProgressBar.propTypes = {
/** Target value */
targetValue: PropTypes.number,
/** Completed value */
completed: PropTypes.number,
/** Hide completed value */
hideCompleted: PropTypes.bool,
/** Height of the progress bar */
height: PropTypes.number,
};

export default ProgressBar;
24 changes: 13 additions & 11 deletions love/src/components/MainTel/M1M3/M1M3.container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,23 @@ const mapDispatchToProps = (dispatch) => {
'event-MTM1M3-0-forceActuatorInfo',
'event-MTM1M3-0-hardpointActuatorState',
'event-MTM1M3-0-hardpointActuatorInfo',
'event-MTM1M3-0-hardpointMonitorInfo',
'event-MTM1M3-0-appliedActiveOpticForces',
'event-MTM1M3-0-appliedOffsetForces',
'event-MTM1M3-0-appliedStaticForces',
'event-MTM1M3-0-enabledForceActuators',
// 'event-MTM1M3-0-preclippedAccelerationForces',
// 'event-MTM1M3-0-preclippedActiveOpticForces',
// 'event-MTM1M3-0-preclippedBalanceForces',
// 'event-MTM1M3-0-preclippedAzimuthForces',
// 'event-MTM1M3-0-preclippedCylinderForces',
// 'event-MTM1M3-0-preclippedElevationForces',
// 'event-MTM1M3-0-preclippedForces',
// 'event-MTM1M3-0-preclippedOffsetForces',
// 'event-MTM1M3-0-preclippedStaticForces',
// 'event-MTM1M3-0-preclippedThermalForces',
// 'event-MTM1M3-0-preclippedVelocityForces',
'event-MTM1M3-0-preclippedAccelerationForces',
'event-MTM1M3-0-preclippedActiveOpticForces',
'event-MTM1M3-0-preclippedBalanceForces',
'event-MTM1M3-0-preclippedAzimuthForces',
'event-MTM1M3-0-preclippedCylinderForces',
'event-MTM1M3-0-preclippedElevationForces',
'event-MTM1M3-0-preclippedForces',
'event-MTM1M3-0-preclippedOffsetForces',
'event-MTM1M3-0-preclippedStaticForces',
'event-MTM1M3-0-preclippedThermalForces',
'event-MTM1M3-0-preclippedVelocityForces',
'event-MTM1M3-0-raisingLoweringInfo',
];
return {
subscriptions,
Expand Down
Loading
Loading