allow users to trigger netmon resync
This commit is contained in:
parent
016a9b4f70
commit
02c094aab2
|
@ -10,7 +10,7 @@ from ffmap.dbtools import FreifunkDB
|
|||
from ffmap import stattools
|
||||
from ffmap.web.helpers import *
|
||||
|
||||
from flask import Flask, render_template, request, Response
|
||||
from flask import Flask, render_template, request, Response, redirect, url_for, flash
|
||||
import bson
|
||||
import pymongo
|
||||
from bson.json_util import dumps as bson2json
|
||||
|
@ -49,9 +49,15 @@ def router_list():
|
|||
"system.clients": 1,
|
||||
}).sort("hostname", pymongo.ASCENDING))
|
||||
|
||||
@app.route('/routers/<dbid>')
|
||||
@app.route('/routers/<dbid>', methods=['GET', 'POST'])
|
||||
def router_info(dbid):
|
||||
try:
|
||||
if request.method == 'POST':
|
||||
if request.form.get("act") == "netmon_resync":
|
||||
r = db.routers.update_one({"_id": ObjectId(dbid)}, {"$unset": {"netmon_id": 1}})
|
||||
assert r.matched_count > 0
|
||||
flash("<b>Netmon Sync triggered!</b>", "success")
|
||||
return redirect(url_for("router_info", dbid=dbid))
|
||||
router = db.routers.find_one({"_id": ObjectId(dbid)})
|
||||
assert router
|
||||
except (bson.errors.InvalidId, AssertionError):
|
||||
|
@ -76,6 +82,9 @@ def global_statistics():
|
|||
newest_routers = db.routers.find({}, {"hostname": 1, "hood": 1, "created": 1}).sort("created", pymongo.DESCENDING).limit(len(hoods)+1)
|
||||
)
|
||||
|
||||
|
||||
app.secret_key = os.urandom(24)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', debug=True)
|
||||
else:
|
||||
|
|
|
@ -133,6 +133,7 @@ def status2css(status):
|
|||
"online": "success",
|
||||
"reboot": "info",
|
||||
"created": "primary",
|
||||
"netmon": "primary",
|
||||
"update": "primary",
|
||||
}
|
||||
return "label label-%s" % status_map.get(status, "default")
|
||||
|
|
|
@ -46,6 +46,20 @@
|
|||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container main_content">{% block content %}{% endblock %}</div><!-- /.container -->
|
||||
<div class="container main_content">
|
||||
{%- block alerts %}
|
||||
{%- with messages = get_flashed_messages(with_categories=true) %}
|
||||
{%- if messages %}
|
||||
{%- for category, message in messages %}
|
||||
<div class="alert alert-{{ category }} alert-dismissible" role="alert" style="margin-bottom: 0px; margin-top: 20px;">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
{{ message|safe }}
|
||||
</div>
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{%- endwith %}
|
||||
{%- endblock %}
|
||||
{%- block content %}{% endblock -%}
|
||||
</div><!-- /.container -->
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -37,7 +37,23 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Router: {{ router.hostname }}</h2>
|
||||
<div class="row" style="margin-top: 5px; margin-bottom: 5px;">
|
||||
<div class="col-xs-12 col-sm-10"><h2 style="margin-top: 10px;">Router: {{ router.hostname }}</h2></div>
|
||||
<div class="col-xs-12 col-sm-2 text-right" style="margin-top: 10px; margin-bottom: 10px;">
|
||||
<form method="post" id="actform">
|
||||
<input type="hidden" name="act" id="act" value="" />
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Actions
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#" onclick="$('#act').val('netmon_resync'); $('#actform').submit()">Trigger Netmon Sync</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<div class="panel panel-default">
|
||||
|
|
Loading…
Reference in New Issue