Disable speed inputs

This commit is contained in:
Rick Carlino 2017-12-12 14:41:04 -06:00
parent 33b119828c
commit 1b4863f4d4
7 changed files with 52 additions and 31 deletions

View file

@ -2,26 +2,18 @@ import * as React from "react";
import { t } from "i18next";
import { Row, Col } from "../ui";
import { AxisDisplayGroupProps } from "./interfaces";
import { isUndefined } from "lodash";
import { isNumber } from "lodash";
const Axis = ({ val }: { val: number | undefined }) => <Col xs={3}>
<input disabled value={isNumber(val) ? val : "---"} />
</Col>;
export let AxisDisplayGroup = ({ position, label }: AxisDisplayGroupProps) => {
const { x, y, z } = position;
return <Row>
<Col xs={3}>
<input
disabled
value={isUndefined(x) ? "---" : x} />
</Col>
<Col xs={3}>
<input
disabled
value={isUndefined(y) ? "---" : y} />
</Col>
<Col xs={3}>
<input
disabled
value={isUndefined(z) ? "---" : z} />
</Col>
<Axis val={x} />
<Axis val={y} />
<Axis val={z} />
<Col xs={3}>
<label>
{t(label)}

View file

@ -2,6 +2,7 @@ import { versionOK, botReducer, initialState } from "../reducer";
import { Actions } from "../../constants";
import { ControlPanelState } from "../interfaces";
import * as _ from "lodash";
import { defensiveClone } from "../../util";
describe("safeStringFetch", () => {
it("Checks the correct version on update", () => {
@ -98,4 +99,21 @@ describe("botRedcuer", () => {
expect(botReducer(initialState(), action).encoder_visibility.scaled_encoders)
.toBe(!initialState().encoder_visibility.scaled_encoders);
});
it("resets hardware state when transitioning into mainenance mode.", () => {
const state = initialState();
const payload = defensiveClone(state.hardware);
payload.informational_settings.sync_status = "maintenance";
payload.location_data.position.x = -1;
payload.location_data.position.y = -1;
payload.location_data.position.z = -1;
const action = { type: Actions.BOT_CHANGE, payload };
// Make the starting state different than initialState();
const result = botReducer(state, action);
// Resets .hardware to initialState()
expect(result.hardware.location_data.position)
.toEqual(initialState().hardware.location_data.position);
expect(result.hardware.informational_settings.sync_status)
.toBe("maintenance");
});
});

View file

@ -142,9 +142,20 @@ export let botReducer = generateReducer<BotState>(initialState())
.add<HardwareState>(Actions.BOT_CHANGE, (state, { payload }) => {
state.hardware = payload;
const { informational_settings } = state.hardware;
const syncStatus = informational_settings.sync_status;
/** USE CASE: You reboot the bot. The old state values are still hanging
* around. You think the bot is broke, but it isn't. The FE is holding on
* to stale data. */
if (syncStatus === "maintenance") {
const emptyState = initialState();
state.hardware = emptyState.hardware;
state.hardware.informational_settings.sync_status = "maintenance";
return state;
}
const info = {
consistent: state.consistent,
syncStatus: informational_settings.sync_status,
syncStatus,
fbosVersion: informational_settings.controller_version,
autoSync: !!state.hardware.configuration.auto_sync
};

View file

@ -55,8 +55,8 @@ describe("<TileMoveAbsolute/>", () => {
const inputs = block.find("input");
const labels = block.find("label");
const buttons = block.find("button");
expect(inputs.length).toEqual(8);
expect(labels.length).toEqual(8);
expect(inputs.length).toEqual(7);
expect(labels.length).toEqual(7);
expect(buttons.length).toEqual(1);
expect(inputs.first().props().placeholder).toEqual("Move Absolute");
expect(labels.at(0).text().toLowerCase()).toEqual("import coordinates from");
@ -64,10 +64,10 @@ describe("<TileMoveAbsolute/>", () => {
checkField(block, 1, "x (mm)", "1");
checkField(block, 2, "y (mm)", "2");
checkField(block, 3, "z (mm)", "3");
checkField(block, 4, "speed (%)", 100);
checkField(block, 5, "x-offset", "4");
checkField(block, 6, "y-offset", "5");
checkField(block, 7, "z-offset", "6");
// checkField(block, 4, "speed (%)", 100);
checkField(block, 4, "x-offset", "4");
checkField(block, 5, "y-offset", "5");
checkField(block, 6, "z-offset", "6");
});
it("retrieves a tool", () => {

View file

@ -30,8 +30,8 @@ describe("<TileMoveRelative/>", () => {
const block = bootstrapTest().component;
const inputs = block.find("input");
const labels = block.find("label");
expect(inputs.length).toEqual(5);
expect(labels.length).toEqual(4);
expect(inputs.length).toEqual(4);
expect(labels.length).toEqual(3);
expect(inputs.first().props().placeholder).toEqual("Move Relative");
expect(labels.at(0).text().toLowerCase()).toEqual("x (mm)");
expect(inputs.at(1).props().value).toEqual(1);
@ -39,7 +39,7 @@ describe("<TileMoveRelative/>", () => {
expect(inputs.at(2).props().value).toEqual(2);
expect(labels.at(2).text().toLowerCase()).toEqual("z (mm)");
expect(inputs.at(3).props().value).toEqual(3);
expect(labels.at(3).text().toLowerCase()).toEqual("speed (%)");
expect(inputs.at(4).props().value).toEqual(100);
// expect(labels.at(3).text().toLowerCase()).toEqual("speed (%)");
// expect(inputs.at(4).props().value).toEqual(100);
});
});

View file

@ -186,7 +186,7 @@ export class TileMoveAbsolute extends Component<StepParams, MoveAbsState> {
</InputBox>
</Col>
<Col xs={3}>
<label>
{/*<label>
{t("Speed (%)")}
</label>
<StepInputBox
@ -194,7 +194,7 @@ export class TileMoveAbsolute extends Component<StepParams, MoveAbsState> {
step={this.step}
index={index}
dispatch={this.props.dispatch}
sequence={this.props.currentSequence} />
sequence={this.props.currentSequence} />*/}
</Col>
</Row>
<Row>

View file

@ -57,12 +57,12 @@ export function TileMoveRelative({ dispatch, currentStep, index, currentSequence
field="z" />
</div>
<div className="col-xs-6 col-md-3">
<label>{t("Speed (%)")}</label>
{/* <label>{t("Speed (%)")}</label>
<StepInputBox dispatch={dispatch}
step={currentStep}
sequence={currentSequence}
index={index}
field="speed" />
field="speed" /> */}
</div>
</div>
</div>