diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-08-31 00:03:46 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-08-31 00:03:46 -0700 |
commit | db769b76ab7b7ed54579225fca836defc7afbd11 (patch) | |
tree | dafe40aa8ffc758b6eee0ea56ca3a5b94fa8da1f | |
parent | 5568ab24decd31e185fa1b19d29838ec3b30e570 (diff) |
Expire completed uploads and introduce a text message that says how
many photos have been uploaded successfully. This is to pave the way
for retry code later on.
-rw-r--r-- | modules/gallery/controllers/uploader.php | 8 | ||||
-rw-r--r-- | modules/gallery/css/gallery.css | 4 | ||||
-rw-r--r-- | modules/gallery/views/form_uploadify.html.php | 32 | ||||
-rw-r--r-- | modules/gallery/views/form_uploadify_buttons.html.php | 1 |
4 files changed, 38 insertions, 7 deletions
diff --git a/modules/gallery/controllers/uploader.php b/modules/gallery/controllers/uploader.php index 85d344d6..fb496f60 100644 --- a/modules/gallery/controllers/uploader.php +++ b/modules/gallery/controllers/uploader.php @@ -102,6 +102,14 @@ class Uploader_Controller extends Controller { } } + public function status($success_count, $error_count) { + // The "errors" won't be properly pluralized :-/ + print t2("Uploaded %count photo (%error errors)", + "Uploaded %count photos (%error errors)", + $success_count, + array("error" => $error_count)); + } + public function finish() { access::verify_csrf(); diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index fb72bd48..8012c6cc 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -78,6 +78,10 @@ margin-bottom: 0 } +#g-add-photos-status-message { + float: right; +} + /* Permissions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #g-edit-permissions-form { diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php index 2ed7912f..36f5f284 100644 --- a/modules/gallery/views/form_uploadify.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -3,7 +3,24 @@ <script type="text/javascript" src="<?= url::file("lib/uploadify/jquery.uploadify.min.js") ?>"></script> <script type="text/javascript"> <? $flash_minimum_version = "9.0.24" ?> + var success_count = 0; + var error_count = 0; + var updating = 0; $("#g-add-photos-canvas").ready(function () { + var update_status = function() { + if (updating) { + // poor man's mutex + setTimeout(function() { update_status(); }, 500); + } + updating = 1; + $.get("<?= url::site("uploader/status/_S/_E") ?>" + .replace("_S", success_count).replace("_E", error_count), + function(data) { + $("#g-add-photos-status-message").html(data); + updating = 0; + }); + }; + if (swfobject.hasFlashPlayerVersion("<?= $flash_minimum_version ?>")) { $("#g-uploadify").uploadify({ width: 150, @@ -40,13 +57,12 @@ onComplete: function(event, queueID, fileObj, response, data) { var re = /^error: (.*)$/i; var msg = re.exec(response); - if (msg) { - $("#g-add-photos-status ul").append( - "<li class=\"g-error\">" + fileObj.name + " - " + msg[1] + "</li>"); - } else { - $("#g-add-photos-status ul").append( - "<li class=\"g-success\">" + fileObj.name + " - " + <?= t("Completed")->for_js() ?> + "</li>"); - } + $("#g-add-photos-status ul").append( + "<li id=\"q" + queueID + "\" class=\"g-success\">" + fileObj.name + " - " + + <?= t("Completed")->for_js() ?> + "</li>"); + setTimeout(function() { $("#q" + queueID).slideUp("slow") }, 5000); + success_count++; + update_status(); return true; }, onError: function(event, queueID, fileObj, errorObj) { @@ -73,6 +89,8 @@ $("#g-add-photos-status ul").append( "<li class=\"g-error\">" + fileObj.name + msg + "</li>"); $("#g-uploadify" + queueID).remove(); + error_count++; + update_status(); }, onSelect: function(event) { if ($("#g-upload-cancel-all").hasClass("ui-state-disabled")) { diff --git a/modules/gallery/views/form_uploadify_buttons.html.php b/modules/gallery/views/form_uploadify_buttons.html.php index ce4d989c..e002d82d 100644 --- a/modules/gallery/views/form_uploadify_buttons.html.php +++ b/modules/gallery/views/form_uploadify_buttons.html.php @@ -7,4 +7,5 @@ <button id="g-upload-cancel-all" class="ui-state-default ui-corner-all ui-state-disabled" onclick="$('#g-uploadify').uploadifyClearQueue();return false;" disabled="disabled"> <?= t("Cancel uploads") ?> </button> + <span id="g-add-photos-status-message" /> </div> |