diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-11 18:47:10 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-11 18:47:10 -0800 |
commit | 421a975c0e042a56c12a9894afa38f5785d1fe6d (patch) | |
tree | f0d27e17d7284956ed4fb903ccb5d6cb6784c784 /modules/gallery | |
parent | 9546e19e34d08e0d55f066f04149794e566c3539 (diff) |
Improve error handling.
Diffstat (limited to 'modules/gallery')
-rw-r--r-- | modules/gallery/controllers/simple_uploader.php | 2 | ||||
-rw-r--r-- | modules/gallery/css/gallery.css | 42 | ||||
-rw-r--r-- | modules/gallery/views/simple_uploader.html.php | 44 |
3 files changed, 38 insertions, 50 deletions
diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index bc508319..d43d2f9d 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -79,7 +79,7 @@ class Simple_Uploader_Controller extends Controller { print "FILEID: $item->id"; } else { header("HTTP/1.1 400 Bad Request"); - print "ERROR: Invalid Upload"; + print "ERROR: " . t("Invalid Upload"); } } diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index 066ab68a..113f0e09 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -54,48 +54,6 @@ margin: 0; } -/* Simple uploader ~~~~~~~~~~~~~~~~~~~~~~~ */ - -#g-add-photos-canvas { - border: 1px solid #ccc; - height: 200px; - margin: .5em 0; - overflow: auto; - width: 469px; -} - -#g-add-photos-status { - border: 1px solid #ccc; - height: 125px; - margin: .5em 0; - overflow: auto; - width: 469px; -} - -#g-add-photos button { - float: right; - margin-bottom: .5em; - margin-left: .5em; -} - -#g-add-photos-status td { - text-align: left; - padding-left: 2em; -} - -#g-add-photos-queue .error { - background-color: #fcc; - border: 1px solid #ebb; -} - -#g-add-photos p { - margin: 0 -} - -#g-add-photos .g-breadcrumbs li { - padding-top: .5em; -} - /** ******************************************************************* * 2) Admin **********************************************************************/ diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index a84a3b00..8133f6c2 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -30,11 +30,43 @@ return true; }, onComplete: function(event, queueID, fileObj, response, data) { - $("#g-add-photos-status tbody").append( - "<tr class=\"g-success\"><td>" + fileObj.name + "</td><td>" + - Math.ceil(fileObj.size / 1000) + " KB" + "</td><td>" + Math.floor(data.speed) + " KB/s </td></tr>"); + // @todo handle a response of "Error: xxxx" as an error + 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 + "</li>"); + } return true; }, + + onError: function(event, queueID, fileObj, errorObj) { + var msg = " - "; + if (errorObj.type == "HTTP") { + if (errorObj.info == "500") { + msg += "Error occurred processing the file"; + // Server error - check server logs + } else if (errorObj.info == "404") { + msg += "The upload script was not found."; + // Server script not found + } else { + // Server Error: status: errorObj.info + msg += "Error occurred communication with the server, status: " + errorObj.info; + } + } else if (errorObj.type == "File Size") { + var sizelimit = $("#g-uploadify").uploadifySettings(sizeLimit); + msg += fileObj.name+' '+errorObj.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB'; + } else { + msg += "Error occurred communication with the server, error " + errorObj.type + ": " + errorObj.info; + } + $("#g-add-photos-status ul").append( + "<li class=\"g-error\">" + fileObj.name + msg + "</li>"); + $("#g-uploadify" + queueID).remove(); + //return false; + }, onSelect: function(event) { if ($("#g-upload-cancel-all").hasClass("ui-state-disabled")) { $("#g-upload-cancel-all") @@ -79,10 +111,8 @@ <div id="g-uploadify"></div> </div> <div id="g-add-photos-status" style="text-align: center;"> - <table> - <tbody> - </tbody> - </table> + <ul> + </ul> </div> <!-- Proxy the done request back to our form, since its been ajaxified --> |