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

some more preparations for local storage

parent 0a3e968a
No related branches found
No related tags found
No related merge requests found
import 'dart:convert';
class Collection { class Collection {
int id; int id;
String description; String description;
...@@ -162,7 +164,7 @@ class EventType{ ...@@ -162,7 +164,7 @@ class EventType{
EventType.fromSensorJson(Map<String, dynamic> json) EventType.fromSensorJson(Map<String, dynamic> json)
: id = json['id'], : id = json['id'],
name = json['generalName']; name = json['generalName'];
EventType.fromJson(Map<String, dynamic> json) EventType.fromJson(Map<String, dynamic> json)
: id = json['id'], : id = json['id'],
...@@ -291,6 +293,27 @@ abstract class EventStoreBase{ ...@@ -291,6 +293,27 @@ abstract class EventStoreBase{
} }
return count; return count;
} }
String getEventDump(){
String ev = '[';
for (var event in events) {
ev += jsonEncode(event);
ev += ',';
}
ev += ']';
return ev;
}
fromEventDump(dump){
events = [];
print(dump);
List<dynamic> data = jsonDecode(dump);
for (var entry in data) {
print(entry);
events.add(Event.fromJson(entry));
}
}
} }
......
...@@ -47,6 +47,8 @@ void main() { ...@@ -47,6 +47,8 @@ void main() {
//configuration.currentCollection = Collection.fromJson({"id":1,"description":"","collectionName":"FRAM"}); //configuration.currentCollection = Collection.fromJson({"id":1,"description":"","collectionName":"FRAM"});
//configuration.initialized = true; //configuration.initialized = true;
//events.fromEventDump([{"id":102,"urn":"mooring:f9-12","label":"cf","type":"Calibration","typeId":15,"description":"fd","status":"PENDING","startDate":"2022-03-25T12:47:30.659436Z","endDate":"2022-03-25T12:47:30.659436Z","latitude":"","longitude":"","elevation":""},{"id":102,"urn":"mooring:f9-12","label":"cf","type":"Calibration","typeId":15,"description":"fd","status":"PENDING","startDate":"2022-03-25T12:47:32.136009Z","endDate":"2022-03-25T12:47:32.136009Z","latitude":"","longitude":"","elevation":""}]);
runApp(MaterialApp( runApp(MaterialApp(
title: 'Mobile Event Log', title: 'Mobile Event Log',
......
...@@ -59,6 +59,7 @@ class _ViewEvents extends State<ViewEvents> { ...@@ -59,6 +59,7 @@ class _ViewEvents extends State<ViewEvents> {
_sync_status = 'export success'; _sync_status = 'export success';
} }
} on SocketException catch (e) { } on SocketException catch (e) {
debugPrint('Exception: $e');
_sync_status = 'No connection'; _sync_status = 'No connection';
setState(() {}); setState(() {});
} catch (e) { } catch (e) {
...@@ -242,9 +243,8 @@ class _ViewEvents extends State<ViewEvents> { ...@@ -242,9 +243,8 @@ class _ViewEvents extends State<ViewEvents> {
icon: null, icon: null,
label: const Text('Sync'), label: const Text('Sync'),
onPressed: () { onPressed: () {
for (var event in _events.events){ debugPrint(_events.getEventDump());
debugPrint("Event: " + jsonEncode(event));
}
syncEvents(); syncEvents();
}, },
......
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