From d0afba04553b6cf587b59a6598a814e5cbc2d58a Mon Sep 17 00:00:00 2001 From: Andreas <andreasv@fsmpi.rwth-aachen.de> Date: Thu, 8 Jun 2017 17:52:26 +0200 Subject: [PATCH] added delete feature to all jobs --- jobs.py | 5 ++++- templates/jobs_overview.html | 31 ++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/jobs.py b/jobs.py index cd86ecb..435da73 100644 --- a/jobs.py +++ b/jobs.py @@ -41,12 +41,15 @@ def jobs_overview(): @csrf_protect def jobs_action(action, jobid=None): 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': query('UPDATE jobs SET state="ready" WHERE state = "failed" AND (id = ? OR ? IS NULL)', jobid, jobid) if action == 'copy': if 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': jobtype = request.values.get('type', None) if jobtype == 'thumbnail': diff --git a/templates/jobs_overview.html b/templates/jobs_overview.html index f3c450a..9cdd5e1 100644 --- a/templates/jobs_overview.html +++ b/templates/jobs_overview.html @@ -177,18 +177,31 @@ <td>{{i.data}}</td> <td>{{i.status}}</td> <td> + <ul class="list-inline" style="white-space: nowrap;"> {% if i.state == "failed" %} - <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> - </a> - <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> - </a> + <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;"> + <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> + </a> + </li> + <li> + <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> + </a> + </li> {% else %} - <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> - </a> + <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"> + <span class="fa fa-refresh" aria-hidden="true"></span> + </a> + </li> {% endif %} + </ul> </td> </tr> {% endfor %} -- GitLab