error checking

This commit is contained in:
2018-01-17 01:41:58 +01:00
parent c9046c7a7e
commit 31a25a50b5
4 changed files with 19 additions and 3 deletions

4
.gitignore vendored
View File

@@ -1,5 +1,3 @@
.vscode .vscode
main main
pdwebconfig.toml pdwebconfig.toml
res/static/res/script/pixellib.js
res/static/res/script/home.js

View File

@@ -29,6 +29,11 @@ var UploadProgressBar = /** @class */ (function () {
+ this.file.name + '<br/>' + this.file.name + '<br/>'
+ '<span style="color: var(--highlight_color);">' + window.location.hostname + '/u/' + id + '</span>'); + '<span style="color: var(--highlight_color);">' + window.location.hostname + '/u/' + id + '</span>');
}; };
UploadProgressBar.prototype.onFailure = function (response, error) {
this.uploadDiv.setAttribute('style', 'background: #821C40');
this.uploadDivJQ.html(this.file.name + '<br/>'
+ 'Upload failed after three tries!');
};
return UploadProgressBar; return UploadProgressBar;
}()); }());
function handleUploads(files) { function handleUploads(files) {
@@ -182,6 +187,8 @@ var UploadWorker = /** @class */ (function () {
if (that.tries === 3) { if (that.tries === 3) {
alert("Upload failed: " + status); alert("Upload failed: " + status);
that.uploading = false; that.uploading = false;
file.onFailure(status, error);
that.start(); // Try to continue
return; // Upload failed return; // Upload failed
} }
// Try again // Try again

View File

@@ -47,6 +47,13 @@ class UploadProgressBar implements FileUpload {
+ '<span style="color: var(--highlight_color);">'+window.location.hostname+'/u/'+id+'</span>' + '<span style="color: var(--highlight_color);">'+window.location.hostname+'/u/'+id+'</span>'
) )
} }
public onFailure(response: JQuery.Ajax.ErrorTextStatus, error: string) {
this.uploadDiv.setAttribute('style', 'background: #821C40')
this.uploadDivJQ.html(
this.file.name+'<br/>'
+ 'Upload failed after three tries!'
)
}
} }
function handleUploads(files: FileList) { function handleUploads(files: FileList) {

View File

@@ -2,6 +2,7 @@ interface FileUpload {
file: File file: File
onProgress(progress: number) onProgress(progress: number)
onFinished(id: string) onFinished(id: string)
onFailure(response: JQuery.Ajax.ErrorTextStatus, error: string)
} }
class UploadManager { class UploadManager {
@@ -100,6 +101,9 @@ class UploadWorker {
if (that.tries === 3) { if (that.tries === 3) {
alert("Upload failed: " + status); alert("Upload failed: " + status);
that.uploading = false that.uploading = false
file.onFailure(status, error)
that.start() // Try to continue
return; // Upload failed return; // Upload failed
} }