load camera selection setting
parent
4a4f67fe0d
commit
f2459d717e
|
@ -32,14 +32,33 @@ const CAMERA_CHOICES = [
|
|||
{ label: "Raspberry Pi Camera", value: "RPI" }
|
||||
];
|
||||
|
||||
const CAMERA_CHOICES_DDI = {
|
||||
[CAMERA_CHOICES[0].value]: {
|
||||
label: CAMERA_CHOICES[0].label,
|
||||
value: CAMERA_CHOICES[0].value
|
||||
},
|
||||
[CAMERA_CHOICES[1].value]: {
|
||||
label: CAMERA_CHOICES[1].label,
|
||||
value: CAMERA_CHOICES[1].value
|
||||
}
|
||||
};
|
||||
|
||||
export class FarmbotOsSettings
|
||||
extends React.Component<FarmbotOsProps, FarmbotOsState> {
|
||||
|
||||
state: FarmbotOsState = {
|
||||
cameraStatus: "",
|
||||
selectedCamera: undefined
|
||||
cameraStatus: ""
|
||||
};
|
||||
|
||||
selectedCamera(): DropDownItem | undefined {
|
||||
let cameraSelection = undefined;
|
||||
let camera = this.props.bot.hardware.user_env["camera"];
|
||||
if (camera) {
|
||||
cameraSelection = CAMERA_CHOICES_DDI[JSON.parse(camera)];
|
||||
}
|
||||
return cameraSelection;
|
||||
}
|
||||
|
||||
changeBot = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
let { account, dispatch } = this.props;
|
||||
dispatch(edit(account, { name: e.currentTarget.value }));
|
||||
|
@ -61,7 +80,6 @@ export class FarmbotOsSettings
|
|||
.current
|
||||
.setUserEnv(message)
|
||||
.then(() => {
|
||||
this.setState({ selectedCamera });
|
||||
success(t("Successfully configured camera!"));
|
||||
})
|
||||
.catch(() => error(t("An error occurred during configuration.")));
|
||||
|
@ -245,7 +263,7 @@ export class FarmbotOsSettings
|
|||
<FBSelect
|
||||
allowEmpty={true}
|
||||
list={CAMERA_CHOICES}
|
||||
selectedItem={this.state.selectedCamera}
|
||||
selectedItem={this.selectedCamera()}
|
||||
placeholder="Select a camera..."
|
||||
onChange={this.sendOffConfig} />
|
||||
</div>
|
||||
|
|
|
@ -16,7 +16,6 @@ import {
|
|||
import { RestResources } from "../resources/interfaces";
|
||||
import { TaggedUser } from "../resources/tagged_resources";
|
||||
import { WD_ENV } from "../farmware/weed_detector/remote_env/interfaces";
|
||||
import { DropDownItem } from "../ui/index";
|
||||
|
||||
export interface Props {
|
||||
auth: AuthState | undefined;
|
||||
|
@ -98,7 +97,6 @@ export interface FarmbotOsProps {
|
|||
}
|
||||
|
||||
export interface FarmbotOsState {
|
||||
selectedCamera: DropDownItem | undefined;
|
||||
cameraStatus: "" | "sending" | "done" | "error";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue