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

new application form view integrated

parent 0d72f305
......@@ -107,36 +107,6 @@
<i class="ni ni-settings-gear-65 text-grey"></i> Settings
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="./examples/icons.html">
<i class="ni ni-planet text-blue"></i> Icons
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="./examples/maps.html">
<i class="ni ni-pin-3 text-orange"></i> Maps
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="./examples/profile.html">
<i class="ni ni-single-02 text-yellow"></i> User profile
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="./examples/tables.html">
<i class="ni ni-bullet-list-67 text-red"></i> Tables
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./examples/login.html">
<i class="ni ni-key-25 text-info"></i> Login
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./examples/register.html">
<i class="ni ni-circle-08 text-pink"></i> Register
</a>
</li>
</ul>
<!-- Divider -->
<hr class="my-3">
......@@ -145,20 +115,10 @@
<!-- Navigation -->
<ul class="navbar-nav mb-md-3">
<li class="nav-item">
<a class="nav-link" href="https://demos.creative-tim.com/argon-dashboard/docs/getting-started/overview.html">
<a class="nav-link" href="/getting-started/overview.html">
<i class="ni ni-spaceship"></i> Getting started
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://demos.creative-tim.com/argon-dashboard/docs/foundation/colors.html">
<i class="ni ni-palette"></i> Foundation
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://demos.creative-tim.com/argon-dashboard/docs/components/alerts.html">
<i class="ni ni-ui-04"></i> Components
</a>
</li>
</ul>
</div>
</div>
......
......@@ -79,7 +79,7 @@
<h3 class="mb-0">Devices</h3>
</div>
<div class="row icon-examples">
{% if devs %}
{% for d in devs %}
<div class="col-lg-3 col-md-6">
<button type="button" class="btn-icon-clipboard" data-clipboard-text="atom" title="{{ d[0] }}">
......@@ -90,6 +90,11 @@
</button>
</div>
{% endfor %}
{% else %}
<div class="col-lg-12 col-md-12">
<center><p> There are no registered devices yet. </p></center>
</div>
{% endif %}
</div>
<div class="row" style="margin-top: 30px;">
......
{% extends 'logged_layout.html' %}
{% block title %} HPC&amp;A IoT - New Application {% endblock %}
{% block location %} <a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="./applications">Applications</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">Applications</h3>
</div>
<div class="card-body">
<form action="new-application" method="post">
<div class="form-group">
<label>Name:</label><br>
<input type="text" maxlength="30" class="form-control" id="appname" name="appname" required><br>
</div>
<div class="form-group">
<label>Description:</label><br>
<textarea id="appdesc" maxlength="200" class="form-control" name="appdesc" rows="5"></textarea>
</div>
<br>
<div class="custom-control custom-control-alternative custom-checkbox">
<input class="custom-control-input" id="secure" type="checkbox" name="secure">
<label class="custom-control-label" for="secure">
<span class="text-muted">Secure</span>
</label>
</div>
<br>
<p> Note, if you use secure option, make sure your device uses aes128 ctr with the corresponding key.</p>
<br>
<div class="form-group">
<button type="submit" class="btn btn-primary">Create Application</button>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
......@@ -157,6 +157,41 @@ def application(appkey):
return redirect(url_for('login', users_signup=app.config['USERS_SIGNUP']))
@app.route('/new-application', methods=['GET', 'POST'])
def new_application():
if 'name' in session:
if request.method == 'GET':
return render_template('new/public/new-application.html')
elif request.method == 'POST':
if request.form['appname'] == '':
flash('Application name cannot be empty.', 'danger')
return render_template(request.url)
else:
appkey = misc.rand_str(app.config['APPKEY_LENGTH']).decode('utf-8')
secure_key = misc.gen_skey_b64(16)
secure = False
if request.form.getlist('secure') and request.form.getlist('secure')[0] == 'true':
secure = True
res = ad.create(request.form['appname'], appkey, session['name'], request.form['appdesc'], secure, secure_key)
if not res[0]:
flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url)
res = dd.create_table(appkey)
if not res[0]:
ad.delete(appkey)
flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url)
return redirect(url_for('applications'))
else:
return redirect(url_for('login', users_signup=app.config['USERS_SIGNUP']))
@app.route('/application/<appkey>/device/<devid>')
def app_device(appkey, devid):
if 'name' in session:
......@@ -183,7 +218,7 @@ def app_device(appkey, devid):
@app.route('/new-app')
def new_application():
def new_app():
if 'name' in session:
return render_template('old/public/new-app.html')
else:
......
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