{# #################################################################################################### #}
{# 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="image" src="/static/print.svg" height="24" width="24" />
</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="image" src="/static/print.svg" height="24" width="24" />
</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="image" src="/static/cancel.svg" height="24" width="24" />
</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="image" src="/static/delete.svg" height="24" width="24" />
</form>
{% endmacro %}

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

{% macro job_active(job) %}
{{
  'dot--active' if not job.finished_at else ''
}}
{% endmacro %}

{# #################################################################################################### #}
{# File CRUD #}
{% macro delete_file(id, endpoint="/files") %}
<form class="inline" method="post" action="{{ endpoint }}">
  <input type="hidden" name="action" value="delete" />
  <input type="hidden" name="file_id" value="{{ id }}" />
  <input id="submit" type="image" src="/static/delete.svg" height="24" width="24" />
</form>
{% endmacro %}

{% macro download_file(id, endpoint="/files") %}
<form class="inline" method="post" action="{{ endpoint }}">
  <input type="hidden" name="action" value="download" />
  <input type="hidden" name="file_id" value="{{ id }}" />
  <input id="submit" type="image" src="/static/download.svg" height="24" width="24" />
</form>
{% endmacro %}

{# #################################################################################################### #}
{# User CRUD #}

{% macro approve_user(id) %}
<form class="inline" method="post" action="/admin/users">
  <input type="hidden" name="action" value="approve" />
  <input type="hidden" name="user_id" value="{{ id }}" />
  <input id="submit" type="submit" value="Approve"/>
</form>
{% endmacro %}

{% macro enable_user(id) %}
<form class="inline" method="post" action="/admin/users">
  <input type="hidden" name="action" value="enable" />
  <input type="hidden" name="user_id" value="{{ id }}" />
  <input id="submit" type="submit" value="Enable"/>
</form>
{% endmacro %}

{% macro lock_user(id) %}
<form class="inline" method="post" action="/admin/users">
  <input type="hidden" name="action" value="lock" />
  <input type="hidden" name="user_id" value="{{ id }}" />
  <input id="submit" type="submit" value="Lock"/>
</form>
{% endmacro %}

{% macro passwdchng_user(id) %}
<form class="inline" method="post" action="/admin/users">
  <input type="hidden" name="action" value="passwdchng" />
  <input type="hidden" name="user_id" value="{{ id }}" />
  <input id="submit" type="submit" value="Password change"/>
</form>
{% endmacro %}
