Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Commit

Permalink
adjust error configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcstiago committed Jun 25, 2019
1 parent 9711a80 commit a6301b4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
42 changes: 17 additions & 25 deletions unbrake-frontend/src/configuration/Configuration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { withStyles } from "@material-ui/core/styles";
import { Grid, Button } from "@material-ui/core";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { reduxForm } from "redux-form";
import { reduxForm, initialize } from "redux-form";
import Request from "../utils/Request";
import { API_URL_GRAPHQL } from "../utils/Constants";
import ConfigurationForm from "./ConfigurationForm";
Expand Down Expand Up @@ -74,7 +74,7 @@ class Configuration extends React.Component {
}

componentDidMount() {
const { configId } = this.props;
const { configId, sendMessage, dispatch } = this.props;

const url = `${API_URL_GRAPHQL}?query=query{configNotDefault{id, name}}`;
const method = "GET";
Expand All @@ -83,7 +83,16 @@ class Configuration extends React.Component {
if (data !== null) this.setState({ allConfiguration: data });
});

if (configId > invalidId) this.handleSelectConfig(configId);
if (configId > invalidId)
selectConfigurationDataBase(configId, sendMessage, dispatch);
}

componentDidUpdate(prevProps) {
const { configId } = this.props;
if (configId !== prevProps.configId) {
return true;
}
return false;
}

handleNext() {
Expand Down Expand Up @@ -130,28 +139,8 @@ class Configuration extends React.Component {
}
}

resetState() {
this.setState({
configuration: {
CONFIG_ENSAIO: {
LSL: "",
LWT: "",
NOS: "",
TAO: false,
TAS: "",
TAT: "",
TBS: "",
TMO: false,
USL: "",
UWT: ""
}
}
});
}

handleUpDefault() {
this.resetState();
const { sendMessage } = this.props;
const { sendMessage, changeConfig, dispatch } = this.props;
const url = `${API_URL_GRAPHQL}?query=query{configDefault{${query}}}`;

const method = "GET";
Expand All @@ -174,20 +163,23 @@ class Configuration extends React.Component {
});
const position = response.data.configDefault.length - positionVector;
const data = response.data.configDefault[position];
changeConfig({ configId: data.id });
const configurationDefault = createConfig(data);

dispatch(initialize("configuration", configurationDefault.CONFIG_ENSAIO));
this.setState({ configuration: configurationDefault });
});
}

handleChange(event) {
this.resetState();
const { changeConfig, sendMessage, dispatch } = this.props;
const { target } = event;

if (target.name === "name") {
this.setState({ [event.target.name]: event.target.value });
return;
}

const idSelect = target.value === invalidId ? "" : target.value;

changeConfig({ configId: idSelect });
Expand Down
1 change: 1 addition & 0 deletions unbrake-frontend/src/testModule/TestFunctions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const requestTest = (states, functions, dispatchs) => {
url = `${API_URL_GRAPHQL}?query=mutation{submitTesting(mqttHost:"${MQTT_HOST}",mqttPort:8080,testingId:${
testing.id
}){succes}}`;

Request(url, "POST").then(json => {
const dataLocal = json.data;
const errosLocal = json.errors;
Expand Down
2 changes: 1 addition & 1 deletion unbrake-frontend/src/utils/Constants.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const API_URL = process.env.REACT_APP_API_URL;
export const API_URL_GRAPHQL = process.env.REACT_APP_API_URL;
export const MQTT_HOST = process.env.REACT_APP_MQTT_HOST;
export const MQTT_HOST = "unbrake-hom.ml"; // process.env.REACT_APP_MQTT_HOST;
export const MQTT_PORT = process.env.REACT_APP_MQTT_PORT;
export const base10 = 10;

Expand Down

0 comments on commit a6301b4

Please sign in to comment.