Farmbot-Web-App/frontend/devices/components/hardware_settings/error_handling.tsx

59 lines
2.2 KiB
TypeScript
Raw Normal View History

2020-02-15 11:29:09 -07:00
import * as React from "react";
import { NumericMCUInputGroup } from "../numeric_mcu_input_group";
2020-02-18 12:21:09 -07:00
import { ToolTips, DeviceSetting } from "../../../constants";
2020-02-15 11:29:09 -07:00
import { ErrorHandlingProps } from "../interfaces";
import { Header } from "./header";
import { Collapse } from "@blueprintjs/core";
import { McuInputBox } from "../mcu_input_box";
import { settingToggle } from "../../actions";
import { SingleSettingRow } from "./single_setting_row";
import { ToggleButton } from "../../../controls/toggle_button";
2020-02-18 12:21:09 -07:00
import { Highlight } from "../maybe_highlight";
2020-02-28 09:50:14 -07:00
import { SpacePanelHeader } from "./space_panel_header";
2020-02-15 11:29:09 -07:00
export function ErrorHandling(props: ErrorHandlingProps) {
const { error_handling } = props.controlPanelState;
const { dispatch, sourceFwConfig } = props;
const eStopOnMoveError = sourceFwConfig("param_e_stop_on_mov_err");
2020-02-18 12:21:09 -07:00
return <Highlight className={"section"}
settingName={DeviceSetting.errorHandling}>
2020-02-15 11:29:09 -07:00
<Header
expanded={error_handling}
2020-02-18 12:21:09 -07:00
title={DeviceSetting.errorHandling}
panel={"error_handling"}
2020-02-15 11:29:09 -07:00
dispatch={dispatch} />
<Collapse isOpen={!!error_handling}>
2020-02-28 09:50:14 -07:00
<div className="label-headings">
<SpacePanelHeader />
</div>
2020-02-15 11:29:09 -07:00
<NumericMCUInputGroup
2020-02-18 12:21:09 -07:00
label={DeviceSetting.timeoutAfter}
2020-02-15 11:29:09 -07:00
tooltip={ToolTips.TIMEOUT_AFTER}
x={"movement_timeout_x"}
y={"movement_timeout_y"}
z={"movement_timeout_z"}
sourceFwConfig={sourceFwConfig}
dispatch={dispatch} />
<SingleSettingRow settingType="input"
2020-02-18 12:21:09 -07:00
label={DeviceSetting.maxRetries}
2020-02-15 11:29:09 -07:00
tooltip={ToolTips.MAX_MOVEMENT_RETRIES}>
<McuInputBox
setting="param_mov_nr_retry"
sourceFwConfig={sourceFwConfig}
dispatch={dispatch} />
</SingleSettingRow>
<SingleSettingRow settingType="button"
2020-02-18 12:21:09 -07:00
label={DeviceSetting.estopOnMovementError}
2020-02-15 11:29:09 -07:00
tooltip={ToolTips.E_STOP_ON_MOV_ERR}>
<ToggleButton
toggleValue={eStopOnMoveError.value}
dim={!eStopOnMoveError.consistent}
toggleAction={() => dispatch(
settingToggle("param_e_stop_on_mov_err", sourceFwConfig))} />
</SingleSettingRow>
</Collapse>
2020-02-18 12:21:09 -07:00
</Highlight>;
2020-02-15 11:29:09 -07:00
}