Farmbot-Web-App/frontend/controls/move/move.tsx

67 lines
2.7 KiB
TypeScript
Raw Normal View History

2018-07-31 18:48:43 -06:00
import * as React from "react";
import { Widget, WidgetBody, WidgetHeader } from "../../ui";
import { MustBeOnline } from "../../devices/must_be_online";
import { validBotLocationData } from "../../util";
import { toggleWebAppBool } from "../../config_storage/actions";
import { ToolTips } from "../../constants";
import { BooleanSetting } from "../../session_keys";
import { MoveProps } from "./interfaces";
import { MoveWidgetSettingsMenu } from "./settings_menu";
import { JogControlsGroup } from "./jog_controls_group";
import { BotPositionRows } from "./bot_position_rows";
2018-08-29 18:55:25 -06:00
import { MotorPositionPlot } from "./motor_position_plot";
import { Popover, Position } from "@blueprintjs/core";
2018-10-22 09:35:44 -06:00
import { BooleanConfigKey } from "farmbot/dist/resources/configs/web_app";
2019-04-02 13:59:37 -06:00
import { t } from "../../i18next_wrapper";
2020-03-13 15:06:40 -06:00
import { getStatus } from "../../connectivity/reducer_support";
2018-07-31 18:48:43 -06:00
export class Move extends React.Component<MoveProps, {}> {
2018-10-22 09:35:44 -06:00
toggle = (key: BooleanConfigKey) => (): void =>
2018-07-31 18:48:43 -06:00
this.props.dispatch(toggleWebAppBool(key));
2018-10-22 09:35:44 -06:00
getValue = (key: BooleanConfigKey): boolean =>
2018-07-31 18:48:43 -06:00
!!this.props.getWebAppConfigVal(BooleanSetting[key]);
render() {
2020-03-13 15:06:40 -06:00
const { bot } = this.props;
const { location_data, informational_settings } = bot.hardware;
2018-07-31 18:48:43 -06:00
const locationData = validBotLocationData(location_data);
2018-10-15 17:23:58 -06:00
return <Widget className="move-widget">
2018-07-31 18:48:43 -06:00
<WidgetHeader
title={t("Move")}
helpText={ToolTips.MOVE}>
2018-08-29 18:55:25 -06:00
<Popover position={Position.BOTTOM_RIGHT}>
<i className="fa fa-gear" />
<MoveWidgetSettingsMenu
toggle={this.toggle}
2020-02-07 16:06:40 -07:00
getValue={this.getValue}
firmwareHardware={this.props.firmwareHardware} />
2018-08-29 18:55:25 -06:00
</Popover>
2018-07-31 18:48:43 -06:00
</WidgetHeader>
<WidgetBody>
<MustBeOnline
lockOpen={process.env.NODE_ENV !== "production"}
2020-03-13 15:06:40 -06:00
networkState={getStatus(bot.connectivity.uptime["bot.mqtt"])}
2018-07-31 18:48:43 -06:00
syncStatus={informational_settings.sync_status}>
<JogControlsGroup
dispatch={this.props.dispatch}
2020-03-13 15:06:40 -06:00
stepSize={bot.stepSize}
2018-07-31 18:48:43 -06:00
botPosition={locationData.position}
getValue={this.getValue}
arduinoBusy={this.props.arduinoBusy}
2019-12-27 11:37:54 -07:00
env={this.props.env}
2018-07-31 18:48:43 -06:00
firmwareSettings={this.props.firmwareSettings} />
<BotPositionRows
locationData={locationData}
getValue={this.getValue}
arduinoBusy={this.props.arduinoBusy}
2020-02-07 16:06:40 -07:00
firmwareHardware={this.props.firmwareHardware} />
2018-07-31 18:48:43 -06:00
</MustBeOnline>
2018-08-29 18:55:25 -06:00
{this.props.getWebAppConfigVal(BooleanSetting.show_motor_plot) &&
<MotorPositionPlot locationData={locationData} />}
2018-07-31 18:48:43 -06:00
</WidgetBody>
</Widget>;
}
}