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
41e0e0ec
Commit
41e0e0ec
authored
3 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
added singleton element for local event storage
parent
572fbb38
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
README.md
+2
-1
2 additions, 1 deletion
README.md
lib/data_model.dart
+38
-10
38 additions, 10 deletions
lib/data_model.dart
lib/main.dart
+26
-28
26 additions, 28 deletions
lib/main.dart
pubspec.lock
+139
-0
139 additions, 0 deletions
pubspec.lock
pubspec.yaml
+2
-0
2 additions, 0 deletions
pubspec.yaml
with
207 additions
and
39 deletions
README.md
+
2
−
1
View file @
41e0e0ec
...
@@ -11,4 +11,5 @@ A cross plattform project for android and ios to log events offline everywhere a
...
@@ -11,4 +11,5 @@ A cross plattform project for android and ios to log events offline everywhere a
## Questions:
## Questions:
-
How to store not uploaded events locally? Dumping jsons to a file?
-
How to store not uploaded events locally? Dumping jsons to a file?, ObjectBox, SharedPreferences,
This diff is collapsed.
Click to expand it.
lib/data_model.dart
+
38
−
10
View file @
41e0e0ec
import
'package:shared_preferences/shared_preferences.dart'
;
class
Event
{
class
Event
{
int
id
;
int
id
;
...
@@ -8,14 +8,40 @@ class Event{
...
@@ -8,14 +8,40 @@ class Event{
String
description
;
String
description
;
String
status
;
String
status
;
Event
({
Event
(
required
this
.
id
,
this
.
id
,
required
this
.
urn
,
this
.
urn
,
required
this
.
label
,
this
.
label
,
required
this
.
type
,
this
.
type
,
required
this
.
description
,
this
.
description
,
required
this
.
status
this
.
status
});
);
factory
Event
.
fromJson
(
Map
<
String
,
dynamic
>
parsedJson
){
return
Event
(
parsedJson
[
'id'
]
as
int
,
parsedJson
[
'urn'
]
as
String
,
parsedJson
[
'label'
]
as
String
,
parsedJson
[
'type'
]
as
String
,
parsedJson
[
'description'
]
as
String
,
parsedJson
[
'status'
]
as
String
);
}
@override
String
toString
(){
return
'{
${this.id}
,
${this.urn}
,
${this.label}
,
${this.type}
,
${this.description}
,
${this.status}
}'
;
}
}
abstract
class
EventStoreBase
{
List
<
Event
>
store
=
[];
void
setStore
(
List
<
Event
>
st
){
store
=
st
;
}
void
reset
(){
store
=
[];
}
}
}
class
EventType
{
class
EventType
{
...
@@ -26,4 +52,6 @@ class EventType{
...
@@ -26,4 +52,6 @@ class EventType{
required
this
.
name
,
required
this
.
name
,
required
this
.
id
required
this
.
id
});
});
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/main.dart
+
26
−
28
View file @
41e0e0ec
...
@@ -2,7 +2,30 @@ import 'package:flutter/cupertino.dart';
...
@@ -2,7 +2,30 @@ import 'package:flutter/cupertino.dart';
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'data_model.dart'
;
import
'data_model.dart'
;
class
EventStoreInstance
extends
EventStoreBase
{
static
final
EventStoreInstance
_instance
=
EventStoreInstance
.
_internal
();
factory
EventStoreInstance
(){
return
_instance
;
}
EventStoreInstance
.
_internal
(){
store
=
[];
}
}
void
main
()
{
void
main
()
{
//Add some dummy events to eventstore
EventStoreInstance
events
=
EventStoreInstance
();
events
.
store
.
add
(
Event
.
fromJson
({
'id'
:
8311
,
'urn'
:
'station:neumayer_iii:awi_snow_sampler_1'
,
'label'
:
'SML_KO21_SC01'
,
'type'
:
'Deployment'
,
'description'
:
'Remi tool Tag1 1 Traverse'
,
'status'
:
'PENDING'
}));
events
.
store
.
add
(
Event
.
fromJson
({
'id'
:
8311
,
'urn'
:
'station:neumayer_iii:awi_snow_sampler_1'
,
'label'
:
'SML_KO21_SC01'
,
'type'
:
'Deployment'
,
'description'
:
'Remi tool Tag1 1 Traverse'
,
'status'
:
'PENDING'
}));
events
.
store
.
add
(
Event
.
fromJson
({
'id'
:
8311
,
'urn'
:
'station:neumayer_iii:awi_snow_sampler_1'
,
'label'
:
'SML_KO21_SC01'
,
'type'
:
'Deployment'
,
'description'
:
'Remi tool Tag1 1 Traverse'
,
'status'
:
'PENDING'
}));
events
.
store
.
add
(
Event
.
fromJson
({
'id'
:
8311
,
'urn'
:
'station:neumayer_iii:awi_snow_sampler_1'
,
'label'
:
'SML_KO21_SC01'
,
'type'
:
'Deployment'
,
'description'
:
'Remi tool Tag1 1 Traverse'
,
'status'
:
'PENDING'
}));
runApp
(
MaterialApp
(
runApp
(
MaterialApp
(
title:
'Mobile Event Log'
,
title:
'Mobile Event Log'
,
theme:
ThemeData
(
theme:
ThemeData
(
...
@@ -82,36 +105,11 @@ class AddEvent extends StatelessWidget {
...
@@ -82,36 +105,11 @@ class AddEvent extends StatelessWidget {
}
}
class
ViewEvents
extends
StatelessWidget
{
class
ViewEvents
extends
StatelessWidget
{
// Add some dummy events:
List
<
Event
>
events
=
[]
.
.
add
(
Event
(
id:
8311
,
urn:
'station:neumayer_iii:awi_snow_sampler_1'
,
label:
'SML_KO21_SC01'
,
type:
'Deployment'
,
description:
'Remi tool Tag1 1 Traverse'
,
status:
'PENDING'
))
.
.
add
(
Event
(
id:
8311
,
urn:
'station:neumayer_iii:awi_snow_sampler_1'
,
label:
'SML_KO21_SC01'
,
type:
'Deployment'
,
description:
'Remi tool Tag1 1 Traverse'
,
status:
'PENDING'
))
.
.
add
(
Event
(
id:
8311
,
urn:
'station:neumayer_iii:awi_snow_sampler_1'
,
label:
'SML_KO21_SC01'
,
type:
'Deployment'
,
description:
'Remi tool Tag1 1 Traverse'
,
status:
'PENDING'
));
//for (var i = 0; i<100; i++){
// events.add(Event(id: i, urn: 'station:neumayer_iii:awi_snow_sampler_1', label: 'SML_KO21_SC01', type: 'Deployment', description: 'Remi tool Tag1 1 Traverse', status: 'PENDING'));
//}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
// Get singleton to access locally stored events:
final
EventStoreInstance
events
=
EventStoreInstance
();
return
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
appBar:
AppBar
(
title:
const
Text
(
"View Added Events"
),
title:
const
Text
(
"View Added Events"
),
...
@@ -160,7 +158,7 @@ class ViewEvents extends StatelessWidget {
...
@@ -160,7 +158,7 @@ class ViewEvents extends StatelessWidget {
),
),
],
],
rows:
<
DataRow
>[
rows:
<
DataRow
>[
for
(
var
event
in
events
)
for
(
var
event
in
events
.
store
)
DataRow
(
DataRow
(
cells:
<
DataCell
>[
cells:
<
DataCell
>[
DataCell
(
Text
(
event
.
id
.
toString
())),
DataCell
(
Text
(
event
.
id
.
toString
())),
...
...
This diff is collapsed.
Click to expand it.
pubspec.lock
+
139
−
0
View file @
41e0e0ec
...
@@ -57,6 +57,20 @@ packages:
...
@@ -57,6 +57,20 @@ packages:
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "1.2.0"
version: "1.2.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
flutter:
flutter:
dependency: "direct main"
dependency: "direct main"
description: flutter
description: flutter
...
@@ -74,6 +88,18 @@ packages:
...
@@ -74,6 +88,18 @@ packages:
description: flutter
description: flutter
source: sdk
source: sdk
version: "0.0.0"
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
lints:
lints:
dependency: transitive
dependency: transitive
description:
description:
...
@@ -102,6 +128,104 @@ packages:
...
@@ -102,6 +128,104 @@ packages:
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "1.8.0"
version: "1.8.0"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.4"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.12"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.10"
shared_preferences_ios:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
sky_engine:
sky_engine:
dependency: transitive
dependency: transitive
description: flutter
description: flutter
...
@@ -163,5 +287,20 @@ packages:
...
@@ -163,5 +287,20 @@ packages:
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "2.1.1"
version: "2.1.1"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.6"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
sdks:
sdks:
dart: ">=2.15.1 <3.0.0"
dart: ">=2.15.1 <3.0.0"
flutter: ">=2.5.0"
This diff is collapsed.
Click to expand it.
pubspec.yaml
+
2
−
0
View file @
41e0e0ec
...
@@ -30,6 +30,8 @@ dependencies:
...
@@ -30,6 +30,8 @@ dependencies:
flutter
:
flutter
:
sdk
:
flutter
sdk
:
flutter
shared_preferences
:
^2.0.12
# The following adds the Cupertino Icons font to your application.
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
# Use with the CupertinoIcons class for iOS style icons.
...
...
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