From 0356534ffa7c0085f08140f5b275f68a65aba702 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk <puiterwijk@redhat.com> Date: May 23 2017 10:38:36 +0000 Subject: Make the first wait happen faster and add appologies after 5 waits Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com> --- diff --git a/pagure/templates/waiting.html b/pagure/templates/waiting.html index cb8c221..b1b7f58 100644 --- a/pagure/templates/waiting.html +++ b/pagure/templates/waiting.html @@ -2,13 +2,7 @@ {% block title %}Waiting{% endblock %} -{% block header %} - <meta http-equiv="refresh" content="5"> -{% endblock %} - {% block content %} - - <div class="container"> <div class="row"> <div class="col-md-8 col-md-offset-2"> @@ -22,11 +16,25 @@ This page should be refreshed automatically, but if not click <a href="{{ url_for('wait_task', taskid=taskid) }}">Here</a> </p> + {% if count >= 5 %} + <p> + This is taking longer than usual... Sorry for that + </p> + {% endif %} </div> </div> </div> </div> </div> +{% endblock %} - +{% block jscripts %} + {{ super() }} + <script type="text/javascript"> + $(document).ready(function() { + window.setTimeout(function() { + window.location = '{{ wait_next }}' + }, {{ wait_delay }}); + }); + </script> {% endblock %} diff --git a/pagure/ui/app.py b/pagure/ui/app.py index 54eefad..a348982 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -504,9 +504,17 @@ def wait_task(taskid): return flask.redirect( flask.url_for(endpoint, **result)) else: + count = int(flask.request.args.get('count', 0)) + # First refresh in 10ms, after that, wait a second + delay = 10 if count == 0 else 1000 return flask.render_template( 'waiting.html', - taskid=taskid) + taskid=taskid, + wait_delay=str(delay), + count=count, + wait_next=flask.url_for('wait_task', + taskid=taskid, + count=str(count + 1))) @APP.route('/settings/', methods=('GET', 'POST'))