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

cleanup sources

parent f189fbcb
No related branches found
No related tags found
No related merge requests found
......@@ -178,7 +178,6 @@ class _AddEventPageState extends State<AddEvent> {
));
}
//TODO: add field validators for freetext fields. Check allowed characters in sensor.awi.de
@override
Widget build(BuildContext context) {
/* Get singletons to access relevant data here.*/
......
......@@ -27,19 +27,19 @@ Future<int> login() async {
if (response.statusCode == 200) {
debugPrint('Login success');
//TODO: display feedback to user that credentials are correct
debugPrint(response.body.toString());
debugPrint(response.headers.toString());
debugPrint(response.headers['set-cookie']);
//TODO store token
} else {
debugPrint('Header: ' + response.headers.toString());
debugPrint('Body: ' + response.body.toString());
debugPrint('StatusCode: ' + response.statusCode.toString());
throw Exception('Failed to login');
//TODO: display feedback to user. Only allow export in view events if user is valid.
}
return 0;
......
......@@ -159,12 +159,10 @@ class EventType{
class SensorLogin{
String mail;
String password;
String token;
SensorLogin(
this.mail,
this.password,
this.token //REST API access Token
);
String toJsonString() {
......@@ -186,7 +184,7 @@ abstract class ConfigurationStoreBase {
Collection currentCollection = Collection(id: -1, description: '', collectionName: '');
List<Device> devices = [];
List<EventType> eventTypes = [];
SensorLogin loginInformation = SensorLogin('', '', '');
SensorLogin loginInformation = SensorLogin('', '');
bool initialized = false;
Collection getCollectionFromName(String name) {
......@@ -221,7 +219,7 @@ abstract class ConfigurationStoreBase {
devices = [];
eventTypes = [];
currentCollection = Collection(id: -1, description: '', collectionName: '');
loginInformation = SensorLogin('admin', 'adminadmin', '');
loginInformation = SensorLogin('admin', 'adminadmin');
initialized = false;
}
}
......
......@@ -31,9 +31,6 @@ Future<int> login() async {
debugPrint(response.headers.toString());
debugPrint(response.headers['set-cookie']);
//TODO store token
} else {
debugPrint('Header: ' + response.headers.toString());
debugPrint('Body: ' + response.body.toString());
......
......@@ -18,79 +18,9 @@ void main() {
configuration.reset();
configuration.loginInformation.mail = 'admin'; // Sandbox.sensor.de admin account
configuration.loginInformation.password ='adminadmin';
configuration.loginInformation.password ='adminadmin'; //TODO: replace for productive version.
// Add some dummy devices
// TODO: load from shared preferences.
// TODO: this shall be requested from sensor.awi.de after selecting a collection in configuration.
//configuration.devices.add(Device.fromJson({'id': 8311, 'urn':'station:neumayer_iii:awi_snow_sampler_1'}));
//configuration.devices.add(Device.fromJson({'id': 4086, 'urn':'acoustic_backscatter_sensor:test'}));
//configuration.devices.add(Device.fromJson({'id': 1393, 'urn':'vessel:polarstern:hydrosweep_ds3'}));
// Fill the textboxes in addevent with some usefull data.
// TODO: store this in shared preferences so that last entered data reappears when restarting the app.
//events.currentEvent.urn = 'vessel:polarstern:hydrosweep_ds3';
//events.currentEvent.id = -1;
//events.currentEvent.description = '';
//events.currentEvent.label = '';
//events.currentEvent.type = 'Configuration';
//events.currentEvent.startDate = '2022-03-09 15:06:00.000Z';
//events.currentEvent.endDate = '2022-03-09 15:08:00.000Z';
//Add some dummy events to event store. Just development purpose. TODO: Remove after development.
/*
events.events.add(Event.fromJson({
'id': 8311,
'urn': 'station:neumayer_iii:awi_snow_sampler_1',
'label': 'SML_KO21_SC01',
'type': 'Deployment',
'description': 'Remi tool Tag1 1 Traverse',
'status': 'PENDING',
'startDate': '2022-03-08T05:29:26Z',
'endDate': '2022-03-08T06:29:26Z'
}));
events.events.add(Event.fromJson({
'id': 8311,
'urn': 'station:neumayer_iii:awi_snow_sampler_1',
'label': 'SML_KO21_SC01',
'type': 'Deployment',
'description': 'Remi tool Tag1 1 Traverse',
'status': 'PENDING',
'startDate': '2022-03-08T05:29:26Z',
'endDate': '2022-03-08T06:29:26Z'
}));
events.events.add(Event.fromJson({
'id': 8311,
'urn': 'station:neumayer_iii:awi_snow_sampler_1',
'label': 'SML_KO21_SC01',
'type': 'Deployment',
'description': 'Remi tool Tag1 1 Traverse',
'status': 'PENDING',
'startDate': '2022-03-08T05:29:26Z',
'endDate': '2022-03-08T06:29:26Z'
}));
events.events.add(Event.fromJson({
'id': 8311,
'urn': 'station:neumayer_iii:awi_snow_sampler_1',
'label': 'SML_KO21_SC01',
'type': 'Deployment',
'description': 'Remi tool Tag1 1 Traverse',
'status': 'PENDING',
'startDate': '2022-03-08T05:29:26Z',
'endDate': '2022-03-08T06:29:26Z'
}));
*/
//Add some dummy eventtypes.
// TODO: loard from shared preferences.
// TODO: request from https://sensor.awi.de/rest/sensors/events/getAllEventTypes in configuration widget.
//configuration.eventTypes.add(EventType.fromJson({'id': 317, 'generalName':'Configuration'}));
//configuration.eventTypes.add(EventType.fromJson({'id': 216, 'generalName':'Decommissioned'}));
//configuration.eventTypes.add(EventType.fromJson({'id': 187, 'generalName':'Deployment'}));
//configuration.eventTypes.add(EventType.fromJson({'id': 50, 'generalName':'Information'}));
//configuration.eventTypes.add(EventType.fromJson({'id': 16, 'generalName':'Maintenance'}));
// TODO: load configuration and events from shared preferences.
runApp(MaterialApp(
title: 'Mobile Event Log',
......
......@@ -7,10 +7,13 @@ import 'package:http/http.dart' as http;
Future<bool> syncEvents() async {
final EventStoreInstance events = EventStoreInstance();
final ConfigurationStoreInstance configuration = ConfigurationStoreInstance();
String base_url = 'https://sandbox.sensor.awi.de/rest/sensors/events/putEvent/';
String baseUrl = 'https://sandbox.sensor.awi.de/rest/sensors/events/putEvent/';
String url = '';
debugPrint('Number of Events: ' + events.events.length.toString());
debugPrint('Pending Events:');
var index = 0;
......@@ -19,11 +22,10 @@ Future<bool> syncEvents() async {
debugPrint('Idx: ' + index.toString() + ' ' + event.toSensorJson().toString());
index++;
url = base_url + event.id.toString() + '?createVersion=false';
url = baseUrl + event.id.toString() + '?createVersion=false';
debugPrint('XXX ' + Uri.parse(url).toString());
final response = await http.put(Uri.parse(url),
headers: {
"Content-Type": "application/json",
"Cookie": "x-auth-token=72d9d4d20a33f87edca7e1ba01ce8db8"
......@@ -32,14 +34,14 @@ Future<bool> syncEvents() async {
encoding: Encoding.getByName("utf-8"),
);
if (response.statusCode == 200) {
if (response.statusCode == 201) {
debugPrint('put success');
event.status = 'EXPORTED'; //Update event status so that it is only exported once.
debugPrint(response.body.toString());
debugPrint(response.headers.toString());
debugPrint(response.headers['set-cookie']);
} else {
debugPrint('Header: ' + response.headers.toString());
debugPrint('Body: ' + response.body.toString());
......@@ -54,17 +56,6 @@ Future<bool> syncEvents() async {
class ViewEvents extends StatelessWidget {
const ViewEvents({Key? key}) : super(key: key);
......
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