{# #################################################################################################### #}
{# Job CRUD #}
{% macro start_job(id) %}
<form class="inline" method="post" action="/jobs">
  <input type="hidden" name="action" value="enqueue" />
  <input type="hidden" name="file_id" value="{{ id }}" />
  <input id="submit" type="submit" value="Enqueue"/>
</form>
{% endmacro %}

{% macro duplicate_job(id) %}
<form class="inline" method="post" action="/jobs">
  <input type="hidden" name="action" value="duplicate" />
  <input type="hidden" name="job_id" value="{{ id }}" />
  <input id="submit" type="submit" value="Duplicate"/>
</form>
{% endmacro %}

{% macro cancel_job(id) %}
<form class="inline" method="post" action="/jobs">
  <input type="hidden" name="action" value="cancel" />
  <input type="hidden" name="job_id" value="{{ id }}" />
  <input id="submit" type="submit" value="Cancel"/>
</form>
{% endmacro %}

{% macro delete_job(id) %}
<form class="inline" method="post" action="/jobs">
  <input type="hidden" name="action" value="delete" />
  <input type="hidden" name="job_id" value="{{ id }}" />
  <input id="submit" type="submit" value="Delete"/>
</form>
{% endmacro %}

{% macro job_state(job) %}
{{ 'queued' if (not job.finished_at and not job.printer_id and not job.cancelled_at) else
   'running' if (not job.finished_at and job.printer_id and not job.cancelled_at) else
   'cancelling' if (not job.finished_at and job.printer_id and job.cancelled_at) else
  job.state }}
{% endmacro %}

{# #################################################################################################### #}
{# File CRUD #}
{% macro delete_file(id) %}
<form class="inline" method="post" action="/files">
  <input type="hidden" name="action" value="delete" />
  <input type="hidden" name="file_id" value="{{ id }}" />
  <input id="submit" type="submit" value="Delete"/>
</form>
{% endmacro %}
