diff --git a/lang/en/error.php b/lang/en/error.php index ee10b9bdc71..bd54f12a7de 100644 --- a/lang/en/error.php +++ b/lang/en/error.php @@ -435,6 +435,7 @@ $string['rpcerror'] = 'Ooops! Your MNET communication has failed! Here\'s that e $string['secretalreadyused'] = 'Change password confirmation link was already used, password was not changed'; $string['sectionnotexist'] = 'This section does not exist'; $string['sendmessage'] = 'Send message'; +$string['serverconnection'] = 'Error connecting to the server'; $string['servicedonotexist'] = 'The service does not exist'; $string['sessionwaiterr'] = 'Timed out while waiting for session lock.
Wait for your current requests to finish and try again later.'; $string['sessioncookiesdisable'] = 'Incorrect use of require_key_login() - session cookies must be disabled!'; diff --git a/lib/form/dndupload.js b/lib/form/dndupload.js index df0fb1919d7..fae2b87424a 100644 --- a/lib/form/dndupload.js +++ b/lib/form/dndupload.js @@ -324,7 +324,6 @@ M.form_dndupload = { update_filemanager: function() { if (this.filemanager) { // update the filemanager that we've uploaded the files - this.hide_progress_spinner(); this.filemanager.filepicker_callback(); } }, @@ -335,6 +334,7 @@ M.form_dndupload = { upload_file: function(file) { if (file.size > this.maxbytes && this.maxbytes > 0) { // Check filesize before attempting to upload + this.hide_progress_spinner(); alert(M.util.get_string('uploadformlimit', 'moodle')+"\n'"+file.name+"'"); return false; } @@ -348,26 +348,29 @@ M.form_dndupload = { var xhr = new XMLHttpRequest(); var self = this; xhr.onreadystatechange = function() { // Process the server response - if (xhr.readyState == 4 && xhr.status == 200) { - var result = JSON.parse(xhr.responseText); - if (result) { - if (result.error) { - self.hide_progress_spinner(); - alert(result.error); - } else if (self.callback) { - // Only update the filepicker if there were no errors - self.hide_progress_spinner(); - if (result.event == 'fileexists') { - // Do not worry about this, as we only care about the last - // file uploaded, with the filepicker - result.file = result.newfile.filename; - result.url = result.newfile.url; + if (xhr.readyState == 4) { + self.hide_progress_spinner(); + if (xhr.status == 200) { + var result = JSON.parse(xhr.responseText); + if (result) { + if (result.error) { + alert(result.error); + } else if (self.callback) { + // Only update the filepicker if there were no errors + if (result.event == 'fileexists') { + // Do not worry about this, as we only care about the last + // file uploaded, with the filepicker + result.file = result.newfile.filename; + result.url = result.newfile.url; + } + result.client_id = self.clientid; + self.callback(result); + } else { + self.update_filemanager(); } - result.client_id = self.clientid; - self.callback(result); - } else { - self.update_filemanager(); } + } else { + alert(M.util.get_string('serverconnection', 'error')); } } }; diff --git a/lib/form/filemanager.php b/lib/form/filemanager.php index e34dee6e7e8..1d9358590ef 100644 --- a/lib/form/filemanager.php +++ b/lib/form/filemanager.php @@ -315,7 +315,7 @@ FMHTML; array('cannotdeletefile', 'error'), array('confirmdeletefile', 'repository'), array('nopathselected', 'repository'), array('popupblockeddownload', 'repository'), array('draftareanofiles', 'repository'), array('path', 'moodle'), array('setmainfile', 'repository'), - array('moving', 'repository'), array('files', 'moodle') + array('moving', 'repository'), array('files', 'moodle'), array('serverconnection', 'error') ) ); $PAGE->requires->js_module($module);