Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2900
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
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
Sara Savanovic Djordjevic
PROG2900
Commits
98f168e8
Commit
98f168e8
authored
11 months ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
add: fetchAllLakeNames() in init_state.dart
parent
616f4a3c
No related branches found
No related tags found
1 merge request
!10
Clhp map
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/server_requests/init_state.dart
+31
-0
31 additions, 0 deletions
app/lib/server_requests/init_state.dart
server/main.py
+2
-1
2 additions, 1 deletion
server/main.py
with
33 additions
and
1 deletion
app/lib/server_requests/init_state.dart
+
31
−
0
View file @
98f168e8
import
'dart:io'
;
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:typed_data'
;
import
'package:app/consts.dart'
;
...
...
@@ -6,6 +8,7 @@ import '../data_classes.dart';
import
'../server_requests/fetch_markers.dart'
;
import
'../server_requests/fetch_relation.dart'
;
Future
<
void
>
initialiseState
()
async
{
bool
serverConnection
=
true
;
...
...
@@ -33,4 +36,32 @@ Future<void> initialiseState() async{
selectedRelation
=
await
relationFuture
;
selectedMarkerList
=
await
markerListFuture
;
}
/// fetchAllLakeNames fetches a list of all lake names in the system
/// and initialises lakeSearchOptions
Future
<
void
>
fetchAllLakeNames
()
async
{
try
{
HttpClient
client
=
HttpClient
()
.
.
badCertificateCallback
=
// NB: temporary disable SSL certificate validation
(
X509Certificate
cert
,
String
host
,
int
port
)
=
>
true
;
var
request
=
await
client
.
getUrl
(
Uri
.
parse
(
'
${serverURI}
/get_lake_names'
));
var
response
=
await
request
.
close
();
if
(
response
.
statusCode
==
200
)
{
var
responseBody
=
await
response
.
transform
(
utf8
.
decoder
)
.
join
();
if
(
responseBody
.
isNotEmpty
)
{
var
jsonData
=
json
.
decode
(
responseBody
);
if
(
jsonData
!=
null
&&
jsonData
is
List
)
{
lakeSearchOptions
=
jsonData
.
map
<
String
>((
item
)
=
>
item
.
toString
())
.
toList
();
return
;
}
}
}
}
catch
(
e
)
{
lakeSearchOptions
=
[
"Mjøsa"
];
// Init default list
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
server/main.py
+
2
−
1
View file @
98f168e8
...
...
@@ -43,13 +43,14 @@ class IceHTTP(BaseHTTPRequestHandler):
with
open
(
'
server/map_handler/lake_relations/all_lake_names.json
'
,
'
r
'
)
as
file
:
lake_names
=
json
.
load
(
file
)
# Disable ensure_ascii to keep 'ø'
json_data
=
json
.
dumps
(
lake_names
,
ensure_ascii
=
False
)
self
.
send_response
(
200
)
self
.
send_header
(
'
Content-type
'
,
'
application/json
'
)
self
.
end_headers
()
self
.
wfile
.
write
(
json_data
.
encode
(
'
iso-8859-1
'
))
self
.
wfile
.
write
(
json_data
.
encode
(
'
iso-8859-1
'
))
# Special character encoding
elif
self
.
path
.
startswith
(
'
/update_map
'
):
# NB: should be POST?
parsed_path
=
urlparse
(
self
.
path
)
query_params
=
parse_qs
(
parsed_path
.
query
)
...
...
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