with changing unit preferences and such to use the user object and not local storage, the decriber needed to be updated as well and i missed that part, so now describeMeasurement takes in an optional user and uses its settings for the unit and such and when not passed in will use the defaults
This commit is contained in:
parent
9d41499c27
commit
52c8a02af3
18 changed files with 117 additions and 56 deletions
|
|
@ -103,7 +103,7 @@ export default function BinConditioningInteraction(props: Props) {
|
|||
let sliderVals: Map<quack.MeasurementType, number> = new Map();
|
||||
let sliderMarks: Map<quack.MeasurementType, number> = new Map();
|
||||
passedInteraction.conditions().forEach(condition => {
|
||||
let describer = describeMeasurement(condition.measurementType, source.type());
|
||||
let describer = describeMeasurement(condition.measurementType, source.type(), undefined, undefined, user);
|
||||
//NOTE: toDisplay will convert the temp value to fahrenheit
|
||||
sliderVals.set(condition.measurementType, describer.toDisplay(condition.value));
|
||||
});
|
||||
|
|
@ -173,17 +173,17 @@ export default function BinConditioningInteraction(props: Props) {
|
|||
return (
|
||||
<Grid container>
|
||||
{interaction.conditions().map((condition, i) => {
|
||||
let describer = describeMeasurement(condition.measurementType, source?.type());
|
||||
let labelTail = "";
|
||||
let describer = describeMeasurement(condition.measurementType, source?.type(), source.subType(), undefined, user);
|
||||
let labelTail = describer.unit();
|
||||
let marks: Mark[] = [];
|
||||
|
||||
if (condition.measurementType === quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE) {
|
||||
if (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
labelTail = "°F";
|
||||
} else {
|
||||
labelTail = "°C";
|
||||
}
|
||||
}
|
||||
// if (condition.measurementType === quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE) {
|
||||
// if (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
// labelTail = "°F";
|
||||
// } else {
|
||||
// labelTail = "°C";
|
||||
// }
|
||||
// }
|
||||
if (condition.measurementType === quack.MeasurementType.MEASUREMENT_TYPE_PERCENT) {
|
||||
labelTail = "%";
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ export default function BinConditioningInteraction(props: Props) {
|
|||
return (
|
||||
<Grid key={i} container item xs={12} alignContent="center" alignItems="center">
|
||||
<Grid item xs={12}>
|
||||
{interactionConditionText(source, condition, false)}
|
||||
{interactionConditionText(source, condition, false, user)}
|
||||
</Grid>
|
||||
<Grid item xs={12} style={{ marginBottom: 20 }}>
|
||||
<Slider
|
||||
|
|
|
|||
|
|
@ -87,9 +87,24 @@ export default function GrainNodeInteractions(props: Props) {
|
|||
const [nodeHum, setNodeHum] = useState<number>();
|
||||
const [nodeMoist, setNodeMoist] = useState<number | undefined>();
|
||||
const [{ user, as }] = useGlobalState();
|
||||
const tempDescriber = describeMeasurement(quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE);
|
||||
const humDescriber = describeMeasurement(quack.MeasurementType.MEASUREMENT_TYPE_PERCENT);
|
||||
const moistureDescriber = describeMeasurement(quack.MeasurementType.MEASUREMENT_TYPE_GRAIN_EMC);
|
||||
const tempDescriber = describeMeasurement(
|
||||
quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE,
|
||||
quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE,
|
||||
undefined,
|
||||
undefined,
|
||||
user);
|
||||
const humDescriber = describeMeasurement(
|
||||
quack.MeasurementType.MEASUREMENT_TYPE_PERCENT,
|
||||
quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE,
|
||||
undefined,
|
||||
undefined,
|
||||
user);
|
||||
const moistureDescriber = describeMeasurement(
|
||||
quack.MeasurementType.MEASUREMENT_TYPE_GRAIN_EMC,
|
||||
quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE,
|
||||
undefined,
|
||||
undefined,
|
||||
user);
|
||||
const [topNode, setTopNode] = useState(false);
|
||||
const [excluded, setExcluded] = useState(false);
|
||||
const componentAPI = useComponentAPI();
|
||||
|
|
|
|||
|
|
@ -288,7 +288,9 @@ if (!selectedDevice) return;
|
|||
describeMeasurement(
|
||||
quack.MeasurementType.MEASUREMENT_TYPE_PERCENT,
|
||||
sensor.settings.type,
|
||||
sensor.settings.subtype
|
||||
sensor.settings.subtype,
|
||||
undefined,
|
||||
user
|
||||
).toStored(hum)
|
||||
)
|
||||
});
|
||||
|
|
@ -301,7 +303,9 @@ if (!selectedDevice) return;
|
|||
let tempVal = describeMeasurement(
|
||||
quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE,
|
||||
sensor.settings.type,
|
||||
sensor.settings.subtype
|
||||
sensor.settings.subtype,
|
||||
undefined,
|
||||
user
|
||||
).toStored(temp);
|
||||
|
||||
let tempCondition = pond.InteractionCondition.create({
|
||||
|
|
@ -385,7 +389,9 @@ if (!selectedDevice) return;
|
|||
value: describeMeasurement(
|
||||
quack.MeasurementType.MEASUREMENT_TYPE_PERCENT,
|
||||
sensor.settings.type,
|
||||
sensor.settings.subtype
|
||||
sensor.settings.subtype,
|
||||
undefined,
|
||||
user
|
||||
).toStored(humidityPreset)
|
||||
});
|
||||
conditions.push(fanConditionOne);
|
||||
|
|
@ -397,7 +403,9 @@ if (!selectedDevice) return;
|
|||
let tempVal = describeMeasurement(
|
||||
quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE,
|
||||
sensor.settings.type,
|
||||
sensor.settings.subtype
|
||||
sensor.settings.subtype,
|
||||
undefined,
|
||||
user
|
||||
).toStored(tempPreset);
|
||||
|
||||
let fanConditionTwo = pond.InteractionCondition.create({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue