task management and task runtime flow

This commit is contained in:
meeb
2020-12-07 21:26:46 +11:00
parent f6d00b47eb
commit 647f7162cc
22 changed files with 543 additions and 48 deletions

View File

@@ -3,6 +3,11 @@
{% block headtitle %}Dashboard{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
<h1 class="truncate">Dashboard</h1>
</div>
</div>
<div class="row">
<div class="col s12">
<div class="card">

View File

@@ -3,6 +3,11 @@
{% block headtitle %}Media{% if source %} - {{ source }}{% endif %}{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
<h1 class="truncate">Media</h1>
</div>
</div>
{% include 'infobox.html' with message=message %}
<div class="row no-margin-bottom">
{% for m in media %}
@@ -22,7 +27,7 @@
{% empty %}
<div class="col s12">
<div class="collection">
<span class="collection-item no-items"><i class="fas fa-info-circle"></i> No media has been indexed.</span>
<span class="collection-item no-items"><i class="fas fa-info-circle"></i> No media has been indexed{% if source %} that matches the specified source filter{% endif %}.</span>
</div>
</div>
{% endfor %}

View File

@@ -3,14 +3,22 @@
{% block headtitle %}Source - {{ source.name }}{% endblock %}
{% block content %}
<div class="row">
<div class="row no-margin-bottom">
<div class="col s12">
<h1 class="truncate">Source <strong>{{ source.name }}</strong></h1>
<p class="truncate"><strong><a href="{{ source.url }}" target="_blank"><i class="fas fa-link"></i> {{ source.url }}</a></strong></p>
<p class="truncate">Saving to: <strong>{{ source.directory_path }}</strong></p>
<p><a href="{% url 'sync:media' %}?filter={{ source.pk }}" class="btn">Media<span class="hide-on-small-only"> linked to this source</span> <i class="fas fa-fw fa-film"></i></a></p>
</div>
</div>
<div class="row">
<div class="col s12 l6 margin-bottom">
<a href="{% url 'sync:media' %}?filter={{ source.pk }}" class="btn">View media<span class="hide-on-small-only"> linked to this source</span> <i class="fas fa-fw fa-film"></i></a>
</div>
<div class="col s12 l6 margin-bottom">
<a href="{% url 'sync:tasks-completed' %}?filter={{ source.pk }}" class="btn">View tasks<span class="hide-on-small-only"> linked to this source</span> <i class="far fa-fw fa-clock"></i></a>
</div>
</div>
{% if source.has_failed %}{% include 'errorbox.html' with message='This source has encountered permanent failures listed at the bottom of this page, check its settings' %}{% endif %}
<div class="row">
<div class="col s12">
<table class="striped">
@@ -22,6 +30,10 @@
<td class="hide-on-small-only">Name</td>
<td><span class="hide-on-med-and-up">Name<br></span><strong>{{ source.name }}</strong></td>
</tr>
<tr title="Number of media items downloaded for the source">
<td class="hide-on-small-only">Media items</td>
<td><span class="hide-on-med-and-up">Media items<br></span><strong><a href="{% url 'sync:media' %}?filter={{ source.pk }}">{{ media|length }}</a></strong></td>
</tr>
<tr title="Unique key of the source, such as the channel name or playlist ID">
<td class="hide-on-small-only">Key</td>
<td><span class="hide-on-med-and-up">Key<br></span><strong>{{ source.key }}</strong></td>
@@ -98,4 +110,20 @@
<a href="{% url 'sync:delete-source' pk=source.pk %}" class="btn delete-button">Delete source <i class="fas fa-trash-alt"></i></a>
</div>
</div>
{% if errors %}
<div class="row">
<div class="col s12">
<h2>Source has encountered {{ errors|length }} Error{{ errors|length|pluralize }}</h2>
<div class="collection">
{% for task in errors %}
<span class="collection-item error-text">
<i class="fas fa-exclamation-triangle"></i> <strong>{{ task.verbose_name }}</strong><br>
Error: &quot;{{ task.error_message }}&quot;<br>
<i class="far fa-clock"></i> Occured at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
</span>
{% endfor %}
</div>
</div>
</div>
{% endif %}
{% endblock %}

View File

@@ -3,8 +3,13 @@
{% block headtitle %}Sources{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
<h1 class="truncate">Sources</h1>
</div>
</div>
{% include 'infobox.html' with message=message %}
<div class="row no-margin-bottom">
<div class="row">
<div class="col s12 l6 margin-bottom">
<a href="{% url 'sync:validate-source' source_type='youtube-channel' %}" class="btn">Add a YouTube channel <i class="fab fa-youtube"></i></a>
</div>
@@ -17,9 +22,13 @@
<div class="collection">
{% for source in sources %}
<a href="{% url 'sync:source' pk=source.pk %}" class="collection-item">
{{ source.icon|safe }} <strong>{{ source.name }}</strong> ({{ source.get_source_type_display }})<br>
{{ source.icon|safe }} <strong>{{ source.name }}</strong> ({{ source.get_source_type_display }} &quot;{{ source.key }}&quot;)<br>
{{ source.format_summary }}<br>
{% if source.has_failed %}
<span class="error-text"><i class="fas fa-exclamation-triangle"></i> <strong>Source has permanent failures</strong></span>
{% else %}
<strong>{{ source.media_count }}</strong> media items{% if source.delete_old_media and source.days_to_keep > 0 %}, keep {{ source.days_to_keep }} days of media{% endif %}
{% endif %}
</a>
{% empty %}
<span class="collection-item no-items"><i class="fas fa-info-circle"></i> You haven't added any sources.</span>

View File

@@ -0,0 +1,33 @@
{% extends 'base.html' %}
{% block headtitle %}Tasks - Completed{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
<h1 class="truncate">Completed tasks</h1>
</div>
</div>
{% include 'infobox.html' with message=message %}
<div class="row">
<div class="col s12">
<div class="collection">
{% for task in tasks %}
<span class="collection-item">
{% if task.has_error %}
<i class="fas fa-exclamation-triangle"></i> <strong>{{ task.verbose_name }}</strong><br>
Error: &quot;{{ task.error_message }}&quot;<br>
<i class="far fa-clock"></i> Task started at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
{% else %}
<i class="fas fa-check"></i> <strong>{{ task.verbose_name }}</strong><br>
<i class="far fa-clock"></i> Task started at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
{% endif %}
</span>
{% empty %}
<span class="collection-item no-items"><i class="fas fa-info-circle"></i> There have been no completed tasks.</span>
{% endfor %}
</div>
</div>
</div>
{% include 'pagination.html' with pagination=sources.paginator filter=source.pk %}
{% endblock %}

View File

@@ -5,7 +5,83 @@
{% block content %}
<div class="row">
<div class="col s12">
tasks
<h1>Tasks</h1>
<p>
Tasks are the background work that TubeSync undertakes to index and download
media. This page allows you to see basic overview of what is running and what is
scheduled to perform in the future as well as check up on any errors that might
have occured.
</p>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>{{ running|length }} Running</h2>
<p>
Running tasks are tasks which currently being worked on right now.
</p>
<div class="collection">
{% for task in running %}
<a href="{% url task.url pk=task.instance.pk %}" class="collection-item">
<i class="fas fa-running"></i> <strong>{{ task }}</strong><br>
<i class="far fa-clock"></i> Task started at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
</a>
{% empty %}
<span class="collection-item no-items"><i class="fas fa-info-circle"></i> There are no running tasks.</span>
{% endfor %}
</div>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>{{ errors|length }} Error{{ errors|length|pluralize }}</h2>
<p>
Tasks which generated an error are shown here. Tasks are retried a couple of
times, so if there was an intermittent error such as a download got interrupted
it will be scheduled to run again.
</p>
<div class="collection">
{% for task in errors %}
<a href="{% url task.url pk=task.instance.pk %}" class="collection-item error-text">
<i class="fas fa-exclamation-triangle"></i> <strong>{{ task }}</strong>, attempted {{ task.attempts }} time{{ task.attempts|pluralize }}<br>
Error: &quot;{{ task.error_message }}&quot;<br>
<i class="fas fa-history"></i> Task will be retried at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
</a>
{% empty %}
<span class="collection-item no-items"><i class="fas fa-info-circle"></i> There are no tasks with errors.</span>
{% endfor %}
</div>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>{{ scheduled|length }} Scheduled</h2>
<p>
Tasks which are scheduled to run in the future or are waiting in a queue to be
processed. They can be waiting for an available worker to run immediately, or
run in the future at the specified &quot;run at&quot; time.
</p>
<div class="collection">
{% for task in scheduled %}
<a href="{% url task.url pk=task.instance.pk %}" class="collection-item">
<i class="far fa-stopwatch"></i> <strong>{{ task }}</strong><br>
Scheduled to run {{ task.instance.get_index_schedule_display|lower }}.<br>
<i class="fas fa-redo"></i> Task will run at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
</a>
{% empty %}
<span class="collection-item no-items"><i class="fas fa-info-circle"></i> There are no scheduled tasks.</span>
{% endfor %}
</div>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>Completed</h2>
<p>
A record of recently completed tasks is kept for a few days. You can use the button
below to view recent tasks which have completed successfully.
</p>
<a href="{% url 'sync:tasks-completed' %}" class="btn"><span class="hide-on-med-and-down">View </span>Completed tasks <i class="fas fa-check-double"></i></a>
</div>
</div>
{% endblock %}