Browse Source

updating code as per issue #12 solution

master
analuizaff 3 years ago
parent
commit
a9c8451870
  1. 22
      src/app/components/AssembleModalObject.js
  2. 22
      src/app/components/MapModal.js
  3. 15
      src/app/hooks/useFiltering.js
  4. 4
      src/app/screens/SharingFloodZonesScreen.js

22
src/app/components/AssembleModalObject.js

@ -25,13 +25,13 @@ function getLogo(name, situation) {
} }
if (name == "rain") { if (name == "rain") {
if (situation == "sem chuva") {
if (situation == "SEM CHUVA") {
return custom_assets.rainLevel[0]; return custom_assets.rainLevel[0];
} else if (situation == "chuva fraca") {
} else if (situation == "CHUVA FRACA") {
return custom_assets.rainLevel[1]; return custom_assets.rainLevel[1];
} else if (situation == "chuva moderada") {
} else if (situation == "CHUVA MODERADA") {
return custom_assets.rainLevel[2]; return custom_assets.rainLevel[2];
} else if (situation == "chuva forte") {
} else if (situation == "CHUVA FORTE") {
return custom_assets.rainLevel[3]; return custom_assets.rainLevel[3];
} else { } else {
return custom_assets.rainLevel[3]; return custom_assets.rainLevel[3];
@ -39,13 +39,13 @@ function getLogo(name, situation) {
} }
if (name == "riverFlood") { if (name == "riverFlood") {
if (situation == "baixo") {
if (situation == "BAIXO") {
return custom_assets.riverLevel[0]; return custom_assets.riverLevel[0];
} else if (situation == "normal") {
} else if (situation == "NORMAL") {
return custom_assets.riverLevel[1]; return custom_assets.riverLevel[1];
} else if (situation == "alto") {
} else if (situation == "ALTO") {
return custom_assets.riverLevel[2]; return custom_assets.riverLevel[2];
} else if (situation == "inundar") {
} else if (situation == "INUNDAR") {
return custom_assets.riverLevel[3]; return custom_assets.riverLevel[3];
} }
return custom_assets.riverLevel[0]; return custom_assets.riverLevel[0];
@ -76,7 +76,9 @@ const AssembleModalObject = (response, name) => {
}; };
if (JSON.parse(response)) { if (JSON.parse(response)) {
const r = JSON.parse(response);
const r = JSON.parse(response).array_to_json;
user = r[0].formsanswersuserinformer;
if (name == "automaticPluviometer") { if (name == "automaticPluviometer") {
(situation = "PLUVIÔMETRO"), (situation = "PLUVIÔMETRO"),
@ -97,7 +99,6 @@ const AssembleModalObject = (response, name) => {
address = f.fieldsanswersvalue; address = f.fieldsanswersvalue;
} }
}); });
} else { } else {
if (r[0].array_to_json) { if (r[0].array_to_json) {
r[0].array_to_json.forEach(function (f) { r[0].array_to_json.forEach(function (f) {
@ -120,6 +121,7 @@ const AssembleModalObject = (response, name) => {
} }
} }
} }
return { return {
name: name, name: name,
title: situation, title: situation,

22
src/app/components/MapModal.js

@ -1,7 +1,7 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { Text, TouchableOpacity, View, StyleSheet, Image } from "react-native"; import { Text, TouchableOpacity, View, StyleSheet, Image } from "react-native";
import { MaterialCommunityIcons } from "@expo/vector-icons"; import { MaterialCommunityIcons } from "@expo/vector-icons";
import { FontAwesome5 } from '@expo/vector-icons';
import { FontAwesome5 } from "@expo/vector-icons";
import SelfClosingModal from "../components/SelfClosingModal"; import SelfClosingModal from "../components/SelfClosingModal";
import colors from "../config/colors"; import colors from "../config/colors";
import { showMessage } from "react-native-flash-message"; import { showMessage } from "react-native-flash-message";
@ -226,15 +226,21 @@ function componentBody(props) {
const date = props.date ? props.date : "implementando..."; const date = props.date ? props.date : "implementando...";
const address = props.address ? props.address : "Erro ao carregar endereço"; const address = props.address ? props.address : "Erro ao carregar endereço";
const user = props.user ? props.user : "Usuário ativo"; const user = props.user ? props.user : "Usuário ativo";
const institution = props.institution ? props.institution : "Erro ao carregar instituição"
const institution = props.institution
? props.institution
: "Erro ao carregar instituição";
return ( return (
<View style={styles.bodyRow}> <View style={styles.bodyRow}>
<Image style={styles.bodyIcon} resizeMode="stretch" source={props.logo} /> <Image style={styles.bodyIcon} resizeMode="stretch" source={props.logo} />
<View style={styles.bodyInfo}> <View style={styles.bodyInfo}>
{!isOfficialPluviometer(props.name) && iconTextRow({ name: "account", description: user })}
{iconInstitutionTextRow({name: "university", description: institution})}
{!isOfficialPluviometer(props.name) &&
iconTextRow({ name: "account", description: user })}
{props.institution && iconInstitutionTextRow({
name: "university",
description: institution,
})}
{iconTextRow({ name: "map-marker", description: address })} {iconTextRow({ name: "map-marker", description: address })}
{!isPluviometer(props.name) && {!isPluviometer(props.name) &&
iconTextRow({ name: "calendar", description: date })} iconTextRow({ name: "calendar", description: date })}
@ -284,7 +290,7 @@ function MapModal({ showModal, setShowModal, markers }) {
if (result.data && showModal && currentMarker == undefined) { if (result.data && showModal && currentMarker == undefined) {
setCurrentMarker( setCurrentMarker(
AssembleModalObject( AssembleModalObject(
JSON.stringify(result.data.responseData.array_to_json),
JSON.stringify(result.data.responseData),
name name
) )
); );
@ -308,16 +314,12 @@ function MapModal({ showModal, setShowModal, markers }) {
{topBar(currentMarker, setShowModal, setCurrentMarker)} {topBar(currentMarker, setShowModal, setCurrentMarker)}
{currentMarker != undefined && ( {currentMarker != undefined && (
<View>
<View style={{ padding: 16 }}> <View style={{ padding: 16 }}>
{componentBody(currentMarker)} {componentBody(currentMarker)}
{isPluviometer(currentMarker.name)
? moreInfo(currentMarker)
: null}
{isPluviometer(currentMarker.name) ? moreInfo(currentMarker) : null}
{/* {!isPluviometer(currentMarker.name) ? reviews(currentMarker) : null} */} {/* {!isPluviometer(currentMarker.name) ? reviews(currentMarker) : null} */}
{userMessage(currentMarker)} {userMessage(currentMarker)}
</View> </View>
</View>
)} )}
{currentMarker == undefined && ( {currentMarker == undefined && (
<View style={styles.bodyInfo}> <View style={styles.bodyInfo}>

15
src/app/hooks/useFiltering.js

@ -1,50 +1,53 @@
import moment from "moment"; import moment from "moment";
function useFiltering(location) { function useFiltering(location) {
const endpoint =
"wss://waterproofing.geog.uni-heidelberg.de/wss/hot/formsanswers?";
const initialDate = moment().add(1, "days").format("YYYY-MM-DDTHH:mm:ss"); const initialDate = moment().add(1, "days").format("YYYY-MM-DDTHH:mm:ss");
const finalDate = moment().subtract(1, "days").format("YYYY-MM-DDTHH:mm:ss"); const finalDate = moment().subtract(1, "days").format("YYYY-MM-DDTHH:mm:ss");
// console.log(initialDate+"/"+finalDate); // console.log(initialDate+"/"+finalDate);
const filters = [ const filters = [
{ {
name: "floodZones", name: "floodZones",
socketUrl: new WebSocket( socketUrl: new WebSocket(
"wss://waterproofing.geog.uni-heidelberg.de/wss/hot/data?" +
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=5000&limit=5`
), ),
}, },
{ {
name: "rain", name: "rain",
socketUrl: new WebSocket( socketUrl: new WebSocket(
"wss://waterproofing.geog.uni-heidelberg.de/wss/hot/data?" +
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=30`
), ),
}, },
{ {
name: "riverFlood", name: "riverFlood",
socketUrl: new WebSocket( socketUrl: new WebSocket(
"wss://waterproofing.geog.uni-heidelberg.de/wss/hot/data?" +
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=5`
), ),
}, },
{ {
name: "pluviometer", name: "pluviometer",
socketUrl: new WebSocket( socketUrl: new WebSocket(
"wss://waterproofing.geog.uni-heidelberg.de/wss/hot/formsanswers?" +
endpoint +
`type=PLUVIOMETER_REGISTRATION&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=5` `type=PLUVIOMETER_REGISTRATION&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=5`
), ),
}, },
{ {
name: "susceptibilityAreas", name: "susceptibilityAreas",
socketUrl: new WebSocket( socketUrl: new WebSocket(
"wss://waterproofing.geog.uni-heidelberg.de/wss/hot/formsanswers?" +
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=15`
), ),
}, },
{ {
name: "automaticPluviometer", name: "automaticPluviometer",
socketUrl: new WebSocket( socketUrl: new WebSocket(
"wss://waterproofing.geog.uni-heidelberg.de/wss/hot/formsanswers?" +
endpoint +
`type=PLUVIOMETERS_OFFICIAL&lat=${location.lat}&lon=${location.long}&buffer=500000&limit=10` `type=PLUVIOMETERS_OFFICIAL&lat=${location.lat}&lon=${location.long}&buffer=500000&limit=10`
), ),
}, },

4
src/app/screens/SharingFloodZonesScreen.js

@ -87,14 +87,14 @@ function SharingFloodZonesScreen(props) {
SvgImage={assets.floodZones.passable} SvgImage={assets.floodZones.passable}
onPress={() => { onPress={() => {
setPassable(1); setPassable(1);
setFloodSituation("TRANSITAVEL");
setFloodSituation("TRANSITÁVEL");
}} }}
/> />
<SvgLabeledButton <SvgLabeledButton
onPress={() => { onPress={() => {
setPassable(0); setPassable(0);
setFloodSituation("INTRANSITAVEL");
setFloodSituation("INTRANSITÁVEL");
}} }}
label={"INTRANSITÁVEL"} label={"INTRANSITÁVEL"}
isToggle={passable == 0} isToggle={passable == 0}

Loading…
Cancel
Save