Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve error handling.

  • Loading branch information...
commit 421a975c0e042a56c12a9894afa38f5785d1fe6d 1 parent 9546e19
@talmdal talmdal authored
View
46 lib/gallery.common.css
@@ -593,6 +593,52 @@ div#g-action-status {
margin-left: 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 li {
+ text-align: left;
+ padding-left: 2em;
+}
+
+#g-add-photos-status li.g-success {
+ background: #d9efc2 url('images/ico-success.png') no-repeat .4em 50%;
+}
+
+#g-add-photos-status li.g-error {
+ background: #f6cbca url('images/ico-error.png') no-repeat .4em 50%;
+/* color: #f00;*/
+}
+
+#g-add-photos p {
+ margin: 0
+}
+
+#g-add-photos .g-breadcrumbs li {
+ padding-top: .5em;
+}
+
/** *******************************************************************
* 7) Right to left language styles
**********************************************************************/
View
2  modules/gallery/controllers/simple_uploader.php
@@ -79,7 +79,7 @@ public function add_photo($id) {
print "FILEID: $item->id";
} else {
header("HTTP/1.1 400 Bad Request");
- print "ERROR: Invalid Upload";
+ print "ERROR: " . t("Invalid Upload");
}
}
View
42 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
**********************************************************************/
View
44 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 -->
Please sign in to comment.
Something went wrong with that request. Please try again.