Commit 05333766 authored by Vladislav Rykov's avatar Vladislav Rykov
Browse files

links fixed

parent e324edd4
......@@ -92,6 +92,7 @@
<i class="ni ni-air-baloon text-yellow"></i> Applications
</a>
</li>
{% if session['role'] == 'admin' %}
<li class="nav-item">
<a class="nav-link " href="./examples/icons.html">
<i class="ni ni-briefcase-24 text-pink"></i> Administration
......@@ -102,6 +103,7 @@
<i class="ni ni-single-02 text-info"></i> Users
</a>
</li>
{% endif %}
<li class="nav-item">
<a class="nav-link " href="./examples/icons.html">
<i class="ni ni-settings-gear-65 text-grey"></i> Settings
......@@ -136,11 +138,8 @@
<li class="nav-item dropdown">
<a class="nav-link pr-0" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<div class="media align-items-center">
<span class="avatar avatar-sm rounded-circle">
<img alt="Image placeholder" src="{{ url_for('static', filename='assets/img/theme/team-4-800x800.jpg') }}">
</span>
<div class="media-body ml-2 d-none d-lg-block">
<span class="mb-0 text-sm font-weight-bold">Jessica Jones</span>
<span class="mb-0 text-sm font-weight-bold">{{ session['name'] }}</span>
</div>
</div>
</a>
......@@ -148,24 +147,16 @@
<div class=" dropdown-header noti-title">
<h6 class="text-overflow m-0">Welcome!</h6>
</div>
<a href="./examples/profile.html" class="dropdown-item">
<a href="/profile" class="dropdown-item">
<i class="ni ni-single-02"></i>
<span>My profile</span>
</a>
<a href="./examples/profile.html" class="dropdown-item">
<a href="/settings" class="dropdown-item">
<i class="ni ni-settings-gear-65"></i>
<span>Settings</span>
</a>
<a href="./examples/profile.html" class="dropdown-item">
<i class="ni ni-calendar-grid-58"></i>
<span>Activity</span>
</a>
<a href="./examples/profile.html" class="dropdown-item">
<i class="ni ni-support-16"></i>
<span>Support</span>
</a>
<div class="dropdown-divider"></div>
<a href="#!" class="dropdown-item">
<a href="/logout" class="dropdown-item">
<i class="ni ni-user-run"></i>
<span>Logout</span>
</a>
......
{% extends 'logged_layout.html' %}
{% block title %} HPC&amp;A IoT - Add Device {% 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>
{% 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">Add Device</h3>
</div>
<div class="card-body">
<form action="/application/{{ app[1] }}/add-device" method="post">
<div class="form-group">
<label>Name:</label><br>
<input type="text" maxlength="30" class="form-control" id="devname" name="devname" required><br>
</div>
<div class="form-group">
<label>Description:</label><br>
<textarea id="devdesc" maxlength="200" class="form-control" name="devdesc" rows="5"></textarea>
</div>
<br>
<div class="form-group">
<label>dev_id: {{ free_ids }}</label><br>
<input type="number" size="3" min="1" max="255" class="form-control" id="devid" name="devid" required><br>
</div>
<br>
<div class="form-group">
<button type="submit" class="btn btn-primary">Add Device</button>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
......@@ -75,7 +75,7 @@
</div>
</div>
</div>
{% if data %}
<div>
<ul class="nav nav-pills" id="pills-tab" role="tablist">
{% for k in data[0][2] %}
......@@ -108,6 +108,13 @@
{% endfor %}
</div>
</div>
{% else %}
<div class="col-lg-12">
<p> Device has not sent any data yet. </p>
</div>
{% endif %}
<div class="row" style="margin-top: 30px;">
<div class="col-lg-4">
......@@ -151,6 +158,7 @@
{% endblock %}
{% block script %}
{% if data %}
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
......@@ -238,4 +246,5 @@
fetch('/application/{{ app[1] }}/device/{{ dev[1] }}/data/'+dname+'/table/'+tscroll[dname]).then(res => res.text()).then(data => console.log(data));
}
</script>
{% endif %}
{% endblock %}
......@@ -193,7 +193,7 @@ def new_application():
@app.route('/application/<appkey>/device/<devid>')
def app_device(appkey, devid):
def application_device(appkey, devid):
if 'name' in session:
ap = ad.get(appkey)
if session['role'] == 'admin' or session['name'] == ap[1][2]:
......@@ -212,10 +212,37 @@ def app_device(appkey, devid):
if ld[0] and ld[1][0] != []:
ltup = ld[1][0][1]
return render_template('new/public/device.html', dev=dev[1], app=ap[1], ltup=ltup, data=ld[1], total=cnt[1][0])
if ld[0]:
return render_template('new/public/device.html', dev=dev[1], app=ap[1], ltup=ltup, data=ld[1], total=cnt[1][0])
else:
return render_template('new/public/device.html', dev=dev[1], app=ap[1], ltup=ltup, data=[], total=cnt[1][0])
else:
return redirect(url_for('login'))
@app.route('/application/<appkey>/add-device', methods=['GET', 'POST'])
def application_add_device(appkey):
if 'name' in session:
if request.method == 'GET':
ap = ad.get(appkey)
dev_list = dd.get_list(appkey)
return render_template('new/public/add-device.html', app=ap[1], free_ids=misc.prep_id_range(dev_list[1]))
elif request.method == 'POST':
res = dd.create(request.form['devname'], request.form['devid'], appkey, request.form['devdesc'])
if not res[0]:
flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url)
else:
res = data.create_table(appkey, request.form['devid'])
if not res[0]:
dd.delete(session['appkey'], request.form['devid'])
flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url)
else:
return redirect(url_for('applications'))
else:
return redirect(url_for('login'))
@app.route('/new-app')
def new_app():
......
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