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

users removed from admin urlpaths

parent 2ad202cf
......@@ -10,7 +10,7 @@ from app.helpers.misc import grant_view
def restricted(access_level, user_protect=False):
def user_control(f):
@wraps(f)
def decorated_function(*args, **kwargs):
def restricted_function(*args, **kwargs):
if 'role' in session:
if not grant_view(access_level, session['role']):
flash('Access denied.', 'danger')
......@@ -22,15 +22,15 @@ def restricted(access_level, user_protect=False):
return redirect(url_for('index'))
return f(*args, **kwargs)
return redirect(url_for('login'))
return decorated_function
return restricted_function
return user_control
def application_protected(f):
def decorated_function(*args, **kwargs):
@wraps(f)
def protected_function(*args, **kwargs):
ap = ad.get(kwargs['appkey'])
print(ap, session)
if not ap[0] or ap[1][2] != session['name']:
flash('Access denied.', 'danger')
return redirect(url_for('index'))
return f(*args, **kwargs)
return decorated_function
return protected_function
{% extends 'logged_layout.html' %}
{% block title %} New User - HPC&A IoT {% endblock %}
{% block title %} Administration - New User - 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>
......@@ -19,7 +19,7 @@
<h3 class="mb-0">New User</h3>
</div>
<div class="card-body">
<form action="/administration/users/new-user" method="post">
<form action="/administration/new-user" method="post">
<div class="form-group">
<label>Name:</label><br>
<input type="text" maxlength="30" class="form-control" id="username" name="username" required>
......
......@@ -11,11 +11,11 @@
<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">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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/application/{{ app[1] }}">{{ app[0] }}</a>
{% endblock %}
{% block body %}
......
{% extends 'logged_layout.html' %}
{% block title %} Administration - Users - Application - Alerts - HPC&amp;A IoT {% endblock %}
{% block title %} Administration - {{ user }} - {{ app[0] }} - Alerts - HPC&amp;A IoT {% endblock %}
{% block header %}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
......@@ -12,11 +12,11 @@
<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">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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/application/{{ app[1] }}">{{ app[0] }}</a>
{% endblock %}
{% block body %}
......@@ -54,7 +54,7 @@
{% endif %}
<br>
<div class="col-lg-4">
<a href="/administration/users/{{ user }}/application/{{ app[1] }}/new-alert"><button class="btn btn-primary" type="submit">New Alert</button></a>
<a href="/administration/{{ user }}/application/{{ app[1] }}/new-alert"><button class="btn btn-primary" type="submit">New Alert</button></a>
</div>
</div>
......@@ -67,7 +67,7 @@
<script type="text/javascript">
function remove_alert(id, devid) {
$.ajax({
url:"/administration/users/{{ user }}/application/{{ app[1] }}/delete-alert?id="+id+"&devid="+devid,
url:"/administration/{{ user }}/application/{{ app[1] }}/delete-alert?id="+id+"&devid="+devid,
type:"get",
success: function() {
location.reload();
......
......@@ -12,11 +12,11 @@
<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">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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/application/{{ app[1] }}">{{ app[0] }}</a>
{% endblock %}
{% block body %}
......@@ -52,7 +52,7 @@
{% endif %}
<br>
<div class="col-lg-4">
<a href="/administration/users/{{ user }}/application/{{ app[1] }}/new-automation"><button class="btn btn-primary" type="submit">New Automation</button></a>
<a href="/administration/{{ user }}/application/{{ app[1] }}/new-automation"><button class="btn btn-primary" type="submit">New Automation</button></a>
</div>
</div>
</div>
......@@ -64,7 +64,7 @@
<script type="text/javascript">
function remove_automation(id, devid) {
$.ajax({
url:"/administration/users/{{ user }}/application/{{ app[1] }}/delete-automation?id="+id+"&devid="+devid,
url:"/administration/{{ user }}/application/{{ app[1] }}/delete-automation?id="+id+"&devid="+devid,
type:"get",
success: function() {
location.reload();
......
{% extends 'logged_layout.html' %}
{% block title %} HPC&amp;A IoT - Device Configuration {% endblock %}
{% block title %} Administration - {{ user }} - {{ app[0] }} - Device Configuration - HPC&amp;A IoT {% endblock %}
{% block header %}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
......@@ -12,13 +12,13 @@
<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">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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}">{{ dev[0] }}</a>
{% endblock %}
{% block body %}
......@@ -92,7 +92,7 @@
<script type="text/javascript">
function onsub() {
$.ajax({
url:"/administration/users/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/configure",
url:"/administration/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/configure",
type:"post",
data:$("#confform").serialize(),
success: function() {
......@@ -102,7 +102,7 @@
}
function remove_configuration(b64) {
$.ajax({
url:"/administration/users/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/remove-configuration?conf="+b64,
url:"/administration/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/remove-configuration?conf="+b64,
type:"get",
success: function() {
location.reload();
......
......@@ -11,13 +11,13 @@
<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">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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}">{{ dev[0] }}</a>
{% endblock %}
{% block body %}
......@@ -31,7 +31,7 @@
<h3 class="mb-0">Device Settings</h3>
</div>
<div class="card-body">
<form action="/administration/users/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/settings" method="post" id="devsettings">
<form action="/administration/{{ 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>
......@@ -77,7 +77,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a href="/administration/users/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/delete"><button type="button" class="btn btn-danger">Delete Device</button></a>
<a href="/administration/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/delete"><button type="button" class="btn btn-danger">Delete Device</button></a>
</div>
</div>
</div>
......
......@@ -7,11 +7,11 @@
<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">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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/application/{{ app[1] }}">{{ app[0] }}</a>
{% endblock %}
{% block body %}
......@@ -25,7 +25,7 @@
<h3 class="mb-0">New Automation</h3>
</div>
<div class="card-body">
<form action="/administration/users/{{ user }}/application/{{ app[1] }}/new-automation" method="post">
<form action="/administration/{{ user }}/application/{{ app[1] }}/new-automation" method="post">
<div class="form-group">
<label>Name:</label><br>
<input type="text" maxlength="30" class="form-control" id="automationname" name="automationname" required><br>
......@@ -105,7 +105,7 @@
var dev_sel = document.getElementById("devid");
var sel_op = dev_sel.options[dev_sel.selectedIndex].value;
if (sel_op != "-") {
fetch("/administration/users/{{ user }}/application/{{ app[1] }}/device/"+sel_op+"/variables").then(res => res.text()).then(data => $("#varname").html(data));
fetch("/administration/{{ user }}/application/{{ app[1] }}/device/"+sel_op+"/variables").then(res => res.text()).then(data => $("#varname").html(data));
}
validate_form();
}
......
......@@ -7,11 +7,11 @@
<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">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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/application/{{ app[1] }}">{{ app[0] }}</a>
{% endblock %}
{% block body %}
......@@ -25,7 +25,7 @@
<h3 class="mb-0">Application Settings</h3>
</div>
<div class="card-body">
<form action="/administration/users/{{ user }}/application/{{ app[1] }}/settings" method="post" id="appsettings">
<form action="/administration/{{ user }}/application/{{ app[1] }}/settings" method="post" id="appsettings">
<div class="form-group">
<label>Name:</label><br>
<input type="text" maxlength="30" class="form-control" id="appname" name="appname" value="{{ app[0] }}" required><br>
......@@ -70,7 +70,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a href="/administration/users/{{ user }}/application/{{ app[1] }}/delete"><button type="button" class="btn btn-danger">Delete Application</button></a>
<a href="/administration/{{ user }}/application/{{ app[1] }}/delete"><button type="button" class="btn btn-danger">Delete Application</button></a>
</div>
</div>
</div>
......
{% extends 'logged_layout.html' %}
{% block title %} Administration - Users - {{ app[0] }} - HPC&amp;A IoT {% endblock %}
{% block title %} Administration - {{ user }} - {{ app[0] }} - HPC&amp;A IoT {% endblock %}
{% block location %}
<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="/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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/application/{{ app[1] }}">{{ app[0] }}</a>
{% endblock %}
{% block stats %}
......
{% extends 'logged_layout.html' %}
{% block title %} User Applications - HPC&amp;A IoT {% endblock %}
{% block title %} Administration - {{ user }} - Applications - HPC&amp;A IoT {% endblock %}
{% block location %}
<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="/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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/applications">Applications</a>
{% endblock %}
{% block body %}
......
{% extends 'logged_layout.html' %}
{% block title %} User Dashboard - HPC&amp;A IoT {% endblock %}
{% block title %} Administration - {{ user }} - Dashboard - HPC&amp;A IoT {% endblock %}
{% block location %}
<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="/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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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="#">Dashboard</a>
{% endblock %}
......@@ -166,14 +166,14 @@
</div>
<div class="row" style="margin-top: 30px;">
<div class="col-lg-3">
<a href="/administration/users/{{ user }}/applications"><button type="submit" class="btn btn-primary btn-block">Applications</button></a>
<a href="/administration/{{ user }}/applications"><button type="submit" class="btn btn-primary btn-block">Applications</button></a>
</div>
<div class="col-lg-3">
</div>
<div class="col-lg-3">
</div>
<div class="col-lg-3">
<a href="/administration/users/{{ user }}/settings"><button type="submit" class="btn btn-primary btn-block">Settings</button></a>
<a href="/administration/{{ user }}/settings"><button type="submit" class="btn btn-primary btn-block">Settings</button></a>
</div>
{% endblock %}
......@@ -182,7 +182,7 @@
(function worker() {
var e = $("#chart-sales");
var e1 = $("#chart-orders");
$.get('/administration/users/{{ user }}/chart-update', function(cdata) {
$.get('/administration/{{ user }}/chart-update', function(cdata) {
cdata = eval(cdata);
var a = new Chart(e,
{
......@@ -281,7 +281,7 @@
});
})();
$.get("/administration/users/{{ user }}/recent-activity", function(cdata) {
$.get("/administration/{{ user }}/recent-activity", function(cdata) {
$("#recent_activity_body").html(cdata);
});
......
{% extends 'logged_layout.html' %}
{% block title %} User Device - HPC&amp;A IoT {% endblock %}
{% block title %} Administration - {{ user }} - {{ app[0] }} - {{ dev[0] }} - HPC&amp;A IoT {% endblock %}
{% block header %}
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
......@@ -11,13 +11,13 @@
<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">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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}">{{ dev[0] }}</a>
{% endblock %}
{% block stats %}
......@@ -190,8 +190,8 @@
tscroll = init_scroll();
fetch('/administration/users/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/data/'+dname+'/graph/1').then(res => res.text()).then(data => drawChart(dname, eval(data)));
fetch('/administration/users/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/data/'+dname+'/table/'+tscroll[dname]).then(res => res.text()).then(data => $('#table_'+dname+'_body').html(data));
fetch('/administration/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/data/'+dname+'/graph/1').then(res => res.text()).then(data => drawChart(dname, eval(data)));
fetch('/administration/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/data/'+dname+'/table/'+tscroll[dname]).then(res => res.text()).then(data => $('#table_'+dname+'_body').html(data));
}
function show_first_page() {
......@@ -200,7 +200,7 @@
function table_load_more(dname) {
tscroll[dname] += 1;
fetch('/administration/users/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/data/'+dname+'/table/'+tscroll[dname]).then(res => res.text()).then(function(data)
fetch('/administration/{{ user }}/application/{{ app[1] }}/device/{{ dev[1] }}/data/'+dname+'/table/'+tscroll[dname]).then(res => res.text()).then(function(data)
{
if (data.length > 0) {
$("#table_"+dname+"_body").append(data);
......
{% extends 'logged_layout.html' %}
{% block title %} Administration - {{ name }} - {{ app[1] }} - New Alert HPC&amp;A IoT {% endblock %}
{% block title %} Administration - {{ name }} - {{ app[1] }} - New Alert - HPC&amp;A IoT {% endblock %}
{% block location %}
<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="/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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/application/{{ app[1] }}">{{ app[0] }}</a>
{% endblock %}
{% block body %}
......@@ -25,7 +25,7 @@
<h3 class="mb-0">New Alert</h3>
</div>
<div class="card-body">
<form action="/administration/users/{{ user }}/application/{{ app[1] }}/new-alert" method="post">
<form action="/administration/{{ user }}/application/{{ app[1] }}/new-alert" method="post">
<div class="form-group">
<label>Name:</label><br>
<input type="text" maxlength="30" class="form-control" id="alertname" name="alertname" required><br>
......@@ -95,7 +95,7 @@
var dev_sel = document.getElementById("devid");
var sel_op = dev_sel.options[dev_sel.selectedIndex].value;
if (sel_op != "-") {
fetch("/administration/users/{{ user }}/application/{{ app[1] }}/device/"+sel_op+"/variables").then(res => res.text()).then(data => $("#varname").html(data));
fetch("/administration/{{ user }}/application/{{ app[1] }}/device/"+sel_op+"/variables").then(res => res.text()).then(data => $("#varname").html(data));
}
validate_form();
}
......
{% extends 'logged_layout.html' %}
{% block title %} New Application - HPC&amp;A IoT {% endblock %}
{% block title %} Administration - {{ user }} - New Application - HPC&amp;A IoT {% endblock %}
{% block location %}
<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="/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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/applications">Applications</a>
{% endblock %}
{% block body %}
......@@ -23,7 +23,7 @@
<h3 class="mb-0">New Application</h3>
</div>
<div class="card-body">
<form action="new-application" method="post">
<form action="/administration/{{ user }}/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>
......@@ -44,7 +44,7 @@
<br>
<div class="form-group">
<button type="submit" class="btn btn-primary">Create Application</button>
<button type="submit" class="btn btn-primary">Create Application for {{ user }}</button>
</div>
</form>
......
......@@ -7,9 +7,9 @@
<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">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="/administration/users/{{ user }}">{{ user }}</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ 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 }}/settings">Settings</a>
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="/administration/{{ user }}/settings">Settings</a>
{% endblock %}
{% block body %}
......@@ -23,7 +23,7 @@
<h3 class="mb-0">User Settings</h3>
</div>
<div class="card-body">
<form action="/administration/users/{{ user }}/settings" method="post" id="settings">
<form action="/administration/{{ user }}/settings" method="post" id="settings">
<div class="form-group">
<label>Name:</label><br>
<input type="text" maxlength="30" class="form-control" id="name" name="name" value="{{ user }}" style="pointer-events: none;">
......@@ -89,7 +89,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a href="/administration/users/{{ user }}/delete-account"><button type="button" class="btn btn-danger">Delete Account</button></a>
<a href="/administration/{{ user }}/delete-account"><button type="button" class="btn btn-danger">Delete Account</button></a>
</div>
</div>
</div>
......
{% extends 'logged_layout.html' %}
{% block title %} Users - HPC&amp;A IoT {% endblock %}
{% block title %} Administration - Users - HPC&amp;A IoT {% endblock %}
{% block header %}
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
......@@ -85,7 +85,7 @@
</thead>
<tbody id="users_body">
{% for u in users %}
<tr onclick="window.location='/administration/users/{{ u[0] }}';">
<tr onclick="window.location='/administration/{{ u[0] }}';">
<th> {{ u[0] }} </th>
<th> {{ u[2] }} </th>
</tr>
......@@ -99,7 +99,7 @@
</div>
<div class="card-body">
<div class="col-lg-4">
<a href="/administration/users/new-user"><button class="btn btn-primary" type="submit">New User</button></a>
<a href="/administration/new-user"><button class="btn btn-primary" type="submit">New User</button></a>
</div>
</div>
......@@ -120,7 +120,7 @@
data = eval(data);
$("#users_body").empty();
data.forEach(function (entry) {
str = "<tr onclick=window.location=\"/administration/users/"+entry[0]+"\"><th>"+entry[0]+"</th>"+"<th>"+entry[1]+"</th></tr>";
str = "<tr onclick=window.location=\"/administration/"+entry[0]+"\"><th>"+entry[0]+"</th>"+"<th>"+entry[1]+"</th></tr>";
$("#users_body").append(unescape(str));
});
}
......@@ -136,7 +136,7 @@
else {
data = eval(data);
data.forEach(function (entry) {
str = "<tr onclick=window.location=\"/administration/users/"+entry[0]+"\"><th>"+entry[0]+"</th>"+"<th>"+entry[1]+"</th></tr>";
str = "<tr onclick=window.location=\"/administration/"+entry[0]+"\"><th>"+entry[0]+"</th>"+"<th>"+entry[1]+"</th></tr>";
$("#users_body").append(unescape(str));
});
next_page++;
......
......@@ -60,9 +60,9 @@ def administration_users():
return render_template('new/admin/users.html', users=users, info=info)
@app.route('/administration/users/<name>')
@app.route('/administration/<name>')
@restricted('admin', True)
def administration_users_user(name):
def administration_user(name):
created_apps = ad.get_count_by_user(name)[1][0]
active_devices = dd.get_count_by_user(name)
total_activity = md.get_user_data_count(name)[1][0]
......@@ -71,16 +71,16 @@ def administration_users_user(name):
return render_template('new/admin/user-dashboard.html', info=info, user=name)
@app.route('/administration/users/<name>/applications')
@app.route('/administration/<name>/applications')
@restricted('admin', True)
def administration_users_user_applications(name):
def administration_user_applications(name):
apps = ad.get_list(name)[1]
return render_template('new/admin/user-applications.html', apps=apps, user=name)
@app.route('/administration/users/<name>/new-application', methods=['GET', 'POST'])
@app.route('/administration/<name>/new-application', methods=['GET', 'POST'])
@restricted('admin', True)
def administration_users_user_application_create(name):
def administration_user_new_application(name):
if request.method == 'GET':
return render_template('new/admin/user-new-application.html', user=name)
elif request.method == 'POST':
......@@ -108,12 +108,12 @@ def administration_users_user_application_create(name):
flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url)
return redirect(url_for('administration_users_user_applications', name=name))
return redirect(url_for('administration_user_applications', name=name))
@app.route('/administration/users/<name>/application/<appkey>')
@app.route('/administration/<name>/application/<appkey>')
@restricted('admin', True)
def administration_users_user_application(name, appkey):
def administration_user_application(name, appkey):
ap = list(ad.get(appkey)[1])
ap[5] = misc.skey_b64_to_hex(ap[5])
devs = dd.get_list(ap[1])[1]
......@@ -121,9 +121,9 @@ def administration_users_user_application(name, appkey):
return render_template('new/admin/user-application.html', app=ap, devs=devs, user=name)
@app.route('/administration/users/<name>/application/<appkey>/add-device', methods=['GET', 'POST'])
@app.route('/administration/<name>/application/<appkey>/add-device', methods=['GET', 'POST'])
@restricted('admin', True)
def administration_users_user_application_add_device(name, appkey):
def administration_user_application_add_device(name, appkey):
if request.method == 'GET':
ap = ad.get(appkey)
dev_list = dd.get_list(appkey)
......@@ -143,12 +143,12 @@ def administration_users_user_application_add_device(name, appkey):
flash('Error: {}'.format(res[1]), 'danger')
return rendirect(request.url)
else:
return redirect(url_for('administration_users_user_application', name=name, appkey=appkey))
return redirect(url_for('administration_user_application', name=name, appkey=appkey))
@app.route('/administration/users/<name>/application/<appkey>/device/<devid>')
@app.route('/administration/<name>/application/<appkey>/device/<devid>')
@restricted('admin', True)
def administration_users_user_application_device(name, appkey, devid):
def administration_user_application_device(name, appkey, devid):
ap = ad.get(appkey)
dev = dd.get(appkey, devid)
......@@ -163,9 +163,9 @@ 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, total=cnt[1][0], user=name, table_max=MAX_PG_ENTRIES_DATA)
@app.route('/administration/users/<name>/application/<appkey>/device/<devid>/settings', methods=['GET', 'POST'])
@app.route('/administration/<name>/application/<appkey>/device/<devid>/settings', methods=['GET', 'POST'])
@restricted('admin', True)
def administration_users_user_application_device_settings(name, appkey, devid):
def administration_user_application_device_settings(name, appkey, devid):
if request.method == 'GET':
ap = ad.get(appkey)
dev = dd.get(appkey, devid)
......@@ -182,9 +182,9 @@ def administration_users_user_application_device_settings(name, appkey, devid):
return redirect(request.url)
@app.route('/administration/users/<name>/application/<appkey>/device/<devid>/delete')
@app.route('/administration/<name>/application/<appkey>/device/<devid>/delete')
@restricted('admin', True)
def administration_users_user_application_device_delete(name, appkey, devid):
def administration_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]:
......@@ -195,20 +195,20 @@ def administration_users_user_application_device_delete(name, appkey, devid):
data.delete_table(appkey, devid)
res = dd.delete(appkey, devid)
return redirect(url_for('administration_users_user_application', name=name, appkey=appkey))
return redirect(url_for('administration_user_application', name=name, appkey=appkey))
@app.route('/administration/users/<name>/application/<appkey>/alerts')
@app.route('/administration/<name>/application/<appkey>/alerts')
@restricted('admin', True)
def administration_users_user_application_alerts(name, appkey):
def administration_user_application_alerts(name, appkey):
ap = ad.get(appkey)
alerts = nfs.get_alerts_list(appkey)
return render_template('new/admin/user-application-alerts.html', alert_list=alerts[1], app=ap[1], user=name)
@app.route('/administration/users/<name>/application/<appkey>/new-alert', methods=['GET', 'POST'])
@app.route('/administration/<name>/application/<appkey>/new-alert', methods=['GET', 'POST'])
@restricted('admin', True)
def administration_users_user_application_new_alert(name, appkey):
def administration_user_application_new_alert(name, appkey):
if request.method == 'GET':
ap = ad.get(appkey)
devs = dd.get_list(appkey)
......@@ -227,7 +227,7 @@ def administration_users_user_application_new_alert(name, appkey):
tr.create_function(appkey, request.form['devid'], nid, [request.form['varname'],request.form['operation'],request.form['avalue']])
tr.create(appkey, request.form['devid'], nid)
flash('Alert created', 'success')
return redirect(url_for('administration_users_user_application_alerts', name=name, appkey=appkey))
return redirect(url_for('administration_user_application_alerts', name=name, appkey=appkey))
else:
flash('Error creating new alert: {}'.format(res[1]), 'danger')
return redirect(request.url)
......@@ -236,18 +236,18 @@ def administration_users_user_application_new_alert(name, appkey):
return redirect(request.url)
@app.route('/administration/users/<name>/application/<appkey>/automation')
@app.route('/administration/<name>/application/<appkey>/automation')
@restricted('admin', True)
def administration_users_user_application_automation(name, appkey):
def administration_user_application_automation(name, appkey):
ap = ad.get(appkey)
ats = nfs.get_automation_list(appkey)
return render_template('new/admin/user-application-automation.html', automations=ats[1], app=ap[1], user=name)
@app.route('/administration/users/<name>/application/<appkey>/new-automation', methods=['GET', 'POST'])
@app.route('/administration/<name>/application/<appkey>/new-automation', methods=['GET', 'POST'])
@restricted('admin', True)
def administration_users_user_application_new_automation(name, appkey):
def administration_user_application_new_automation(name, appkey):
if request.method == 'GET':
ap = ad.get(appkey)
devs = dd.get_list(appkey)
......@@ -269,7 +269,7 @@ def administration_users_user_application_new_automation(name, appkey):
tr.create_function(appkey, request.form['devid'], nid, [request.form['varname'],request.form['operation'],request.form['avalue']])
tr.create(appkey, request.form['devid'], nid)
flash('Automation created', 'success')
return redirect(url_for('administration_users_user_application_automation', name=name, appkey=appkey))
return redirect(url_for('administration_user_application_automation', name=name, appkey=appkey))
else:
flash('Error creating new alert: {}'.format(res[1]), 'danger')
return redirect(request.url)
......@@ -278,9 +278,9 @@ def administration_users_user_application_new_automation(name, appkey):
return redirect(request.url)
@app.route('/administration/users/<name>/application/<appkey>/delete')
@app.route('/administration/<name>/application/<appkey>/delete')
@restricted('admin', True)
def administration_users_user_application_delete(name, appkey):
def administration_user_application_delete(name, appkey):
devs = dd.get_list(appkey)
for dev in devs[1]:
......@@ -299,15 +299,15 @@ def administration_users_user_application_delete(name, appkey):
if not res[0]:
flash('Error deleting application: {}'.format(res[1]), 'danger')
return redirect(url_for('administration_users_user_application_settings', name=name, appkey=appkey))
return redirect(url_for('administration_user_application_settings', name=name, appkey=appkey))
else:
flash('Application deleted.', 'success')
return redirect(url_for('administration_users_user_applications', name=name))
return redirect(url_for('administration_user_applications', name=name))
@app.route('/administration/users/<name>/application/<appkey>/settings', methods=['GET', 'POST'])
@app.route('/administration/<name>/application/<appkey>/settings', methods=['GET', 'POST'])
@restricted('admin', True)
def administration_users_user_application_settings(name, appkey):
def administration_user_application_settings(name, appkey):
if request.method == 'GET':
ap = ad.get(appkey)
......@@ -327,9 +327,9 @@ def administration_users_user_application_settings(name, appkey):
return redirect(request.url)
@app.route('/administration/users/<name>/application/<appkey>/delete-<ntype>')
@app.route('/administration/<name>/application/<appkey>/delete-<ntype>')
@restricted('admin', True)
def administration_users_user_application_notification_remove(name, appkey, ntype):
def administration_user_application_notification_remove(name, appkey, ntype):
nq.delete(appkey, request.args.get('devid'), request.args.get('id'))
tr.delete(appkey, request.args.get('devid'), request.args.get('id'))
tr.delete_function(appkey, request.args.get('devid'), request.args.get('id'))
......@@ -343,9 +343,9 @@ def administration_users_user_application_notification_remove(name, appkey, ntyp
return '', 500
@app.route('/administration/users/<name>/application/<appkey>/device/<devid>/variables')
@app.route('/administration/<name>/application/<appkey>/device/<devid>/variables')
@restricted('admin', True)
def administration_users_user_application_device_variables(name, appkey, devid):
def administration_user_application_device_variables(name, appkey, devid):
dev = dd.get(appkey, devid)[1]
select = '<select class="form-control" id="varname" name="varname" onchange="validate_form();" required>'
select += '<option value="-">Select Variable</option>'
......@@ -355,9 +355,9 @@ def administration_users_user_application_device_variables(name, appkey, devid):
return select
@app.route('/administration/users/<name>/application/<appkey>/device/<devid>/data/<var>/<dest>/<page>')
@app.route('/administration/<name>/application/<appkey>/device/<devid>/data/<var>/<dest>/<page>')
@restricted('admin', True)
def administration_users_user_application_device_data(name, appkey, devid, var, dest, page):
def administration_user_application_device_data(name, appkey, devid, var, dest, page):
dev = dd.get(appkey, devid)[1]
if dest == 'graph':
last = data.get_last_hours(appkey, devid, MAX_PG_ENTRIES_GRAPH_HOURS, int(page))
......@@ -379,9 +379,9 @@ def administration_users_user_application_device_data(name, appkey, devid, var,
return t
@app.route('/administration/users/<name>/application/<appkey>/device/<devid>/configure', methods=['GET', 'POST'])
@app.route('/administration/<name>/application/<appkey>/device/<devid>/configure', methods=['GET', 'POST'])
@restricted('admin', True)
def administration_users_user_application_device_configuration(name, appkey, devid):
def administration_user_application_device_configuration(name, appkey, devid):
if request.method == 'GET':
pend_msgs = pend.get_list(appkey, devid)
ap = ad.get(appkey)[1]
......@@ -405,9 +405,9 @@ def administration_users_user_application_device_configuration(name, appkey, dev
return '', 201
@app.route('/administration/users/<name>/application/<appkey>/device/<devid>/remove-configuration')
@app.route('/administration/<name>/application/<appkey>/device/<devid>/remove-configuration')
@restricted('admin', True)
def administration_users_user_application_device_configuration_remove(name, appkey, devid):
def administration_user_application_device_configuration_remove(name, appkey, devid):
res = pend.delete(appkey, devid, request.args.get('conf')+'_')
if res[0]:
......@@ -418,9 +418,9 @@ def administration_users_user_application_device_configuration_remove(name, appk
return '', 200
@app.route('/administration/users/<name>/application/<appkey>/device/<devid>/download-csv')
@app.route('/administration/<name>/application/<appkey>/device/<devid>/download-csv')
@restricted('admin', True)
def administration_users_user_application_device_download_csv(name, appkey, devid):
def administration_user_application_device_download_csv(name, appkey, devid):
@after_this_request
def clean_data_folder(response):
try:
......@@ -453,9 +453,9 @@ def administration_users_user_application_device_download_csv(name, appkey, devi
return send_from_directory(app.config['DATA_DOWNLOAD_DIR'], fn, as_attachment=True)
@app.route('/administration/users/<name>/chart-update')
@app.route('/administration/<name>/chart-update')
@restricted('admin', True)
def administration_users_user_chart_update(name):
def administration_user_chart_update(name):
day_chart_values = md.get_user_data_count_per_hour_period(name, 11)[1]
day_chart_values = [x[0] for x in day_chart_values]
day_chart_labels = [misc.local_hour(x) for x in range(11,-1,-1)]
......@@ -469,9 +469,9 @@ def administration_users_user_chart_update(name):
return "[{}, {}]".format(day_chart, week_chart)
@app.route('/administration/users/<name>/recent-activity')
@app.route('/administration/<name>/recent-activity')
@restricted('admin', True)
def administration_users_user_recent_activity(name):
def administration_user_recent_activity(name):
recent_activity = md.get_recent_activity(name)[1]
ra = ''
......@@ -491,9 +491,9 @@ def administration_users_table(page):
return str(users), 200
@app.route('/administration/users/new-user', methods=['POST', 'GET'])
@app.route('/administration/new-user', methods=['POST', 'GET'])
@restricted('admin')
def administration_users_new_user():
def administration_new_user():
if request.method == 'GET':
return render_template('new/admin/new-user.html')
elif request.method == 'POST':
......@@ -513,12 +513,12 @@ def administration_users_new_user():
flash('Error: {}'.format(res[1]), 'danger')
return redirect(request.url)
else:
return redirect(url_for('administration_users_user', name=username))
return redirect(url_for('administration_user', name=username))
@app.route('/administration/users/<name>/settings', methods=['GET', 'POST'])
@app.route('/administration/<name>/settings', methods=['GET', 'POST'])
@restricted('admin', True)
def administration_users_user_settings(name):
def administration_user_settings(name):
user = ud.get(name)
if user[0] and misc.grant_view(user[1][2], session['role']):
if request.method == 'GET':
......@@ -543,12 +543,12 @@ def administration_users_user_settings(name):
return redirect(request.url)
else:
flash('Access denied' ,'danger')
return redirect(url_for('administration_users_user', name=name))
return redirect(url_for('administration_user', name=name))
@app.route('/administration/users/<name>/delete-account')
@app.route('/administration/<name>/delete-account')
@restricted('admin', True)
def administration_users_user_delete_account(name):
def administration_user_delete_account(name):
user = ud.get(name)
if user[0] and misc.grant_view(user[1][2], session['role']):
app_list = ad.get_list(user[1][0])
......@@ -582,4 +582,4 @@ def administration_users_user_delete_account(name):
return redirect(url_for('administration_users'))
else:
flash('Warning: the user is admin or does not exist.' ,'danger')
return redirect(url_for('administration_users_user_settings', name=name))
return redirect(url_for('administration_user_settings', name=name))
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