summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-11-05 09:24:25 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-11-05 10:11:50 +0100
commita793b1027c6fdf0cade31bf84cf64d378f2727b4 (patch)
tree3e759f4a0c5100ac3f4dd5ec649d759a6d8e9d3d
parentf85215e41c2c17c4e45603591e0988d730858449 (diff)
downloadnextcloud-server-a793b1027c6fdf0cade31bf84cf64d378f2727b4.tar.gz
nextcloud-server-a793b1027c6fdf0cade31bf84cf64d378f2727b4.zip
Ask before cancelling an ongoing upload
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
-rw-r--r--apps/files/js/file-upload.js29
1 files changed, 24 insertions, 5 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 9c1e2df53a0..8d18761acc8 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -409,6 +409,13 @@ OC.Uploader.prototype = _.extend({
_pendingUploadDoneCount: 0,
/**
+ * Is it currently uploading?
+ *
+ * @type boolean
+ */
+ _uploading: false,
+
+ /**
* List of directories known to exist.
*
* Key is the fullpath and value is boolean, true meaning that the directory
@@ -544,6 +551,12 @@ OC.Uploader.prototype = _.extend({
});
},
+ confirmBeforeUnload: function() {
+ if (this._uploading) {
+ return t('files', 'This will stop your current uploads.')
+ }
+ },
+
/**
* Show conflict for the given file object
*
@@ -681,8 +694,8 @@ OC.Uploader.prototype = _.extend({
// resubmit upload
this.submitUploads([upload]);
},
- _trace:false, //TODO implement log handler for JS per class?
- log:function(caption, e, data) {
+ _trace: false, //TODO implement log handler for JS per class?
+ log: function(caption, e, data) {
if (this._trace) {
console.log(caption);
console.log(data);
@@ -990,6 +1003,7 @@ OC.Uploader.prototype = _.extend({
self.log('start', e, null);
//hide the tooltip otherwise it covers the progress bar
$('#upload').tooltip('hide');
+ self._uploading = true;
},
fail: function(e, data) {
var upload = self.getUpload(data);
@@ -1016,10 +1030,12 @@ OC.Uploader.prototype = _.extend({
self.cancelUploads();
} else {
// HTTP connection problem or other error
- var message = '';
+ var message = t('files', 'An unknown error has occurred');
if (upload) {
var response = upload.getResponse();
- message = response.message;
+ if (response) {
+ message = response.message;
+ }
}
OC.Notification.show(message || data.errorThrown, {type: 'error'});
}
@@ -1055,6 +1071,7 @@ OC.Uploader.prototype = _.extend({
*/
stop: function(e, data) {
self.log('stop', e, data);
+ self._uploading = false;
}
};
@@ -1263,7 +1280,9 @@ OC.Uploader.prototype = _.extend({
return false;
}
});
-
+ }
+ window.onbeforeunload = function() {
+ return self.confirmBeforeUnload();
}
}