Nicer DB list, bootstrap
This commit is contained in:
parent
a09c4bcd73
commit
2c7e0bdf70
7 changed files with 94 additions and 24 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,3 +9,4 @@ larigira.db
|
|||
larigira.db_*
|
||||
*.json
|
||||
.coverage
|
||||
*.db
|
||||
|
|
|
@ -15,6 +15,7 @@ def get_conf(prefix='LARIGIRA_'):
|
|||
conf['MPD_PORT'] = int(os.getenv('MPD_PORT', '6600'))
|
||||
conf['CACHING_TIME'] = 10
|
||||
conf['DB_URI'] = 'larigira.db'
|
||||
conf['BOOTSTRAP_SERVE_LOCAL'] = True
|
||||
conf.update(from_envvars(prefix=prefix))
|
||||
return conf
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
'''
|
||||
This module contains a flask blueprint for db administration stuff
|
||||
|
||||
Templates are self-contained in this directory
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
from flask import current_app, Blueprint, render_template
|
||||
|
|
54
larigira/dbadmin/templates/dbadmin_base.html
Normal file
54
larigira/dbadmin/templates/dbadmin_base.html
Normal file
|
@ -0,0 +1,54 @@
|
|||
{% extends "bootstrap/base.html" %}
|
||||
{% block title %}Larigira{% endblock title %}
|
||||
{% block navbar %}
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed"
|
||||
data-toggle="collapse"
|
||||
data-target="#bs-navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="{{url_for('db.db_list')}}">Larigira</a>
|
||||
</div>{# navbar-header #}
|
||||
|
||||
<div class="collapse navbar-collapse" id="bs-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="{{url_for('db.db_list')}}">List</a></li>
|
||||
<li><a href="{{url_for('db.db_list')}}">List</a></li>
|
||||
<li><a href="{{url_for('db.db_list')}}">List</a></li>
|
||||
<li><a href="{{url_for('db.db_list')}}">List</a></li>
|
||||
<li><a href="{{url_for('db.db_list')}}">List</a></li>
|
||||
<li><a href="{{url_for('db.db_list')}}">List</a></li>
|
||||
<li><a href="{{url_for('db.db_list')}}">List</a></li>
|
||||
</ul>
|
||||
</div>{# collapse #}
|
||||
|
||||
</div>{#container-fluid#}
|
||||
</nav>
|
||||
{% endblock %}
|
||||
|
||||
{% macro dict_table(obj, exclude_list=[]) %}
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for key in obj if key not in exclude_list%}
|
||||
<tr>
|
||||
<td>{{key}}</td>
|
||||
<td>{{obj[key]}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endmacro %}
|
||||
|
||||
{# vim: set ts=2 sw=2 noet: #}
|
|
@ -1,24 +1,28 @@
|
|||
<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>
|
||||
{% extends "dbadmin_base.html" %}
|
||||
{% block title %}Larigira - DB list {%endblock%}
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid">
|
||||
{% for e, actions in events %}
|
||||
<div class="event row">
|
||||
<div class="col-md-8">
|
||||
<h2>Event {{e.eid}} <small>{{e.nick if 'nick'}}</small></h2>
|
||||
{{dict_table(e, ['nick', 'actions'])}}
|
||||
|
||||
</div>
|
||||
<div class="actions col-md-4">
|
||||
<h3>Actions</h3>
|
||||
<ol>
|
||||
{% for a in actions %}
|
||||
<li>
|
||||
<strong> {{a.nick}} </strong>
|
||||
{{dict_table(a, ['nick'])}}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</div>{# actions #}
|
||||
</div>{# event #}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock content %}
|
||||
{# vim: set ts=2 sw=2 noet: #}
|
||||
|
|
|
@ -4,8 +4,10 @@ import gc
|
|||
from greenlet import greenlet
|
||||
|
||||
from flask import current_app, Blueprint, Flask, jsonify
|
||||
from flask_bootstrap import Bootstrap
|
||||
|
||||
from .dbadmin import db
|
||||
from .config import get_conf
|
||||
|
||||
rpc = Blueprint('rpc', __name__, url_prefix='/api')
|
||||
|
||||
|
@ -67,7 +69,9 @@ def rpc_wip():
|
|||
|
||||
|
||||
def create_app(queue, larigira):
|
||||
app = Flask(__name__)
|
||||
app = Flask('larigira')
|
||||
app.config.update(get_conf())
|
||||
Bootstrap(app)
|
||||
app.register_blueprint(rpc)
|
||||
app.register_blueprint(db)
|
||||
app.queue = queue
|
||||
|
|
1
setup.py
1
setup.py
|
@ -39,6 +39,7 @@ setup(name='larigira',
|
|||
install_requires=[
|
||||
'gevent',
|
||||
'flask',
|
||||
'flask-bootstrap',
|
||||
'python-mpd2',
|
||||
'tinydb'
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue