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

22
src/app/components/MapModal.js

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

15
src/app/hooks/useFiltering.js

@ -1,50 +1,53 @@
import moment from "moment";
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 finalDate = moment().subtract(1, "days").format("YYYY-MM-DDTHH:mm:ss");
// console.log(initialDate+"/"+finalDate);
const filters = [
{
name: "floodZones",
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`
),
},
{
name: "rain",
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`
),
},
{
name: "riverFlood",
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`
),
},
{
name: "pluviometer",
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`
),
},
{
name: "susceptibilityAreas",
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`
),
},
{
name: "automaticPluviometer",
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`
),
},

4
src/app/screens/SharingFloodZonesScreen.js

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

Loading…
Cancel
Save