How to use farmbot - 10 common examples

To help you get started, we’ve selected a few farmbot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FarmBot / Farmbot-Web-App / frontend / demo / demo_iframe.tsx View on Github external
interface State {
  client?: MqttClient;
  error: Error | undefined;
  stage: string;
}

const VIDEO_URL =
  "https://cdn.shopify.com/s/files/1/2040/0289/files/Farm_Designer_Loop.mp4?9552037556691879018";
const PHONE_URL =
  "https://cdn.shopify.com/s/files/1/2040/0289/files/Controls.png?9668345515035078097";
const WS_CONFIG = {
  username: "farmbot_demo",
  password: "required, but not used.",
};

const SECRET = uuid().split("-").join("");
const MQTT_CHAN = "demos/" + SECRET;
const HTTP_URL = "/api/demo_account";
const EASTER_EGG = "BIRDS AREN'T REAL";
export const WAITING_ON_API = "Planting your demo garden...";

// APPLICATION CODE ==============================

export class DemoIframe extends React.Component<{}, State> {
  state: State = {
    client: undefined,
    error: undefined,
    stage: "DEMO THE APP"
  };

  setError = (error?: Error) => this.setState({ error });
github FarmBot / Farmbot-Web-App / frontend / api / __tests__ / crud_malformed_data_tests.ts View on Github external
it("rejects malformed API data", () => {
    const payload = {
      uuid: "",
      statusBeforeError: SpecialStatus.DIRTY,
      dispatch: jest.fn(),
      index: buildResourceIndex([fakePeripheral()]).index
    };
    payload.uuid = Object.keys(payload.index.all)[0];
    console.error = jest.fn();
    updateViaAjax(payload).catch(e => {
      expect("" + e).toEqual("Error: Just saved a malformed TR.");
      expect(console.error).toHaveBeenCalledTimes(1);
      expect(console.error).toHaveBeenCalledWith(
        expect.stringContaining("Peripheral"));
    });
  });
});
github FarmBot / Farmbot-Web-App / frontend / account / __tests__ / test_change_password.tsx View on Github external
it("doesn't fire maybeClearForm() if form is filled", () => {
    const { el, instance } = testCase();
    el.setState({
      status: SpecialStatus.DIRTY,
      form: { ...instance().state.form, password: "X" }
    });
    el.update();
    expect(instance().state.form.password).toEqual("X");
    expect(instance().state.status).toBe(SpecialStatus.DIRTY);
    instance().maybeClearForm();
    expect(instance().state.status).toBe(SpecialStatus.DIRTY);
    expect(instance().state.form.password).toEqual("X");
  });
github FarmBot / Farmbot-Web-App / frontend / account / __tests__ / test_change_password.tsx View on Github external
it("doesn't fire maybeClearForm() if form is filled", () => {
    const { el, instance } = testCase();
    el.setState({
      status: SpecialStatus.DIRTY,
      form: { ...instance().state.form, password: "X" }
    });
    el.update();
    expect(instance().state.form.password).toEqual("X");
    expect(instance().state.status).toBe(SpecialStatus.DIRTY);
    instance().maybeClearForm();
    expect(instance().state.status).toBe(SpecialStatus.DIRTY);
    expect(instance().state.form.password).toEqual("X");
  });
github FarmBot / Farmbot-Web-App / frontend / __test_support__ / user.ts View on Github external
import { User } from "farmbot/dist/resources/api_resources";
import { TaggedUser, SpecialStatus } from "farmbot";

export const user: User = {
  created_at: "2016-10-05T03:02:58.000Z",
  email: "farmbot1@farmbot.io",
  id: 2,
  name: "FarmBot 1",
  updated_at: "2017-08-04T19:53:29.724Z"
};

export const taggedUser: TaggedUser = {
  kind: "User",
  uuid: "1234-5678",
  specialStatus: SpecialStatus.SAVED,
  body: {
    created_at: "2016-10-05T03:02:58.000Z",
    email: "farmbot1@farmbot.io",
    id: 2,
    name: "FarmBot 1",
    updated_at: "2017-08-04T19:53:29.724Z"
  }
};
github FarmBot / Farmbot-Web-App / frontend / __test_support__ / fake_state / images.ts View on Github external
"device_id": 8,
      "attachment_processed_at": "2017-06-01T14:16:45.899Z",
      "updated_at": "2017-06-01T14:16:45.903Z",
      "created_at": "2017-06-01T14:14:22.747Z",
      "attachment_url": "imgur.com",
      "meta": {
        "x": 632,
        "y": 347,
        "z": 164
      }
    },
    "uuid": "Image.8.4"
  },
  {
    "kind": "Image",
    "specialStatus": SpecialStatus.SAVED,
    "body": {
      "id": 7,
      "device_id": 8,
      "attachment_processed_at": "2017-06-01T14:16:34.839Z",
      "updated_at": "2017-06-01T14:16:34.984Z",
      "created_at": "2017-06-01T14:14:22.726Z",
      "attachment_url": "imgur.com",
      "meta": {
        "x": 266,
        "y": 330,
        "z": 53
      }
    },
    "uuid": "Image.7.5"
  }
];
github FarmBot / Farmbot-Web-App / frontend / __test_support__ / resource_index_builder.ts View on Github external
};

export function fakeDevice(body: Partial = {}):
  TaggedDevice {

  return {
    "kind": "Device",
    "specialStatus": SpecialStatus.SAVED,
    "body": { ...DEFAULT_DEVICE_BODY, ...body },
    "uuid": "Device.415.0"
  };
}

const tr0: TaggedResource = {
  "kind": "Sequence",
  "specialStatus": SpecialStatus.SAVED,
  "body": {
    "id": 23,
    "name": "Goto 0, 0, 0",
    "color": "gray",
    "folder_id": undefined,
    "body": [
      {
        "kind": "move_absolute",
        "args": {
          "location": {
            "kind": "coordinate",
            "args": {
              "x": 0,
              "y": 0,
              "z": 0
            }
github FarmBot / Farmbot-Web-App / frontend / __test_support__ / fake_state / resources.ts View on Github external
export function fakePinBinding(): TaggedPinBinding {
  return fakeResource("PinBinding", {
    id: idCounter++,
    pin_num: 10,
    sequence_id: idCounter++,
    binding_type: PinBindingType.standard,
  });
}
github FarmBot / Farmbot-Web-App / src / draggable / actions.ts View on Github external
export function stepPut(value: Step,
  ev: React.DragEvent,
  intent: DataXferIntent,
  draggerId: number):
  ReduxAction {
  let uuid = id();
  console.log("dispatching step_put");
  ev.dataTransfer.setData(STEP_DATATRANSFER_IDENTIFER, uuid);
  return {
    type: Actions.PUT_DATA_XFER,
    payload: {
      intent,
      uuid,
      value,
      draggerId
    }
  };
}
github FarmBot / Farmbot-Web-App / frontend / tools / components / toolbay_slot_direction_selection.tsx View on Github external
[ToolPulloutDirection.NONE]:
    { label: t("None"), value: ToolPulloutDirection.NONE },
  [ToolPulloutDirection.POSITIVE_X]:
    { label: t("Positive X"), value: ToolPulloutDirection.POSITIVE_X },
  [ToolPulloutDirection.NEGATIVE_X]:
    { label: t("Negative X"), value: ToolPulloutDirection.NEGATIVE_X },
  [ToolPulloutDirection.POSITIVE_Y]:
    { label: t("Positive Y"), value: ToolPulloutDirection.POSITIVE_Y },
  [ToolPulloutDirection.NEGATIVE_Y]:
    { label: t("Negative Y"), value: ToolPulloutDirection.NEGATIVE_Y },
};

const DIRECTION_CHOICES: DropDownItem[] = [
  DIRECTION_CHOICES_DDI[ToolPulloutDirection.NONE],
  DIRECTION_CHOICES_DDI[ToolPulloutDirection.POSITIVE_X],
  DIRECTION_CHOICES_DDI[ToolPulloutDirection.NEGATIVE_X],
  DIRECTION_CHOICES_DDI[ToolPulloutDirection.POSITIVE_Y],
  DIRECTION_CHOICES_DDI[ToolPulloutDirection.NEGATIVE_Y],
];

export interface SlotDirectionSelectProps {
  dispatch: Function;
  slot: TaggedToolSlotPointer;
}

export function SlotDirectionSelect(props: SlotDirectionSelectProps) {
  const { dispatch, slot } = props;
  const direction = slot.body.pullout_direction;

  const changePulloutDirection = (selectedDirection: DropDownItem) => {
    const { value } = selectedDirection;
    dispatch(edit(slot, {