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
f4558f94
Commit
f4558f94
authored
Jun 02, 2020
by
Vladislav Rykov
Browse files
admin:user app dev settings+delete completely integrated
parent
77e9f22d
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/app/__pycache__/views_admin.cpython-37.pyc
View file @
f4558f94
No preview for this file type
app/app/templates/new/admin/user-device-settings.html
→
app/app/templates/new/admin/user-
application-
device-settings.html
View file @
f4558f94
{% extends 'logged_layout.html' %}
{% block title %}
HPC
&
A IoT - Device Settings
{% endblock %}
{% block title %}
Administration - {{ user }} - {{ app[0] }} - {{ dev[0] }} - Settings - HPC
&
A IoT
{% endblock %}
{% block location %}
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/a
pplic
ation
s
"
>
A
pplic
ation
s
</a>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/a
dministr
ation"
>
A
dministr
ation
</a>
<p
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
>
-
</p>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/a
pplication/{{ app[1] }}"
>
{{ app[0] }}
</a>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/a
dministration/users"
>
Users
</a>
<p
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
>
-
</p>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/application/{{ app[1] }}/device/{{ dev[1] }}"
>
{{ dev[0] }}
</a>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/administration/users/{{ user }}"
>
{{ user }}
</a>
<p
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
>
-
</p>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/administration/users/{{ user }}/applications"
>
Applications
</a>
<p
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
>
-
</p>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/administration/users/{{ user }}/application/{{ app[1] }}"
>
{{ app[0] }}
</a>
<p
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
>
-
</p>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/administration/users/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}"
>
{{ dev[0] }}
</a>
{% endblock %}
{% block body %}
...
...
@@ -21,7 +27,7 @@
<h3
class=
"mb-0"
>
Device Settings
</h3>
</div>
<div
class=
"card-body"
>
<form
action=
"/application/{{ app[1] }}/device/{{ dev[1] }}/settings"
method=
"post"
id=
"devsettings"
>
<form
action=
"/
administration/users/{{ user }}/
application/{{ app[1] }}/device/{{ dev[1] }}/settings"
method=
"post"
id=
"devsettings"
>
<div
class=
"form-group"
>
<label>
Name:
</label><br>
<input
type=
"text"
maxlength=
"30"
class=
"form-control"
id=
"devname"
name=
"devname"
value=
"{{ dev[0] }}"
required
><br>
...
...
@@ -56,7 +62,7 @@
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
Close
</button>
<a
href=
"/application/{{ app[1] }}/device/{{ dev[1] }}/delete"
><button
type=
"button"
class=
"btn btn-danger"
>
Delete Device
</button></a>
<a
href=
"/
administration/users/{{ user }}/
application/{{ app[1] }}/device/{{ dev[1] }}/delete"
><button
type=
"button"
class=
"btn btn-danger"
>
Delete Device
</button></a>
</div>
</div>
</div>
...
...
app/app/views_admin.py
View file @
f4558f94
...
...
@@ -164,6 +164,41 @@ def administration_users_user_application_device(name, appkey, devid):
return
render_template
(
'new/admin/user-device.html'
,
dev
=
dev
[
1
],
app
=
ap
[
1
],
ltup
=
ltup
,
data
=
[],
total
=
cnt
[
1
][
0
],
user
=
name
)
@
app
.
route
(
'/administration/users/<name>/application/<appkey>/device/<devid>/settings'
,
methods
=
[
'GET'
,
'POST'
])
@
restricted
(
access_level
=
'admin'
)
def
administration_users_user_application_device_settings
(
name
,
appkey
,
devid
):
if
request
.
method
==
'GET'
:
ap
=
ad
.
get
(
appkey
)
dev
=
dd
.
get
(
appkey
,
devid
)
dev_list
=
dd
.
get_list
(
appkey
)
return
render_template
(
'new/admin/user-application-device-settings.html'
,
app
=
ap
[
1
],
dev
=
dev
[
1
],
free_ids
=
misc
.
prep_id_range
(
dev_list
[
1
]),
user
=
name
)
elif
request
.
method
==
'POST'
:
res
=
dd
.
update
(
appkey
,
devid
,
request
.
form
[
'devname'
],
request
.
form
[
'devdesc'
])
if
not
res
[
0
]:
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
render_template
(
request
.
url
)
return
redirect
(
request
.
url
)
@
app
.
route
(
'/administration/users/<name>/application/<appkey>/device/<devid>/delete'
)
@
restricted
(
access_level
=
'admin'
)
def
administration_users_user_application_device_delete
(
name
,
appkey
,
devid
):
nq
.
delete_per_device
(
appkey
,
devid
)
nfss
=
nfs
.
get_per_device
(
appkey
,
devid
)
for
nf
in
nfss
[
1
]:
tr
.
delete
(
appkey
,
devid
,
nf
[
0
])
tr
.
delete_function
(
appkey
,
devid
,
nf
[
0
])
nfs
.
delete
(
appkey
,
devid
,
nf
[
0
])
data
.
delete_table
(
appkey
,
devid
)
res
=
dd
.
delete
(
appkey
,
devid
)
return
redirect
(
url_for
(
'administration_users_user_application'
,
name
=
name
,
appkey
=
appkey
))
@
app
.
route
(
'/administration/users/<name>/application/<appkey>/alerts'
)
@
restricted
(
access_level
=
'admin'
)
def
administration_users_user_application_alerts
(
name
,
appkey
):
...
...
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