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

View file

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