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 {
int id;
String description;
......@@ -162,7 +164,7 @@ class EventType{
EventType.fromSensorJson(Map<String, dynamic> json)
: id = json['id'],
name = json['generalName'];
name = json['generalName'];
EventType.fromJson(Map<String, dynamic> json)
: id = json['id'],
......@@ -291,6 +293,27 @@ abstract class EventStoreBase{
}
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() {
//configuration.currentCollection = Collection.fromJson({"id":1,"description":"","collectionName":"FRAM"});
//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(
title: 'Mobile Event Log',
......
......@@ -59,6 +59,7 @@ class _ViewEvents extends State<ViewEvents> {
_sync_status = 'export success';
}
} on SocketException catch (e) {
debugPrint('Exception: $e');
_sync_status = 'No connection';
setState(() {});
} catch (e) {
......@@ -242,9 +243,8 @@ class _ViewEvents extends State<ViewEvents> {
icon: null,
label: const Text('Sync'),
onPressed: () {
for (var event in _events.events){
debugPrint("Event: " + jsonEncode(event));
}
debugPrint(_events.getEventDump());
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