Skip to content

Commit

Permalink
fix: UI update after mock sensor change [PT-187809478]
Browse files Browse the repository at this point in the history
Updates the mock sensor poll value to use measurement and unit based on sensor selected.
  • Loading branch information
dougmartin committed Jun 30, 2024
1 parent 3d15b03 commit dc8d216
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/mobile-app/components/sensor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export const SensorComponent: React.FC<ISensorComponentProps> = ({sensor, manual
const displayValue = value !== undefined ? value.toFixed(1) : "--";

return (
<div className={css.timeSeriesValue}>
<div className={css.timeSeriesValue} key={`timeseries-${selectableSensorId}`}>
<div className={css.tsvLeft}>
<div className={css.tsvGraph}>
<DataTableSparkGraph
Expand Down Expand Up @@ -323,7 +323,7 @@ export const SensorComponent: React.FC<ISensorComponentProps> = ({sensor, manual
}
const className = connected ? css.connectedValues : css.disconnectedValues;
return (
<div className={className}>
<div className={className} key={`values-${selectableSensorId}`}>
{fragments}
</div>
);
Expand Down
12 changes: 8 additions & 4 deletions src/sensors/mock-sensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,20 @@ export class MockSensor extends Sensor {
}

public timeSeriesCapabilities(selectableSensorId: any): ITimeSeriesCapabilities {
selectableSensorId = parseInt(selectableSensorId ?? "0", 10);
const {measurement, units, minValue, maxValue} = selectableSensorId === 0
? {measurement: "Force", units: "N", minValue: -50, maxValue: 50}
: {measurement: "Temperature", units: "°C", minValue: -40, maxValue: 125};
const defaultMeasurementPeriod = 50;
return {
measurementPeriod: defaultMeasurementPeriod,
minMeasurementPeriod: 10,
defaultMeasurementPeriod,
measurement: "Fake Value",
measurement,
valueKey: TimeSeriesDataKey,
units: "N/A",
minValue: -5,
maxValue: 5,
units,
minValue,
maxValue,
};
}

Expand Down

0 comments on commit dc8d216

Please sign in to comment.