From dbbccb4e40f02d2ea4323e313137e9e5ccb98386 Mon Sep 17 00:00:00 2001 From: Simon Busborg Date: Mon, 23 Nov 2015 12:02:24 +0100 Subject: [PATCH] Ensure drag/drop media uploads show notifications - since the way this works has been overhauled in 7.4 Awaits `maxFileSize` variable from U4-7394 ( http://issues.umbraco.org/issue/U4-7394 ) --- .../upload/umbfiledropzone.directive.js | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/upload/umbfiledropzone.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/upload/umbfiledropzone.directive.js index 724940bd9d..460c35868a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/upload/umbfiledropzone.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/upload/umbfiledropzone.directive.js @@ -144,33 +144,61 @@ angular.module("umbraco.directives") }).success(function (data, status, headers, config) { - // set done status on file - file.uploadStatus = "done"; + if(data.notifications && data.notifications.length > 0) { - // set date/time for when done - used for sorting - file.doneDate = new Date(); + // set error status on file + file.uploadStatus = "error"; + + // Throw message back to user with the cause of the error + file.serverErrorMessage = data.notifications[0].message; + + // Put the file in the rejected pool + scope.rejected.push(file); + + } else { + + // set done status on file + file.uploadStatus = "done"; + + // set date/time for when done - used for sorting + file.doneDate = new Date(); + + // Put the file in the done pool + scope.done.push(file); + + } - scope.done.push(file); scope.currentFile = undefined; //after processing, test if everthing is done _processQueueItem(); }).error( function (evt, status, headers, config) { + + // set status done file.uploadStatus = "error"; //if the service returns a detailed error if(evt.InnerException){ - file.errorMessage = evt.InnerException.ExceptionMessage; + file.serverErrorMessage = evt.InnerException.ExceptionMessage; //Check if its the common "too large file" exception if(evt.InnerException.StackTrace && evt.InnerException.StackTrace.indexOf("ValidateRequestEntityLength") > 0){ - file.errorMessage = "File too large to upload"; + file.serverErrorMessage = "File too large to upload"; } } + if(evt.Message) { + file.serverErrorMessage = evt.Message; + } + + // If file not found, server will return a 404 and display this message + if(status === 404 ) { + file.serverErrorMessage = "File not found"; + } + //after processing, test if everthing is done - scope.done.push(file); + scope.rejected.push(file); scope.currentFile = undefined; _processQueueItem();