Commit 2033dff4 authored by Andreas Valder's avatar Andreas Valder
Browse files

added gui and backend to create a thumbnail job

parent 775c8a35
......@@ -2,6 +2,7 @@ from server import *
import traceback
import json
import random
from sorter import schedule_thumbnail
@register_navbar('Jobs', iconlib='fa', icon='suitcase')
......@@ -34,8 +35,8 @@ def jobs_overview():
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, pagecount=pagecount)
@app.route('/internal/jobs/action/<action>', methods=['GET', 'POST'])
@app.route('/internal/jobs/action/<action>/<jobid>', methods=['GET', 'POST'])
def jobs_action(action, jobid=None):
......@@ -46,6 +47,11 @@ def jobs_action(action, jobid=None):
if action == 'copy':
if jobid:
query("INSERT INTO jobs SELECT NULL, type, priority, 'ready', '', '' , ?, '', NULL, data, '{}' FROM jobs where ID=?;",, jobid)
if action == 'add':
jobtype = request.values.get('type', None)
if jobtype == 'thumbnail':
lectureid = int(request.values.get('lecture_id', -1))
return redirect(request.values.get('ref', url_for('jobs_overview')))
def jobs_api_token_required(func):
{% extends "base.html" %}
{% block modals %}
{{ super() }}
<div class="modal fade" id="modal_addjob" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
Neue(n) Job(s) erzeugen
<div class="modal-body">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#add_thtumbnail" aria-controls="thumbnail" role="tab" data-toggle="tab">Thumbnaile</a></li>
<div class="tab-content" style="margin-top: 10px;">
<div role="tabpanel" class="tab-pane active" id="add_thumbnail">
<form class="form-inline" action="{{url_for('jobs_action', action='add', ref=request.url)}}" method="post">
<div class="form-group">
<input type="hidden" name="type" value="thumbnail">
<input type="text" class="form-control" id="thumbnail_lectureid" placeholder="Lecture ID" name="lecture_id">
<button type="submit" class="btn btn-primary">Hinzufügen</button>
<div class="modal-footer">
{% endblock %}
{% block content %}
<div class="panel-group">
<div class="panel panel-default">
......@@ -36,7 +71,7 @@
<div class="panel-heading">
<h1 class="panel-title">
<a class="btn btn-default">Job(s) erzeugen</a>
<a class="btn btn-default" href="javascript:$('#modal_addjob').modal()" >Job(s) erzeugen</a>
<a class="btn btn-default" href="{{url_for('jobs_action', action='clear_failed', ref=request.url)}}" >Alle fehlgeschlagenen Jobs löschen</a>
<a class="btn btn-default" href="{{url_for('jobs_action', action='retry_failed', ref=request.url)}}" >Alle fehlgeschlagenen Jobs neustarten</a>
......@@ -143,7 +178,7 @@
{% if i.state == "failed" %}
<a class="btn btn-default" href="{{url_for('jobs_action', action='clear_failed',, ref=request.url)}}" title="Löschen" >
<a class="btn btn-default" href="{{url_for('jobs_action', action='clear_failed',, ref=request.url)}}" title="Löschen" style="background-color: red;">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
<a class="btn btn-default" href="{{url_for('jobs_action', action='retry_failed',, ref=request.url)}}" title="Neustarten">
Markdown is supported
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