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
58739b2e
Commit
58739b2e
authored
May 25, 2020
by
Vladislav Rykov
Browse files
configure device view integrated and tested
parent
073fba5c
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/app/__pycache__/views.cpython-37.pyc
View file @
58739b2e
No preview for this file type
app/app/templates/new/public/.
new-applic
ation.html.swp
→
app/app/templates/new/public/.
device-configur
ation.html.swp
View file @
58739b2e
No preview for this file type
app/app/templates/new/public/device-configuration.html
0 → 100644
View file @
58739b2e
{% extends 'logged_layout.html' %}
{% block title %} HPC
&
A IoT - Device Configuration {% 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>
<a
class=
"h4 mb-0 text-white text-uppercase d-none d-lg-inline-block"
href=
"/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=
"/application/{{ app[1] }}/device/{{ dev[1] }}"
>
{{ dev[0] }}
</a>
{% endblock %}
{% block body %}
<!-- Page content -->
<div
class=
"container-fluid mt--7"
>
<!-- Table -->
<div
class=
"row"
>
<div
class=
"col"
>
<div
class=
"card shadow"
>
<div
class=
"card-header bg-transparent"
>
<h3
class=
"mb-0"
>
Device Configuration - {{ dev[0] }}
</h3>
</div>
<div
class=
"card-body"
>
<form
action=
""
method=
"post"
>
<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>
</div>
<div
class=
"form-group"
>
<label>
Argument:
</label><br>
<textarea
id=
"arg"
name=
"arg"
class=
"form-control"
maxlength=
"50"
name=
"appdesc"
rows=
"2"
required
></textarea>
</div>
<br>
<div
class=
"form-group"
>
<button
type=
"submit"
class=
"btn btn-primary"
>
Configure
</button>
</div>
<br>
</form>
<div
class=
"card-header bg-transparent"
>
<h3
class=
"mb-0"
>
Configuration history
</h3>
</div>
{% if config_list %}
<table
class=
"table"
>
<thead>
<th>
Config ID
</th>
<th>
Arguments
</th>
<th>
Status
</th>
<th>
</th>
</thead>
<tbody>
{% for c in config_list %}
<td>
{{ c[0] }}
</td>
<td>
{{ c[1] }}
</td>
<td>
<span
class=
"badge badge-dot"
>
{% if c[2] %}
<i
class=
"bg-success"
></i>
Completed
{% else %}
<i
class=
"bg-warning"
></i>
Pending
{% endif %}
</span>
</td>
<td>
<a
href=
"/dev-conf-rm?conf={{ c[3] }}"
>
<span
class=
"glyphicon glyphicon-remove"
</
span
>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div
class=
"col-lg-12"
>
<center><p
style=
"margin-top: 35px;"
>
No configuration messages.
</p></center>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}
app/app/templates/new/public/device.html
View file @
58739b2e
...
@@ -118,7 +118,7 @@
...
@@ -118,7 +118,7 @@
<div
class=
"row"
style=
"margin-top: 30px;"
>
<div
class=
"row"
style=
"margin-top: 30px;"
>
<div
class=
"col-lg-4"
>
<div
class=
"col-lg-4"
>
<button
type=
"submit"
class=
"btn btn-primary btn-block"
>
Configure
</button>
<a
href=
"./{{ dev[1] }}/configure"
>
<button
type=
"submit"
class=
"btn btn-primary btn-block"
>
Configure
</button>
</a>
</div>
</div>
<div
class=
"col-lg-4"
>
<div
class=
"col-lg-4"
>
<button
type=
"submit"
class=
"btn btn-primary btn-block"
>
Download CSV
</button>
<button
type=
"submit"
class=
"btn btn-primary btn-block"
>
Download CSV
</button>
...
...
app/app/templates/old/public/.dev-data-t.html.swp
deleted
100644 → 0
View file @
073fba5c
File deleted
app/app/views.py
View file @
58739b2e
...
@@ -244,6 +244,35 @@ def application_add_device(appkey):
...
@@ -244,6 +244,35 @@ def application_add_device(appkey):
else
:
else
:
return
redirect
(
url_for
(
'login'
))
return
redirect
(
url_for
(
'login'
))
@
app
.
route
(
'/application/<appkey>/device/<devid>/configure'
,
methods
=
[
'GET'
,
'POST'
])
def
application_device_configuration
(
appkey
,
devid
):
if
'name'
in
session
:
if
request
.
method
==
'GET'
:
pend_msgs
=
pend
.
get_list
(
appkey
,
devid
)
ap
=
ad
.
get
(
appkey
)[
1
]
dev
=
dd
.
get
(
appkey
,
devid
)[
1
]
if
pend_msgs
[
0
]:
config_list
=
[]
for
pm
in
pend_msgs
[
1
]:
cntt
=
binascii
.
a2b_base64
(
pm
[
2
])
config_id
=
int
(
cntt
[
0
])
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
)
else
:
base64_args
=
misc
.
pend_base64_encode
(
request
.
form
[
'arg'
],
request
.
form
[
'confid'
])
pend
.
create
(
appkey
,
devid
,
base64_args
)
return
redirect
(
url_for
(
'applications'
))
else
:
return
redirect
(
url_for
(
'login'
))
@
app
.
route
(
'/new-app'
)
@
app
.
route
(
'/new-app'
)
def
new_app
():
def
new_app
():
if
'name'
in
session
:
if
'name'
in
session
:
...
...
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