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
cb94977b
Commit
cb94977b
authored
3 years ago
by
Maximilian Betz
Browse files
Options
Downloads
Patches
Plain Diff
remove obsolete login widget
parent
723b9bf7
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/login.dart
+0
-152
0 additions, 152 deletions
lib/login.dart
lib/main.dart
+0
-2
0 additions, 2 deletions
lib/main.dart
with
0 additions
and
154 deletions
lib/login.dart
deleted
100644 → 0
+
0
−
152
View file @
723b9bf7
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'datamodel.dart'
;
import
'dart:convert'
;
import
'package:http/http.dart'
as
http
;
Future
<
int
>
login
()
async
{
// Get Access to local configuration store. Token must be stored there!
ConfigurationStoreInstance
configuration
=
ConfigurationStoreInstance
();
String
url
=
'https://sandbox.sensor.awi.de/rest/sensors/contacts/login'
;
debugPrint
(
"Start login to : "
+
url
);
Map
<
String
,
dynamic
>
body
=
{
'username'
:
configuration
.
loginInformation
.
mail
,
'authPassword'
:
configuration
.
loginInformation
.
password
};
String
encodedBody
=
body
.
keys
.
map
((
key
)
=
>
"
$key
=
${body[key]}
"
)
.
join
(
"&"
);
debugPrint
(
encodedBody
);
final
response
=
await
http
.
post
(
Uri
.
parse
(
url
),
body:
encodedBody
,
headers:
{
'Accept'
:
'application/json'
,
'Content-Type'
:
'application/x-www-form-urlencoded'
},
encoding:
Encoding
.
getByName
(
"utf-8"
)
);
if
(
response
.
statusCode
==
200
)
{
debugPrint
(
'Login success'
);
debugPrint
(
response
.
body
.
toString
());
debugPrint
(
response
.
headers
.
toString
());
debugPrint
(
response
.
headers
[
'set-cookie'
]);
}
else
{
debugPrint
(
'Header: '
+
response
.
headers
.
toString
());
debugPrint
(
'Body: '
+
response
.
body
.
toString
());
debugPrint
(
'StatusCode: '
+
response
.
statusCode
.
toString
());
throw
Exception
(
'Failed to login'
);
}
return
0
;
}
class
LoginPage
extends
StatefulWidget
{
static
String
tag
=
'login-page'
;
const
LoginPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
_LoginPageState
createState
()
=
>
_LoginPageState
();
}
class
_LoginPageState
extends
State
<
LoginPage
>
{
@override
Widget
build
(
BuildContext
context
){
final
ConfigurationStoreInstance
configuration
=
ConfigurationStoreInstance
();
var
logo
=
Hero
(
tag:
'blabla'
,
child:
CircleAvatar
(
backgroundColor:
Colors
.
transparent
,
radius:
48.0
,
child:
Image
.
asset
(
'assets/awi_logo.png'
),
)
);
final
email
=
TextFormField
(
keyboardType:
TextInputType
.
emailAddress
,
autofocus:
false
,
initialValue:
configuration
.
loginInformation
.
mail
,
decoration:
InputDecoration
(
hintText:
'sensor e-mail address'
,
contentPadding:
const
EdgeInsets
.
fromLTRB
(
20.0
,
10.0
,
20.0
,
10.0
),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
32.0
)
)
),
onChanged:
(
value
)
{
configuration
.
loginInformation
.
mail
=
value
;
},
);
final
password
=
TextFormField
(
autofocus:
false
,
initialValue:
configuration
.
loginInformation
.
password
,
decoration:
InputDecoration
(
hintText:
'sensor password'
,
contentPadding:
const
EdgeInsets
.
fromLTRB
(
20.0
,
10.0
,
20.0
,
10.0
),
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
32.0
)
)
),
onChanged:
(
value
){
configuration
.
loginInformation
.
password
=
value
;
},
);
final
loginButton
=
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
16.0
),
child:
Material
(
borderRadius:
BorderRadius
.
circular
(
30.0
),
shadowColor:
Colors
.
lightBlueAccent
.
shade100
,
elevation:
5.0
,
child:
MaterialButton
(
minWidth:
200.0
,
height:
42.0
,
onPressed:
(){
login
();
//Navigator.pop(context); // Go back to previous widget
//Return to previous widget if successfully logged in. Store x-auth-token.
//Display login error if login not possible.
},
color:
Colors
.
lightBlueAccent
,
child:
const
Text
(
'Log In'
,
style:
TextStyle
(
color:
Colors
.
white
)),
),
),
);
final
forgotLabel
=
TextButton
(
onPressed:
()
{
},
child:
const
Text
(
'Forgot password?'
,
style:
TextStyle
(
color:
Colors
.
black54
),
),
);
return
Scaffold
(
backgroundColor:
Colors
.
white
,
body:
Center
(
child:
ListView
(
shrinkWrap:
true
,
padding:
const
EdgeInsets
.
only
(
left:
24.0
,
right:
24.0
),
children:
<
Widget
>[
logo
,
const
SizedBox
(
height:
48.0
),
email
,
const
SizedBox
(
height:
8.0
),
password
,
const
SizedBox
(
height:
24.0
),
loginButton
,
forgotLabel
//TODO: launch https://data.awi.de/auth/
],
)
)
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/main.dart
+
0
−
2
View file @
cb94977b
...
...
@@ -6,7 +6,6 @@ import 'addevent.dart';
import
'viewevents.dart'
;
import
'overview.dart'
;
import
'configuration.dart'
;
import
'login.dart'
;
void
main
()
{
...
...
@@ -33,7 +32,6 @@ void main() {
'/second'
:
(
context
)
=
>
const
AddEvent
(),
'/third'
:
(
context
)
=
>
const
ViewEvents
(),
'/forth'
:
(
context
)
=
>
const
Configuration
(),
'/fifth'
:
(
context
)
=
>
const
LoginPage
(),
},
));
}
...
...
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