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
9f3cc723
Commit
9f3cc723
authored
Jun 06, 2020
by
Vladislav Rykov
Browse files
recent activity fixed
parent
355d9257
Changes
6
Show whitespace changes
Inline
Side-by-side
app/app/__pycache__/views.cpython-37.pyc
View file @
9f3cc723
No preview for this file type
app/app/__pycache__/views_admin.cpython-37.pyc
View file @
9f3cc723
No preview for this file type
app/app/dao/misc/__pycache__/misc.cpython-37.pyc
View file @
9f3cc723
No preview for this file type
app/app/dao/misc/misc.py
View file @
9f3cc723
...
...
@@ -161,11 +161,13 @@ def get_recent_activity(cur, username, n=5):
devs
=
dd
.
get_list
(
a
[
1
])
for
d
in
devs
[
1
]:
query
+=
"""
(SELECT timedate, appname, devname, data, utc from
(SELECT timedate, appname, devname, data, utc
, appkey, devid
from
(SELECT utc, timedate, data from dev_{}_{} ORDER BY utc DESC limit 5) AS utc,
(SELECT '{}' as appname) AS appname,
(SELECT '{}' as appkey) AS appkey,
(SELECT '{}' as devid) AS devid,
(SELECT '{}' as devname) AS devname)
UNION ALL"""
.
format
(
a
[
1
],
d
[
1
],
a
[
0
],
d
[
0
])
UNION ALL"""
.
format
(
a
[
1
],
d
[
1
],
a
[
0
],
a
[
1
],
d
[
1
],
d
[
0
])
query
=
query
[
0
:
-
9
]
query
+=
' ORDER BY utc DESC LIMIT {}'
.
format
(
n
)
...
...
app/app/views.py
View file @
9f3cc723
...
...
@@ -245,6 +245,7 @@ def application_device_delete(appkey, devid):
data
.
delete_table
(
appkey
,
devid
)
res
=
dd
.
delete
(
appkey
,
devid
)
flash
(
'Device removed.'
,
'success'
)
return
redirect
(
url_for
(
'application'
,
appkey
=
appkey
))
else
:
return
redirect
(
utl_for
(
'login'
))
...
...
@@ -327,10 +328,13 @@ def chart_update():
def
recent_activity
():
if
'name'
in
session
:
recent_activity
=
md
.
get_recent_activity
(
session
[
'name'
])[
1
]
ra
=
''
for
r
in
recent_activity
:
ra
+=
'<tr><th scope="row">'
+
r
[
1
]
+
'</th><th>'
+
r
[
2
]
+
'</th><th>'
+
r
[
0
]
+
'</th><th>'
+
str
(
r
[
3
])
+
'</th></tr>'
print
(
r
)
dev
=
dd
.
get
(
r
[
5
],
r
[
6
])[
1
]
ra
+=
'<tr><th scope="row">'
+
r
[
1
]
+
'</th><th>'
+
r
[
2
]
+
'</th><th>'
+
r
[
0
]
+
'</th><th>'
+
str
(
ddm
.
read_data
(
r
[
3
],
dev
[
3
]))
+
'</th></tr>'
return
ra
,
200
else
:
...
...
@@ -355,11 +359,11 @@ def application_device_configuration_remove(appkey, devid):
@
app
.
route
(
'/application/<appkey>/device/<devid>/variables'
)
def
application_device_variables
(
appkey
,
devid
):
if
'name'
in
session
:
last
=
d
ata
.
get
_last_n
(
appkey
,
devid
,
1
)
if
last
[
0
]:
dmodel
=
d
d
.
get
(
appkey
,
devid
)
if
dmodel
[
0
]:
select
=
'<select class="form-control" id="varname" name="varname" onchange="validate_form();" required>'
select
+=
'<option value="-">Select Variable</option>'
for
k
in
last
[
1
][
0
][
2
]:
for
k
in
dmodel
[
1
][
3
][
'format'
]:
select
+=
'<option>'
+
k
+
'</option>'
select
+=
'</select>'
return
select
...
...
app/app/views_admin.py
View file @
9f3cc723
...
...
@@ -136,7 +136,7 @@ def administration_users_user_application_add_device(name, appkey):
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
request
.
url
)
else
:
res
=
data
.
create_table
(
appkey
,
request
.
form
[
'devid'
])
res
=
data
.
create_table
_ddm
(
appkey
,
request
.
form
[
'devid'
])
if
not
res
[
0
]:
dd
.
delete
(
appkey
,
request
.
form
[
'devid'
])
...
...
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