UI for upcoming events /view/status/running

fix #15
This commit is contained in:
boyska 2016-08-23 17:57:03 +02:00
parent 59741db5eb
commit e64880b445
No known key found for this signature in database
GPG key ID: 7395DCAE58289CA9
3 changed files with 60 additions and 2 deletions

View file

@ -12,7 +12,7 @@ $(function() {
</script> </script>
{%endblock%} {%endblock%}
{% block title %}Larigira - DB list {%endblock%} {% block title %}Larigira - DB list{%endblock%}
{% block content %} {% block content %}
<div class="container-fluid"> <div class="container-fluid">

View file

@ -4,13 +4,15 @@ import gc
from copy import deepcopy from copy import deepcopy
from greenlet import greenlet from greenlet import greenlet
from flask import current_app, Blueprint, Flask, jsonify from flask import current_app, Blueprint, Flask, jsonify, render_template
from flask_bootstrap import Bootstrap from flask_bootstrap import Bootstrap
from .dbadmin import db from .dbadmin import db
from .config import get_conf from .config import get_conf
rpc = Blueprint('rpc', __name__, url_prefix='/api') rpc = Blueprint('rpc', __name__, url_prefix='/api')
viewui = Blueprint('view', __name__, url_prefix='/view',
template_folder='templates')
def send_to_parent(kind, *args): def send_to_parent(kind, *args):
@ -59,6 +61,16 @@ def get_scheduled_audiogen():
return events return events
@viewui.route('/status/running')
def ui_wip():
audiogens = get_scheduled_audiogen()
return render_template('running.html',
audiogens=sorted(
audiogens.items(),
key=lambda x: x[1]['running_time'])
)
@rpc.route('/debug/running') @rpc.route('/debug/running')
def rpc_wip(): def rpc_wip():
def treeify(flat): def treeify(flat):
@ -114,6 +126,7 @@ def create_app(queue, larigira):
app.config.update(get_conf()) app.config.update(get_conf())
Bootstrap(app) Bootstrap(app)
app.register_blueprint(rpc) app.register_blueprint(rpc)
app.register_blueprint(viewui)
app.register_blueprint(db) app.register_blueprint(db)
app.queue = queue app.queue = queue
app.larigira = larigira app.larigira = larigira

View file

@ -0,0 +1,45 @@
{% extends "bootstrap/base.html" %}
{% block title %}Larigira - Upcoming events{%endblock%}
{%macro print_action(aid, action)%}
<span class="action-nick" data-actionid="{{aid}}" data-kind="{{action['kind']}}">
{% if 'nick' in action %}
{{action['nick']}}
{% else %}
{{ action['kind'] }}
{% endif %}
{%endmacro%}
{%macro print_actions(actions)%}
{% if actions|length == 0 %}
<span class="action-none">NOTHING</span>
{% else %}
<span class="action">{{print_action(*actions.items()|first)}}</span>
{% endif %}
{%endmacro%}
{% block content %}
<h1>Upcoming events</h2>
<div class="container-fluid">
<table class="upcoming-events table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Running time</th>
<th>Action</th>
</tr>
</thead>
{% for id, event in audiogens %}
<tr>
<td>{{id}}</td>
<td>{{event['running_time']}}</td>
<td>{{print_actions(event['timespec']['actions'])}}</td>
</tr>
{%endfor%}
</table>
</div>
{% endblock content %}
{# vim: set ts=2 sw=2 noet: #}