Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MobileEventLog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Data-Logistics-Support
MobileEventLog
Commits
30973c57
Commit
30973c57
authored
2 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
moved json event file export to configuration widget
parent
5bd68ac0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/addevent.dart
+5
-3
5 additions, 3 deletions
lib/addevent.dart
lib/configuration.dart
+41
-10
41 additions, 10 deletions
lib/configuration.dart
lib/viewevents.dart
+0
-23
0 additions, 23 deletions
lib/viewevents.dart
with
46 additions
and
36 deletions
lib/addevent.dart
+
5
−
3
View file @
30973c57
...
...
@@ -143,7 +143,7 @@ class _AddEventPageState extends State<AddEvent> {
if
(
RegExp
(
r'^[a-z A-Z . \- 0-9 , ( ) + - _ :]+$'
)
.
hasMatch
(
eventStore
.
currentEvent
.
label
))
{
if
(
RegExp
(
r'^[a-z A-Z . \- 0-9 , ( ) + - _ :]+$'
)
.
hasMatch
(
eventStore
.
currentEvent
.
description
))
{
eventStore
.
currentEvent
.
description
)
||
eventStore
.
currentEvent
.
description
==
''
)
{
if
(
_validateLatitude
(
eventStore
.
currentEvent
.
latitude
)){
if
(
_validateLongitude
(
eventStore
.
currentEvent
.
longitude
)){
if
(
_validateElevation
(
eventStore
.
currentEvent
.
elevation
)){
...
...
@@ -282,9 +282,11 @@ class _AddEventPageState extends State<AddEvent> {
validator:
(
value
)
{
if
(
!
RegExp
(
r'^[a-z A-Z . \- 0-9 , ( ) + - _ :]+$'
)
.
hasMatch
(
value
!
))
{
if
(
value
==
''
){
return
null
;
//An empty description is also allowed.
}
return
"Only: a-z , A-Z , _ , 0-9 , ,(Comma) , ( , ) , + , - , . , :"
;
}
else
{
//eventStore.currentEvent.label = value;
return
null
;
// Entered Text is valid
}
},
...
...
@@ -486,7 +488,7 @@ class _AddEventPageState extends State<AddEvent> {
//child: const Icon(Icons.check),
)
),
const
SizedBox
(
width:
10
.0
),
const
SizedBox
(
width:
5
.0
),
],
),
);
...
...
This diff is collapsed.
Click to expand it.
lib/configuration.dart
+
41
−
10
View file @
30973c57
import
'dart:convert'
;
import
'dart:io'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'datamodel.dart'
;
import
'sensorconnector.dart'
;
import
'databaseconnector.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:path/path.dart'
;
import
'package:path_provider/path_provider.dart'
;
class
Configuration
extends
StatefulWidget
{
const
Configuration
({
Key
?
key
})
:
super
(
key:
key
);
...
...
@@ -19,10 +22,37 @@ class _MyHomePageState extends State<Configuration> {
late
Future
<
List
<
EventType
>>
futureEventTypes
;
late
Future
<
List
<
Device
>>
futureDevices
;
late
Future
<
String
>
futureAuthToken
;
var
database
=
DatabaseInstance
();
SensorConnector
connector
=
SensorConnector
();
final
ConfigurationStoreInstance
configuration
=
ConfigurationStoreInstance
();
Future
<
void
>
dumpToFile
()
async
{
var
date
=
DateTime
.
now
()
.
toUtc
();
var
isoDate
=
date
.
toIso8601String
();
String
filename
=
date
.
year
.
toString
()
.
padLeft
(
4
,
'0'
)
+
date
.
month
.
toString
()
.
padLeft
(
2
,
'0'
)
+
date
.
day
.
toString
()
.
padLeft
(
2
,
'0'
)
+
date
.
hour
.
toString
()
.
padLeft
(
2
,
'0'
)
+
date
.
minute
.
toString
()
.
padLeft
(
2
,
'0'
)
+
date
.
second
.
toString
()
.
padLeft
(
2
,
'0'
)
+
'_events.json'
;
String
eventsJson
=
await
database
.
eventDump
();
final
Directory
?
directory
=
await
getExternalStorageDirectory
();
if
(
directory
!=
null
)
{
String
filepath
=
join
(
directory
.
path
,
filename
);
final
File
file
=
File
(
filepath
);
await
file
.
writeAsString
(
eventsJson
);
debugPrint
(
'Stored file at: '
+
filepath
);
}
}
Future
<
void
>
updateConfiguration
()
async
{
final
EventStoreInstance
event
=
EventStoreInstance
();
...
...
@@ -197,18 +227,19 @@ class _MyHomePageState extends State<Configuration> {
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
children:
[
const
SizedBox
(
width:
10.0
),
//
const SizedBox(width: 10.0),
FloatingActionButton
.
extended
(
heroTag:
null
,
tooltip:
'
Reset all data
'
,
icon:
const
Icon
(
Icons
.
cancel
),
label:
const
Text
(
'
Reset all
'
),
tooltip:
'
Export events to local .json file
'
,
icon:
const
Icon
(
Icons
.
download
),
label:
const
Text
(
'
Export Events
'
),
onPressed:
()
{
//events.reset(); //TODO: remove before release!
var
db
=
DatabaseInstance
();
db
.
delete
();
dumpToFile
();
configuration
.
reset
();
//TODO: remove before release this is not a real use case!
//events.reset(); //TODO: remove before release this is not a real use case!
//var db = DatabaseInstance();
//db.delete();
//configuration.reset();
},
),
const
SizedBox
(
width:
50
),
...
...
@@ -222,7 +253,7 @@ class _MyHomePageState extends State<Configuration> {
//TODO: display failed as user feedback somehow
},
),
const
SizedBox
(
width:
10
.0
),
const
SizedBox
(
width:
5
.0
),
],
),
)
...
...
This diff is collapsed.
Click to expand it.
lib/viewevents.dart
+
0
−
23
View file @
30973c57
import
'dart:io'
;
import
'package:flutter/material.dart'
;
import
'package:path_provider/path_provider.dart'
;
import
'datamodel.dart'
;
import
'sensorconnector.dart'
;
import
'databaseconnector.dart'
;
import
'package:path/path.dart'
;
class
ViewEvents
extends
StatefulWidget
{
const
ViewEvents
({
Key
?
key
})
:
super
(
key:
key
);
...
...
@@ -34,24 +32,6 @@ class _ViewEvents extends State<ViewEvents> {
setState
(()
{});
//Got events from database, so update UI
}
Future
<
void
>
dumpToFile
()
async
{
//localEvents = await database.getEvents();
var
date
=
DateTime
.
now
()
.
toUtc
();
var
isoDate
=
date
.
toIso8601String
();
String
eventsJson
=
await
database
.
eventDump
();
final
Directory
?
directory
=
await
getExternalStorageDirectory
();
if
(
directory
!=
null
)
{
String
filename
=
'time_event_dump.json'
;
String
filepath
=
join
(
directory
.
path
,
filename
);
final
File
file
=
File
(
filepath
);
await
file
.
writeAsString
(
eventsJson
);
debugPrint
(
'Stored file at: '
+
filepath
);
}
}
@override
void
initState
()
{
_syncStatus
=
''
;
...
...
@@ -279,8 +259,6 @@ class _ViewEvents extends State<ViewEvents> {
label:
const
Text
(
'Sync'
),
onPressed:
()
{
syncEvents
();
dumpToFile
();
//TODO. Move to right button.
},
),
),
...
...
@@ -291,4 +269,3 @@ class _ViewEvents extends State<ViewEvents> {
}
}
//TODO: allow editing fields here. Check validation of input value!
//TODO: dump events to json for local backups in the field. "dumpToFile"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment