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

admin:user app dev settings+delete completely integrated

parent 77e9f22d
{% extends 'logged_layout.html' %}
{% block title %} HPC&A IoT - Device Settings {% endblock %}
{% block title %} Administration - {{ user }} - {{ app[0] }} - {{ dev[0] }} - Settings - HPC&A IoT {% endblock %}
{% block location %}
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/applications">Applications</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration">Administration</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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/users">Users</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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/users/{{ user }}">{{ user }}</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="/administration/users/{{ user }}/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="/administration/users/{{ user }}/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="/administration/users/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}">{{ dev[0] }}</a>
{% endblock %}
{% block body %}
......@@ -21,7 +27,7 @@
<h3 class="mb-0">Device Settings</h3>
</div>
<div class="card-body">
<form action="/application/{{ app[1] }}/device/{{ dev[1] }}/settings" method="post" id="devsettings">
<form action="/administration/users/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/settings" method="post" id="devsettings">
<div class="form-group">
<label>Name:</label><br>
<input type="text" maxlength="30" class="form-control" id="devname" name="devname" value="{{ dev[0] }}" required><br>
......@@ -56,7 +62,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a href="/application/{{ app[1] }}/device/{{ dev[1] }}/delete"><button type="button" class="btn btn-danger">Delete Device</button></a>
<a href="/administration/users/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/delete"><button type="button" class="btn btn-danger">Delete Device</button></a>
</div>
</div>
</div>
......
......@@ -164,6 +164,41 @@ def administration_users_user_application_device(name, appkey, devid):
return render_template('new/admin/user-device.html', dev=dev[1], app=ap[1], ltup=ltup, data=[], total=cnt[1][0], user=name)
@app.route('/administration/users/<name>/application/<appkey>/device/<devid>/settings', methods=['GET', 'POST'])
@restricted(access_level='admin')
def administration_users_user_application_device_settings(name, appkey, devid):
if request.method == 'GET':
ap = ad.get(appkey)
dev = dd.get(appkey, devid)
dev_list = dd.get_list(appkey)
return render_template('new/admin/user-application-device-settings.html', app=ap[1], dev=dev[1], free_ids=misc.prep_id_range(dev_list[1]), user=name)
elif request.method == 'POST':
res = dd.update(appkey, devid, request.form['devname'], request.form['devdesc'])
if not res[0]:
flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url)
return redirect(request.url)
@app.route('/administration/users/<name>/application/<appkey>/device/<devid>/delete')
@restricted(access_level='admin')
def administration_users_user_application_device_delete(name, appkey, devid):
nq.delete_per_device(appkey, devid)
nfss = nfs.get_per_device(appkey, devid)
for nf in nfss[1]:
tr.delete(appkey, devid, nf[0])
tr.delete_function(appkey, devid, nf[0])
nfs.delete(appkey, devid, nf[0])
data.delete_table(appkey, devid)
res = dd.delete(appkey, devid)
return redirect(url_for('administration_users_user_application', name=name, appkey=appkey))
@app.route('/administration/users/<name>/application/<appkey>/alerts')
@restricted(access_level='admin')
def administration_users_user_application_alerts(name, appkey):
......
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