Start a first, simple, db interface

by now, it's just a very raw "list" of db events.
Needs to be "bootstrapped", and of course forms are still missing!
This commit is contained in:
boyska 2015-02-01 00:57:01 +01:00
parent d973474a37
commit a09c4bcd73
No known key found for this signature in database
GPG key ID: 7395DCAE58289CA9
3 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,13 @@
from __future__ import print_function
from flask import current_app, Blueprint, render_template
db = Blueprint('db', __name__, url_prefix='/db', template_folder='templates')
@db.route('/list')
def db_list():
model = current_app.larigira.monitor.source.model
alarms = tuple(model.get_all_alarms())
events = [(alarm, model.get_actions_by_alarm(alarm))
for alarm in alarms]
return render_template('list.html', events=events)

View file

@ -0,0 +1,24 @@
<html>
<meta>
<title>Larigira - DB list</title>
</meta>
<body>
<div class="main">
{% for e, actions in events %}
<div class="event">
<h2>Event {{e.eid}}</h2>
<pre>{{ e }}</pre>
<div class="actions">
<h3>Actions</h3>
<ol>
{% for a in actions %}
<li><pre>{{ a }}</pre></li>
{% endfor %}
</ol>
</div>{# actions #}
</div>{# event #}
{% endfor %}
</div>{# main #}
</body>
</html>
{# vim: set ts=2 sw=2 noet: #}

View file

@ -4,6 +4,9 @@ import gc
from greenlet import greenlet
from flask import current_app, Blueprint, Flask, jsonify
from .dbadmin import db
rpc = Blueprint('rpc', __name__, url_prefix='/api')
@ -66,6 +69,7 @@ def rpc_wip():
def create_app(queue, larigira):
app = Flask(__name__)
app.register_blueprint(rpc)
app.register_blueprint(db)
app.queue = queue
app.larigira = larigira
return app