Emit event when upload of image starts & stops

Listen for events in content edit JS controller to change the state of the buttons to be 'busy' to avoid page/node being saved whilst large image is uploaded or slow connection
This commit is contained in:
Warren Buckley
2019-09-18 15:27:30 +01:00
parent 251d12b1fd
commit 3f30be450d
2 changed files with 21 additions and 1 deletions

View File

@@ -171,6 +171,18 @@
}
}));
evts.push(eventsService.on("rte.file.uploading", function(){
notificationsService.info("Saving Disabled", "The node cannot be saved until the image/s has finished uploading")
$scope.page.saveButtonState = "busy";
$scope.page.buttonGroupState = "busy";
}));
evts.push(eventsService.on("rte.file.uploaded", function(){
$scope.page.saveButtonState = "success";
$scope.page.buttonGroupState = "success";
}));
}
/**

View File

@@ -7,7 +7,7 @@
* A service containing all logic for all of the Umbraco TinyMCE plugins
*/
function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, stylesheetResource, macroResource, macroService,
$routeParams, umbRequestHelper, angularHelper, userService, editorService, entityResource) {
$routeParams, umbRequestHelper, angularHelper, userService, editorService, entityResource, eventsService) {
//These are absolutely required in order for the macros to render inline
//we put these as extended elements because they get merged on top of the normal allowed elements by tiny mce
@@ -167,6 +167,14 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
xhr = new XMLHttpRequest();
xhr.open('POST', Umbraco.Sys.ServerVariables.umbracoUrls.tinyMceApiBaseUrl + 'UploadImage');
xhr.onloadstart = function(e) {
eventsService.emit("rte.file.uploading");
};
xhr.onloadend = function(e) {
eventsService.emit("rte.file.uploaded");
};
xhr.upload.onprogress = function (e) {
progress(e.loaded / e.total * 100);
};