diff options
author | Johannes Zellner <johannes@cloudron.io> | 2018-10-08 16:03:12 +0200 |
---|---|---|
committer | Johannes Zellner <johannes@cloudron.io> | 2018-10-08 16:03:12 +0200 |
commit | 3760489ffc7596a13909907c60d1410d8161b89e (patch) | |
tree | df54e9b1c1a128239791f66023dbfd4db8577d5a /frontend | |
parent | 5c17272a887a2b5ff4810c64c68a2bbc49825291 (diff) | |
download | Surfer-3760489ffc7596a13909907c60d1410d8161b89e.tar.gz Surfer-3760489ffc7596a13909907c60d1410d8161b89e.tar.zst Surfer-3760489ffc7596a13909907c60d1410d8161b89e.zip |
Superagent is a bit bogus
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/js/app.js | 7 |
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(); |