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
d9b87bbc
Commit
d9b87bbc
authored
3 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
selection of devices in configuration works now
parent
c62aede3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/configuration.dart
+37
-11
37 additions, 11 deletions
lib/configuration.dart
with
37 additions
and
11 deletions
lib/configuration.dart
+
37
−
11
View file @
d9b87bbc
...
@@ -4,17 +4,40 @@ import 'package:http/http.dart' as http;
...
@@ -4,17 +4,40 @@ import 'package:http/http.dart' as http;
import
'dart:convert'
;
import
'dart:convert'
;
import
'datamodel.dart'
;
import
'datamodel.dart'
;
Future
<
List
<
Device
>>
updateDevices
(
int
collectionId
)
async
{
debugPrint
(
"Start HTTP GET Collection Devices. Collection Id: "
+
collectionId
.
toString
());
String
url
=
'https://sensor.awi.de/rest/sensors/collections/getItemsOfCollection/'
+
collectionId
.
toString
();
Future
<
Collection
>
fetchCollection
()
async
{
// Get Access to local device and current event store.
debugPrint
(
"Start HTTP GET++##"
);
DeviceStoreInstance
availableDevices
=
DeviceStoreInstance
();
EventCurrentInstance
currentEvent
=
EventCurrentInstance
();
final
response
=
await
http
final
response
=
await
http
.
get
(
Uri
.
parse
(
'https://sensor.awi.de/rest/sensors/collections/getCollection/22'
));
.
get
(
Uri
.
parse
(
url
));
debugPrint
(
"Got something via Sensor Rest..."
);
List
<
Device
>
collectionDevices
=
[];
if
(
response
.
statusCode
==
200
)
{
if
(
response
.
statusCode
==
200
)
{
// If the server did return a 200 OK response,
// If the server did return a 200 OK response, then parse the JSON.
// then parse the JSON.
List
<
dynamic
>
data
=
json
.
decode
(
response
.
body
);
return
Collection
.
fromJson
(
jsonDecode
(
response
.
body
));
for
(
var
entry
in
data
)
{
collectionDevices
.
add
(
Device
.
fromJson
(
entry
));
}
debugPrint
(
"Got the following devices: "
);
for
(
var
device
in
collectionDevices
){
debugPrint
(
device
.
toString
());
}
/*Update to local event store*/
availableDevices
.
store
=
collectionDevices
;
//Update id and urn in add event widget
currentEvent
.
store
.
id
=
collectionDevices
[
0
]
.
id
;
currentEvent
.
store
.
urn
=
collectionDevices
[
0
]
.
urn
;
return
collectionDevices
;
}
else
{
}
else
{
// If the server did not return a 200 OK response,
// If the server did not return a 200 OK response,
// then throw an exception.
// then throw an exception.
...
@@ -58,7 +81,7 @@ class _MyHomePageState extends State<Configuration> {
...
@@ -58,7 +81,7 @@ class _MyHomePageState extends State<Configuration> {
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
futureCollection
=
fetchCollection
();
//
futureCollection = fetchCollection();
futureCollections
=
fetchCollections
();
futureCollections
=
fetchCollections
();
}
}
late
Future
<
String
>
eventTypes
;
late
Future
<
String
>
eventTypes
;
...
@@ -126,16 +149,19 @@ class _MyHomePageState extends State<Configuration> {
...
@@ -126,16 +149,19 @@ class _MyHomePageState extends State<Configuration> {
FloatingActionButton
.
extended
(
FloatingActionButton
.
extended
(
heroTag:
null
,
heroTag:
null
,
tooltip:
'Request Collections from sensor.awi.de'
,
tooltip:
'Request Collections from sensor.awi.de'
,
icon:
Icon
(
Icons
.
download
),
icon:
const
Icon
(
Icons
.
download
),
label:
const
Text
(
"Get Collections"
),
label:
const
Text
(
"Get Collections"
),
onPressed:
null
,
onPressed:
()
{
},
),
),
FloatingActionButton
.
extended
(
FloatingActionButton
.
extended
(
heroTag:
null
,
heroTag:
null
,
tooltip:
'Select Collection and download corresponding devices'
,
tooltip:
'Select Collection and download corresponding devices'
,
icon:
Icon
(
Icons
.
save
),
icon:
const
Icon
(
Icons
.
save
),
label:
const
Text
(
'Select'
),
label:
const
Text
(
'Select'
),
onPressed:
null
,
onPressed:
()
{
updateDevices
(
activeCollection
.
store
.
id
);
},
),
),
],
],
),
),
...
...
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