diff --git a/unbrake-api/production/settings.py b/unbrake-api/production/settings.py index 49c93712..37dcb964 100644 --- a/unbrake-api/production/settings.py +++ b/unbrake-api/production/settings.py @@ -66,11 +66,11 @@ def get_secret(secret_name, filename): CORS_ORIGIN_ALLOW_ALL = False CORS_ORIGIN_WHITELIST = ( - 'unbrake-hom.ml', 'unbrake.ml' + 'unbrake-hom.ml', 'unbrake.ml', 'api.unbrake-hom.ml' ) CSRF_TRUSTED_ORIGINS = ( - 'unbrake-hom.ml', 'unbrake.ml' + 'unbrake-hom.ml', 'unbrake.ml', 'api.unbrake-hom.ml' ) LANGUAGE_CODE = 'en-us' diff --git a/unbrake-frontend/src/configuration/Configuration.jsx b/unbrake-frontend/src/configuration/Configuration.jsx index 5555204e..f503adc7 100644 --- a/unbrake-frontend/src/configuration/Configuration.jsx +++ b/unbrake-frontend/src/configuration/Configuration.jsx @@ -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"; @@ -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() { @@ -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 } = this.props; const url = `${API_URL_GRAPHQL}?query=query{configDefault{${query}}}`; const method = "GET"; @@ -174,13 +163,15 @@ 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; @@ -188,6 +179,7 @@ class Configuration extends React.Component { this.setState({ [event.target.name]: event.target.value }); return; } + const idSelect = target.value === invalidId ? "" : target.value; changeConfig({ configId: idSelect }); diff --git a/unbrake-frontend/src/testModule/TestFunctions.jsx b/unbrake-frontend/src/testModule/TestFunctions.jsx index 7c2d11da..b228e1b0 100644 --- a/unbrake-frontend/src/testModule/TestFunctions.jsx +++ b/unbrake-frontend/src/testModule/TestFunctions.jsx @@ -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; diff --git a/unbrake-frontend/src/utils/Constants.jsx b/unbrake-frontend/src/utils/Constants.jsx index 7c5d8796..8136a649 100644 --- a/unbrake-frontend/src/utils/Constants.jsx +++ b/unbrake-frontend/src/utils/Constants.jsx @@ -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.ml"; // process.env.REACT_APP_MQTT_HOST; export const MQTT_PORT = process.env.REACT_APP_MQTT_PORT; export const base10 = 10;