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
70d47c00
Commit
70d47c00
authored
May 25, 2020
by
Vladislav Rykov
Browse files
device config correct ajax and redirect added. done
parent
dcbba1e7
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/app/__pycache__/views.cpython-37.pyc
View file @
70d47c00
No preview for this file type
app/app/templates/new/public/.device-configuration.html.swp
View file @
70d47c00
No preview for this file type
app/app/templates/new/public/device-configuration.html
View file @
70d47c00
...
...
@@ -2,7 +2,10 @@
{% block title %} HPC
&
A IoT - Device Configuration {% endblock %}
{% block header %}
<link
href=
"https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
rel=
"stylesheet"
>
{% endblock %}
{% block header %}
<link
href=
"https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
rel=
"stylesheet"
>
<script
type=
"text/javascript"
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"
></script>
{% endblock %}
{% block location %}
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"./applications"
>
Applications
</a>
<p
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
>
-
</p>
...
...
@@ -22,7 +25,7 @@
<h3
class=
"mb-0"
>
Device Configuration - {{ dev[0] }}
</h3>
</div>
<div
class=
"card-body"
>
<form
action=
""
method=
"post
"
>
<form
id=
"confform"
onsubmit=
"onsub()
"
>
<div
class=
"form-group"
>
<label>
Config ID:
</label><br>
<input
type=
"number"
min=
"0"
max=
"255"
size=
"3"
class=
"form-control"
id=
"confid"
name=
"confid"
required
><br>
...
...
@@ -39,7 +42,7 @@
<br>
</form>
<div
class=
"card-header bg-transparent"
>
<h3
class=
"mb-0"
>
Configuration history
</h3>
<h3
class=
"mb-0"
id=
"confhistory"
>
Configuration history
</h3>
</div>
{% if config_list %}
<table
class=
"table"
>
...
...
@@ -62,7 +65,7 @@
{% endif %}
</span>
</td>
<td>
<a
href=
"
/application/{{ app[1] }}/device/{{ dev[1] }}/
remove
-
configuration
?conf=
{{ c[3] }}"
>
<span
class=
"fa fa-remove"
</
span
>
</a>
</td>
<td>
<a
href=
"
javascript:void(0)"
onclick=
"return
remove
_
configuration
('
{{ c[3]
[0:-1]
}}
')
"
>
<span
class=
"fa fa-remove"
>
</span>
</a>
</td>
</tr>
{% endfor %}
</tbody>
...
...
@@ -77,3 +80,27 @@
</div>
</div>
{% endblock %}
{% block script %}
<script
type=
"text/javascript"
>
function
onsub
()
{
$
.
ajax
({
url
:
"
/application/{{ app[1] }}/device/{{ dev[1] }}/configure
"
,
type
:
"
post
"
,
data
:
$
(
"
#confform
"
).
serialize
(),
success
:
function
()
{
location
.
reload
();
}
});
}
function
remove_configuration
(
b64
)
{
$
.
ajax
({
url
:
"
/application/{{ app[1] }}/device/{{ dev[1] }}/remove-configuration?conf=
"
+
b64
,
type
:
"
get
"
,
success
:
function
()
{
location
.
reload
();
}
});
}
</script>
{% endblock %}
app/app/views.py
View file @
70d47c00
...
...
@@ -261,13 +261,13 @@ def application_device_configuration(appkey, devid):
config_args
=
cntt
[
2
:(
len
(
cntt
)
-
1
)].
decode
(
'utf-8'
)
ack
=
pm
[
3
]
config_list
.
append
((
config_id
,
config_args
,
ack
,
pm
[
2
]))
return
render_template
(
'new/public/device-configuration.html'
,
dev
=
dev
,
app
=
ap
,
config_list
=
config_list
)
el
se
:
el
if
request
.
method
==
'POST'
:
base64_args
=
misc
.
pend_base64_encode
(
request
.
form
[
'arg'
],
request
.
form
[
'confid'
])
pend
.
create
(
appkey
,
devid
,
base64_args
)
return
redirect
(
url_for
(
'applications'
))
return
''
,
201
else
:
return
redirect
(
url_for
(
'login'
))
...
...
@@ -430,10 +430,10 @@ def dev_conf_rm(appkey, devid):
if
res
[
0
]:
flash
(
'Configuration message successfully removed.'
,
'success'
)
return
redirect
(
url_for
(
'applications'
))
else
:
flash
(
'Error removing configuration message: {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
url_for
(
'applications'
))
return
''
,
200
else
:
return
redirect
(
url_for
(
'login'
))
...
...
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