Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladislav Rykov
THSO.server
Commits
6ee038d7
Commit
6ee038d7
authored
Jul 04, 2020
by
Vladislav Rykov
Browse files
map view integrated
parent
3b2bf2a8
Changes
6
Show whitespace changes
Inline
Side-by-side
app/app/__pycache__/views.cpython-37.pyc
View file @
6ee038d7
No preview for this file type
app/app/dao/misc/__pycache__/misc.cpython-37.pyc
View file @
6ee038d7
No preview for this file type
app/app/dao/misc/misc.py
View file @
6ee038d7
...
@@ -21,7 +21,6 @@ def get_user_data_count(cur, username):
...
@@ -21,7 +21,6 @@ def get_user_data_count(cur, username):
i
+=
1
i
+=
1
query
=
query
[
0
:
-
9
]
query
=
query
[
0
:
-
9
]
query
+=
') SELECT SUM(count) FROM t'
query
+=
') SELECT SUM(count) FROM t'
print
(
query
)
cur
.
execute
(
query
,
())
cur
.
execute
(
query
,
())
return
(
True
,
cur
.
fetchone
())
return
(
True
,
cur
.
fetchone
())
...
@@ -49,7 +48,6 @@ def get_user_data_count_per_hour(cur, username, hour):
...
@@ -49,7 +48,6 @@ def get_user_data_count_per_hour(cur, username, hour):
query
=
query
[
0
:
-
10
]
query
=
query
[
0
:
-
10
]
query
+=
') SELECT COUNT(*) FROM t WHERE utc > {} AND utc < {}'
.
format
(
utc_hour
,
utc_hour
+
60
*
60
)
query
+=
') SELECT COUNT(*) FROM t WHERE utc > {} AND utc < {}'
.
format
(
utc_hour
,
utc_hour
+
60
*
60
)
#print(query)
cur
.
execute
(
query
,
())
cur
.
execute
(
query
,
())
return
(
True
,
cur
.
fetchone
())
return
(
True
,
cur
.
fetchone
())
...
...
app/app/templates/logged_layout.html
View file @
6ee038d7
...
@@ -92,6 +92,11 @@
...
@@ -92,6 +92,11 @@
<i
class=
"ni ni-air-baloon text-yellow"
></i>
Applications
<i
class=
"ni ni-air-baloon text-yellow"
></i>
Applications
</a>
</a>
</li>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link "
href=
"/map"
>
<i
class=
"ni ni-map-big text-warning"
></i>
Map
</a>
</li>
{% if grant_view('admin', session['role']) %}
{% if grant_view('admin', session['role']) %}
<li
class=
"nav-item"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link "
href=
"/administration"
>
<a
class=
"nav-link "
href=
"/administration"
>
...
...
app/app/templates/views/public/map.html
0 → 100644
View file @
6ee038d7
{% extends 'logged_layout.html' %}
{% block title %} HPC
&
A IoT - Map {% endblock %}
{% block header %}
<link
href=
"https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
rel=
"stylesheet"
>
<link
rel=
"stylesheet"
href=
"https://unpkg.com/leaflet@1.6.0/dist/leaflet.css"
integrity=
"sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=
""
/>
{% endblock %}
{% block location %}
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/map"
>
Map
</a>
{% endblock %}
{% block stats %}
<!-- Card stats -->
<div
class=
"row"
>
<div
class=
"col-xl-3 col-lg-6"
>
<div
class=
"card card-stats mb-4 mb-xl-0"
>
<div
class=
"card-body"
>
<div
class=
"row"
>
<div
class=
"col"
>
<h5
class=
"card-title text-uppercase text-muted mb-0"
>
Created Apps
</h5>
<span
class=
"h2 font-weight-bold mb-0"
>
{{ info[0] }}
</span>
</div>
<div
class=
"col-auto"
>
<div
class=
"icon icon-shape bg-success text-white rounded-circle shadow"
>
<i
class=
"fas fa-cubes"
></i>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"col-xl-3 col-lg-6"
>
<div
class=
"card card-stats mb-4 mb-xl-0"
>
<div
class=
"card-body"
>
<div
class=
"row"
>
<div
class=
"col"
>
<h5
class=
"card-title text-uppercase text-muted mb-0"
>
Active Devices
</h5>
<span
class=
"h2 font-weight-bold mb-0"
>
{{ info[1] }}
</span>
</div>
<div
class=
"col-auto"
>
<div
class=
"icon icon-shape bg-info text-white rounded-circle shadow"
>
<i
class=
"fas fa-microchip"
></i>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"col-xl-3 col-lg-6"
>
<div
class=
"card card-stats mb-4 mb-xl-0"
>
<div
class=
"card-body"
>
<div
class=
"row"
>
<div
class=
"col"
>
<h5
class=
"card-title text-uppercase text-muted mb-0"
>
Total Activity
</h5>
<span
class=
"h2 font-weight-bold mb-0"
>
{{ info[2] }}
</span>
</div>
<div
class=
"col-auto"
>
<div
class=
"icon icon-shape bg-warning text-white rounded-circle shadow"
>
<i
class=
"fas fa-area-chart"
></i>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"col-xl-3 col-lg-6"
>
<div
class=
"card card-stats mb-4 mb-xl-0"
>
<div
class=
"card-body"
>
<div
class=
"row"
>
<div
class=
"col"
>
<h5
class=
"card-title text-uppercase text-muted mb-0"
>
Last 24 Hours Activity
</h5>
<span
class=
"h2 font-weight-bold mb-0"
>
{{ info[3] }}
</span>
</div>
<div
class=
"col-auto"
>
<div
class=
"icon icon-shape bg-danger text-white rounded-circle shadow"
>
<i
class=
"fas fa-line-chart"
></i>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block body %}
<!-- Page content -->
<div
class=
"container-fluid mt--7"
>
<div
class=
"row"
>
<div
class=
"col"
>
<div
class=
"card shadow border-0"
>
<div
id=
"map"
class=
"map"
style=
"height: 600px;"
></div>
</div>
</div>
</div>
{% endblock %}
{% block script %}
<script
src=
"https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"
integrity=
"sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
crossorigin=
""
>
</script>
<script
type=
"text/javascript"
>
var
devmap
=
L
.
map
(
'
map
'
).
setView
([
50
,
50
],
2
);
L
.
tileLayer
(
'
https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
'
,
{
attribution
:
'
Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>
'
,
maxZoom
:
18
}).
addTo
(
devmap
);
</script>
{% endblock %}
app/app/views.py
View file @
6ee038d7
...
@@ -646,3 +646,15 @@ def application_device_settings(appkey, devid):
...
@@ -646,3 +646,15 @@ def application_device_settings(appkey, devid):
flash
(
'Settings saved'
,
'success'
)
flash
(
'Settings saved'
,
'success'
)
return
redirect
(
request
.
url
)
return
redirect
(
request
.
url
)
@
app
.
route
(
'/map'
)
@
decorators
.
restricted
(
'interface'
)
def
map
():
created_apps
=
ad
.
get_count_by_user
(
session
[
'name'
])[
1
][
0
]
active_devices
=
dd
.
get_count_by_user
(
session
[
'name'
])
total_activity
=
md
.
get_user_data_count
(
session
[
'name'
])[
1
][
0
]
last_activity
=
md
.
get_user_data_count_per_day
(
session
[
'name'
])[
1
][
0
]
info
=
[
created_apps
,
active_devices
,
total_activity
,
last_activity
]
print
(
'render'
)
return
render_template
(
'views/public/map.html'
,
info
=
info
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment