Factor down farmbot_os_settings.tsx
parent
ad86e86c3b
commit
4baf9616dd
|
@ -8,12 +8,7 @@ Bundler.require(:default, Rails.env)
|
|||
|
||||
module FarmBot
|
||||
class Application < Rails::Application
|
||||
# if ENV["CLOUDAMQP_URL"]
|
||||
# config.active_job.queue_adapter = :sneakers
|
||||
# Sneakers.configure(connection: Transport.connection)
|
||||
# else
|
||||
config.active_job.queue_adapter = :delayed_job
|
||||
# end
|
||||
config.active_job.queue_adapter = :delayed_job
|
||||
config.action_dispatch.perform_deep_munge = false
|
||||
I18n.enforce_available_locales = false
|
||||
config.generators do |g|
|
||||
|
|
|
@ -8,10 +8,10 @@ const mockOk = jest.fn();
|
|||
jest.mock("farmbot-toastr", () => ({ success: mockOk }));
|
||||
|
||||
import * as React from "react";
|
||||
import { OsUpdateButton } from "../os_update_button";
|
||||
import { mount } from "enzyme";
|
||||
import { bot } from "../../../__test_support__/fake_state/bot";
|
||||
import { getDevice } from "../../../device";
|
||||
import { OsUpdateButton } from "../fbos_settings/os_update_button";
|
||||
|
||||
describe("<OsUpdateButton/>", () => {
|
||||
beforeEach(function () {
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
import * as React from "react";
|
||||
import { t } from "i18next";
|
||||
import { FarmbotOsProps } from "../interfaces";
|
||||
import {
|
||||
saveAccountChanges,
|
||||
reboot,
|
||||
powerOff,
|
||||
factoryReset
|
||||
} from "../actions";
|
||||
import { OsUpdateButton } from "./os_update_button";
|
||||
import { saveAccountChanges } from "../actions";
|
||||
import {
|
||||
Widget,
|
||||
WidgetHeader,
|
||||
|
@ -24,6 +18,10 @@ import { timezoneMismatch } from "../timezones/guess_timezone";
|
|||
import { LastSeen } from "./last_seen_widget";
|
||||
import { CameraSelection } from "./camera_selection";
|
||||
import { BoardType } from "./board_type";
|
||||
import { AutoUpdateRow } from "./fbos_settings/auto_update_row";
|
||||
import { RestartRow } from "./fbos_settings/restart_row";
|
||||
import { ShutdownRow } from "./fbos_settings/shutdown_row";
|
||||
import { FactoryResetRow } from "./fbos_settings/factory_reset_row";
|
||||
|
||||
export class FarmbotOsSettings
|
||||
extends React.Component<FarmbotOsProps> {
|
||||
|
@ -65,6 +63,9 @@ export class FarmbotOsSettings
|
|||
|
||||
render() {
|
||||
const { account } = this.props;
|
||||
const { hardware } = this.props.bot;
|
||||
const { firmware_version } = hardware.informational_settings;
|
||||
const { controller_version } = hardware.informational_settings;
|
||||
|
||||
return <Widget className="device-widget">
|
||||
<form onSubmit={this.saveBot.bind(this)}>
|
||||
|
@ -107,95 +108,12 @@ export class FarmbotOsSettings
|
|||
<MustBeOnline
|
||||
status={this.props.bot.hardware.informational_settings.sync_status}
|
||||
lockOpen={process.env.NODE_ENV !== "production"}>
|
||||
<Row>
|
||||
<Col xs={2}>
|
||||
<label>
|
||||
{t("FARMBOT OS")}
|
||||
</label>
|
||||
</Col>
|
||||
<Col xs={3}>
|
||||
<p>
|
||||
{t("Version {{ version }}", {
|
||||
version:
|
||||
this
|
||||
.props
|
||||
.bot
|
||||
.hardware
|
||||
.informational_settings.controller_version
|
||||
|| t(" unknown (offline)")
|
||||
}
|
||||
)}
|
||||
</p>
|
||||
</Col>
|
||||
<Col xs={7}>
|
||||
<OsUpdateButton bot={this.props.bot} />
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col xs={2}>
|
||||
<label>
|
||||
{t("RESTART FARMBOT")}
|
||||
</label>
|
||||
</Col>
|
||||
<Col xs={7}>
|
||||
<p>
|
||||
{t(Content.RESTART_FARMBOT)}
|
||||
</p>
|
||||
</Col>
|
||||
<Col xs={3}>
|
||||
<button
|
||||
className="fb-button yellow"
|
||||
type="button"
|
||||
onClick={reboot}>
|
||||
{t("RESTART")}
|
||||
</button>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col xs={2}>
|
||||
<label>
|
||||
{t("SHUTDOWN FARMBOT")}
|
||||
</label>
|
||||
</Col>
|
||||
<Col xs={7}>
|
||||
<p>
|
||||
{t(Content.SHUTDOWN_FARMBOT)}
|
||||
</p>
|
||||
</Col>
|
||||
<Col xs={3}>
|
||||
<button
|
||||
className="fb-button red"
|
||||
type="button"
|
||||
onClick={powerOff}>
|
||||
{t("SHUTDOWN")}
|
||||
</button>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col xs={2}>
|
||||
<label>
|
||||
{t("Factory Reset")}
|
||||
</label>
|
||||
</Col>
|
||||
<Col xs={7}>
|
||||
<p>
|
||||
{t(Content.FACTORY_RESET_WARNING)}
|
||||
</p>
|
||||
</Col>
|
||||
<Col xs={3}>
|
||||
<button
|
||||
className="fb-button red"
|
||||
type="button"
|
||||
onClick={factoryReset}>
|
||||
{t("FACTORY RESET")}
|
||||
</button>
|
||||
</Col>
|
||||
</Row>
|
||||
<CameraSelection
|
||||
env={this.props.bot.hardware.user_env} />
|
||||
<BoardType
|
||||
firmwareVersion={this.props.bot.hardware
|
||||
.informational_settings.firmware_version} />
|
||||
<AutoUpdateRow bot={this.props.bot} controller_version={controller_version} />
|
||||
<RestartRow />
|
||||
<ShutdownRow />
|
||||
<FactoryResetRow />
|
||||
<CameraSelection env={this.props.bot.hardware.user_env} />
|
||||
<BoardType firmwareVersion={firmware_version} />
|
||||
</MustBeOnline>
|
||||
</WidgetBody>
|
||||
</form>
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import * as React from "react";
|
||||
import { Row, Col } from "../../../ui/index";
|
||||
import { t } from "i18next";
|
||||
import { OsUpdateButton } from "./os_update_button";
|
||||
import { BotState } from "../../interfaces";
|
||||
|
||||
interface AutoUpdateRowProps {
|
||||
controller_version: string | undefined;
|
||||
bot: BotState;
|
||||
}
|
||||
|
||||
export function AutoUpdateRow(props: AutoUpdateRowProps) {
|
||||
const version = props.controller_version || t(" unknown (offline)");
|
||||
return <Row>
|
||||
<Col xs={2}>
|
||||
<label>
|
||||
{t("FARMBOT OS")}
|
||||
</label>
|
||||
</Col>
|
||||
<Col xs={3}>
|
||||
<p>
|
||||
{t("Version {{ version }}", { version })}
|
||||
</p>
|
||||
</Col>
|
||||
<Col xs={7}>
|
||||
<OsUpdateButton bot={props.bot} />
|
||||
</Col>
|
||||
</Row>;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
import * as React from "react";
|
||||
import { Row, Col } from "../../../ui/index";
|
||||
import { t } from "i18next";
|
||||
import { Content } from "../../../constants";
|
||||
import { factoryReset } from "../../actions";
|
||||
|
||||
export function FactoryResetRow() {
|
||||
return <Row>
|
||||
<Col xs={2}>
|
||||
<label>
|
||||
{t("Factory Reset")}
|
||||
</label>
|
||||
</Col>
|
||||
<Col xs={7}>
|
||||
<p>
|
||||
{t(Content.FACTORY_RESET_WARNING)}
|
||||
</p>
|
||||
</Col>
|
||||
<Col xs={3}>
|
||||
<button
|
||||
className="fb-button red"
|
||||
type="button"
|
||||
onClick={factoryReset}>
|
||||
{t("FACTORY RESET")}
|
||||
</button>
|
||||
</Col>
|
||||
</Row>;
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
import * as React from "react";
|
||||
import { BotProp } from "../interfaces";
|
||||
import { t } from "i18next";
|
||||
import { ToggleButton } from "../../controls/toggle_button";
|
||||
import { checkControllerUpdates, updateConfig } from "../actions";
|
||||
import { isUndefined, noop } from "lodash";
|
||||
import { semverCompare, SemverResult } from "../../util";
|
||||
import * as _ from "lodash";
|
||||
import { Row, Col } from "../../ui/index";
|
||||
import { JobProgress, Configuration } from "farmbot/dist";
|
||||
import { SemverResult, semverCompare } from "../../../util";
|
||||
import { BotProp } from "../../interfaces";
|
||||
import { Row, Col } from "../../../ui/index";
|
||||
import { ToggleButton } from "../../../controls/toggle_button";
|
||||
import { updateConfig, checkControllerUpdates } from "../../actions";
|
||||
|
||||
export let OsUpdateButton = ({ bot }: BotProp) => {
|
||||
const osUpdateBool = bot.hardware.configuration.os_auto_update;
|
|
@ -0,0 +1,28 @@
|
|||
import * as React from "react";
|
||||
import { Row, Col } from "../../../ui/index";
|
||||
import { t } from "i18next";
|
||||
import { Content } from "../../../constants";
|
||||
import { reboot } from "../../actions";
|
||||
|
||||
export function RestartRow() {
|
||||
return <Row>
|
||||
<Col xs={2}>
|
||||
<label>
|
||||
{t("RESTART FARMBOT")}
|
||||
</label>
|
||||
</Col>
|
||||
<Col xs={7}>
|
||||
<p>
|
||||
{t(Content.RESTART_FARMBOT)}
|
||||
</p>
|
||||
</Col>
|
||||
<Col xs={3}>
|
||||
<button
|
||||
className="fb-button yellow"
|
||||
type="button"
|
||||
onClick={reboot}>
|
||||
{t("RESTART")}
|
||||
</button>
|
||||
</Col>
|
||||
</Row>;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
import * as React from "react";
|
||||
import { Row, Col } from "../../../ui/index";
|
||||
import { t } from "i18next";
|
||||
import { Content } from "../../../constants";
|
||||
import { powerOff } from "../../actions";
|
||||
|
||||
export function ShutdownRow() {
|
||||
return <Row>
|
||||
<Col xs={2}>
|
||||
<label>
|
||||
{t("SHUTDOWN FARMBOT")}
|
||||
</label>
|
||||
</Col>
|
||||
<Col xs={7}>
|
||||
<p>
|
||||
{t(Content.SHUTDOWN_FARMBOT)}
|
||||
</p>
|
||||
</Col>
|
||||
<Col xs={3}>
|
||||
<button
|
||||
className="fb-button red"
|
||||
type="button"
|
||||
onClick={powerOff}>
|
||||
{t("SHUTDOWN")}
|
||||
</button>
|
||||
</Col>
|
||||
</Row>;
|
||||
}
|
Loading…
Reference in New Issue