Commit e9f1c214 authored by Tobias Reich's avatar Tobias Reich
Browse files

Improved error handling

parent b19c4727
...@@ -118,4 +118,15 @@ ...@@ -118,4 +118,15 @@
.upload_message .rows .row a.status.success { .upload_message .rows .row a.status.success {
color: rgb(42, 213, 0); color: rgb(42, 213, 0);
} }
\ No newline at end of file
.upload_message .rows .row p.notice {
display: none;
float: left;
padding: 2px 10px 5px;
width: calc(100% - 20px);
color: rgba(255,255,255,.5);
font-size: 12px;
overflow: hidden;
line-height: 16px;
}
\ No newline at end of file
...@@ -220,21 +220,14 @@ build = { ...@@ -220,21 +220,14 @@ build = {
if (files[i].name.length>40) files[i].name = files[i].name.substr(0, 17) + "..." + files[i].name.substr(files[i].name.length-20, 20); if (files[i].name.length>40) files[i].name = files[i].name.substr(0, 17) + "..." + files[i].name.substr(files[i].name.length-20, 20);
if (files[i].supported===true) { modal += "<div class='row'>";
modal += "<a class='name'>" + lychee.escapeHTML(files[i].name) + "</a>";
modal += "<div class='row'>" if (files[i].supported===true) modal += "<a class='status'></a>";
modal += "<a class='name'>" + lychee.escapeHTML(files[i].name) + "</a>" else modal += "<a class='status error'>Not supported</a>";
modal += "<a class='status'></a>"
modal += "</div>";
} else { modal += "<p class='notice'></p>";
modal += "</div>";
modal += "<div class='row'>"
modal += "<a class='name'>" + lychee.escapeHTML(files[i].name) + "</a>"
modal += "<a class='status error'>Not supported</a>"
modal += "</div>";
}
} }
......
...@@ -69,6 +69,7 @@ upload = { ...@@ -69,6 +69,7 @@ upload = {
$("#upload_files").val(""); $("#upload_files").val("");
upload.close(); upload.close();
upload.notify("Upload complete");
if (album.getID()===false) lychee.goto("0"); if (album.getID()===false) lychee.goto("0");
else album.load(albumID); else album.load(albumID);
...@@ -112,34 +113,43 @@ upload = { ...@@ -112,34 +113,43 @@ upload = {
xhr.onload = function() { xhr.onload = function() {
// On success var wait = false;
if (xhr.status===200) {
var wait; file.ready = true;
// Set status to finished // Set status
if (xhr.status===200&&xhr.responseText==="1") {
// Success
$(".upload_message .rows .row:nth-child(" + (file.num+1) + ") .status") $(".upload_message .rows .row:nth-child(" + (file.num+1) + ") .status")
.html("Finished") .html("Finished")
.addClass("success"); .addClass("success");
file.ready = true; } else {
wait = false;
// Check if there are file which are not finished // Error
for (var i = 0; i < files.length; i++) { $(".upload_message .rows .row:nth-child(" + (file.num+1) + ") .status")
.html("Error")
.addClass("error");
$(".upload_message .rows .row:nth-child(" + (file.num+1) + ") p.notice")
.html("Server returned the status code " + xhr.status)
.show();
if (files[i].ready===false) { }
wait = true;
break;
}
} // Check if there are file which are not finished
for (var i = 0; i < files.length; i++) {
// Finish upload when all files are finished if (files[i].ready===false) {
if (wait===false) finish(); wait = true;
break;
}
} }
// Finish upload when all files are finished
if (wait===false) finish();
}; };
xhr.upload.onprogress = function(e) { xhr.upload.onprogress = function(e) {
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment