From 07493f88cd126539607e3c1978ff7ab22a6a2fd1 Mon Sep 17 00:00:00 2001
From: Andreas <andreasv@fsmpi.rwth-aachen.de>
Date: Thu, 8 Jun 2017 09:55:21 +0200
Subject: [PATCH] added gui to only reschedule/delete one failed job; added
 option to insert a copy of an existing job

---
 jobs.py                      |  5 ++++-
 templates/jobs_overview.html | 15 +++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/jobs.py b/jobs.py
index 1195828..d831bdb 100644
--- a/jobs.py
+++ b/jobs.py
@@ -35,14 +35,17 @@ def jobs_overview():
 	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>')
+@app.route('/internal/jobs/action/<action>/<jobid>')
 @mod_required
 @csrf_protect
 def jobs_action(action, jobid=None):
-	print(jobid)
 	if action == 'clear_failed':
 		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)
 	return redirect(request.values.get('ref', url_for('jobs_overview')))
 
 def jobs_api_token_required(func):
diff --git a/templates/jobs_overview.html b/templates/jobs_overview.html
index 66db847..775da81 100644
--- a/templates/jobs_overview.html
+++ b/templates/jobs_overview.html
@@ -112,6 +112,7 @@
 							<th>Gescheduled am</th>
 							<th>Daten</th>
 							<th>Status</th>
+							<th></th>
 						</tr>
 						{% for i in jobs %}
 							{% if i.last_ping %}
@@ -140,6 +141,20 @@
 								<td>{{i.time_scheduled}}</td>
 								<td>{{i.data}}</td>
 								<td>{{i.status}}</td>
+								<td>
+									{% 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" >
+									                <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>
+									{% 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>
+									{% endif %}
+								</td>
 							</tr>
 						{% endfor %}
 					</table>
-- 
GitLab