Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #2110

Merged
merged 1 commit into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ export enum DeviceSetting {
// FarmBot
farmbotSettings = `FarmBot`,
name = `name`,
orderNumber = `FarmBot Order Number`,
orderNumber = `Order Number`,
timezone = `timezone`,
time_zone = `time zone`,
camera = `camera`,
Expand Down
9 changes: 8 additions & 1 deletion frontend/css/farm_designer/farm_designer_panels.scss
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,10 @@
}
}
}
.move-to-button {
margin-top: 1rem;
margin-left: 1.5rem;
}
}

.soil-height-checkbox {
Expand Down Expand Up @@ -1037,14 +1041,17 @@
padding: 0;
margin-left: -1rem;
}
button {
button.blue {
margin-top: 0.5rem;
margin-right: 0.5rem;
height: 2.5rem;
.fa {
font-size: 1.5rem;
}
}
button.gray {
margin-top: 1rem;
}
}
.tool-direction-input,
.gantry-mounted-input {
Expand Down
1 change: 1 addition & 0 deletions frontend/css/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,7 @@ ul {
}
textarea {
height: 100% !important;
font-family: monospace;
}
}

Expand Down
6 changes: 3 additions & 3 deletions frontend/farm_events/add_farm_event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export class RawAddFarmEvent
render() {
const farmEvent = this.props.findFarmEventByUuid(this.state.uuid);
const panelName = "add-farm-event";
const executableOptions = this.props.executableOptions.filter(x => !x.heading);
return <DesignerPanel panelName={panelName} panel={Panel.FarmEvents}>
<DesignerPanelHeader
panelName={panelName}
Expand All @@ -112,12 +111,13 @@ export class RawAddFarmEvent
fieldGet={this.getField}
fieldSet={this.setField}
timeSettings={this.props.timeSettings}
executableOptions={executableOptions}
executableOptions={this.props.executableOptions}
executableSet={this.initFarmEvent}
executableGet={() => undefined}
dispatch={this.props.dispatch}
specialStatus={SpecialStatus.DIRTY}
onSave={() => error(executableOptions.length < 1
onSave={() => error(this.props.executableOptions
.filter(x => !x.heading).length < 1
? t(Content.MISSING_EXECUTABLE)
: t("Please select a sequence or regimen."))} />}
</DesignerPanelContent>
Expand Down
2 changes: 1 addition & 1 deletion frontend/farm_events/edit_fe_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ export const FarmEventForm = (props: FarmEventFormProps) => {
<label>
{t("Sequence or Regimen")}
</label>
{props.executableOptions.length < 1 &&
{props.executableOptions.filter(x => !x.heading).length < 1 &&
<Help
text={Content.MISSING_EXECUTABLE}
customIcon={"exclamation-triangle"} />}
Expand Down
25 changes: 21 additions & 4 deletions frontend/photos/images/__tests__/photos_test.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
const mockDevice = { takePhoto: jest.fn(() => Promise.resolve({})) };
const mockDevice = {
takePhoto: jest.fn(() => Promise.resolve({})),
moveAbsolute: jest.fn(() => Promise.resolve({})),
};
jest.mock("../../../device", () => ({ getDevice: () => mockDevice }));

jest.mock("../../../api/crud", () => ({ destroy: jest.fn() }));

import React from "react";
import { mount, shallow } from "enzyme";
import { Photos, PhotoFooter } from "../photos";
import { Photos, PhotoFooter, MoveToLocation } from "../photos";
import { JobProgress } from "farmbot";
import { fakeImages } from "../../../__test_support__/fake_state/images";
import { destroy } from "../../../api/crud";
import { clickButton } from "../../../__test_support__/helpers";
import { PhotosProps, PhotoFooterProps } from "../interfaces";
import { PhotosProps, PhotoFooterProps, MoveToLocationProps } from "../interfaces";
import { fakeTimeSettings } from "../../../__test_support__/fake_time_settings";
import { success, error } from "../../../toast/toast";
import { Content, ToolTips, Actions } from "../../../constants";
Expand All @@ -20,7 +23,7 @@ import {
import { fakeImageShowFlags } from "../../../__test_support__/fake_camera_data";
import { mockDispatch } from "../../../__test_support__/fake_dispatch";

describe("<Photos/>", () => {
describe("<Photos />", () => {
const fakeProps = (): PhotosProps => ({
images: [],
currentImage: undefined,
Expand Down Expand Up @@ -236,6 +239,7 @@ describe("<PhotoFooter />", () => {
timeSettings: fakeTimeSettings(),
flags: fakeImageShowFlags(),
size: { width: 0, height: 0 },
botOnline: true,
});

it("highlights map image", () => {
Expand All @@ -253,3 +257,16 @@ describe("<PhotoFooter />", () => {
});
});
});

describe("<MoveToLocation />", () => {
const fakeProps = (): MoveToLocationProps => ({
imageLocation: { x: 0, y: 0, z: 0 },
botOnline: true,
});

it("moves to location", () => {
const wrapper = mount(<MoveToLocation {...fakeProps()} />);
clickButton(wrapper, 0, "move farmbot to location");
expect(mockDevice.moveAbsolute).toHaveBeenCalledWith({ x: 0, y: 0, z: 0 });
});
});
8 changes: 7 additions & 1 deletion frontend/photos/images/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TaggedImage, JobProgress, SyncStatus } from "farmbot";
import { TaggedImage, JobProgress, SyncStatus, Xyz } from "farmbot";
import { NetworkState } from "../../connectivity/interfaces";
import { TimeSettings } from "../../interfaces";
import { UserEnv } from "../../devices/interfaces";
Expand Down Expand Up @@ -111,6 +111,12 @@ export interface PhotoFooterProps {
timeSettings: TimeSettings;
dispatch: Function;
flags: ImageShowFlags;
botOnline: boolean;
}

export interface MoveToLocationProps {
botOnline: boolean;
imageLocation: Record<Xyz, number | undefined>;
}

export interface PhotosComponentState {
Expand Down
39 changes: 32 additions & 7 deletions frontend/photos/images/photos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ import {
} from "./image_flipper";
import {
PhotosProps, PhotoButtonsProps, PhotoFooterProps, PhotosComponentState,
MoveToLocationProps,
} from "./interfaces";
import { timeFormatString } from "../../util";
import { destroy } from "../../api/crud";
import { downloadProgress } from "../../settings/fbos_settings/os_update_button";
import { startCase } from "lodash";
import { MustBeOnline } from "../../devices/must_be_online";
import { isNumber, startCase } from "lodash";
import { isBotOnline, MustBeOnline } from "../../devices/must_be_online";
import { t } from "../../i18next_wrapper";
import { cameraBtnProps } from "../capture_settings/camera_selection";
import { Overlay, Popover } from "@blueprintjs/core";
import { ImageShowMenu, ImageShowMenuTarget } from "./image_show_menu";
import { setShownMapImages } from "./actions";
import { TaggedImage, Xyz } from "farmbot";
import { MarkedSlider } from "../../ui";
import { takePhoto } from "../../devices/actions";
import { moveAbsolute, takePhoto } from "../../devices/actions";

const PhotoButtons = (props: PhotoButtonsProps) => {
const imageUploadJobProgress = downloadProgress(props.imageJobs[0]);
Expand Down Expand Up @@ -99,10 +100,15 @@ export const PhotoFooter = (props: PhotoFooterProps) => {
<div className={"image-metadata"}>
{image
? ["x", "y", "z"].map((axis: Xyz, index) =>
<div className={"meta-info"} key={index}>
<label>{startCase(axis)}:</label>
<span>{image.body.meta[axis] ?? "---"}</span>
</div>)
<Popover key={index}>
<div className={"meta-info"}>
<label>{startCase(axis)}:</label>
<span>{image.body.meta[axis] ?? "---"}</span>
</div>
<MoveToLocation
imageLocation={image.body.meta}
botOnline={props.botOnline} />
</Popover>)
: <div className={"meta-info"}>
<label>{t("Image")}:</label>
<span>{t("No meta data.")}</span>
Expand All @@ -111,6 +117,24 @@ export const PhotoFooter = (props: PhotoFooterProps) => {
</div>;
};

export const MoveToLocation = (props: MoveToLocationProps) =>
<button
className={"fb-button gray no-float"}
type={"button"}
disabled={!props.botOnline}
title={t("move to location")}
onClick={() =>
isNumber(props.imageLocation.x) &&
isNumber(props.imageLocation.y) &&
isNumber(props.imageLocation.z) &&
moveAbsolute({
x: props.imageLocation.x,
y: props.imageLocation.y,
z: props.imageLocation.z,
})}>
{t("Move FarmBot to location")}
</button>;

export class Photos extends React.Component<PhotosProps, PhotosComponentState> {
state: PhotosComponentState = {
crop: true, rotate: true, fullscreen: false,
Expand Down Expand Up @@ -193,6 +217,7 @@ export class Photos extends React.Component<PhotosProps, PhotosComponentState> {
flags={this.props.flags}
size={this.props.currentImageSize}
dispatch={this.props.dispatch}
botOnline={isBotOnline(this.props.syncStatus, this.props.botToMqttStatus)}
timeSettings={this.props.timeSettings} />
{this.props.images.length > 1 &&
<MarkedSlider
Expand Down
4 changes: 2 additions & 2 deletions frontend/plants/plant_panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ interface MoveToPlantProps {
}

const MoveToPlant = (props: MoveToPlantProps) =>
<button className="fb-button gray no-float"
<button className={"fb-button gray no-float"}
style={{ marginTop: "1rem" }}
title={t("Move to this plant")}
onClick={() =>
Expand Down Expand Up @@ -195,10 +195,10 @@ export function PlantPanel(props: PlantPanelProps) {
<ListItem name={t("Location")}>
<EditPlantLocation {...commonProps} plantLocation={{ x, y, z }} />
</ListItem>
<MoveToPlant x={x} y={y} z={z} dispatch={dispatch} />
<ListItem name={t("Size")}>
<EditPlantRadius {...commonProps} radius={info.radius} />
</ListItem>
<MoveToPlant x={x} y={y} z={z} dispatch={dispatch} />
<ListItem name={t("Status")}>
{(!inSavedGarden)
? <EditPlantStatus {...commonProps} plantStatus={plantStatus} />
Expand Down
1 change: 1 addition & 0 deletions frontend/points/__tests__/point_edit_actions_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe("<EditPointLocation />", () => {
const fakeProps = (): EditPointLocationProps => ({
updatePoint: jest.fn(),
pointLocation: { x: 1, y: 2, z: 0 },
botOnline: true,
});

it("edits location", () => {
Expand Down
1 change: 1 addition & 0 deletions frontend/points/__tests__/point_info_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe("<EditPoint />", () => {
const fakeProps = (): EditPointProps => ({
findPoint: fakePoint,
dispatch: jest.fn(),
botOnline: true,
});

it("redirects", () => {
Expand Down
23 changes: 12 additions & 11 deletions frontend/points/point_edit_actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const updatePoint =
export interface EditPointPropertiesProps {
point: TaggedGenericPointer | TaggedWeedPointer;
updatePoint(update: PointUpdate): void;
botOnline: boolean;
}

export interface AdditionalWeedPropertiesProps {
Expand All @@ -59,6 +60,7 @@ export const EditPointProperties = (props: EditPointPropertiesProps) =>
y: props.point.body.y,
z: props.point.body.z,
}}
botOnline={props.botOnline}
updatePoint={props.updatePoint} />
</ListItem>
<ListItem name={t("Size")}>
Expand Down Expand Up @@ -127,22 +129,12 @@ export const lookupPointSource = (createdBy: string | undefined) =>
SOURCE_LOOKUP()[createdBy || ""] || t("unknown");

export interface PointActionsProps {
x: number;
y: number;
z: number;
uuid: UUID;
dispatch: Function;
}

export const PointActions = ({ x, y, z, uuid, dispatch }: PointActionsProps) =>
export const PointActions = ({ uuid, dispatch }: PointActionsProps) =>
<div className={"point-actions"}>
<button
className="fb-button gray no-float"
type="button"
title={t("move to location")}
onClick={() => moveAbsolute({ x, y, z })}>
{t("Move Device to location")}
</button>
<button
className="fb-button red no-float"
title={t("delete")}
Expand Down Expand Up @@ -171,6 +163,7 @@ export const EditPointName = (props: EditPointNameProps) =>
export interface EditPointLocationProps {
updatePoint(update: PointUpdate): void;
pointLocation: Record<Xyz, number>;
botOnline: boolean;
}

export const EditPointLocation = (props: EditPointLocationProps) =>
Expand All @@ -187,6 +180,14 @@ export const EditPointLocation = (props: EditPointLocationProps) =>
[axis]: round(parseIntInput(e.currentTarget.value))
})} />
</Col>)}
<button
className={"fb-button gray no-float move-to-button"}
type={"button"}
disabled={!props.botOnline}
title={t("move to location")}
onClick={() => moveAbsolute(props.pointLocation)}>
{t("Move FarmBot to location")}
</button>
</Row>;

export interface EditPointRadiusProps {
Expand Down
11 changes: 5 additions & 6 deletions frontend/points/point_info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ import {
EditPointProperties, updatePoint, PointActions, lookupPointSource,
} from "./point_edit_actions";
import { ListItem } from "../plants/plant_panel";
import { isBotOnlineFromState } from "../devices/must_be_online";

export interface EditPointProps {
dispatch: Function;
findPoint(id: number): TaggedGenericPointer | undefined;
botOnline: boolean;
}

export const mapStateToProps = (props: Everything): EditPointProps => ({
dispatch: props.dispatch,
findPoint: id => maybeFindGenericPointerById(props.resources.index, id),
botOnline: isBotOnlineFromState(props.bot),
});

export class RawEditPoint extends React.Component<EditPointProps, {}> {
Expand Down Expand Up @@ -51,6 +54,7 @@ export class RawEditPoint extends React.Component<EditPointProps, {}> {
{this.point
? <div className={"point-panel-content-wrapper"}>
<EditPointProperties point={this.point}
botOnline={this.props.botOnline}
updatePoint={updatePoint(this.point, this.props.dispatch)} />
<ul className="meta">
{Object.entries(this.point.body.meta).map(([key, value]) => {
Expand All @@ -73,12 +77,7 @@ export class RawEditPoint extends React.Component<EditPointProps, {}> {
}
})}
</ul>
<PointActions
x={this.point.body.x}
y={this.point.body.y}
z={this.point.body.z}
uuid={this.point.uuid}
dispatch={this.props.dispatch} />
<PointActions uuid={this.point.uuid} dispatch={this.props.dispatch} />
</div>
: <span>{t("Redirecting")}...</span>}
</DesignerPanelContent>
Expand Down
2 changes: 1 addition & 1 deletion frontend/sequences/step_tiles/tile_assertion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ToolTips } from "../../constants";
import { LuaTextArea } from "./tile_lua_support";

export const TileAssertion = (props: StepParams<Assertion>) => {
const [monaco, setMonaco] = React.useState(true);
const [monaco, setMonaco] = React.useState(window.innerWidth > 450);
return <StepWrapper
className={"assertion-step"}
helpText={ToolTips.ASSERTION}
Expand Down
Loading