Browse Source

Better error-handling for import.url() and import.dropbox()

Tobias Reich 9 years ago
parent
commit
61431c6e59
1 changed files with 48 additions and 6 deletions
  1. 48 6
      src/scripts/upload.js

+ 48 - 6
src/scripts/upload.js

@@ -303,7 +303,30 @@ upload.start = {
 
 					api.post('Import::url', params, function(data) {
 
-						basicModal.close();
+						// Same code as in import.dropbox()
+
+						if (data!==true) {
+
+							$('.basicModal .rows .row p.notice')
+								.html('The import has been finished, but returned warnings or errors. Please take a look at the log (Settings -> Show Log) for further details.')
+								.show();
+
+							$('.basicModal .rows .row .status')
+								.html('Finished')
+								.addClass('warning');
+
+							// Show close button
+							$('.basicModal #basicModal__action.hidden').show();
+
+							// Log error
+							lychee.error(null, params, data);
+
+						} else {
+
+							basicModal.close();
+
+						}
+
 						upload.notify('Import complete');
 
 						albums.refresh();
@@ -311,8 +334,6 @@ upload.start = {
 						if (album.getID()===false) lychee.goto('0');
 						else album.load(albumID);
 
-						if (data!==true) lychee.error(null, params, data);
-
 					});
 
 				});
@@ -441,7 +462,30 @@ upload.start = {
 
 				api.post('Import::url', params, function(data) {
 
-					basicModal.close();
+					// Same code as in import.url()
+
+					if (data!==true) {
+
+						$('.basicModal .rows .row p.notice')
+							.html('The import has been finished, but returned warnings or errors. Please take a look at the log (Settings -> Show Log) for further details.')
+							.show();
+
+						$('.basicModal .rows .row .status')
+							.html('Finished')
+							.addClass('warning');
+
+						// Show close button
+						$('.basicModal #basicModal__action.hidden').show();
+
+						// Log error
+						lychee.error(null, params, data);
+
+					} else {
+
+						basicModal.close();
+
+					}
+
 					upload.notify('Import complete');
 
 					albums.refresh();
@@ -449,8 +493,6 @@ upload.start = {
 					if (album.getID()===false) lychee.goto('0');
 					else album.load(albumID);
 
-					if (data!==true) lychee.error(null, params, data);
-
 				});
 
 			});