From a09c4bcd738484476de8739b15a6a1cb4e337a14 Mon Sep 17 00:00:00 2001 From: boyska Date: Sun, 1 Feb 2015 00:57:01 +0100 Subject: [PATCH] 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! --- larigira/dbadmin/__init__.py | 13 +++++++++++++ larigira/dbadmin/templates/list.html | 24 ++++++++++++++++++++++++ larigira/rpc.py | 4 ++++ 3 files changed, 41 insertions(+) create mode 100644 larigira/dbadmin/__init__.py create mode 100644 larigira/dbadmin/templates/list.html diff --git a/larigira/dbadmin/__init__.py b/larigira/dbadmin/__init__.py new file mode 100644 index 0000000..250cc7b --- /dev/null +++ b/larigira/dbadmin/__init__.py @@ -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) diff --git a/larigira/dbadmin/templates/list.html b/larigira/dbadmin/templates/list.html new file mode 100644 index 0000000..a2cee7e --- /dev/null +++ b/larigira/dbadmin/templates/list.html @@ -0,0 +1,24 @@ + + +Larigira - DB list + + +
+ {% for e, actions in events %} +
+

Event {{e.eid}}

+
{{ e }}
+
+

Actions

+
    + {% for a in actions %} +
  1. {{ a }}
  2. + {% endfor %} +
+
{# actions #} +
{# event #} + {% endfor %} +
{# main #} + + +{# vim: set ts=2 sw=2 noet: #} diff --git a/larigira/rpc.py b/larigira/rpc.py index d8fe03c..386b20f 100644 --- a/larigira/rpc.py +++ b/larigira/rpc.py @@ -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