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
0045f696
Commit
0045f696
authored
2 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
some ui improvements
parent
02b8797e
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
+157
-147
157 additions, 147 deletions
lib/configuration.dart
lib/viewevents.dart
+1
-1
1 addition, 1 deletion
lib/viewevents.dart
with
158 additions
and
148 deletions
lib/configuration.dart
+
157
−
147
View file @
0045f696
...
...
@@ -44,160 +44,170 @@ class _MyHomePageState extends State<Configuration> {
final
EventStoreInstance
events
=
EventStoreInstance
();
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Configuration'
),
),
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
const
Text
(
'You must be online to do something here!'
,
style:
TextStyle
(
fontSize:
14
)
),
const
SizedBox
(
height:
50
),
TextFormField
(
keyboardType:
TextInputType
.
emailAddress
,
autofocus:
false
,
initialValue:
configuration
.
loginInformation
.
mail
,
decoration:
const
InputDecoration
(
labelText:
'Sensor E-Mail'
,
hintText:
'User for writing events'
,
),
onChanged:
(
value
)
{
configuration
.
loginInformation
.
mail
=
value
;
},
onFieldSubmitted:
(
value
)
{
futureAuthToken
=
connector
.
getAuthToken
(
configuration
.
loginInformation
.
mail
,
configuration
.
loginInformation
.
password
);
},
),
TextFormField
(
autofocus:
false
,
initialValue:
configuration
.
loginInformation
.
password
,
decoration:
const
InputDecoration
(
labelText:
'Sensor Password'
,
hintText:
'Password for writing events'
,
),
onChanged:
(
value
){
configuration
.
loginInformation
.
password
=
value
;
},
onFieldSubmitted:
(
value
)
{
futureAuthToken
=
connector
.
getAuthToken
(
configuration
.
loginInformation
.
mail
,
configuration
.
loginInformation
.
password
);
},
),
const
SizedBox
(
height:
50
),
FutureBuilder
<
List
<
Collection
>>(
future:
futureCollections
,
builder:
(
context
,
snapshot
){
if
(
snapshot
.
hasData
)
{
configuration
.
collections
=
[];
snapshot
.
data
?.
forEach
((
element
)
{
configuration
.
collections
.
add
(
element
);
});
/*Initialize active collection with first received
appBar:
AppBar
(
title:
const
Text
(
'Configuration'
),
),
body:
Container
(
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
5.0
),
child:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
const
Text
(
'You must be online to do something here!'
,
style:
TextStyle
(
fontSize:
14
)
),
const
SizedBox
(
height:
50
),
TextFormField
(
keyboardType:
TextInputType
.
emailAddress
,
autofocus:
false
,
initialValue:
configuration
.
loginInformation
.
mail
,
decoration:
const
InputDecoration
(
labelText:
'Sensor E-Mail'
,
hintText:
'User for writing events'
,
),
onChanged:
(
value
)
{
configuration
.
loginInformation
.
mail
=
value
;
},
onFieldSubmitted:
(
value
)
{
futureAuthToken
=
connector
.
getAuthToken
(
configuration
.
loginInformation
.
mail
,
configuration
.
loginInformation
.
password
);
},
),
TextFormField
(
autofocus:
false
,
initialValue:
configuration
.
loginInformation
.
password
,
decoration:
const
InputDecoration
(
labelText:
'Sensor Password'
,
hintText:
'Password for writing events'
,
),
onChanged:
(
value
){
configuration
.
loginInformation
.
password
=
value
;
},
onFieldSubmitted:
(
value
)
{
futureAuthToken
=
connector
.
getAuthToken
(
configuration
.
loginInformation
.
mail
,
configuration
.
loginInformation
.
password
);
},
),
const
SizedBox
(
height:
50
),
FutureBuilder
<
List
<
Collection
>>(
future:
futureCollections
,
builder:
(
context
,
snapshot
){
if
(
snapshot
.
hasData
)
{
configuration
.
collections
=
[];
snapshot
.
data
?.
forEach
((
element
)
{
configuration
.
collections
.
add
(
element
);
});
/*Initialize active collection with first received
collection if not initialized yet*/
if
(
configuration
.
currentCollection
.
id
==
-
1
){
configuration
.
currentCollection
=
configuration
.
collections
[
0
];
futureDevices
=
connector
.
fetchCollectionDevices
(
configuration
.
currentCollection
.
id
);
}
return
DropdownButtonFormField
(
value:
configuration
.
currentCollection
.
collectionName
,
decoration:
const
InputDecoration
(
labelText:
'Chose Collection'
,
),
items:
configuration
.
collections
.
map
((
Collection
collection
)
{
return
DropdownMenuItem
(
value:
collection
.
collectionName
,
child:
Text
(
collection
.
collectionName
),
);
})
.
toList
(),
onChanged:
(
value
)
{
configuration
.
currentCollection
=
configuration
.
getCollectionFromName
(
value
.
toString
());
//Fetch new selected collection devices
if
(
configuration
.
currentCollection
.
id
==
-
1
){
configuration
.
currentCollection
=
configuration
.
collections
[
0
];
futureDevices
=
connector
.
fetchCollectionDevices
(
configuration
.
currentCollection
.
id
);
}
);
}
else
{
return
const
CircularProgressIndicator
();
}
}
return
DropdownButtonFormField
(
value:
configuration
.
currentCollection
.
collectionName
,
decoration:
const
InputDecoration
(
labelText:
'Chose Collection'
,
),
items:
configuration
.
collections
.
map
((
Collection
collection
)
{
return
DropdownMenuItem
(
value:
collection
.
collectionName
,
child:
Text
(
collection
.
collectionName
),
);
})
.
toList
(),
onChanged:
(
value
)
{
configuration
.
currentCollection
=
configuration
.
getCollectionFromName
(
value
.
toString
());
//Fetch new selected collection devices
futureDevices
=
connector
.
fetchCollectionDevices
(
configuration
.
currentCollection
.
id
);
}
);
}
else
{
return
const
CircularProgressIndicator
();
}
}
),
],
),
],
),
),
bottomNavigationBar:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
FloatingActionButton
.
extended
(
heroTag:
null
,
tooltip:
'Reset all data'
,
icon:
const
Icon
(
Icons
.
cancel
),
label:
const
Text
(
'Reset all'
),
onPressed:
()
{
//events.reset(); //TODO: remove before release!
configuration
.
reset
();
//TODO: remove before release this is not a real use case!
},
),
FloatingActionButton
.
extended
(
heroTag:
null
,
tooltip:
'Select Collection and download corresponding devices'
,
icon:
const
Icon
(
Icons
.
save
),
label:
const
Text
(
'Store'
),
onPressed:
()
{
futureAuthToken
.
then
((
value
){
//NOTE: Counterintuitive async callback function
debugPrint
(
"Login credentials correct! Auth Token: "
+
value
);
futureDevices
.
then
((
value
)
{
debugPrint
(
"Device List complete"
);
configuration
.
devices
=
value
;
futureEventTypes
.
then
((
value
)
{
debugPrint
(
"Event Types List complete"
);
configuration
.
eventTypes
=
value
;
debugPrint
(
"EventType Json: "
+
jsonEncode
(
configuration
.
eventTypes
[
0
]));
debugPrint
(
"Device Json: "
+
jsonEncode
(
configuration
.
devices
[
0
]));
debugPrint
(
"Current Collection Json: "
+
jsonEncode
(
configuration
.
currentCollection
));
debugPrint
(
"Sensor Login Json: "
+
jsonEncode
(
configuration
.
loginInformation
));
try
{
//Update id and urn for the add event widget with some initial data
events
.
currentEvent
.
id
=
configuration
.
devices
[
0
]
.
id
;
//TODO: fix if devices are an empty list.
events
.
currentEvent
.
urn
=
configuration
.
devices
[
0
]
.
urn
;
events
.
currentEvent
.
description
=
''
;
events
.
currentEvent
.
label
=
''
;
events
.
currentEvent
.
type
=
configuration
.
eventTypes
[
0
]
.
name
;
var
date
=
DateTime
.
now
()
.
toUtc
();
var
isoDate
=
date
.
toIso8601String
();
events
.
currentEvent
.
startDate
=
isoDate
;
events
.
currentEvent
.
endDate
=
isoDate
;
configuration
.
initialized
=
true
;
HapticFeedback
.
vibrate
();
//TODO: display success user feedback
}
catch
(
e
)
{
throw
Exception
(
'Something went wrong try again'
);
}
),
bottomNavigationBar:
Container
(
margin:
const
EdgeInsets
.
symmetric
(
vertical:
10.0
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
children:
[
const
SizedBox
(
width:
10.0
),
FloatingActionButton
.
extended
(
heroTag:
null
,
tooltip:
'Reset all data'
,
icon:
const
Icon
(
Icons
.
cancel
),
label:
const
Text
(
'Reset all'
),
onPressed:
()
{
//events.reset(); //TODO: remove before release!
configuration
.
reset
();
//TODO: remove before release this is not a real use case!
},
),
const
SizedBox
(
width:
50
),
FloatingActionButton
.
extended
(
heroTag:
null
,
tooltip:
'Select Collection and download corresponding devices'
,
icon:
const
Icon
(
Icons
.
save
),
label:
const
Text
(
'Store'
),
onPressed:
()
{
futureAuthToken
.
then
((
value
){
//NOTE: Counterintuitive async callback function
debugPrint
(
"Login credentials correct! Auth Token: "
+
value
);
futureDevices
.
then
((
value
)
{
debugPrint
(
"Device List complete"
);
configuration
.
devices
=
value
;
futureEventTypes
.
then
((
value
)
{
debugPrint
(
"Event Types List complete"
);
configuration
.
eventTypes
=
value
;
debugPrint
(
"EventType Json: "
+
jsonEncode
(
configuration
.
eventTypes
[
0
]));
debugPrint
(
"Device Json: "
+
jsonEncode
(
configuration
.
devices
[
0
]));
debugPrint
(
"Current Collection Json: "
+
jsonEncode
(
configuration
.
currentCollection
));
debugPrint
(
"Sensor Login Json: "
+
jsonEncode
(
configuration
.
loginInformation
));
try
{
//Update id and urn for the add event widget with some initial data
events
.
currentEvent
.
id
=
configuration
.
devices
[
0
]
.
id
;
//TODO: fix if devices are an empty list.
events
.
currentEvent
.
urn
=
configuration
.
devices
[
0
]
.
urn
;
events
.
currentEvent
.
description
=
''
;
events
.
currentEvent
.
label
=
''
;
events
.
currentEvent
.
type
=
configuration
.
eventTypes
[
0
]
.
name
;
var
date
=
DateTime
.
now
()
.
toUtc
();
var
isoDate
=
date
.
toIso8601String
();
events
.
currentEvent
.
startDate
=
isoDate
;
events
.
currentEvent
.
endDate
=
isoDate
;
configuration
.
initialized
=
true
;
HapticFeedback
.
vibrate
();
//TODO: display success user feedback
}
catch
(
e
)
{
throw
Exception
(
'Something went wrong try again'
);
}
});
});
});
});
});
//TODO: display failed as user feedback somehow
},
//TODO: display failed as user feedback somehow
},
),
const
SizedBox
(
width:
10.0
),
],
),
],
),
)
);
}
}
This diff is collapsed.
Click to expand it.
lib/viewevents.dart
+
1
−
1
View file @
0045f696
...
...
@@ -246,7 +246,7 @@ class _ViewEvents extends State<ViewEvents> {
},
),
),
const
SizedBox
(
width:
10
.0
),
const
SizedBox
(
width:
5
.0
),
],
),
);
...
...
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