diff --git a/app/services/views.py b/app/services/views.py index c6965572..df46ca20 100644 --- a/app/services/views.py +++ b/app/services/views.py @@ -25,7 +25,7 @@ def ocr(): "--skip-binarisation"], "lang": new_ocr_job_form.language.data, "version": new_ocr_job_form.version.data}), - status="submitted", + status="pending", title=new_ocr_job_form.title.data) db.session.add(ocr_job) db.session.commit() @@ -74,7 +74,7 @@ def nlp(): service_args=json.dumps({"args": [], "lang": new_nlp_job_form.language.data, "version": new_nlp_job_form.version.data}), - status="submitted", + status="pending", title=new_nlp_job_form.title.data) db.session.add(nlp_job) db.session.commit() diff --git a/app/swarm.py b/app/swarm.py index 02cf3c23..b870b27a 100644 --- a/app/swarm.py +++ b/app/swarm.py @@ -101,16 +101,19 @@ class Swarm: ' Poll the service until the job is completly executed. ''' session = self.Session() + job.status = 'running' + session.add(job) + session.commit() + current_state = None while True: current_state = service.tasks()[0].get('Status').get('State') - if job.status != current_state: - job.status = current_state - session.add(job) - session.commit() - if current_state == 'complete': + if current_state == 'complete' or current_state == 'failed': break time.sleep(1) service.reload() + job.status = current_state + session.add(job) + session.commit() session.close() # Remove the service from the swarm. service.remove() diff --git a/app/templates/main/dashboard.html.j2 b/app/templates/main/dashboard.html.j2 index 6607078b..f39decaa 100644 --- a/app/templates/main/dashboard.html.j2 +++ b/app/templates/main/dashboard.html.j2 @@ -58,17 +58,27 @@ {% for job in current_user.jobs.all() %} + {% if job.service == 'nlp' %} + {% set service_icon = 'format_textdirection_l_to_r' %} + {% elif job.service =='ocr' %} + {% set service_icon = 'find_in_page' %} + {% else %} + {% set service_icon = 'help' %} + {% endif %} + + {% if job.status == 'pending' %} + {% set badge_color = 'amber' %} + {% elif job.status =='running' %} + {% set badge_color = 'indigo' %} + {% elif job.status =='complete' %} + {% set badge_color = 'teal' %} + {% else %} + {% set badge_color = 'red' %} + {% endif %} +
  • - - {% if job.service == 'nlp' %} - format_textdirection_l_to_r - {% elif job.service =='ocr' %} - find_in_page - {% else %} - help - {% endif %} - - {{ job.status }} + {{ service_icon }} + {{ job.status }} {{ job.title }}

    {{ job.description }}