Commit d0afba04 authored by Andreas Valder's avatar Andreas Valder
Browse files

added delete feature to all jobs

parent 2033dff4
...@@ -41,12 +41,15 @@ def jobs_overview(): ...@@ -41,12 +41,15 @@ def jobs_overview():
@csrf_protect @csrf_protect
def jobs_action(action, jobid=None): def jobs_action(action, jobid=None):
if action == 'clear_failed': if action == 'clear_failed':
query('UPDATE jobs SET state="deleted" WHERE state = "failed" AND (id = ? OR ? IS NULL)',jobid, jobid) query('UPDATE jobs SET state="deleted" WHERE state = "failed" AND (id = ? OR ? IS NULL)', jobid, jobid)
if action == 'retry_failed': if action == 'retry_failed':
query('UPDATE jobs SET state="ready" WHERE state = "failed" AND (id = ? OR ? IS NULL)', jobid, jobid) query('UPDATE jobs SET state="ready" WHERE state = "failed" AND (id = ? OR ? IS NULL)', jobid, jobid)
if action == 'copy': if action == 'copy':
if jobid: if jobid:
query("INSERT INTO jobs SELECT NULL, type, priority, 'ready', '', '' , ?, '', NULL, data, '{}' FROM jobs where ID=?;", datetime.now(), jobid) query("INSERT INTO jobs SELECT NULL, type, priority, 'ready', '', '' , ?, '', NULL, data, '{}' FROM jobs where ID=?;", datetime.now(), jobid)
if action == 'delete':
if jobid:
query('UPDATE jobs SET state="deleted" WHERE id = ?', jobid)
if action == 'add': if action == 'add':
jobtype = request.values.get('type', None) jobtype = request.values.get('type', None)
if jobtype == 'thumbnail': if jobtype == 'thumbnail':
......
...@@ -177,18 +177,31 @@ ...@@ -177,18 +177,31 @@
<td>{{i.data}}</td> <td>{{i.data}}</td>
<td>{{i.status}}</td> <td>{{i.status}}</td>
<td> <td>
<ul class="list-inline" style="white-space: nowrap;">
{% if i.state == "failed" %} {% if i.state == "failed" %}
<li>
<a class="btn btn-default" href="{{url_for('jobs_action', action='clear_failed', jobid=i.id, ref=request.url)}}" title="Löschen" style="background-color: red;"> <a class="btn btn-default" href="{{url_for('jobs_action', action='clear_failed', jobid=i.id, ref=request.url)}}" title="Löschen" style="background-color: red;">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
</a> </a>
</li>
<li>
<a class="btn btn-default" href="{{url_for('jobs_action', action='retry_failed', jobid=i.id, ref=request.url)}}" title="Neustarten"> <a class="btn btn-default" href="{{url_for('jobs_action', action='retry_failed', jobid=i.id, ref=request.url)}}" title="Neustarten">
<span class="fa fa-refresh" aria-hidden="true"></span> <span class="fa fa-refresh" aria-hidden="true"></span>
</a> </a>
</li>
{% else %} {% else %}
<li>
<a class="btn btn-default" href="{{url_for('jobs_action', action='delete', jobid=i.id, ref=request.url)}}" title="Löschen" style="background-color: red;">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
</a>
</li>
<li>
<a class="btn btn-default" href="{{url_for('jobs_action', action='copy', jobid=i.id, ref=request.url)}}" title="Kopie neu einreihen"> <a class="btn btn-default" href="{{url_for('jobs_action', action='copy', jobid=i.id, ref=request.url)}}" title="Kopie neu einreihen">
<span class="fa fa-refresh" aria-hidden="true"></span> <span class="fa fa-refresh" aria-hidden="true"></span>
</a> </a>
</li>
{% endif %} {% endif %}
</ul>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
......
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