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
2b703d7c
Commit
2b703d7c
authored
3 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
some cleanup
parent
d9b87bbc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/configuration.dart
+12
-16
12 additions, 16 deletions
lib/configuration.dart
lib/main.dart
+4
-4
4 additions, 4 deletions
lib/main.dart
with
16 additions
and
20 deletions
lib/configuration.dart
+
12
−
16
View file @
2b703d7c
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:http/http.dart'
as
http
;
import
'dart:convert'
;
import
'datamodel.dart'
;
...
...
@@ -11,16 +12,12 @@ Future<List<Device>> updateDevices(int collectionId) async {
// Get Access to local device and current event store.
DeviceStoreInstance
availableDevices
=
DeviceStoreInstance
();
EventCurrentInstance
currentEvent
=
EventCurrentInstance
();
List
<
Device
>
collectionDevices
=
[];
final
response
=
await
http
.
get
(
Uri
.
parse
(
url
));
debugPrint
(
"Got something via Sensor Rest..."
);
List
<
Device
>
collectionDevices
=
[];
if
(
response
.
statusCode
==
200
)
{
// If the server did return a 200 OK response, then parse the JSON.
List
<
dynamic
>
data
=
json
.
decode
(
response
.
body
);
for
(
var
entry
in
data
)
{
collectionDevices
.
add
(
Device
.
fromJson
(
entry
));
...
...
@@ -31,16 +28,14 @@ Future<List<Device>> updateDevices(int collectionId) async {
debugPrint
(
device
.
toString
());
}
/*Update to local ev
ent
store*/
/*Update to local
d
ev
ice
store*/
availableDevices
.
store
=
collectionDevices
;
//Update id and urn
in
add event widget
//Update id and urn
for the
add event widget
currentEvent
.
store
.
id
=
collectionDevices
[
0
]
.
id
;
currentEvent
.
store
.
urn
=
collectionDevices
[
0
]
.
urn
;
return
collectionDevices
;
}
else
{
// If the server did not return a 200 OK response,
// then throw an exception.
throw
Exception
(
'Failed to load Collection'
);
}
}
...
...
@@ -57,9 +52,6 @@ Future<List<Collection>> fetchCollections() async {
.
toList
();
}
else
{
// If the server did not return a 200 OK response,
// then throw an exception.
//throw Exception('Failed to load Collection');
debugPrint
(
'Failed to load Collection'
);
return
collectionList
;
}
...
...
@@ -100,20 +92,23 @@ class _MyHomePageState extends State<Configuration> {
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
const
Text
(
'You must be online to do something here!'
,
style:
TextStyle
(
fontSize:
18
)
),
const
SizedBox
(
height:
50
),
FutureBuilder
<
List
<
Collection
>>(
future:
futureCollections
,
builder:
(
context
,
snapshot
){
if
(
snapshot
.
hasData
)
{
collections
.
store
=
[];
//debugPrint('Got Collections:');
snapshot
.
data
?.
forEach
((
element
)
{
//debugPrint(element.id.toString() + ' ' + element.collectionName.toString() + ' #' + element.description.toString());
collections
.
store
.
add
(
element
);
});
/*Initialize active collection with first received collection if not initialized yet*/
/*Initialize active collection with first received
collection if not initialized yet*/
if
(
activeCollection
.
store
.
collectionName
==
''
){
activeCollection
.
store
=
collections
.
store
[
0
];
}
...
...
@@ -161,6 +156,7 @@ class _MyHomePageState extends State<Configuration> {
label:
const
Text
(
'Select'
),
onPressed:
()
{
updateDevices
(
activeCollection
.
store
.
id
);
HapticFeedback
.
vibrate
();
},
),
],
...
...
This diff is collapsed.
Click to expand it.
lib/main.dart
+
4
−
4
View file @
2b703d7c
...
...
@@ -36,7 +36,7 @@ void main() {
currentEvent
.
store
.
label
=
'PS129_ABC'
;
currentEvent
.
store
.
type
=
'Deployment'
;
//Add some dummy events to eventstore. Just development purpose. TODO: Remove after development.
//Add some dummy events to event
store. Just development purpose. TODO: Remove after development.
events
.
store
.
add
(
Event
.
fromJson
({
'id'
:
8311
,
'urn'
:
'station:neumayer_iii:awi_snow_sampler_1'
,
...
...
@@ -87,9 +87,9 @@ void main() {
initialRoute:
'/'
,
routes:
{
'/'
:
(
context
)
=
>
Overview
(),
'/second'
:
(
context
)
=
>
AddEvent
(),
'/third'
:
(
context
)
=
>
ViewEvents
(),
'/forth'
:
(
context
)
=
>
Configuration
(),
'/second'
:
(
context
)
=
>
const
AddEvent
(),
'/third'
:
(
context
)
=
>
const
ViewEvents
(),
'/forth'
:
(
context
)
=
>
const
Configuration
(),
},
));
}
...
...
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