From 31a25a50b56c66f69b860fbfe92e9877fbfdb4a7 Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Wed, 17 Jan 2018 01:41:58 +0100 Subject: [PATCH] error checking --- .gitignore | 4 +--- res/static/res/script/compiled/home.js | 7 +++++++ res/static/res/typescript/home/home.ts | 7 +++++++ res/static/res/typescript/lib/uploader.ts | 4 ++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f03aff9..f64d2da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ .vscode main -pdwebconfig.toml -res/static/res/script/pixellib.js -res/static/res/script/home.js \ No newline at end of file +pdwebconfig.toml \ No newline at end of file diff --git a/res/static/res/script/compiled/home.js b/res/static/res/script/compiled/home.js index 0d52639..446b15e 100644 --- a/res/static/res/script/compiled/home.js +++ b/res/static/res/script/compiled/home.js @@ -29,6 +29,11 @@ var UploadProgressBar = /** @class */ (function () { + this.file.name + '
' + '' + window.location.hostname + '/u/' + id + ''); }; + UploadProgressBar.prototype.onFailure = function (response, error) { + this.uploadDiv.setAttribute('style', 'background: #821C40'); + this.uploadDivJQ.html(this.file.name + '
' + + 'Upload failed after three tries!'); + }; return UploadProgressBar; }()); function handleUploads(files) { @@ -182,6 +187,8 @@ var UploadWorker = /** @class */ (function () { if (that.tries === 3) { alert("Upload failed: " + status); that.uploading = false; + file.onFailure(status, error); + that.start(); // Try to continue return; // Upload failed } // Try again diff --git a/res/static/res/typescript/home/home.ts b/res/static/res/typescript/home/home.ts index 8acdd44..92bcf4e 100644 --- a/res/static/res/typescript/home/home.ts +++ b/res/static/res/typescript/home/home.ts @@ -47,6 +47,13 @@ class UploadProgressBar implements FileUpload { + ''+window.location.hostname+'/u/'+id+'' ) } + public onFailure(response: JQuery.Ajax.ErrorTextStatus, error: string) { + this.uploadDiv.setAttribute('style', 'background: #821C40') + this.uploadDivJQ.html( + this.file.name+'
' + + 'Upload failed after three tries!' + ) + } } function handleUploads(files: FileList) { diff --git a/res/static/res/typescript/lib/uploader.ts b/res/static/res/typescript/lib/uploader.ts index a4811b8..94d36cd 100644 --- a/res/static/res/typescript/lib/uploader.ts +++ b/res/static/res/typescript/lib/uploader.ts @@ -2,6 +2,7 @@ interface FileUpload { file: File onProgress(progress: number) onFinished(id: string) + onFailure(response: JQuery.Ajax.ErrorTextStatus, error: string) } class UploadManager { @@ -100,6 +101,9 @@ class UploadWorker { if (that.tries === 3) { alert("Upload failed: " + status); that.uploading = false + file.onFailure(status, error) + + that.start() // Try to continue return; // Upload failed }