Fix / improve progress display somewhat

This commit is contained in:
Lance Edgar 2016-10-16 03:30:12 -05:00
parent d0d8da9e47
commit 7e3d47aa5c
2 changed files with 14 additions and 11 deletions

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2014 Lance Edgar # Copyright © 2010-2016 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -20,12 +20,11 @@
# along with Rattail. If not, see <http://www.gnu.org/licenses/>. # along with Rattail. If not, see <http://www.gnu.org/licenses/>.
# #
################################################################################ ################################################################################
""" """
Progress Indicator Progress Indicator
""" """
from __future__ import unicode_literals from __future__ import unicode_literals, absolute_import
from beaker.session import Session from beaker.session import Session
@ -56,6 +55,7 @@ class SessionProgress(object):
self.clear() self.clear()
self.session['message'] = message self.session['message'] = message
self.session['maximum'] = maximum self.session['maximum'] = maximum
self.session['maximum_display'] = '{:,d}'.format(maximum)
self.session['value'] = 0 self.session['value'] = 0
self.session.save() self.session.save()
return self return self

View file

@ -1,13 +1,14 @@
## -*- coding: utf-8 -*- ## -*- coding: utf-8 -*-
<%namespace file="tailbone:templates/base.mako" import="core_javascript" />
<%namespace file="/base.mako" import="jquery_theme" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html style="direction: ltr;" xmlns="http://www.w3.org/1999/xhtml" lang="en-us"> <html style="direction: ltr;" xmlns="http://www.w3.org/1999/xhtml" lang="en-us">
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Working...</title> <title>Working...</title>
${h.javascript_link('https://code.jquery.com/jquery-1.11.3.min.js')} ${core_javascript()}
${h.javascript_link('https://code.jquery.com/ui/1.11.4/jquery-ui.min.js')} ${h.stylesheet_link(request.static_url('tailbone:static/css/normalize.css'))}
${h.javascript_link(request.static_url('tailbone:static/js/lib/jquery.ui.menubar.js'))} ${jquery_theme()}
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.js'))}
${h.stylesheet_link(request.static_url('tailbone:static/css/base.css'))} ${h.stylesheet_link(request.static_url('tailbone:static/css/base.css'))}
${h.stylesheet_link(request.static_url('tailbone:static/css/layout.css'))} ${h.stylesheet_link(request.static_url('tailbone:static/css/layout.css'))}
<style type="text/css"> <style type="text/css">
@ -52,8 +53,8 @@
width: 50px; width: 50px;
} }
#cancel { #cancel .ui-button-text {
min-width: 200px; white-space: nowrap;
} }
</style> </style>
@ -69,7 +70,7 @@
location.href = '${cancel_url}'; location.href = '${cancel_url}';
} else if (data.complete || data.maximum) { } else if (data.complete || data.maximum) {
$('#message').html(data.message); $('#message').html(data.message);
$('#total').html('('+data.maximum+' total)'); $('#total').html('('+data.maximum_display+' total)');
$('#cancel button').show(); $('#cancel button').show();
if (data.complete) { if (data.complete) {
clearInterval(updater); clearInterval(updater);
@ -96,10 +97,11 @@
updater = setInterval(function() {update_progress()}, 1000); updater = setInterval(function() {update_progress()}, 1000);
$(function() { $(function() {
$('#cancel button').click(function() { $('#cancel button').click(function() {
if (confirm("Do you really wish to cancel this operation?")) { if (confirm("Do you really wish to cancel this operation?")) {
clearInterval(updater); clearInterval(updater);
disable_button(this, "Cancelling"); $(this).button('disable').button('option', 'label', "Canceling, please wait...");
$.ajax({ $.ajax({
url: '${url('progress.cancel', key=key)}', url: '${url('progress.cancel', key=key)}',
data: { data: {
@ -111,6 +113,7 @@
}); });
} }
}); });
}); });
</script> </script>