forked from cemaden-educacao/WPD-MobileApp
analuizaff
3 years ago
8 changed files with 168 additions and 91 deletions
-
5src/app/api/RequestFieldsAnswers/getFieldsAnswers.js
-
189src/app/components/AssembleModalObject.js
-
1src/app/components/DatePicker.js
-
26src/app/components/MapModal.js
-
18src/app/components/PluviometerGraphics.js
-
2src/app/components/forms/AssembleIngestionObject.js
-
6src/app/hooks/useFiltering.js
-
2src/app/hooks/useSocketMarkers.js
@ -1,7 +1,8 @@ |
|||||
import apiClient from "../client"; |
import apiClient from "../client"; |
||||
|
|
||||
const endpoint = "/hot/fieldsanswers?&faid="; |
|
||||
|
const endpoint = "/hot/fieldsanswers?"; |
||||
|
|
||||
const fieldsAnswers = (id) => apiClient.get(endpoint+id); |
|
||||
|
const fieldsAnswers = (time, id) => |
||||
|
apiClient.get(endpoint + `time=${time}&faid=${id}`); |
||||
|
|
||||
export default { fieldsAnswers }; |
export default { fieldsAnswers }; |
@ -1,86 +1,135 @@ |
|||||
import moment from 'moment'; |
|
||||
import React from 'react' |
|
||||
import { View, Text } from 'react-native' |
|
||||
|
import moment from "moment"; |
||||
|
import React from "react"; |
||||
|
import { View, Text } from "react-native"; |
||||
|
import assets from "../config/assets"; |
||||
|
|
||||
|
const custom_assets = { |
||||
|
pluviometer: assets.pluviometer, |
||||
|
officialPluviometer: assets.officialPluviometer, |
||||
|
floodZones: assets.floodZones, |
||||
|
riverLevel: ["low", "normal", "high", "flooding"].map((key) => { |
||||
|
return assets.riverLevel[key]; |
||||
|
}), |
||||
|
rainLevel: ["rain_0_5", "rain_1_5", "rain_2_5", "rain_3_5"].map((key) => { |
||||
|
return assets.rainLevel[key]; |
||||
|
}), |
||||
|
}; |
||||
|
|
||||
function getLogo(name, situation) { |
function getLogo(name, situation) { |
||||
if (name == "automaticPluviometer") { |
|
||||
return custom_assets.officialPluviometer; |
|
||||
} |
|
||||
|
if (name == "automaticPluviometer") { |
||||
|
return custom_assets.officialPluviometer; |
||||
|
} |
||||
|
|
||||
if (name == "pluviometer") { |
|
||||
return custom_assets.pluviometer; |
|
||||
} |
|
||||
|
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 == "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]; |
|
||||
} |
|
||||
|
if (name == "riverFlood") { |
||||
|
if (situation == "baixo") { |
||||
return custom_assets.riverLevel[0]; |
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]; |
||||
} |
} |
||||
if (name == "floodZones") { |
|
||||
return custom_assets.floodZones; |
|
||||
} |
|
||||
|
return custom_assets.riverLevel[0]; |
||||
|
} |
||||
|
if (name == "floodZones") { |
||||
|
return custom_assets.floodZones; |
||||
} |
} |
||||
|
} |
||||
|
|
||||
|
function verifyMeasureDates(labels, measureDate) { |
||||
|
if (labels == null || !labels.find((f) => f == measureDate)) { |
||||
|
labels.push(measureDate); |
||||
|
} |
||||
|
} |
||||
|
|
||||
const AssembleModalObject = (response, name) => { |
const AssembleModalObject = (response, name) => { |
||||
|
var situation = null; |
||||
|
var user = null; |
||||
|
var address = null; |
||||
|
var date = null; |
||||
|
var time = null; |
||||
|
var comments = null; |
||||
|
var pictures = null; |
||||
|
var data = { |
||||
|
values: [], |
||||
|
labels: [], |
||||
|
}; |
||||
|
|
||||
|
if (JSON.parse(response)) { |
||||
const r = JSON.parse(response); |
const r = JSON.parse(response); |
||||
|
|
||||
var situation = null; |
|
||||
var address = null; |
|
||||
var date = null; |
|
||||
var time = null; |
|
||||
var comments = null; |
|
||||
var pictures = null; |
|
||||
|
if (name == "automaticPluviometer") { |
||||
|
(situation = "PLUVIÔMETRO"), |
||||
|
r[0].array_to_json.forEach(function (f) { |
||||
|
if (f.fieldname == "medicao") { |
||||
|
verifyMeasureDates( |
||||
|
data.labels, |
||||
|
moment(f.fieldsanswersdtfilling).format("DD/MM") |
||||
|
); //data.labels.push(moment(f.fieldsanswersdtfilling).format("DD/MM/YYYY"));
|
||||
|
data.values.push( |
||||
|
f.fieldsanswersvalue ? parseFloat(f.fieldsanswersvalue) : null |
||||
|
); |
||||
|
} |
||||
|
if (f.fieldname == "siglarede") { |
||||
|
user = f.fieldsanswersvalue; |
||||
|
} |
||||
|
if (f.fieldname == "nome") { |
||||
|
address = f.fieldsanswersvalue; |
||||
|
} |
||||
|
}); |
||||
|
|
||||
if (r[0].array_to_json) { |
|
||||
r[0].array_to_json.forEach(function (f) { |
|
||||
if (f.fieldname == "situation") { |
|
||||
situation = f.fieldsanswersvalue; |
|
||||
} |
|
||||
if (f.fieldname == "eventaddress") { |
|
||||
address = f.fieldsanswersvalue; |
|
||||
} |
|
||||
if (f.fieldname == "eventdate") { |
|
||||
date = f.fieldsanswersvalue; |
|
||||
} |
|
||||
if (f.fieldname == "eventtime") { |
|
||||
time = f.fieldsanswersvalue; |
|
||||
} |
|
||||
if (f.fieldname == "comments") { |
|
||||
comments = f.fieldsanswersvalue; |
|
||||
} |
|
||||
}); |
|
||||
|
} else { |
||||
|
if (r[0].array_to_json) { |
||||
|
r[0].array_to_json.forEach(function (f) { |
||||
|
if (f.fieldname == "situation") { |
||||
|
situation = f.fieldsanswersvalue; |
||||
|
} |
||||
|
if (f.fieldname == "eventaddress") { |
||||
|
address = f.fieldsanswersvalue; |
||||
|
} |
||||
|
if (f.fieldname == "eventdate") { |
||||
|
date = f.fieldsanswersvalue; |
||||
|
} |
||||
|
if (f.fieldname == "eventtime") { |
||||
|
time = f.fieldsanswersvalue; |
||||
|
} |
||||
|
if (f.fieldname == "comments") { |
||||
|
comments = f.fieldsanswersvalue; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
} |
} |
||||
|
} |
||||
|
return { |
||||
|
name: name, |
||||
|
title: situation, |
||||
|
user: user, |
||||
|
address: address, |
||||
|
date: date + " | " + time, |
||||
|
description: comments, |
||||
|
logo: getLogo(name, situation), |
||||
|
pictures: pictures, |
||||
|
data: data, |
||||
|
}; |
||||
|
}; |
||||
|
|
||||
return { |
|
||||
"name": name, |
|
||||
"title": situation, |
|
||||
"address": address, |
|
||||
"date": date + " | " + time, |
|
||||
"description": comments, |
|
||||
"logo": getLogo(), |
|
||||
"pictures": pictures, |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
export default AssembleModalObject |
|
||||
|
export default AssembleModalObject; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue