Skip to content
Snippets Groups Projects
Commit 9e6e1d47 authored by Maximilian Betz's avatar Maximilian Betz
Browse files

updated date time format to sensor format

parent 60a02b5f
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,6 @@ A cross plattform project for android and ios to log events offline everywhere a ...@@ -14,7 +14,6 @@ A cross plattform project for android and ios to log events offline everywhere a
- How to store not uploaded events locally? Dumping jsons to a file?, ObjectBox, SharedPreferences, - How to store not uploaded events locally? Dumping jsons to a file?, ObjectBox, SharedPreferences,
## Local Base Data Concept ## Local Base Data Concept
- The configuration.dart age widget is used to get the online available information for available - The configuration.dart age widget is used to get the online available information for available
devices and event creation. devices and event creation.
...@@ -22,37 +21,40 @@ A cross plattform project for android and ios to log events offline everywhere a ...@@ -22,37 +21,40 @@ A cross plattform project for android and ios to log events offline everywhere a
- This "base data" is required to provide the dropdown menu options on the addevent.dart page. - This "base data" is required to provide the dropdown menu options on the addevent.dart page.
- This "base data" needs to be stored persistently, so that it is available also offline! - This "base data" needs to be stored persistently, so that it is available also offline!
## Add Event Widget ## Add Event Page
- Usw Switch for automatic GNSS and Time update. - Usw Switch for automatic GNSS and Time update.
- Show "now" time button only if GNSS is disabled. This button shall fill the timestamp with the current utc time. - Show "now" time button only if GNSS is disabled. This button shall fill the timestamp with the current utc time.
## View Events Widget ## View & Sync Page
- Events added on the addevent.dart page have to be stored locally persistently. They can be displayed in the view - Events added on the addevent.dart page have to be stored locally persistently. They can be displayed in the view
events widget. Each event has a flag which shows if the event is already exported to sensor. events widget. Each event has a flag which shows if the event is already exported to sensor.
Shall exported events be displayed here? Slide switch to also show exported events? Shall exported events be displayed here? Slide switch to also show exported events?
- Functionality to export events locally for backup in the field! - Functionality to export events locally for backup in the field!
## Configuration Page ## Configuration Page
- Dropdown "Collection" to select a collection - Switch to select if Mission or Collection based.
- Textfield to show current locally selected and offline available collection - Dropdown "Collection" to select a collection / mission
- Button "get Collection devices from Sensor" - Button "get Collection devices from Sensor"
- Button "store Collection devices locally" - Button "store Collection devices locally"
- Select a Mission from the new Sensor-Mission-Management to get a set of devices. - Select a Mission from the new Sensor-Mission-Management to get a set of devices.
- Also input username und passwort on this page. "Test login on store even if not required here" - Username und passwort. "Test login on store even if not required here"
## GNSS ## GNSS
- Checkbox on add event page which activates GNSS locationing. A field shall signal "no fix" or presision in meter. - Switch on add event page which activates GNSS locationing. A field shall signal "no fix" or presision in meter.
The fields lat, long, elevation are updated automatically if checkbox is checked. The fields lat, long, elevation and timestamp are updated automatically if checkbox is checked.
# Input validation # Input validation
a-z , A-Z , _ , 0-9 , ,(Comma) , ( , ) , + , - , . , : a-z , A-Z , _ , 0-9 , ,(Comma) , ( , ) , + , - , . , :
-90 => Latitude <= +90 -90 => Latitude <= +90
-180 => Longitude <= +180 -180 => Longitude <= +180
Elevation: any numer Elevation: any numer
## TODOs
- FlutterSecureStorage for user password?
...@@ -189,8 +189,9 @@ class _AddEventPageState extends State<AddEvent> { ...@@ -189,8 +189,9 @@ class _AddEventPageState extends State<AddEvent> {
eventsStore.currentEvent.elevation = alt; eventsStore.currentEvent.elevation = alt;
var date = DateTime.now().toUtc(); var date = DateTime.now().toUtc();
eventsStore.currentEvent.startDate = '$date'; var isoDate = date.toIso8601String();
eventsStore.currentEvent.endDate = '$date'; eventsStore.currentEvent.startDate = isoDate;
eventsStore.currentEvent.endDate = isoDate;
if(accuracy == 0.0){ if(accuracy == 0.0){
gnssStatusText = "No-Fix"; gnssStatusText = "No-Fix";
...@@ -315,9 +316,10 @@ class _AddEventPageState extends State<AddEvent> { ...@@ -315,9 +316,10 @@ class _AddEventPageState extends State<AddEvent> {
showTitleActions: true, showTitleActions: true,
onConfirm: (date) { onConfirm: (date) {
//Only one field for start and end date. //Only one field for start and end date.
eventsStore.currentEvent.startDate = '$date'; var isoDate = date.toIso8601String();
eventsStore.currentEvent.endDate = '$date'; eventsStore.currentEvent.startDate = isoDate;
debugPrint('Date set to : $date'); eventsStore.currentEvent.endDate = isoDate;
debugPrint('Date set to : $isoDate');
setState(() {}); setState(() {});
}, },
currentTime: DateTime.now().toUtc(), currentTime: DateTime.now().toUtc(),
...@@ -328,8 +330,9 @@ class _AddEventPageState extends State<AddEvent> { ...@@ -328,8 +330,9 @@ class _AddEventPageState extends State<AddEvent> {
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
var date = DateTime.now().toUtc(); var date = DateTime.now().toUtc();
eventsStore.currentEvent.startDate = '$date'; var isoDate = date.toIso8601String();
eventsStore.currentEvent.endDate = '$date'; eventsStore.currentEvent.startDate = isoDate;
eventsStore.currentEvent.endDate = isoDate;
debugPrint('Date set to : ' + debugPrint('Date set to : ' +
eventsStore.currentEvent.endDate.toString()); eventsStore.currentEvent.endDate.toString());
setState(() {}); setState(() {});
...@@ -468,8 +471,11 @@ class _AddEventPageState extends State<AddEvent> { ...@@ -468,8 +471,11 @@ class _AddEventPageState extends State<AddEvent> {
//Update time for next event //Update time for next event
var date = DateTime.now().toUtc(); var date = DateTime.now().toUtc();
eventsStore.currentEvent.startDate = '$date'; var isoDate = date.toIso8601String();
eventsStore.currentEvent.endDate = '$date'; eventsStore.currentEvent.startDate = isoDate;
eventsStore.currentEvent.endDate = isoDate;
debugPrint(date.toIso8601String());
} }
setState(() {}); setState(() {});
}, },
......
...@@ -88,19 +88,19 @@ class Event{ ...@@ -88,19 +88,19 @@ class Event{
} }
Map<String, dynamic> toSensorJson() => { Map<String, dynamic> toSensorJson() => {
'itemID':id, "\"itemID\"":"\"$id\"",
'inheritToAllChildren':'false', "\"inheritToAllChildren\"":"\"false\"",
'inheritToChildren':[], "\"inheritToChildren\"":[],
'event':{ "\"event\"":{
'startDate':startDate, "\"startDate\"":"\"$startDate\"",
'endDate':endDate, "\"endDate\"":"\"$endDate\"",
'label':label, "\"label\"":"\"$label\"",
'description':description, "\"description\"":"\"$description\"",
'eventType':type, "\"eventType\"":"\"$type\"",
'latitude':latitude, "\"latitude\"":"\"$latitude\"",
'longitude':longitude, "\"longitude\"":"\"$longitude\"",
'elevationInMeter':elevation, "\"elevationInMeter\"":"\"$elevation\"",
'id':0 "\"id\"":"\"0\""
} }
}; };
......
...@@ -22,7 +22,12 @@ Future<bool> syncEvents() async { ...@@ -22,7 +22,12 @@ Future<bool> syncEvents() async {
url = base_url + event.id.toString() + '?createVersion=false'; url = base_url + event.id.toString() + '?createVersion=false';
debugPrint('XXX ' + Uri.parse(url).toString()); debugPrint('XXX ' + Uri.parse(url).toString());
final response = await http.put(Uri.parse(url), final response = await http.put(Uri.parse(url),
headers: { "Accept" : "application/json"},
headers: {
"Content-Type": "application/json",
"Cookie": "x-auth-token=72d9d4d20a33f87edca7e1ba01ce8db8"
},
body: event.toSensorJson().toString(), body: event.toSensorJson().toString(),
encoding: Encoding.getByName("utf-8"), encoding: Encoding.getByName("utf-8"),
); );
...@@ -39,13 +44,8 @@ Future<bool> syncEvents() async { ...@@ -39,13 +44,8 @@ Future<bool> syncEvents() async {
debugPrint('Header: ' + response.headers.toString()); debugPrint('Header: ' + response.headers.toString());
debugPrint('Body: ' + response.body.toString()); debugPrint('Body: ' + response.body.toString());
debugPrint('StatusCode: ' + response.statusCode.toString()); debugPrint('StatusCode: ' + response.statusCode.toString());
throw Exception('Failed to login'); throw Exception('Failed to put.');
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment