diff --git a/web/app/jobs/tables.py b/web/app/jobs/tables.py new file mode 100644 index 00000000..15edf916 --- /dev/null +++ b/web/app/jobs/tables.py @@ -0,0 +1,27 @@ +from flask_table import Table, Col, LinkCol + + +class JobInputTable(Table): + """ + Declares the table describing colum by column. + """ + classes = ['highlight', 'responsive-table'] + filename = Col('Filename', column_html_attrs={'class': 'filename'}, + th_html_attrs={'class': 'sort', + 'data-sort': 'filename'}) + url = LinkCol('Download', 'jobs.download_job_input', + url_kwargs=dict(job_id='job.id', + job_input_id='input_id'), + anchor_attrs={'class': 'waves-effect waves-light btn-small', + 'download': ''}) + + +class JobInputItem(object): + """ + Describes one item like one row per table. + """ + + def __init__(self, filename, job, input_id): + self.filename = filename + self.job = job + self.input_id = input_id diff --git a/web/app/jobs/views.py b/web/app/jobs/views.py index 1708f1c7..394146d9 100644 --- a/web/app/jobs/views.py +++ b/web/app/jobs/views.py @@ -3,6 +3,7 @@ from flask import (abort, current_app, flash, redirect, render_template, from flask_login import current_user, login_required from . import jobs from . import tasks +from . tables import JobInputItem, JobInputTable from ..models import Job, JobInput, JobResult import os @@ -13,7 +14,16 @@ def job(job_id): job = Job.query.get_or_404(job_id) if not (job.creator == current_user or current_user.is_administrator()): abort(403) - return render_template('jobs/job.html.j2', job=job, title='Job') + items = [JobInputItem(input.filename, job, input.id) + for input in job.inputs] + # Convert table object to html string + job_input_table = JobInputTable(items).__html__() + # Add class "list" to tbody element. Needed for "List.js" + job_input_table = job_input_table.replace('tbody', 'tbody class="list"', 1) + return render_template('jobs/job.html.j2', + job=job, + job_input_table=job_input_table, + title='Job') @jobs.route('//delete') diff --git a/web/app/templates/admin/index.html.j2 b/web/app/templates/admin/index.html.j2 index 7e538b9c..7c85c715 100644 --- a/web/app/templates/admin/index.html.j2 +++ b/web/app/templates/admin/index.html.j2 @@ -21,9 +21,19 @@ diff --git a/web/app/templates/jobs/job.html.j2 b/web/app/templates/jobs/job.html.j2 index ee893d77..7373543b 100644 --- a/web/app/templates/jobs/job.html.j2 +++ b/web/app/templates/jobs/job.html.j2 @@ -79,7 +79,7 @@
-
+
inputInputs @@ -87,13 +87,9 @@
- {% for input in job.inputs %} - - {% endfor %} +
    + {{ job_input_table }} +
      @@ -137,6 +133,25 @@