Commit 3696c663 authored by Andreas Valder's avatar Andreas Valder
Browse files

now using bootstrap style for paging

parent 9d9d64b1
......@@ -161,3 +161,21 @@ def create(table):
if 'ref' in request.values:
return redirect(request.values['ref'])
return str(id), 200
@app.route('/internal/changelog')
@register_navbar('Changelog', icon='book')
@mod_required
def changelog():
if 'page' in request.args:
page = max(0, int(request.args['page']))
else:
page = 0
if 'pagesize' in request.args:
pagesize = min(500, int(request.args['pagesize']))
else:
pagesize = 50
changelog = query('SELECT * FROM changelog LEFT JOIN users ON (changelog.who = users.id) ORDER BY `when` DESC LIMIT ? OFFSET ?', pagesize, page*pagesize)
pagecount = math.ceil(query('SELECT count(id) as count FROM changelog')[0]['count']/pagesize)
for entry in changelog:
entry['path'] = '.'.join([entry['table'], entry['id_value'], entry['field']])
return render_template('changelog.html', changelog=changelog, page=page, pagesize=pagesize, pagecount=pagecount)
......@@ -15,6 +15,7 @@ def jobs_overview():
pagesize = min(500, int(request.args['pagesize']))
else:
pagesize = 50
pagecount = math.ceil(query('SELECT count(id) as count FROM jobs')[0]['count']/pagesize)
worker = query('SELECT * FROM worker ORDER BY last_ping DESC')
......@@ -31,7 +32,7 @@ def jobs_overview():
'worker': request.args.get('worker','%') }
jobs = query('SELECT * FROM jobs WHERE (type like ?) AND (worker like ? OR (worker IS NULL AND ? = "%")) AND (state like ?) ORDER BY `time_created` DESC LIMIT ? OFFSET ?', filter['type'], filter['worker'], filter['worker'], filter['state'], pagesize, page*pagesize)
return render_template('jobs_overview.html',worker=worker,jobs=jobs, filter_values=filter_values, filter=filter, page=page, pagesize=pagesize)
return render_template('jobs_overview.html',worker=worker,jobs=jobs, filter_values=filter_values, filter=filter, page=page, pagesize=pagesize, pagecount=pagecount)
def jobs_api_token_required(func):
@wraps(func)
......
......@@ -12,6 +12,7 @@ import traceback
import string
from socket import gethostname
from ipaddress import ip_address, ip_network
import math
app = Flask(__name__)
......@@ -21,6 +22,8 @@ app.add_template_global(random.randint, name='randint')
app.add_template_global(datetime, name='datetime')
app.add_template_global(timedelta, name='timedelta')
app.add_template_global(gethostname, name='gethostname')
app.add_template_global(min, name='min')
app.add_template_global(max, name='max')
scheduler = sched.scheduler()
def run_scheduler():
......@@ -565,23 +568,6 @@ def auth(): # For use with nginx auth_request
return Response("Login required", 401, {'WWW-Authenticate': 'Basic realm="Login Required"'})
return "Not allowed", 403
@app.route('/internal/changelog')
@register_navbar('Changelog', icon='book')
@mod_required
def changelog():
if 'page' in request.args:
page = max(0, int(request.args['page']))
else:
page = 0
if 'pagesize' in request.args:
pagesize = min(500, int(request.args['pagesize']))
else:
pagesize = 50
changelog = query('SELECT * FROM changelog LEFT JOIN users ON (changelog.who = users.id) ORDER BY `when` DESC LIMIT ? OFFSET ?', pagesize, page*pagesize)
for entry in changelog:
entry['path'] = '.'.join([entry['table'], entry['id_value'], entry['field']])
return render_template('changelog.html', changelog=changelog, page=page, pagesize=pagesize)
@app.route('/files/<filename>')
def files(filename):
return redirect(config['VIDEOPREFIX']+'/'+filename)
......
......@@ -8,10 +8,23 @@
</div>
<div class="panel-body">
<p>Hier werden alle Änderungen an Kursen/Veranstaltungen/Videos etc. geloggt und können Rückgängig gemacht werden.</p>
<div style="margin-top: 10px;" class="col-xs-12">
<a href="{{url_for('changelog', page=page-1) }}" class="pull-left btn btn-default">{{ "<<" }}</a>
<a href="{{url_for('changelog', page=page+1) }}" class="pull-right btn btn-default">{{ ">>" }}</a>
</div>
<ul class="pagination pull-right">
<li class="page-item">
<a class="page-link" href="{{url_for('changelog', page=page-1) }}">
<span aria-hidden="true">&laquo;</span>
<span class="sr-only">Previous</span>
</a>
</li>
{% for i in range(max(0, pagecount - 5) ,min(pagecount, pagecount + 5)) %}
<li class="page-item"><a class="page-link" href="{{url_for('changelog', page=i) }}">{{ i }}</a></li>
{% endfor %}
<li class="page-item">
<a class="page-link" href="{{url_for('changelog', page=page+1) }}">
<span aria-hidden="true">&raquo;</span>
<span class="sr-only">Next</span>
</a>
</li>
</ul>
</div>
<div class="table-responsive">
<table class="table table-condensed">
......
......@@ -42,7 +42,6 @@
<div class="panel-body">
<div class="row">
<form>
<a href="{{url_for('jobs_overview', page=page-1, **(request.args|filterdict(['page','pagesize'])) ) }}" class="pull-left btn btn-default col-xs-1">{{ "<<" }}</a>
<div class="form-group col-xs-3">
<label for="type">Type</label>
<input list="job_type" name="type" value="{{ filter.type }}">
......@@ -71,8 +70,25 @@
</datalist>
</div>
<button type="submit" class="btn btn-primary col-xs-1">Filter</button>
<a href="{{url_for('jobs_overview', page=page+1, **(request.args|filterdict(['page','pagesize'])) ) }}" class="pull-right btn btn-default col-xs-1">{{ ">>" }}</a>
</form>
<ul class="pagination pull-right">
<li class="page-item">
<a class="page-link" href="{{url_for('jobs_overview', page=page-1, **(request.args|filterdict(['page','pagesize']))) }}">
<span aria-hidden="true">&laquo;</span>
<span class="sr-only">Previous</span>
</a>
</li>
{% for i in range(max(0, pagecount - 5) ,min(pagecount, pagecount + 5)) %}
<li class="page-item"><a class="page-link" href="{{url_for('jobs_overview', page=i, **(request.args|filterdict(['page','pagesize']))) }}">{{ i }}</a></li>
{% endfor %}
<li class="page-item">
<a class="page-link" href="{{url_for('jobs_overview', page=page+1, **(request.args|filterdict(['page','pagesize']))) }}">
<span aria-hidden="true">&raquo;</span>
<span class="sr-only">Next</span>
</a>
</li>
</ul>
</div>
<table class="table">
<tr>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment