Porównaj commity

...

10 Commity

Autor SHA1 Wiadomość Data
Hartmut Holzgraefe 8d5380fd2b documentation update 2023-10-03 06:39:05 +00:00
Hartmut Holzgraefe f1c51256a9 write status updates to log output for now, too 2023-10-02 21:09:38 +00:00
Hartmut Holzgraefe e699b89a97 comment updates 2023-10-02 21:09:20 +00:00
Hartmut Holzgraefe 9555555f5f add one more status update message 2023-10-02 21:08:50 +00:00
Hartmut Holzgraefe 2240ab4c37 preserve output format order 2023-10-01 21:52:22 +00:00
Hartmut Holzgraefe fe3c669d3a streamline error buttons 2023-10-01 19:42:13 +00:00
Hartmut Holzgraefe 3ccc9ab38e show download files as soon as each of them is ready 2023-09-30 23:26:13 +00:00
Hartmut Holzgraefe d97f334b4e refactor map request status output 2023-09-29 21:04:39 +00:00
Hartmut Holzgraefe 699c701339 allow of direct use of selected settings in templates 2023-09-29 20:59:09 +00:00
Hartmut Holzgraefe 9389d5082f remove queue waiting bar completely, it never really worked out well anyway 2023-09-29 05:58:13 +00:00
10 zmienionych plików z 105 dodań i 101 usunięć

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 49 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 39 KiB

Wyświetl plik

@ -111,8 +111,12 @@ from them (but not the actual uploaded files themselves) will be visible to
everyone. So do not upload any sensitive data you don't want to to be seen in
public, or that you don't have the permission to share in public.
Once files have been selected and verified, the form switches back to the
area selection tabl, where it will show a preview of the imported file
Regarding the uploaded files themselves you can select to delete them right after
use, or to keep them on the server for (currently) a year, allowing to re-run the
rendering job at a later date.
Once files have been selected and verified you can switch back to the
area selection tab, where it will show a preview of the imported file
contents, and the optimal map area to display all contained data.
image::gpx-selected.png[GPX Preview,width=80%,pdfwidth=80%,align=center]

Wyświetl plik

@ -369,6 +369,7 @@ class JobRenderer(threading.Thread):
self._email_submitter("render_email_failure.txt")
def _gen_thumbnail(self, prefix, paper_width_mm, paper_height_mm):
# TODO make this a renderer method
LOG.info('Creating map thumbnail...')
if self.job.layout == "multi_page":
@ -420,6 +421,7 @@ class JobRenderer(threading.Thread):
LOG.warning("PNG color reduction failed: %s" % e)
def _status_update(self, msg):
LOG.warning("Status update: %s" % msg)
self.job.renderstep = msg
self.job.save()
@ -504,14 +506,17 @@ class JobRenderer(threading.Thread):
# Compute the intersection of the accepted output formats
# with the desired output formats.
output_formats = \
list(set(compatible_output_formats) & set(RENDERING_RESULT_FORMATS))
output_formats = []
for format in RENDERING_RESULT_FORMATS:
if format in compatible_output_formats:
output_formats.append(format)
output_count = renderer.render(config, self.job.layout,
output_formats, result_file_prefix)
# Create thumbnail
try:
config.status_update("Generating preview thumbnail")
self._gen_thumbnail(result_file_prefix, config.paper_width_mm,
config.paper_height_mm)
except:

Wyświetl plik

@ -255,7 +255,7 @@ class MapRenderingJob(models.Model):
Their actual presence is checked if the job is considered done and not
yet obsolete."""
if self.is_done():
if self.is_rendering() or self.is_done():
files = self.output_files()
return len(files['maps']) + len(files['indeces']) + len(files['thumbnail'])

Wyświetl plik

@ -11,13 +11,13 @@
{% with date=map.submission_time|date:"DATETIME_FORMAT" %}
<tr><td><strong>{% trans "Request submitted" %}</strong></td><td title="{{ date }}">{% blocktrans with map.submission_time|timesince as since %}{{since}} ago{% endblocktrans %}</td></tr>
{% endwith %}
{% if map.is_rendering %}
{% with date=map.startofrendering_time|date:"DATETIME_FORMAT" duration=map.submission_time|timesince:map.startofrendering_time %}
<tr><td><strong>{% trans "Rendering started" %}</strong></td><td title="{{ date }}">{% blocktrans with map.submission_time|timesince as since %}{{since}} ago{% endblocktrans %}, {% blocktrans %}after {{ duration}} in the queue{% endblocktrans %}</td></tr>
{% endwith %}
{% endif %}
{% if map.is_done or map.is_obsolete %}
{% with date=map.startofrendering_time|date:"DATETIME_FORMAT" duration=map.submission_time|timesince:map.startofrendering_time %}
<tr><td><strong>{% trans "Rendering started" %}</strong></td><td title="{{ date }}">{% blocktrans with map.startofrendering_time|timesince as since %}{{since}} ago{% endblocktrans %}, {% blocktrans %}after {{ duration}} in the queue{% endblocktrans %}</td></tr>
@ -26,39 +26,67 @@
<tr><td><strong>{% trans "Rendering completed" %}</strong></td><td title="{{ date }}">{% blocktrans with map.endofrendering_time|timesince as since %}{{since}} ago{% endblocktrans %}, {% blocktrans %}after {{ duration }} {% endblocktrans %}</td></tr>
{% endwith %}
{% endif %}
{% if map.is_cancelled %}
{% with map.endofrendering_time|date:"DATETIME_FORMAT" as date %}
<tr><td><strong>{% trans "Rendering cancelled" %}</strong></td><td>{{ date }}</td></tr>
{% endwith %}
{% endif %}
</table>
<div>
{{ map|job_status_to_str }}
{% if map.status == 0 %}
<div class='alert alert-info' role='alert'>
<span class='spinner-border spinner-border-sm text-primary'></span>&nbsp;
{% blocktrans with counter=map.current_position_in_queue %}
Waiting for rendering to begin, {{ counter }} jobs still ahead of us
{% endblocktrans %}
</div>
<div style="height: 2em"></div>
{% if map.is_waiting %}
<div class="progress">
<div id="queue-progress" class="progress-bar progress-bar-striped progress-bar-animated"" role="progressbar"
style="width: {{ progress }}%" aria-valuenow="{{ progress }}" aria-valuemin="0" aria-valuemax="100">
<span class="text-dark font-weight-bold">{{ map.current_position_in_queue }} {% trans "jobs ahead of us" %}</span>
</div>
{% elif map.status == 1 %}
<div class='alert alert-info' role='alert'>
<span class='spinner-border spinner-border-sm text-primary'></span>&nbsp;
{{ map.renderstep }}
</div>
{% endif %}
{% elif map.status == 2 %}
{% if map.resultmsg == "ok" %}
<div class='alert alert-info' role='alert'>
{% trans "Rendering was successful." %}
</div>
{% else %}
<div class='alert alert-danger' role='alert'>
<h4><i class='fas fa-triangle-exclamation'></i> <b>{{ map.resultmsg }}</b></h4>
{% if not map.resultmsg|startswith:'Not enough memory' %}
{% if map|error_log_tail %}
{% blocktrans with url=map.get_errorlog %}
Check the <a target='_blank' href='{{ url }}'><i class='fas fa-file-lines'></i> error log</a> for more details<br>
{% endblocktrans %}
{% if settings.CONTACT_EMAIL %}
{% blocktrans with email=map|email_url %}
or contact {{ email }} for more information.
{% endblocktrans %}
{% endif %}
<hr><tt>{{ map|error_log_tail }}</tt>
{% endif %}
{% endif %}
</div>
{% endif %}
{% elif map.status == 3 %}
<div class='alert alert-warning' role='alert'>
{% if map.resultmsg == "ok" %}
{% trans "Rendering is obsolete: the rendering was successful, but the files are no longer available." %}
{% else %}
{% trans "Obsolete failed rendering: the rendering failed, and the incomplete files have been removed." %}
{% endif %}
</div>
{% elif map.status == 4 %}
<div class='alert alert-warning' role='alert'>
{% trans "The rendering was cancelled by the user." %}
</div>
{% else %}
<div class='alert alert-danger' role='alert'>{% trans "Unknown status" %} '{{ map.status }}'</div>
{% endif %}
{% if map.is_waiting %}
<i class="fas fa-hourglass"></i> {% trans "Pending..." %}
{% endif %}
{% if map.is_rendering %}
<i class="fas fa-pen-to-square"></i> {% trans "Rendering..." %} {{ status }}
{% endif %}
{% if not map.needs_waiting %}
{% if not map.needs_waiting %}
<form method="post" action="{% url "recreate" %}">
<input type="hidden" name="id" value="{{ map.id }}" />
<button class="btn btn-primary tooltipped" align="right"
@ -69,7 +97,6 @@
</form>
{% endif %}
{% if map.is_done %}
{% if map.has_output_files %}
<div style="height: 2em"></div>
<div class="card card-default">
@ -118,10 +145,9 @@
</a>
{% endif %}
{% endif %}
{% if map.needs_waiting %}
<span class="refresh-time pull-right">{% blocktrans %}Updating in <span>{{ refresh }}</span>s...{% endblocktrans %}</span>
<input id="refreshtime" type="hidden" value="{{ refresh }}"</input>
{% if map.is_waiting %}
{% if nonce == map.nonce %}
<div style="height: 2em"></div>

Wyświetl plik

@ -37,11 +37,15 @@
{% block extrajs %}
{% if map.needs_waiting %}
setInterval(function() {
var t = $('.refresh-time > span').text() - 1;
$('.refresh-time > span').text(t);
if (t == 0) {
$('.refresh-time').text('{% trans "Updating now..." %}');
$('#map-rendering-status').load("../../apis/rendering-status/{{ map.id }}")
var f = $('#refreshtime');
if (f.length) {
t = f.val();
if (t == 0) {
$('#map-rendering-status').load("../../apis/rendering-status/{{ map.id }}");
f.val(-42);
} else if (t > 0) {
f.val(t - 1);
}
}
}, 1000);
{% endif %}

Wyświetl plik

@ -190,21 +190,18 @@
</div>
{% endif %}
{% if not map.is_done_ok and not map.needs_waiting %}
{% if map.get_errorlog %}
<a class="btn btn-large tooltipped"
{% if map.get_errorlog %}
<a class="btn btn-large btn-danger"
href="{{map.get_errorlog}}"
target="_blank"
data-placement="right"
data-original-title="{% trans "Something went wrong while processing this job." %}">
title="{% trans "Something went wrong, view the error log." %}">
<i class="fas fa-ban"></i> {% trans "Error log" %}
</a>
{% else %}
<a class="btn disabled tooltipped"
data-placement="top"
data-original-title="{{ map|job_status_to_str }}">
<i class="fas fa-ban"></i> {% trans "Download" %}
{% else %}
<a class="btn btn-warning disabled">
<i class="fas fa-ban"></i> {% trans "No Downloads" %}
</a>
{% endif %}
{% endif %}
{% endif %}
</div>
<div class="col-6">

Wyświetl plik

@ -44,6 +44,9 @@ from . import paper_tags, rss_feed_tags, job_tags
def add_blank_after_comma(value):
return value.replace(",",", ")
@register.filter('startswith')
def startswith(text, starts):
return text.startswith(starts)
register.filter('abs', lambda x: abs(x))
register.filter('getitem', lambda d,i: d.get(i,''))

Wyświetl plik

@ -9,12 +9,6 @@ from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from django.utils.html import escape
_alert_ok = "<div class='alert alert-success' role='alert'>"
_alert_info = "<div class='alert alert-info' role='alert'>"
_alert_warn = "<div class='alert alert-warning' role='alert'>"
_alert_err = "<div class='alert alert-danger' role='alert'>"
_alert_end = "</div>"
def _lastline(filename):
try:
with open(filename, "rb") as file:
@ -26,50 +20,16 @@ def _lastline(filename):
return ""
@register.filter()
def job_status_to_str(value):
if value.status == 0:
return mark_safe(_alert_info + str(_("Waiting for rendering to begin...")) + _alert_end)
elif value.status == 1:
return mark_safe(_alert_info + str(_("The rendering is in progress...")) + _alert_end)
elif value.status == 2:
if value.resultmsg == 'ok':
return mark_safe(_alert_ok + str(_("Rendering was successful.")) + _alert_end)
else:
# TODO properly templatize this
result = _alert_err
result+= "<h4><i class='fas fa-triangle-exclamation'></i> <b>%s!</b></h4>" % value.resultmsg # TODO localize the result messages
def error_log_tail(value):
error_log_tail = escape(_lastline(value.get_errorlog_file())).replace(':',':<br/>')
return mark_safe(error_log_tail)
@register.filter()
def email_url(value):
return mark_safe("<a href='mailto:%(email)s?subject=[MapOSMatic] Error on request %(id)d'><i class='fas fa-envelope'></i> %(email)s</a>" % {
"email": www.settings.CONTACT_EMAIL,
"id": value.id
})
if not value.resultmsg.startswith("Not enough memory"):
error_log_tail = escape(_lastline(value.get_errorlog_file())).replace(':',':<br/>')
if error_log_tail:
result+= _("Check the %(error_log)s for more details<br/>") % {
'error_log': "<a target='_blank' href='%s'><i class='fas fa-file-lines'></i> %s</a>" % (value.get_errorlog(), _("error log")),
}
if www.settings.CONTACT_EMAIL:
if error_log_tail:
result+= "or "
result+= _("contact %(email)s for more information.") % {
'email': "<a href='mailto:%(email)s?subject=[MapOSMatic] Error on request %(id)d'><i class='fas fa-envelope'></i> %(email)s</a>" % {
"email": www.settings.CONTACT_EMAIL,
"id": value.id
}
}
if error_log_tail:
result+= "<hr/><tt>%s</tt>" % error_log_tail
result += _alert_end
return mark_safe(result)
elif value.status == 3:
if value.resultmsg == 'ok':
return mark_safe(_alert_info + str(_("Rendering is obsolete: the rendering was successful, but the files are no longer available.")) + _alert_end)
else:
return mark_safe(_alert_warn + str(_("Obsolete failed rendering: the rendering failed, and the incomplete files have been removed.")) + _alert_end)
elif value == 4:
return mark_safe(_alert_warn + str(_("The rendering was cancelled by the user.")) + _alert_end)
return ''

Wyświetl plik

@ -91,6 +91,7 @@ TEMPLATES = [
'debug': True,
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django_settings_export.settings_export',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
@ -104,6 +105,10 @@ TEMPLATES = [
},
]
SETTINGS_EXPORT = [
'CONTACT_EMAIL',
]
MIDDLEWARE = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
@ -326,8 +331,8 @@ MAP_LANGUAGES_LIST= list(MAP_LANGUAGES.items())
# Job page refresh frequency, in seconds, for when the job is waiting in queue
# and when the job is currently being rendered.
REFRESH_JOB_WAITING = 15
REFRESH_JOB_RENDERING = 10
REFRESH_JOB_WAITING = 5
REFRESH_JOB_RENDERING = 2
QUEUE_NAMES = ['default', 'api', 'multipage']