Farmbot-Web-App/frontend/farm_designer/map_size_setting.tsx

52 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-05-21 19:04:30 -06:00
import * as React from "react";
import {
GetWebAppConfigValue, setWebAppConfigValue
2019-06-14 16:59:11 -06:00
} from "../config_storage/actions";
import { t } from "../i18next_wrapper";
import { Row, Col } from "../ui";
import { NumericSetting } from "../session_keys";
2019-05-21 19:04:30 -06:00
import {
NumberConfigKey as WebAppNumberConfigKey
} from "farmbot/dist/resources/configs/web_app";
interface LengthInputProps {
value: number;
label: string;
setting: WebAppNumberConfigKey;
dispatch: Function;
}
const LengthInput = (props: LengthInputProps) =>
<Row>
2019-06-14 16:59:11 -06:00
<Col xs={4}>
2019-05-21 19:04:30 -06:00
<label style={{ float: "right" }}>{t(props.label)}</label>
</Col>
2019-06-14 16:59:11 -06:00
<Col xs={5}>
2019-05-21 19:04:30 -06:00
<input
type="number"
2020-02-28 09:34:28 -07:00
name={props.setting}
2019-06-05 14:48:18 -06:00
value={"" + props.value}
2019-05-21 19:04:30 -06:00
onChange={e => props.dispatch(setWebAppConfigValue(
props.setting, e.currentTarget.value))} />
</Col>
</Row>;
2019-06-14 16:59:11 -06:00
export interface MapSizeInputsProps {
2019-06-10 15:43:11 -06:00
dispatch: Function;
getConfigValue: GetWebAppConfigValue;
}
export const MapSizeInputs = (props: MapSizeInputsProps) =>
<div className="map-size-inputs">
<LengthInput
value={parseInt("" + props.getConfigValue(NumericSetting.map_size_x))}
label={t("x (mm)")}
setting={NumericSetting.map_size_x}
dispatch={props.dispatch} />
<LengthInput
value={parseInt("" + props.getConfigValue(NumericSetting.map_size_y))}
label={t("y (mm)")}
setting={NumericSetting.map_size_y}
dispatch={props.dispatch} />
</div>;