Commit 58739b2e authored by Vladislav Rykov's avatar Vladislav Rykov
Browse files

configure device view integrated and tested

parent 073fba5c
{% 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"> &nbsp;-&nbsp; </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"> &nbsp;-&nbsp; </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 %}
......@@ -118,7 +118,7 @@
<div class="row" style="margin-top: 30px;">
<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 class="col-lg-4">
<button type="submit" class="btn btn-primary btn-block">Download CSV</button>
......
......@@ -244,6 +244,35 @@ def application_add_device(appkey):
else:
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')
def new_app():
if 'name' in session:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment