aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--frontend/js/app.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/frontend/js/app.js b/frontend/js/app.js
index 2679187..c1a63a9 100644
--- a/frontend/js/app.js
+++ b/frontend/js/app.js
@@ -146,11 +146,16 @@ function uploadFiles(files) {
146 var formData = new FormData(); 146 var formData = new FormData();
147 formData.append('file', file); 147 formData.append('file', file);
148 148
149 var finishedUploadSize = app.uploadStatus.done;
150
149 superagent.post('/api/files' + path) 151 superagent.post('/api/files' + path)
150 .query({ access_token: localStorage.accessToken }) 152 .query({ access_token: localStorage.accessToken })
151 .send(formData) 153 .send(formData)
152 .on('progress', function (event) { 154 .on('progress', function (event) {
153 app.uploadStatus.done += event.loaded; 155 // only handle upload events
156 if (!(event.target instanceof XMLHttpRequestUpload)) return;
157
158 app.uploadStatus.done = finishedUploadSize + event.loaded;
154 app.uploadStatus.percentDone = Math.round(app.uploadStatus.done / app.uploadStatus.size * 100); 159 app.uploadStatus.percentDone = Math.round(app.uploadStatus.done / app.uploadStatus.size * 100);
155 }).end(function (error, result) { 160 }).end(function (error, result) {
156 if (result && result.statusCode === 401) return logout(); 161 if (result && result.statusCode === 401) return logout();