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
f8f87cac
Commit
f8f87cac
authored
2 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
sync progress alert dialog partly done
parent
d073bed3
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/viewevents.dart
+52
-23
52 additions, 23 deletions
lib/viewevents.dart
pubspec.lock
+7
-0
7 additions, 0 deletions
pubspec.lock
pubspec.yaml
+1
-1
1 addition, 1 deletion
pubspec.yaml
with
60 additions
and
24 deletions
lib/viewevents.dart
+
52
−
23
View file @
f8f87cac
...
...
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import
'datamodel.dart'
;
import
'sensorconnector.dart'
;
import
'databaseconnector.dart'
;
//
import 'package:getwidget/getwidget.dart';
import
'package:getwidget/getwidget.dart'
;
class
ViewEvents
extends
StatefulWidget
{
const
ViewEvents
({
Key
?
key
})
:
super
(
key:
key
);
...
...
@@ -18,14 +18,27 @@ class _ViewEvents extends State<ViewEvents> {
TextStyle
_statusStyle
=
const
TextStyle
(
color:
Colors
.
black
);
String
_appBarText
=
''
;
int
_selectedRow
=
-
1
;
String
_pendingEventCnt
=
''
;
String
_syncedEventCnt
=
''
;
bool
_cancelSync
=
false
;
//Flag to cancel sync process
bool
_currentlySyncing
=
false
;
// State flag to indicate if sync is ongoing
var
database
=
DatabaseInstance
();
List
<
Event
>
_localEvents
=
[];
List
<
Event
>
_localEvents
=
[];
Widget
_buildSyncDialog
(
BuildContext
context
)
{
SensorConnector
sensorConnector
=
SensorConnector
();
String
startButtonText
=
''
;
String
closeButtonText
=
''
;
if
(
_currentlySyncing
==
true
){
startButtonText
=
'Syncing'
;
closeButtonText
=
'Cancel'
;
}
else
{
startButtonText
=
'Start'
;
closeButtonText
=
'Close'
;
}
return
WillPopScope
(
onWillPop:
()
async
=
>
false
,
child:
AlertDialog
(
...
...
@@ -34,36 +47,40 @@ class _ViewEvents extends State<ViewEvents> {
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
<
Widget
>[
const
Text
(
'Syncing Events...'
),
//TODO: show progress bar here., Horizontal progress bar?
const
SizedBox
(
height:
15.0
),
GFProgressBar
(
percentage:
0.7
,
//Get percentage from global variable here
backgroundColor
:
Colors
.
black12
,
progressBarColor:
Colors
.
blue
,
),
const
SizedBox
(
height:
5.0
),
Text
(
_syncedEventCnt
+
' / '
+
_pendingEventCnt
),
//TODO: show text XX pending events. count down
//GFProgressBar(
// percentage: 0.7,
// backgroundColor : Colors.pink,
// progressBarColor: Colors.red,
//),
],
),
actions:
<
Widget
>[
TextButton
(
onPressed:
()
{
//Start sync process but only once.
if
(
_currentlySyncing
==
false
){
syncEvents
();
//Initiate sync
}
},
child:
const
Text
(
'S
tart
'
),
//Change text to Syncing... during Sync process.
child:
Text
(
s
tart
ButtonText
),
//Change text to Syncing... during Sync process.
),
TextButton
(
onPressed:
()
{
// Depending on state. Cancel or close. TODO: implement statemachine.
Navigator
.
of
(
context
)
.
pop
();
if
(
_currentlySyncing
){
_cancelSync
=
true
;
// Set flag so that async tasks stops syncing
}
else
{
Navigator
.
of
(
context
)
.
pop
();
// Close widget only if sync has stopped.
}
},
child:
const
Text
(
'C
lose
'
),
// Change to Cancel during Sync process.
child:
Text
(
c
lose
ButtonText
),
// Change to Cancel during Sync process.
),
],
)
);
}
Future
<
void
>
fetchEventsFromDb
()
async
{
...
...
@@ -103,11 +120,14 @@ class _ViewEvents extends State<ViewEvents> {
}
Future
<
void
>
syncEvents
()
async
{
_cancelSync
=
false
;
final
ConfigurationStoreInstance
configuration
=
ConfigurationStoreInstance
();
SensorConnector
connection
=
SensorConnector
();
List
<
Event
>
events
=
await
database
.
getPendingEvents
();
int
syncCounter
=
events
.
length
;
_pendingEventCnt
=
syncCounter
.
toString
();
debugPrint
(
'Pending Events'
);
for
(
var
event
in
events
){
debugPrint
(
event
.
toString
());
...
...
@@ -120,6 +140,13 @@ class _ViewEvents extends State<ViewEvents> {
configuration
.
loginInformation
.
password
);
var
index
=
0
;
for
(
var
event
in
events
)
{
if
(
_cancelSync
==
true
){
_currentlySyncing
=
false
;
debugPrint
(
'Sync process canceled'
);
return
;
}
_currentlySyncing
=
true
;
debugPrint
(
'Idx: '
+
index
.
toString
()
+
' '
+
event
.
toSensorJson
()
.
toString
());
index
++
;
...
...
@@ -138,6 +165,7 @@ class _ViewEvents extends State<ViewEvents> {
}
_status
=
'export success'
;
_statusStyle
=
const
TextStyle
(
color:
Colors
.
green
);
_syncedEventCnt
=
index
.
toString
();
}
catch
(
e
)
{
String
errorText
=
e
.
toString
();
errorText
=
errorText
.
substring
(
10
,
errorText
.
length
);
//Remove 'Exception' from string.
...
...
@@ -148,6 +176,7 @@ class _ViewEvents extends State<ViewEvents> {
}
else
{
debugPrint
(
'No PENDING event(s)'
);
}
_currentlySyncing
=
false
;
}
@override
...
...
@@ -301,13 +330,13 @@ class _ViewEvents extends State<ViewEvents> {
icon:
null
,
label:
const
Text
(
'Sync'
),
onPressed:
()
{
syncEvents
();
//
syncEvents();
//
showDialog(
//
barrierDismissible: false,
//
context: context,
//
builder: (BuildContext context) => _buildSyncDialog(context),
//
);
showDialog
(
barrierDismissible:
false
,
context:
context
,
builder:
(
BuildContext
context
)
=
>
_buildSyncDialog
(
context
),
);
},
...
...
This diff is collapsed.
Click to expand it.
pubspec.lock
+
7
−
0
View file @
f8f87cac
...
...
@@ -226,6 +226,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1"
getwidget:
dependency: "direct main"
description:
name: getwidget
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
http:
dependency: "direct main"
description:
...
...
This diff is collapsed.
Click to expand it.
pubspec.yaml
+
1
−
1
View file @
f8f87cac
...
...
@@ -39,7 +39,7 @@ dependencies:
flutter_login
:
^3.1.0
datetime_picker_formfield
:
^2.0.0
flutter_datetime_picker
:
^1.5.1
#
getwidget: ^3.0.1
getwidget
:
^3.0.1
# The following adds the Cupertino Icons font to your application.
# 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