Skip to content

Commit

Permalink
add OTA time step to setup wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielburnworth committed Jun 19, 2024
1 parent 0643d76 commit 4b83166
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 22 deletions.
9 changes: 9 additions & 0 deletions frontend/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,15 @@ export namespace SetupWizardContent {
re-flashing the SD card via Etcher. If possible, ensure line-of-sight
between devices when trying to connect.`);

export const AUTO_UPDATE =
trim(`Set the time you wish for FarmBot to automatically download and
install updates when available. During this time FarmBot will reboot
to apply the update, so you should never schedule any events to occur
during the same hour. We recommend selecting 3 AM.`);

export const AUTO_UPDATE_QUESTION =
trim(`Did you select a time when you will not need to use your FarmBot?`);

export const MAP_ORIENTATION =
trim(`Watch the video below showing how to match the virtual FarmBot
map to your real life FarmBot. The relevant controls are available
Expand Down
4 changes: 3 additions & 1 deletion frontend/settings/__tests__/default_values_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { fakeState } from "../../__test_support__/fake_state";
import { buildResourceIndex } from "../../__test_support__/resource_index_builder";
import { fakeFbosConfig, fakeWebAppConfig } from "../../__test_support__/fake_state/resources";
import {
fakeFbosConfig, fakeWebAppConfig,
} from "../../__test_support__/fake_state/resources";
const mockState = fakeState();
const config = fakeWebAppConfig();
config.body.highlight_modified_settings = true;
Expand Down
14 changes: 14 additions & 0 deletions frontend/wizard/__tests__/checks_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
} from "../../__test_support__/resource_index_builder";
import {
AssemblyDocs,
AutoUpdate,
AxisActions,
BootSequence,
CameraCalibrationCard,
Expand Down Expand Up @@ -478,6 +479,19 @@ describe("<Connectivity />", () => {
});
});

describe("<AutoUpdate />", () => {
it("renders OTA time selector", () => {
const p = fakeProps();
const config = fakeFbosConfig();
config.body.os_auto_update = true;
const device = fakeDevice();
device.body.ota_hour = 1;
p.resources = buildResourceIndex([config, device]).index;
const wrapper = mount(<AutoUpdate {...p} />);
expect(wrapper.text()).toEqual("1:00 AM");
});
});

describe("<DisableStallDetection />", () => {
const state = fakeState();
const config = fakeFirmwareConfig();
Expand Down
19 changes: 17 additions & 2 deletions frontend/wizard/checks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
selectAllFarmwareEnvs,
selectAllImages, selectAllLogs, selectAllPeripherals, selectAllSensors,
selectAllTools,
maybeGetTimeSettings,
} from "../resources/selectors";
import { last, some, uniq } from "lodash";
import {
Expand All @@ -25,7 +26,7 @@ import {
} from "../settings/fbos_settings/fbos_details";
import { ExternalUrl } from "../external_urls";
import { getFbosConfig, getFirmwareConfig } from "../resources/getters";
import { validFwConfig } from "../util";
import { validFbosConfig, validFwConfig } from "../util";
import { validBotLocationData } from "../util/location";
import {
getFwHardwareValue, isExpress,
Expand All @@ -43,7 +44,9 @@ import { FirmwareHardware, TaggedLog, Xyz } from "farmbot";
import { ConnectivityDiagram } from "../devices/connectivity/diagram";
import { Diagnosis } from "../devices/connectivity/diagnosis";
import { connectivityData } from "../devices/connectivity/generate_data";
import { sourceFwConfigValue } from "../settings/source_config_value";
import {
sourceFbosConfigValue, sourceFwConfigValue,
} from "../settings/source_config_value";
import {
emergencyUnlock, findAxisLength, findHome, setHome, settingToggle,
} from "../devices/actions";
Expand Down Expand Up @@ -99,6 +102,7 @@ import {
import { WaterFlowRateInput } from "../tools/edit_tool";
import { RPI_OPTIONS } from "../settings/fbos_settings/rpi_model";
import { BoxTop } from "../settings/pin_bindings/box_top";
import { OtaTimeSelector } from "../settings/fbos_settings/ota_time_selector";

export const Language = (props: WizardStepComponentProps) => {
const user = getUserAccountSettings(props.resources);
Expand Down Expand Up @@ -461,6 +465,17 @@ export const Connectivity = (props: WizardStepComponentProps) => {
</div>;
};

export const AutoUpdate = (props: WizardStepComponentProps) => {
return <OtaTimeSelector
dispatch={props.dispatch}
device={getDeviceAccountSettings(props.resources)}
timeSettings={maybeGetTimeSettings(props.resources)}
sourceFbosConfig={sourceFbosConfigValue(
validFbosConfig(getFbosConfig(props.resources)),
props.bot.hardware.configuration)}
/>;
};

export const InvertJogButton = (axis: Xyz) =>
(props: WizardOutcomeComponentProps) => {
const setting: Record<Xyz, BooleanWebAppConfigKey> = {
Expand Down
50 changes: 31 additions & 19 deletions frontend/wizard/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
DownloadOS,
DownloadImager,
Language,
AutoUpdate,
} from "./checks";
import { TaggedWizardStepResult } from "farmbot";
import {
Expand Down Expand Up @@ -128,6 +129,7 @@ export enum WizardStepSlug {
configuratorBrowser = "configuratorBrowser",
configuratorSteps = "configuratorSteps",
connection = "connection",
autoUpdate = "autoUpdate",
mapOrientation = "mapOrientation",
xMotor = "xMotor",
yMotor = "yMotor",
Expand Down Expand Up @@ -480,6 +482,16 @@ export const WIZARD_STEPS = (props: WizardStepDataProps): WizardSteps => {
},
],
},
{
section: WizardSectionSlug.connectivity,
slug: WizardStepSlug.autoUpdate,
title: t("Auto update"),
content: SetupWizardContent.AUTO_UPDATE,
component: AutoUpdate,
question: t(SetupWizardContent.AUTO_UPDATE_QUESTION),
outcomes: [
],
},
{
section: WizardSectionSlug.map,
slug: WizardStepSlug.mapOrientation,
Expand Down Expand Up @@ -719,25 +731,30 @@ export const WIZARD_STEPS = (props: WizardStepDataProps): WizardSteps => {
},
{
section: WizardSectionSlug.home,
slug: WizardStepSlug.xAxisFindHome,
title: t("Home X"),
slug: WizardStepSlug.zAxisFindHome,
title: t("Home Z"),
prerequisites: [botOnlineReq],
content: t(SetupWizardContent.FIND_HOME, { axis: "X" }),
component: AxisActions,
question: SetupWizardContent.HOME,
content: isExpress(firmwareHardware)
? SetupWizardContent.FIND_HOME_Z_EXPRESS
: t(SetupWizardContent.FIND_HOME, { axis: "Z" }),
component: isExpress(firmwareHardware) ? undefined : AxisActions,
controlsCheckOptions: isExpress(firmwareHardware) ? {} : undefined,
question: isExpress(firmwareHardware)
? SetupWizardContent.HOME_Z_EXPRESS
: SetupWizardContent.HOME,
outcomes: [
{
slug: "notAtHome",
description: t("The axis is not at the home position"),
tips: t(SetupWizardContent.HOME_AXIS, { axis: "x" }),
tips: t(SetupWizardContent.HOME_AXIS, { axis: "z" }),
component: CheckForResistance,
controlsCheckOptions: { home: true },
},
{
slug: "notZero",
description: t("The coordinate is not zero"),
tips: "",
component: SetHome("x"),
component: SetHome("z"),
},
],
},
Expand Down Expand Up @@ -767,30 +784,25 @@ export const WIZARD_STEPS = (props: WizardStepDataProps): WizardSteps => {
},
{
section: WizardSectionSlug.home,
slug: WizardStepSlug.zAxisFindHome,
title: t("Home Z"),
slug: WizardStepSlug.xAxisFindHome,
title: t("Home X"),
prerequisites: [botOnlineReq],
content: isExpress(firmwareHardware)
? SetupWizardContent.FIND_HOME_Z_EXPRESS
: t(SetupWizardContent.FIND_HOME, { axis: "Z" }),
component: isExpress(firmwareHardware) ? undefined : AxisActions,
controlsCheckOptions: isExpress(firmwareHardware) ? {} : undefined,
question: isExpress(firmwareHardware)
? SetupWizardContent.HOME_Z_EXPRESS
: SetupWizardContent.HOME,
content: t(SetupWizardContent.FIND_HOME, { axis: "X" }),
component: AxisActions,
question: SetupWizardContent.HOME,
outcomes: [
{
slug: "notAtHome",
description: t("The axis is not at the home position"),
tips: t(SetupWizardContent.HOME_AXIS, { axis: "z" }),
tips: t(SetupWizardContent.HOME_AXIS, { axis: "x" }),
component: CheckForResistance,
controlsCheckOptions: { home: true },
},
{
slug: "notZero",
description: t("The coordinate is not zero"),
tips: "",
component: SetHome("z"),
component: SetHome("x"),
},
],
},
Expand Down

0 comments on commit 4b83166

Please sign in to comment.