diff --git a/src/app/components/AssembleModalObject.js b/src/app/components/AssembleModalObject.js index aa1b5a9..c57e186 100644 --- a/src/app/components/AssembleModalObject.js +++ b/src/app/components/AssembleModalObject.js @@ -66,6 +66,7 @@ function verifyMeasureDates(labels, measureDate) { } const AssembleModalObject = (response, name) => { + console.log(response); var situation = null; var user = null; var institution = null; diff --git a/src/app/components/MapModal.js b/src/app/components/MapModal.js index 3303f03..9d75d38 100644 --- a/src/app/components/MapModal.js +++ b/src/app/components/MapModal.js @@ -240,7 +240,7 @@ function componentBody(props) { {!isOfficialPluviometer(props.name) && iconTextRow({ name: "account", description: user })} - {props.institution && iconInstitutionTextRow({ + {iconInstitutionTextRow({ name: "university", description: institution, })} @@ -282,11 +282,14 @@ function MapModal({ showModal, setShowModal, markers }) { var timeFilter = null; const getAnswers = async (id, name) => { + // console.log("----------id:"+id); if (isPluviometer(name)) { const initialDate = moment().format("YYYY-MM-DD"); const finalDate = moment().subtract(5, "days").format("YYYY-MM-DD"); timeFilter = finalDate + "/" + initialDate; + // console.log(timeFilter); + } const result = await getFieldsAnswers.fieldsAnswers(timeFilter, id); diff --git a/src/app/components/forms/AssembleIngestionObject.js b/src/app/components/forms/AssembleIngestionObject.js index c4afacc..2dbec28 100644 --- a/src/app/components/forms/AssembleIngestionObject.js +++ b/src/app/components/forms/AssembleIngestionObject.js @@ -1,9 +1,10 @@ import moment from "moment"; -import React from "react"; import sendFormAnswer from "../../api/Ingestion/sendFormAnswer"; + const AssembleIngestionObject = ( { images, description }, + user, situation, code, location, @@ -16,7 +17,7 @@ const AssembleIngestionObject = ( array_to_json: [ { formcode: code, - formsanswersuserinformer: "admin@wpd.com", + formsanswersuserinformer: user.id, fieldsanswerslongitude: location["longitude"], fieldsanswerslatitude: location["latitude"], fields: [ @@ -39,6 +40,7 @@ const AssembleIngestionPluviometer = ({ pluviometer, description, images, + user, date, time, }) => { @@ -47,7 +49,7 @@ const AssembleIngestionPluviometer = ({ array_to_json: [ { formcode: "PLUVIOMETERS_FORM", - formsanswersuserinformer: "admin@wpd.com", + formsanswersuserinformer: user.id, fias: [ { fieldsanswersdate: moment(date).format("DD-MM-YYYY"), @@ -62,29 +64,31 @@ const AssembleIngestionPluviometer = ({ }; }; -const AssembleIngestionPluvRegistration = ({ date, time, user }) => { +const AssembleIngestionPluvRegistration = ( date, time, user, address, coordinates ) => { + console.log(user); + console.log(coordinates); const pluvResgistrationObject = { responseData: { array_to_json: [ { formcode: "PLUVIOMETER_REGISTRATION", - formsanswersuserinformer: "admin@wpd.com", //user - fieldsanswerslongitude: -46.5637, //location["longitude"], - fieldsanswerslatitude: -23.623, //location["latitude"], + formsanswersuserinformer: user.id, + fieldsanswerslongitude: coordinates["longitude"], + fieldsanswerslatitude: coordinates["latitude"], fields: [ { - fieldsanswerseventaddress: "Rua Rio de Janeiros, 81", //address + fieldsanswerseventaddress: address, fieldsanswerseventdate: moment(date).format("DD-MM-YYYY"), fieldsanswerseventtime: moment(time).format("HH:mm"), - fieldsanswersinstitutename: "E. E. Vagner", - fieldsanswerrinstitutetype: "Escola", + fieldsanswersinstitutename: user.institutionName ? user.institutionName : null, + fieldsanswerrinstitutetype: user.institutionType ? user.institutionType : null }, ], }, ], }, }; - const a = sendFormAnswer(ingestionObject); + const a = sendFormAnswer(pluvResgistrationObject); }; export { AssembleIngestionObject, diff --git a/src/app/hooks/useFiltering.js b/src/app/hooks/useFiltering.js index 32e888f..72a5f52 100644 --- a/src/app/hooks/useFiltering.js +++ b/src/app/hooks/useFiltering.js @@ -13,42 +13,42 @@ function useFiltering(location) { name: "floodZones", socketUrl: new WebSocket( endpoint + - `type=FLOODZONES_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=5000&limit=5` + `type=FLOODZONES_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=15` ), }, { name: "rain", socketUrl: new WebSocket( endpoint + - `type=RAIN_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=30` + `type=RAIN_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=15` ), }, { name: "riverFlood", socketUrl: new WebSocket( endpoint + - `type=RIVERFLOOD_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=5` + `type=RIVERFLOOD_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=15` ), }, { name: "pluviometer", socketUrl: new WebSocket( endpoint + - `type=PLUVIOMETER_REGISTRATION&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=5` + `type=PLUVIOMETER_REGISTRATION&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=15` ), }, { name: "susceptibilityAreas", socketUrl: new WebSocket( endpoint + - `type=FLOODZONES_OFFICIAL&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=15` + `type=FLOODZONES_OFFICIAL&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=10` ), }, { name: "automaticPluviometer", socketUrl: new WebSocket( endpoint + - `type=PLUVIOMETERS_OFFICIAL&lat=${location.lat}&lon=${location.long}&buffer=500000&limit=10` + `type=PLUVIOMETERS_OFFICIAL&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=15` ), }, ]; diff --git a/src/app/hooks/useSocketMarkers.js b/src/app/hooks/useSocketMarkers.js index 580fead..3b1587a 100644 --- a/src/app/hooks/useSocketMarkers.js +++ b/src/app/hooks/useSocketMarkers.js @@ -82,46 +82,6 @@ function getImage(name, situation) { } } -function getLogo(name, situation) { - if (name == "automaticPluviometer") { - return custom_assets.officialPluviometer; - } - - if (name == "pluviometer") { - return custom_assets.pluviometer; - } - - if (name == "rain") { - if (situation == "sem chuva") { - return custom_assets.rainLevel[0]; - } else if (situation == "chuva fraca") { - return custom_assets.rainLevel[1]; - } else if (situation == "chuva moderada") { - return custom_assets.rainLevel[2]; - } else if (situation == "chuva forte") { - return custom_assets.rainLevel[3]; - } else { - return custom_assets.rainLevel[3]; - } - } - - if (name == "riverFlood") { - if (situation == "baixo") { - return custom_assets.riverLevel[0]; - } else if (situation == "normal") { - return custom_assets.riverLevel[1]; - } else if (situation == "alto") { - return custom_assets.riverLevel[2]; - } else if (situation == "inundar") { - return custom_assets.riverLevel[3]; - } - return custom_assets.riverLevel[0]; - } - if (name == "floodZones") { - return custom_assets.floodZones; - } -} - function buildPolygonsObject(response, name) { var r = JSON.parse(response); var coordinate = []; @@ -155,7 +115,7 @@ function buildPolygonsObject(response, name) { function buildMarkerObject(response, name) { const r = JSON.parse(response); - console.log(r); + // console.log(r); const resposta = r.formsanswersgeom; const formsanswersgeom = JSON.parse(resposta).coordinates; var situation = null; diff --git a/src/app/screens/MapFormScreen.js b/src/app/screens/MapFormScreen.js index 18e91fe..761a737 100644 --- a/src/app/screens/MapFormScreen.js +++ b/src/app/screens/MapFormScreen.js @@ -33,8 +33,11 @@ const MapFormScreen = (props) => { const setLocation = () => { getAddress(moveEndListener).then((addr) => { - if (props.route.params && props.route.params.setLocationAddr) + if (props.route.params && props.route.params.setLocationAddr){ props.route.params.setLocationAddr(addr); + if(props.route.params.setGeoLocation){ + props.route.params.setGeoLocation(moveEndListener); + }} else context.saveNewLocation(addr, moveEndListener); }); diff --git a/src/app/screens/PluviometerRegisterScreen.js b/src/app/screens/PluviometerRegisterScreen.js index 6e8f33a..6f421e8 100644 --- a/src/app/screens/PluviometerRegisterScreen.js +++ b/src/app/screens/PluviometerRegisterScreen.js @@ -35,9 +35,12 @@ function Institution({ user }) { ); } -function LocationPicker({ navigation }) { - const [location, setLocationAddr] = useState("Defina o endereço no mapa"); - +function LocationPicker({ + navigation, + location, + setLocationAddr, + setGeoLocation, +}) { return ( navigation.navigate("FormMap", { setLocationAddr: setLocationAddr, + setGeoLocation: setGeoLocation, }) } > @@ -90,6 +94,8 @@ function LocationPicker({ navigation }) { function PluviometerRegisterScreen(props) { const [date, setDate] = useState(moment()); const [time, setTime] = useState(moment()); + const [location, setLocationAddr] = useState("Defina o endereço no mapa"); + const [coordinates, setCoordinates] = useState(null); const { user, _ } = useContext(AuthContext); return ( @@ -97,13 +103,13 @@ function PluviometerRegisterScreen(props) {
{ - showMessage({ - message: "Ainda não implementado", - duration: 1950, - icon: "warning", - type: "warning", - onPress: () => {AssembleIngestionPluvRegistration(date, time, user)}, - }); + AssembleIngestionPluvRegistration( + date, + time, + user, + location, + coordinates + ); }} > @@ -137,7 +143,12 @@ function PluviometerRegisterScreen(props) { Endereço do pluviômetro*: - + {user.institutionType && } diff --git a/src/app/screens/PluviometerSharingDataScreen.js b/src/app/screens/PluviometerSharingDataScreen.js index fb85ddb..2852ae3 100644 --- a/src/app/screens/PluviometerSharingDataScreen.js +++ b/src/app/screens/PluviometerSharingDataScreen.js @@ -28,6 +28,7 @@ const validationSchema = Yup.object().shape({ }); function PluviometerSharingDataScreen(props) { + const user = props.route.params.user; const context = useContext(EventLocationContext); const [date, setDate] = useState(moment()); const [time, setTime] = useState(moment()); @@ -49,7 +50,7 @@ function PluviometerSharingDataScreen(props) { }} onSubmit={(values) => { // insertPluviometerData({ ...values, dateTime, time }); - AssembleIngestionPluviometer({ ...values, date, time}) + AssembleIngestionPluviometer({ ...values, user, date, time}) showMessage({ message: "Informação enviada!", duration: 3000, diff --git a/src/app/screens/RainSharingDataScreen.js b/src/app/screens/RainSharingDataScreen.js index fcc5584..7d73153 100644 --- a/src/app/screens/RainSharingDataScreen.js +++ b/src/app/screens/RainSharingDataScreen.js @@ -25,9 +25,11 @@ const validationSchema = Yup.object().shape({ }); function RainSharingDataScreen(props) { + const user = props.route.params.user; const [rain, setRain] = useState(-1); const [rainSituation, setRainSituation] = useState(null); const [error, setError] = useState(false); +; const dims = scaleDimsFromWidth(85, 85, 27); @@ -61,6 +63,7 @@ function RainSharingDataScreen(props) { { ...values, }, + user, rainSituation, code, location, diff --git a/src/app/screens/RiverFloodSharingDataScreen.js b/src/app/screens/RiverFloodSharingDataScreen.js index 0368adf..9c1b9f9 100644 --- a/src/app/screens/RiverFloodSharingDataScreen.js +++ b/src/app/screens/RiverFloodSharingDataScreen.js @@ -25,6 +25,7 @@ const validationSchema = Yup.object().shape({ }); function RiverFloodSharingDataScreen(props) { + const user = props.route.params.user; const [riverScale, setRiverScale] = useState(-1); const [riverSituation, setRiverSituation] = useState(null); @@ -64,6 +65,7 @@ function RiverFloodSharingDataScreen(props) { { ...values, }, + user, riverSituation, code, location, diff --git a/src/app/screens/SharingDataScreen.js b/src/app/screens/SharingDataScreen.js index 52e4108..0e97aa3 100644 --- a/src/app/screens/SharingDataScreen.js +++ b/src/app/screens/SharingDataScreen.js @@ -13,6 +13,7 @@ function SharingDataScreen({ navigation }) { const [showLog, setShowLog] = useState(false); const isRegistered = authContext.user?.username != null; + const currentUser = authContext.user; return ( @@ -36,14 +37,16 @@ function SharingDataScreen({ navigation }) { label={"ÁREA DE \nALAGAMENTO"} style={{ marginRight: 24 }} SvgImage={assets.floodZones.FloodZonesIcon} - onPress={() => navigation.navigate("FloodSharingData")} + onPress={() => navigation.navigate("FloodSharingData", { user: currentUser })} active={isRegistered} inactiveOnPress={() => setShowLog(true)} /> navigation.navigate("RainSharingData")} + onPress={() => + navigation.navigate("RainSharingData", { user: currentUser }) + } SvgImage={assets.rainLevel.RainIcon} active={isRegistered} inactiveOnPress={() => setShowLog(true)} @@ -61,7 +64,7 @@ function SharingDataScreen({ navigation }) { navigation.navigate("PluviometerSharingData")} + onPress={() => navigation.navigate("PluviometerSharingData", { user: currentUser })} SvgImage={assets.PluviometerIcon} active={isRegistered} inactiveOnPress={() => setShowLog(true)} @@ -69,7 +72,7 @@ function SharingDataScreen({ navigation }) { navigation.navigate("RiverFloodData")} + onPress={() => navigation.navigate("RiverFloodData", { user: currentUser })} SvgImage={assets.riverLevel.RiverIcon} active={isRegistered} inactiveOnPress={() => setShowLog(true)} diff --git a/src/app/screens/SharingFloodZonesScreen.js b/src/app/screens/SharingFloodZonesScreen.js index 9c0ce92..87c4933 100644 --- a/src/app/screens/SharingFloodZonesScreen.js +++ b/src/app/screens/SharingFloodZonesScreen.js @@ -24,6 +24,7 @@ const validationSchema = Yup.object().shape({ }); function SharingFloodZonesScreen(props) { + const user = props.route.params.user; const [passable, setPassable] = useState(-1); const [floodSituation, setFloodSituation] = useState(null); @@ -62,6 +63,7 @@ function SharingFloodZonesScreen(props) { { ...values, }, + user, floodSituation, code, location,