Merge branch 'allow-zero' into 'v3'

Allow 0 as a setting in the webapp

Closes #693

See merge request openflexure/openflexure-microscope-server!508
This commit is contained in:
Julian Stirling 2026-02-24 13:29:03 +00:00
commit de08bb1740
3 changed files with 5 additions and 4 deletions

View file

@ -290,7 +290,7 @@ class HistoScanWorkflow(RectGridWorkflow[HistoScanSettingsModel]):
This uses the settings from the ``BackgroundDetectThing``.
"""
max_range: int = lt.setting(default=45000)
max_range: int = lt.setting(default=45000, ge=0)
"""The maximum distance in steps from the centre of the scan."""
# Stacking settings

View file

@ -346,7 +346,8 @@ export default {
}
// Rounding to about 5 sig figs to stop weird javascript rounding.
const magnitude = Math.floor(Math.log10(Math.abs(newValue)));
const absVal = Math.abs(newValue);
const magnitude = absVal > Number.EPSILON ? Math.floor(Math.log10(absVal)) : 0;
const factor = 10 ** -(Math.floor(magnitude) - 4);
this.internalValue = Math.round(newValue * factor) / factor;
},

View file

@ -56,10 +56,10 @@ export default {
"writeproperty",
false,
);
// `false` fails because axios somehow eats it!
// `false` and 0 fail because axios turns it to ""
// Other values should not be stringified or pydantic
// can't parse them.
if (value === false || value === true) {
if (value === false || value === true || value === 0) {
value = JSON.stringify(value);
}
await axios.put(url, value);