98 lines
4.9 KiB
HTML
98 lines
4.9 KiB
HTML
{% extends "base.html" %}
|
|
{% block content %}
|
|
<h1>Tasks</h1>
|
|
{% if not groups %}
|
|
<p>No task groups found.</p>
|
|
{% endif %}
|
|
{% for group in groups %}
|
|
{% set group_run = latest[("group", group.id)] %}
|
|
<section class="group">
|
|
<div class="group-heading">
|
|
<h2>{{ group.display_name }}</h2>
|
|
{% if group.can_run_as_group %}
|
|
<form method="post" action="{{ url_for('run_group', group_id=group.id) }}">
|
|
<button type="submit">Run group</button>
|
|
</form>
|
|
{% endif %}
|
|
</div>
|
|
{% if group_run %}
|
|
<p class="run-summary">
|
|
Group: <a href="{{ url_for('run_detail', run_id=group_run.id) }}">{{ group_run.status }}</a>
|
|
· {{ group_run.finished_at|timestamp if group_run.finished_at else "in progress" }}
|
|
</p>
|
|
{% endif %}
|
|
<ul class="tasks">
|
|
{% for task in group.tasks %}
|
|
{% set task_run = latest[("task", task.id)] %}
|
|
<li>
|
|
<div>
|
|
<h3>{{ task.display_name }}</h3>
|
|
{% if task.description %}<p>{{ task.description }}</p>{% endif %}
|
|
{% if task_run %}
|
|
<p class="run-summary">
|
|
Last run:
|
|
<a href="{{ url_for('run_detail', run_id=task_run.id) }}">{{ task_run.status }}</a>
|
|
· {{ task_run.finished_at|timestamp if task_run.finished_at else "in progress" }}
|
|
· <a href="{{ url_for('history', target_kind='task', target_path=task.id) }}">history</a>
|
|
</p>
|
|
{% endif %}
|
|
</div>
|
|
<form method="post" action="{{ url_for('run_task', task_id=task.id) }}"{% if task.wait_for_result %} data-wait-for-result{% endif %}>
|
|
{% set values = form_values.get(task.id, {}) %}
|
|
{% set errors = input_errors.get(task.id, {}) %}
|
|
{% for field in task.inputs %}
|
|
<div class="task-input">
|
|
{% if field.type == "multi_choice" %}
|
|
<fieldset>
|
|
<legend>{{ field.label }}{% if field.required %} (required){% endif %}</legend>
|
|
{% set selected = values.get(field.name, field.default or ()) %}
|
|
{% for option in field.options %}
|
|
<label>
|
|
<input type="checkbox" name="{{ field.name }}" value="{{ option.value }}" {% if option.value in selected %}checked{% endif %}>
|
|
{{ option.label }}
|
|
</label>
|
|
{% endfor %}
|
|
</fieldset>
|
|
{% elif field.type == "choice" %}
|
|
<label>{{ field.label }}{% if field.required %} (required){% endif %}
|
|
<select name="{{ field.name }}" {% if field.required %}required{% endif %}>
|
|
{% if not field.required %}<option value="">No selection</option>{% endif %}
|
|
{% set selected = values.get(field.name, field.default or "") %}
|
|
{% for option in field.options %}
|
|
<option value="{{ option.value }}" {% if option.value == selected %}selected{% endif %}>{{ option.label }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</label>
|
|
{% else %}
|
|
{% set html_type = "number" if field.type == "integer" else "datetime-local" if field.type == "datetime" else field.type %}
|
|
<label>{{ field.label }}{% if field.required %} (required){% endif %}
|
|
<input
|
|
type="{{ html_type }}"
|
|
name="{{ field.name }}"
|
|
value="{{ values.get(field.name, field.default if field.default is not none else "") }}"
|
|
{% if field.required %}required{% endif %}
|
|
{% if field.minimum is not none %}min="{{ field.minimum }}"{% endif %}
|
|
{% if field.maximum is not none %}max="{{ field.maximum }}"{% endif %}
|
|
{% if field.step is not none %}step="{{ field.step }}"{% endif %}
|
|
{% if field.pattern %}pattern="{{ field.pattern }}"{% endif %}
|
|
>
|
|
</label>
|
|
{% endif %}
|
|
{% if errors.get(field.name) %}<p class="input-error">{{ errors[field.name] }}</p>{% endif %}
|
|
</div>
|
|
{% endfor %}
|
|
<button type="submit">
|
|
<span class="button-label">Run</span>
|
|
{% if task.wait_for_result %}<span class="spinner" aria-hidden="true"></span>{% endif %}
|
|
</button>
|
|
{% if task.wait_for_result %}<p class="task-result" aria-live="polite"></p>{% endif %}
|
|
</form>
|
|
</li>
|
|
{% else %}
|
|
<li>No exposed tasks in this group.</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</section>
|
|
{% endfor %}
|
|
{% endblock %}
|