mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-03-09 15:40:09 +00:00
add settings page, add way to add/remove ignored pools
This commit is contained in:
parent
ecd7809749
commit
5fb7f66624
5 changed files with 126 additions and 0 deletions
|
@ -355,6 +355,37 @@ def delete_user(user):
|
||||||
return '', 403
|
return '', 403
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/settings")
|
||||||
|
@auth.oidc_auth
|
||||||
|
def settings():
|
||||||
|
user = session['userinfo']['preferred_username']
|
||||||
|
rtp = 'rtp' in session['userinfo']['groups']
|
||||||
|
active = 'active' in session['userinfo']['groups']
|
||||||
|
if rtp:
|
||||||
|
ignored_pools = get_ignored_pools(db)
|
||||||
|
return render_template(
|
||||||
|
'settings.html',
|
||||||
|
username=user,
|
||||||
|
rtp=rtp,
|
||||||
|
active=active,
|
||||||
|
ignored_pools=ignored_pools)
|
||||||
|
else:
|
||||||
|
return '', 403
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/pool/<string:pool>/ignore", methods=['POST', 'DELETE'])
|
||||||
|
@auth.oidc_auth
|
||||||
|
def ignored_pools(pool):
|
||||||
|
if 'rtp' in session['userinfo']['groups']:
|
||||||
|
if request.method == 'POST':
|
||||||
|
add_ignored_pool(db, pool)
|
||||||
|
elif request.method == "DELETE":
|
||||||
|
delete_ignored_pool(db, pool)
|
||||||
|
return '', 200
|
||||||
|
else:
|
||||||
|
return '', 403
|
||||||
|
|
||||||
|
|
||||||
@app.route('/vm/<string:vmid>/rrd/<path:path>')
|
@app.route('/vm/<string:vmid>/rrd/<path:path>')
|
||||||
@auth.oidc_auth
|
@auth.oidc_auth
|
||||||
def send_rrd(vmid, path):
|
def send_rrd(vmid, path):
|
||||||
|
|
|
@ -131,3 +131,17 @@ def get_ignored_pools(db):
|
||||||
for pool in db.query(Ignored_Pools).all():
|
for pool in db.query(Ignored_Pools).all():
|
||||||
ignored_pools.append(pool.id)
|
ignored_pools.append(pool.id)
|
||||||
return ignored_pools
|
return ignored_pools
|
||||||
|
|
||||||
|
|
||||||
|
def delete_ignored_pool(db, pool):
|
||||||
|
if db.query(exists().where(Ignored_Pools.id == pool)).scalar():
|
||||||
|
ignored_pool = db.query(Ignored_Pools).filter(Ignored_Pools.id == pool).one()
|
||||||
|
db.delete(ignored_pool)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
def add_ignored_pool(db, pool):
|
||||||
|
if not db.query(exists().where(Ignored_Pools.id == pool)).scalar():
|
||||||
|
ignored_pool = Ignored_Pools(id=pool)
|
||||||
|
db.add(ignored_pool)
|
||||||
|
db.commit()
|
||||||
|
|
|
@ -745,3 +745,21 @@ $(".delete-user").click(function(){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".delete-ignored-pool").click(function(){
|
||||||
|
const pool = $(this).data('pool')
|
||||||
|
fetch(`/pool/${pool}/ignore`, {
|
||||||
|
credentials: 'same-origin',
|
||||||
|
method: 'delete'
|
||||||
|
});
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".add-ignored-pool").click(function(){
|
||||||
|
const pool = document.getElementById('pool').value
|
||||||
|
fetch(`/pool/${pool}/ignore`, {
|
||||||
|
credentials: 'same-origin',
|
||||||
|
method: 'post'
|
||||||
|
});
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
|
|
@ -40,6 +40,14 @@
|
||||||
Create VM
|
Create VM
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if rtp %}
|
||||||
|
<li>
|
||||||
|
<a href="/settings">
|
||||||
|
<span class="glyphicon glyphicon-cog"></span>
|
||||||
|
Settings
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
|
55
proxstar/templates/settings.html
Normal file
55
proxstar/templates/settings.html
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-9 col-sm-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">Templates</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 col-sm-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">Ignored Pools</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<table class="table table-bordered table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr role="row">
|
||||||
|
<th>Pool</th>
|
||||||
|
<th>Delete</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for pool in ignored_pools %}
|
||||||
|
<tr role="row">
|
||||||
|
<td class="col-md-9">{{ pool }}</td>
|
||||||
|
<td class="col-md-3">
|
||||||
|
<button class="btn btn-sm btn-danger delete-ignored-pool" data-pool="{{ pool }}">
|
||||||
|
<span class="glyphicon glyphicon-remove"></span>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<input type="text" id="pool" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<button class="btn btn-sm btn-success add-ignored-pool" data-pool="{{ pool }}">
|
||||||
|
<span class="glyphicon glyphicon-plus"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue