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_*
|
larigira.db_*
|
||||||
*.json
|
*.json
|
||||||
.coverage
|
.coverage
|
||||||
|
*.db
|
||||||
|
|
|
@ -15,6 +15,7 @@ def get_conf(prefix='LARIGIRA_'):
|
||||||
conf['MPD_PORT'] = int(os.getenv('MPD_PORT', '6600'))
|
conf['MPD_PORT'] = int(os.getenv('MPD_PORT', '6600'))
|
||||||
conf['CACHING_TIME'] = 10
|
conf['CACHING_TIME'] = 10
|
||||||
conf['DB_URI'] = 'larigira.db'
|
conf['DB_URI'] = 'larigira.db'
|
||||||
|
conf['BOOTSTRAP_SERVE_LOCAL'] = True
|
||||||
conf.update(from_envvars(prefix=prefix))
|
conf.update(from_envvars(prefix=prefix))
|
||||||
return conf
|
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 __future__ import print_function
|
||||||
|
|
||||||
from flask import current_app, Blueprint, render_template
|
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>
|
{% extends "dbadmin_base.html" %}
|
||||||
<meta>
|
{% block title %}Larigira - DB list {%endblock%}
|
||||||
<title>Larigira - DB list</title>
|
|
||||||
</meta>
|
{% block content %}
|
||||||
<body>
|
<div class="container-fluid">
|
||||||
<div class="main">
|
{% for e, actions in events %}
|
||||||
{% for e, actions in events %}
|
<div class="event row">
|
||||||
<div class="event">
|
<div class="col-md-8">
|
||||||
<h2>Event {{e.eid}}</h2>
|
<h2>Event {{e.eid}} <small>{{e.nick if 'nick'}}</small></h2>
|
||||||
<pre>{{ e }}</pre>
|
{{dict_table(e, ['nick', 'actions'])}}
|
||||||
<div class="actions">
|
|
||||||
<h3>Actions</h3>
|
</div>
|
||||||
<ol>
|
<div class="actions col-md-4">
|
||||||
{% for a in actions %}
|
<h3>Actions</h3>
|
||||||
<li><pre>{{ a }}</pre></li>
|
<ol>
|
||||||
{% endfor %}
|
{% for a in actions %}
|
||||||
</ol>
|
<li>
|
||||||
</div>{# actions #}
|
<strong> {{a.nick}} </strong>
|
||||||
</div>{# event #}
|
{{dict_table(a, ['nick'])}}
|
||||||
{% endfor %}
|
</li>
|
||||||
</div>{# main #}
|
{% endfor %}
|
||||||
</body>
|
</ol>
|
||||||
</html>
|
</div>{# actions #}
|
||||||
|
</div>{# event #}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
||||||
{# vim: set ts=2 sw=2 noet: #}
|
{# vim: set ts=2 sw=2 noet: #}
|
||||||
|
|
|
@ -4,8 +4,10 @@ import gc
|
||||||
from greenlet import greenlet
|
from greenlet import greenlet
|
||||||
|
|
||||||
from flask import current_app, Blueprint, Flask, jsonify
|
from flask import current_app, Blueprint, Flask, jsonify
|
||||||
|
from flask_bootstrap import Bootstrap
|
||||||
|
|
||||||
from .dbadmin import db
|
from .dbadmin import db
|
||||||
|
from .config import get_conf
|
||||||
|
|
||||||
rpc = Blueprint('rpc', __name__, url_prefix='/api')
|
rpc = Blueprint('rpc', __name__, url_prefix='/api')
|
||||||
|
|
||||||
|
@ -67,7 +69,9 @@ def rpc_wip():
|
||||||
|
|
||||||
|
|
||||||
def create_app(queue, larigira):
|
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(rpc)
|
||||||
app.register_blueprint(db)
|
app.register_blueprint(db)
|
||||||
app.queue = queue
|
app.queue = queue
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -39,6 +39,7 @@ setup(name='larigira',
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'gevent',
|
'gevent',
|
||||||
'flask',
|
'flask',
|
||||||
|
'flask-bootstrap',
|
||||||
'python-mpd2',
|
'python-mpd2',
|
||||||
'tinydb'
|
'tinydb'
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue