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:
parent
d973474a37
commit
a09c4bcd73
3 changed files with 41 additions and 0 deletions
13
larigira/dbadmin/__init__.py
Normal file
13
larigira/dbadmin/__init__.py
Normal 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)
|
24
larigira/dbadmin/templates/list.html
Normal file
24
larigira/dbadmin/templates/list.html
Normal 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: #}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue