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
5a88e760
Commit
5a88e760
authored
3 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
adding events locally works basically
parent
730d082f
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
+37
-12
37 additions, 12 deletions
lib/addevent.dart
lib/datamodel.dart
+46
-13
46 additions, 13 deletions
lib/datamodel.dart
lib/main.dart
+7
-6
7 additions, 6 deletions
lib/main.dart
with
90 additions
and
31 deletions
lib/addevent.dart
+
37
−
12
View file @
5a88e760
...
@@ -2,11 +2,29 @@ import 'package:flutter/cupertino.dart';
...
@@ -2,11 +2,29 @@ import 'package:flutter/cupertino.dart';
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'datamodel.dart'
;
import
'datamodel.dart'
;
class
AddEvent
extends
StatelessWidget
{
class
AddEvent
extends
StatelessWidget
{
void
_storeCurrentEvent
()
{
final
EventStoreInstance
storedEvents
=
EventStoreInstance
();
final
EventCurrentInstance
currentEvent
=
EventCurrentInstance
();
storedEvents
.
store
.
add
(
Event
(
currentEvent
.
store
.
id
,
currentEvent
.
store
.
urn
,
currentEvent
.
store
.
label
,
currentEvent
.
store
.
type
,
currentEvent
.
store
.
description
,
currentEvent
.
store
.
status
,
));
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
/* Get singletons to access relevant data here.*/
/* Get singletons to access relevant data here.*/
final
EventTypeStoreInstance
eventTypes
=
EventTypeStoreInstance
();
final
EventTypeStoreInstance
eventTypes
=
EventTypeStoreInstance
();
final
DeviceStoreInstance
availableDevice
=
DeviceStoreInstance
();
final
EventStoreInstance
storedEvents
=
EventStoreInstance
();
final
EventCurrentInstance
currentEvent
=
EventCurrentInstance
();
final
EventCurrentInstance
currentEvent
=
EventCurrentInstance
();
return
Scaffold
(
return
Scaffold
(
...
@@ -16,9 +34,13 @@ class AddEvent extends StatelessWidget {
...
@@ -16,9 +34,13 @@ class AddEvent extends StatelessWidget {
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
<
Widget
>[
children:
<
Widget
>[
TextFormField
(
TextFormField
(
initialValue:
currentEvent
.
store
.
label
,
decoration:
const
InputDecoration
(
decoration:
const
InputDecoration
(
labelText:
'Label'
labelText:
'Label'
),
),
onChanged:
(
value
)
{
currentEvent
.
store
.
label
=
value
;
},
),
),
DropdownButtonFormField
(
DropdownButtonFormField
(
value:
currentEvent
.
store
.
type
,
value:
currentEvent
.
store
.
type
,
...
@@ -37,26 +59,29 @@ class AddEvent extends StatelessWidget {
...
@@ -37,26 +59,29 @@ class AddEvent extends StatelessWidget {
}
}
),
),
DropdownButtonFormField
(
DropdownButtonFormField
(
value:
currentEvent
.
store
.
urn
,
decoration:
const
InputDecoration
(
decoration:
const
InputDecoration
(
labelText:
'URN'
,
labelText:
'URN'
,
),
),
items:
[
items:
DropdownMenuItem
(
availableDevice
.
store
.
map
((
Device
device
)
{
child:
Text
(
'ADCP'
),
return
DropdownMenuItem
(
value:
'ADCP'
,
value:
device
.
urn
,
),
child:
Text
(
device
.
urn
),
DropdownMenuItem
(
);
child:
Text
(
'EM712'
),
})
.
toList
(),
value:
'EM712'
,
)
],
onChanged:
(
value
)
{
onChanged:
(
value
)
{
currentEvent
.
store
.
urn
=
value
.
toString
();
}
}
),
),
TextFormField
(
TextFormField
(
initialValue:
currentEvent
.
store
.
description
,
decoration:
const
InputDecoration
(
decoration:
const
InputDecoration
(
labelText:
'Description'
labelText:
'Description'
),
),
onChanged:
(
value
)
{
currentEvent
.
store
.
description
=
value
;
},
),
),
TextFormField
(
TextFormField
(
decoration:
const
InputDecoration
(
decoration:
const
InputDecoration
(
...
@@ -76,7 +101,7 @@ class AddEvent extends StatelessWidget {
...
@@ -76,7 +101,7 @@ class AddEvent extends StatelessWidget {
]),
]),
bottomNavigationBar:
Row
(
bottomNavigationBar:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
mainAxisAlignment:
MainAxisAlignment
.
end
,
children:
const
[
children:
[
FloatingActionButton
(
FloatingActionButton
(
heroTag:
null
,
heroTag:
null
,
onPressed:
null
,
onPressed:
null
,
...
@@ -86,7 +111,7 @@ class AddEvent extends StatelessWidget {
...
@@ -86,7 +111,7 @@ class AddEvent extends StatelessWidget {
SizedBox
(
width:
50
),
SizedBox
(
width:
50
),
FloatingActionButton
(
FloatingActionButton
(
heroTag:
null
,
heroTag:
null
,
onPressed:
null
,
onPressed:
_storeCurrentEvent
,
tooltip:
'Add Event'
,
tooltip:
'Add Event'
,
child:
Icon
(
Icons
.
add
),
child:
Icon
(
Icons
.
add
),
),
),
...
...
This diff is collapsed.
Click to expand it.
lib/datamodel.dart
+
46
−
13
View file @
5a88e760
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
class
Device
{
int
id
;
String
urn
;
Device
(
this
.
id
,
this
.
urn
);
factory
Device
.
fromJson
(
Map
<
String
,
dynamic
>
parsedJson
){
return
Device
(
parsedJson
[
'id'
]
as
int
,
parsedJson
[
'urn'
]
as
String
);
}
@override
String
toString
(){
return
'{
${this.id}
,
${this.urn}
}'
;
}
}
class
Event
{
class
Event
{
int
id
;
int
id
;
String
urn
;
String
urn
;
...
@@ -32,30 +49,33 @@ class Event{
...
@@ -32,30 +49,33 @@ class Event{
}
}
}
}
abstract
class
EventStoreBase
{
List
<
Event
>
store
=
[];
}
abstract
class
EventCurrentBase
{
Event
store
=
Event
(
0
,
'urn0'
,
''
,
''
,
''
,
'PENDING'
);
}
class
EventType
{
class
EventType
{
int
id
;
int
id
;
String
name
;
String
name
;
EventType
(
EventType
(
this
.
id
,
this
.
id
,
this
.
name
this
.
name
);
);
factory
EventType
.
fromJson
(
Map
<
String
,
dynamic
>
parsedJson
){
factory
EventType
.
fromJson
(
Map
<
String
,
dynamic
>
parsedJson
){
return
EventType
(
parsedJson
[
'id'
]
as
int
,
parsedJson
[
'name'
]
as
String
);
return
EventType
(
parsedJson
[
'id'
]
as
int
,
parsedJson
[
'name'
]
as
String
);
}
}
}
}
abstract
class
DeviceStoreBase
{
List
<
Device
>
store
=
[];
}
abstract
class
EventStoreBase
{
List
<
Event
>
store
=
[];
}
abstract
class
EventCurrentBase
{
Event
store
=
Event
(
0
,
'urn0'
,
''
,
''
,
''
,
'PENDING'
);
}
abstract
class
EventTypeStoreBase
{
abstract
class
EventTypeStoreBase
{
List
<
EventType
>
store
=
[];
List
<
EventType
>
store
=
[];
}
}
...
@@ -94,4 +114,17 @@ class EventTypeStoreInstance extends EventTypeStoreBase{
...
@@ -94,4 +114,17 @@ class EventTypeStoreInstance extends EventTypeStoreBase{
EventTypeStoreInstance
.
_internal
(){
EventTypeStoreInstance
.
_internal
(){
store
=
[];
store
=
[];
}
}
}
class
DeviceStoreInstance
extends
DeviceStoreBase
{
static
final
DeviceStoreInstance
_instance
=
DeviceStoreInstance
.
_internal
();
factory
DeviceStoreInstance
(){
return
_instance
;
}
DeviceStoreInstance
.
_internal
(){
store
=
[];
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/main.dart
+
7
−
6
View file @
5a88e760
...
@@ -12,19 +12,20 @@ void main() {
...
@@ -12,19 +12,20 @@ void main() {
EventStoreInstance
events
=
EventStoreInstance
();
EventStoreInstance
events
=
EventStoreInstance
();
EventTypeStoreInstance
eventTypes
=
EventTypeStoreInstance
();
EventTypeStoreInstance
eventTypes
=
EventTypeStoreInstance
();
EventCurrentInstance
currentEvent
=
EventCurrentInstance
();
EventCurrentInstance
currentEvent
=
EventCurrentInstance
();
DeviceStoreInstance
availableDevice
=
DeviceStoreInstance
();
// Add some dummy devices
availableDevice
.
store
.
add
(
Device
.
fromJson
({
'id'
:
8311
,
'urn'
:
'station:neumayer_iii:awi_snow_sampler_1'
}));
availableDevice
.
store
.
add
(
Device
.
fromJson
({
'id'
:
4086
,
'urn'
:
'acoustic_backscatter_sensor:test'
}));
// Create current event as basis when starting add event widget
// Create current event as basis when starting add event widget
currentEvent
.
store
.
urn
=
'
ADCP
'
;
currentEvent
.
store
.
urn
=
'
acoustic_backscatter_sensor:test
'
;
currentEvent
.
store
.
id
=
1234
;
currentEvent
.
store
.
id
=
1234
;
currentEvent
.
store
.
description
=
'blabla'
;
currentEvent
.
store
.
description
=
'blabla'
;
currentEvent
.
store
.
label
=
'PS129_ABC'
;
currentEvent
.
store
.
label
=
'PS129_ABC'
;
currentEvent
.
store
.
type
=
'Deployment'
;
currentEvent
.
store
.
type
=
'Deployment'
;
//Add some dummy events to eventstore
//Add some dummy events to eventstore
events
.
store
.
add
(
Event
.
fromJson
({
events
.
store
.
add
(
Event
.
fromJson
({
'id'
:
8311
,
'id'
:
8311
,
...
...
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