Browse Source

Merge branch 'main' of github.com:IGSD-UoW/WPD-MobileApp

master
GabrielTrettel 3 years ago
parent
commit
8b48df26ad
  1. 1
      src/app/api/Ingestion/sendFormAnswer.js
  2. 30
      src/app/components/forms/AssembleIngestionObject.js
  3. 3
      src/app/config/assets.js
  4. 2
      src/app/navigation/FeedNavigator.js
  5. 2
      src/app/screens/Abbout.js
  6. 15
      src/app/screens/LoginScreen.js
  7. 84
      src/app/screens/PluviometerRegisterScreen.js
  8. 2
      src/app/screens/SharingDataScreen.js

1
src/app/api/Ingestion/sendFormAnswer.js

@ -9,7 +9,6 @@ async function sendFormAnswer(ingestionObject) {
endpoint, endpoint,
JSON.stringify(ingestionObject) JSON.stringify(ingestionObject)
); );
return response; return response;
} }

30
src/app/components/forms/AssembleIngestionObject.js

@ -1,7 +1,6 @@
import moment from "moment"; import moment from "moment";
import sendFormAnswer from "../../api/Ingestion/sendFormAnswer"; import sendFormAnswer from "../../api/Ingestion/sendFormAnswer";
const AssembleIngestionObject = ( const AssembleIngestionObject = (
{ images, description }, { images, description },
user, user,
@ -17,7 +16,7 @@ const AssembleIngestionObject = (
array_to_json: [ array_to_json: [
{ {
formcode: code, formcode: code,
formsanswersuserinformer: "admin@wpd.com",//user.id,
formsanswersuserinformer: "admin@wpd.com", //user.id,
fieldsanswerslongitude: location["longitude"], fieldsanswerslongitude: location["longitude"],
fieldsanswerslatitude: location["latitude"], fieldsanswerslatitude: location["latitude"],
fields: [ fields: [
@ -49,7 +48,7 @@ const AssembleIngestionPluviometer = ({
array_to_json: [ array_to_json: [
{ {
formcode: "PLUVIOMETERS_FORM", formcode: "PLUVIOMETERS_FORM",
formsanswersuserinformer: "admin@wpd.com",//user.id,
formsanswersuserinformer: "admin@wpd.com", //user.id,
fias: [ fias: [
{ {
fieldsanswersdate: moment(date).format("DD-MM-YYYY"), fieldsanswersdate: moment(date).format("DD-MM-YYYY"),
@ -64,7 +63,13 @@ const AssembleIngestionPluviometer = ({
}; };
}; };
const AssembleIngestionPluvRegistration = ( date, time, user, address, coordinates ) => {
async function AssembleIngestionPluvRegistration(
date,
time,
user,
address,
coordinates
) {
console.log(user); console.log(user);
console.log(coordinates); console.log(coordinates);
const pluvResgistrationObject = { const pluvResgistrationObject = {
@ -72,24 +77,29 @@ const AssembleIngestionPluvRegistration = ( date, time, user, address, coordinat
array_to_json: [ array_to_json: [
{ {
formcode: "PLUVIOMETER_REGISTRATION", formcode: "PLUVIOMETER_REGISTRATION",
formsanswersuserinformer: "admin@wpd.com",//user.id,
formsanswersuserinformer: "admin@wpd.com", //user.id,
fieldsanswerslongitude: coordinates["longitude"], fieldsanswerslongitude: coordinates["longitude"],
fieldsanswerslatitude: coordinates["latitude"],
fieldsanswerslatitude: coordinates["latitude"],
fields: [ fields: [
{ {
fieldsanswerseventaddress: address, fieldsanswerseventaddress: address,
fieldsanswerseventdate: moment(date).format("DD-MM-YYYY"), fieldsanswerseventdate: moment(date).format("DD-MM-YYYY"),
fieldsanswerseventtime: moment(time).format("HH:mm"), fieldsanswerseventtime: moment(time).format("HH:mm"),
fieldsanswersinstitutename: user.institutionName ? user.institutionName : null,
fieldsanswerrinstitutetype: user.institutionType ? user.institutionType : null
fieldsanswersinstitutename: user.institutionName
? user.institutionName
: null,
fieldsanswerrinstitutetype: user.institutionType
? user.institutionType
: null,
}, },
], ],
}, },
], ],
}, },
}; };
const a = sendFormAnswer(pluvResgistrationObject);
};
const a = await sendFormAnswer(pluvResgistrationObject);
return a;
}
export { export {
AssembleIngestionObject, AssembleIngestionObject,
AssembleIngestionPluviometer, AssembleIngestionPluviometer,

3
src/app/config/assets.js

@ -1,4 +1,6 @@
import Pluviometer from "../assets/pluviometer/pluviometer-logo.svg"; import Pluviometer from "../assets/pluviometer/pluviometer-logo.svg";
import PluviometerSharingData from "../assets/pluviometer/pluviometricDataIcon.svg";
import OfficialPluviometer from "../assets/pluviometer/PluviometroOficial.svg"; import OfficialPluviometer from "../assets/pluviometer/PluviometroOficial.svg";
import SusceptibilityAreas from "../assets/dataMenu/suceptibilitiesAreas.svg"; import SusceptibilityAreas from "../assets/dataMenu/suceptibilitiesAreas.svg";
import RainIcon from "../assets/rain/rain-icon.svg"; import RainIcon from "../assets/rain/rain-icon.svg";
@ -105,6 +107,7 @@ export default {
officialPluviometer: require("../assets/pluviometer/pluviometroOficial.png"), officialPluviometer: require("../assets/pluviometer/pluviometroOficial.png"),
officialPluviometer_pin: PinPluviometerOfficial, officialPluviometer_pin: PinPluviometerOfficial,
PluviometerIcon: Pluviometer, PluviometerIcon: Pluviometer,
PluviometricDataIcon: PluviometerSharingData,
OfficialPluviometer: OfficialPluviometer, OfficialPluviometer: OfficialPluviometer,
AppLogoTitle: AppLogoTitle, AppLogoTitle: AppLogoTitle,
SusceptibilityAreas: SusceptibilityAreas, SusceptibilityAreas: SusceptibilityAreas,

2
src/app/navigation/FeedNavigator.js

@ -8,7 +8,7 @@ const FeedNavigator = () => (
<Stack.Navigator> <Stack.Navigator>
<Stack.Screen name="Map" component={MapFeedScreen} <Stack.Screen name="Map" component={MapFeedScreen}
options={{ options={{
title: "Pega Chuva",
title: "Dados à Prova d'água",
headerStyle: { headerStyle: {
backgroundColor: "white", backgroundColor: "white",
}, },

2
src/app/screens/Abbout.js

@ -15,7 +15,7 @@ export default function Abbout(props) {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<View style={styles.HeaderBackground}> <View style={styles.HeaderBackground}>
<Text style={styles.txtHeader}>Waterproofing Data</Text>
<Text style={styles.txtHeader}>Dados à Prova d'água</Text>
</View> </View>
<ScrollView style={styles.scrollContainer}> <ScrollView style={styles.scrollContainer}>
<View style={{ padding: dimensions.spacing.normal_padding }}> <View style={{ padding: dimensions.spacing.normal_padding }}>

15
src/app/screens/LoginScreen.js

@ -102,13 +102,7 @@ export default function LoginScreen(props) {
} }
> >
<View paddingHorizontal={14}> <View paddingHorizontal={14}>
<assets.AppLogoTitle
preserveAspectRatio="xMidYMid meet"
width={300}
height={30}
alignSelf="center"
marginBottom={dimensions.spacing.big_padding}
/>
<Text style={styles.txtHeader}>Dados à Prova d'água</Text>
<ErrorMessage <ErrorMessage
error="Email ou senha inválidos" error="Email ou senha inválidos"
@ -182,4 +176,11 @@ const styles = StyleSheet.create({
containter: { containter: {
justifyContent: "center", justifyContent: "center",
}, },
txtHeader: {
fontSize: dimensions.text.header,
color: colors.primary,
fontWeight: "bold",
textAlign: "center",
padding: dimensions.spacing.normal_padding,
},
}); });

84
src/app/screens/PluviometerRegisterScreen.js

@ -102,46 +102,74 @@ function PluviometerRegisterScreen(props) {
<View> <View>
<Form <Form
initialValues={{}} initialValues={{}}
onSubmit={() => {
AssembleIngestionPluvRegistration(
onSubmit={async () => {
showMessage({
message: "Aguarde! Estamos enviando a informação.",
duration: 2005,
icon: "warning",
type: "warning",
onPress: () => {},
});
const isSent = await AssembleIngestionPluvRegistration(
date, date,
time, time,
user, user,
location, location,
coordinates coordinates
); );
if (isSent.ok) {
showMessage({
message: "Pluviômetro cadastrado!",
duration: 1950,
icon: "success",
type: "success",
onPress: () => {},
});
props.navigation.navigate("Home");
}
else{
showMessage({
message: "Erro ao cadastrar pluviômetro. Por favor, tente mais tarde!",
duration: 1950,
icon: "danger",
type: "danger",
onPress: () => {},
});
}
}} }}
> >
<View padding={16}> <View padding={16}>
<Text style={styles.title}>Cadastro do Pluviômetro</Text> <Text style={styles.title}>Cadastro do Pluviômetro</Text>
<View>
<Text
style={{
marginTop: 24,
marginBottom: 16,
fontSize: dimensions.text.secondary,
fontWeight: "bold",
textAlign: "left",
color: colors.secondary,
}}
>
Data do cadastro:{" "}
</Text>
<Text
style={{
marginTop: 24,
marginBottom: 16,
fontSize: dimensions.text.secondary,
fontWeight: "bold",
textAlign: "left",
color: colors.secondary,
}}
>
Data do cadastro:{" "}
</Text>
<View
style={{
marginBottom: 24,
}}
>
<FormDatePicker
onDateChange={(value) => setDate(value)}
onTimeChange={(value) => setTime(value)}
date={date}
time={time}
formTypeFace={"pluviometerRegister"}
/>
<View
style={{
marginBottom: 24,
}}
>
<FormDatePicker
onDateChange={(value) => setDate(value)}
onTimeChange={(value) => setTime(value)}
date={date}
time={time}
formTypeFace={"pluviometerRegister"}
/>
</View>
</View> </View>
<Text style={styles.label}>Endereço do pluviômetro*: </Text> <Text style={styles.label}>Endereço do pluviômetro*: </Text>
<LocationPicker <LocationPicker
navigation={props.navigation} navigation={props.navigation}

2
src/app/screens/SharingDataScreen.js

@ -65,7 +65,7 @@ function SharingDataScreen({ navigation }) {
style={{ marginRight: 24 }} style={{ marginRight: 24 }}
label={"DIÁRIO DO\nPLUVIÔMETRO"} label={"DIÁRIO DO\nPLUVIÔMETRO"}
onPress={() => navigation.navigate("PluviometerSharingData", { user: currentUser })} onPress={() => navigation.navigate("PluviometerSharingData", { user: currentUser })}
SvgImage={assets.PluviometerIcon}
SvgImage={assets.PluviometricDataIcon}
active={isRegistered} active={isRegistered}
inactiveOnPress={() => setShowLog(true)} inactiveOnPress={() => setShowLog(true)}
/> />

Loading…
Cancel
Save