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
fa71e882
Commit
fa71e882
authored
Apr 24, 2020
by
Vladislav Rykov
Browse files
dashboard tested
parent
2b5a9a5f
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/app/__pycache__/views.cpython-35.pyc
View file @
fa71e882
No preview for this file type
app/app/dao/device/__pycache__/device.cpython-35.pyc
View file @
fa71e882
No preview for this file type
app/app/dao/device/device.py
View file @
fa71e882
...
...
@@ -133,13 +133,10 @@ def get_device_table_names(cur):
def
get_count_all
():
count
=
0
tns
=
get_device_table_names
()
print
(
tns
)
if
tns
[
0
]
and
len
(
tns
[
1
])
>
0
:
for
tn
in
tns
[
1
]:
sp
=
tn
[
0
].
split
(
'_'
)
print
(
sp
)
r
=
get_count
(
sp
[
1
])
print
(
r
)
if
r
[
0
]:
count
+=
r
[
1
][
0
]
...
...
app/app/dao/user/__pycache__/user.cpython-35.pyc
View file @
fa71e882
No preview for this file type
app/app/dao/user/user.py
View file @
fa71e882
...
...
@@ -83,3 +83,20 @@ def get_range(cur, rng):
"""
cur
.
execute
(
query
,
(
rng
[
0
],
rng
[
1
]))
return
(
True
,
cur
.
fetchall
())
@
with_psql
def
get_range_name
(
cur
,
name
,
rng
):
name
+=
'%'
query
=
"""
SELECT * FROM
users
WHERE name LIKE %s
ORDER BY
name ASC
LIMIT %s OFFSET %s
"""
cur
.
execute
(
query
,
(
name
,
rng
[
0
],
rng
[
1
]))
return
(
True
,
cur
.
fetchall
())
app/app/templates/admin/dashboard.html
View file @
fa71e882
...
...
@@ -43,6 +43,7 @@
<div
class=
"form-group"
>
<button
type=
"submit"
class=
"btn btn-default"
>
Filter
</button>
</div>
<a
href=
"dashboard-clean-search"
><span
class=
"glyphicon glyphicon-remove"
></span></a>
</form>
</div>
<br>
...
...
app/app/views.py
View file @
fa71e882
...
...
@@ -354,7 +354,6 @@ def dashboard():
user_cnt
=
ud
.
get_count
()
apps_cnt
=
ad
.
get_count
()
devs_cnt
=
dd
.
get_count_all
()
print
(
devs_cnt
)
cur_pg
=
1
if
request
.
args
.
get
(
'p'
):
...
...
@@ -362,18 +361,29 @@ def dashboard():
if
cur_pg
<
1
:
cur_pg
=
1
users
=
ud
.
get_range
([
MAX_PG_ENTRIES_USERS
,
(
cur_pg
-
1
)
*
MAX_PG_ENTRIES_USERS
])
users
=
None
if
request
.
method
==
'
GE
T'
:
users
=
ud
.
get_range
([
MAX_PG_ENTRIES_USERS
,
(
cur_pg
-
1
)
*
MAX_PG_ENTRIES_USERS
])
if
request
.
method
==
'
POS
T'
:
session
[
'users_filter'
]
=
request
.
form
[
'username'
]
rd
=
misc
.
paging
(
cur_pg
,
user_cnt
[
1
][
0
],
MAX_PG_ENTRIES_USERS
,
MAX_PG
)
return
render_template
(
'admin/dashboard.html'
,
users_cnt
=
user_cnt
[
1
][
0
],
apps_cnt
=
apps_cnt
[
1
][
0
],
dev_cnt
=
devs_cnt
,
users
=
users
[
1
],
pp
=
rd
[
0
],
pr
=
rd
[
1
],
np
=
rd
[
2
],
cp
=
cur_pg
,
usn
=
(
cur_pg
-
1
)
*
MAX_PG_ENTRIES_USERS
+
1
)
if
'users_filter'
in
session
:
users
=
ud
.
get_range_name
(
session
[
'users_filter'
],
[
MAX_PG_ENTRIES_USERS
,
(
cur_pg
-
1
)
*
MAX_PG_ENTRIES_USERS
])
print
(
users
)
rd
=
misc
.
paging
(
cur_pg
,
len
(
users
[
1
]),
MAX_PG_ENTRIES_USERS
,
MAX_PG
)
else
:
pass
users
=
ud
.
get_range
([
MAX_PG_ENTRIES_USERS
,
(
cur_pg
-
1
)
*
MAX_PG_ENTRIES_USERS
])
rd
=
misc
.
paging
(
cur_pg
,
user_cnt
[
1
][
0
],
MAX_PG_ENTRIES_USERS
,
MAX_PG
)
return
render_template
(
'admin/dashboard.html'
,
users_cnt
=
user_cnt
[
1
][
0
],
apps_cnt
=
apps_cnt
[
1
][
0
],
dev_cnt
=
devs_cnt
,
users
=
users
[
1
],
pp
=
rd
[
0
],
pr
=
rd
[
1
],
np
=
rd
[
2
],
cp
=
cur_pg
,
usn
=
(
cur_pg
-
1
)
*
MAX_PG_ENTRIES_USERS
+
1
)
else
:
return
redirect
(
url_for
(
'index'
))
@
app
.
route
(
'/dashboard-clean-search'
)
def
dashboard_clean_search
():
if
'users_filter'
in
session
:
session
.
pop
(
'users_filter'
,
None
)
return
redirect
(
url_for
(
'dashboard'
))
def
pend_delete_all_ack
():
pend
.
delete_all_ack
()
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