Skip to content

Instantly share code, notes, and snippets.

@warrenbuckley
Last active August 29, 2015 14:10
Show Gist options
  • Save warrenbuckley/07d21b682c8e076cb5e2 to your computer and use it in GitHub Desktop.
Save warrenbuckley/07d21b682c8e076cb5e2 to your computer and use it in GitHub Desktop.
This is a POC idea to hook into when content node is Saved or Saved & Published do a $http Get/Post to perform some action such as auto create media folder. Then once successful show a notification with notificationService. This is a POC way to try and get around the current lack of firing a notification from an eventHandler like V6 style.
//Get the same base module that Umbraco uses
var app = angular.module("umbraco");
//When the module runs/excutes...
app.run(["$rootScope", "notificationsService", "eventsService", function ($rootScope, notificationsService, eventsService) {
//Let's listen for any time formSubmitting
eventsService.on("formSubmitting", function (e, args) {
console.log("e", e);
console.log("args", args);
//Sad panda :(
//This event 'formSubmitting' from formHelper.service.js only fires on the relative scope
//And not the rootScope so have no easy way to listen in for this
//Need another smart way?!
//Psudeo code
//Check for the type of docType that is being saved
//If type == "magic"
//Then do $http post or own service/resource with promise
//Do some funky event stuff - create an auto media folder
//If success promise
//Show notificationwith notificationService.add() using JSON response from API $http
});
//Let's listen for any time formSubmitted
eventsService.on("formSubmitted", function (e, args) {
console.log("e", e);
console.log("args", args);
});
//Let's listen for any time app.ready this is an event on the rootScope that is emitted
//So this works just lovely
eventsService.on("app.ready", function (e, args) {
console.log("e", e);
console.log("args", args);
notificationsService.success("Warren", "says hello");
});
}]);
@warrenbuckley
Copy link
Author

@Shazwazza Off to create an issue on the tracker for C# events to push out a notification for this now 😄

I understand and agree with your reasonings. I was just trying to think of a temporary way to get around this until C# events pushing notifications is supported.

I came up with this idea after reading the source code for Umbraco and wondering how the UpdateChecker works to show a notification that a new version is available, and this works in a similar way on the backoffice loading it goes off and checks and depending on the result will show that notification message. Hence me thinking of doing this in the same methodolgy.

@warrenbuckley
Copy link
Author

If anyone reads or follows this thread.
Recommend you vote up the issue here on the Umbraco Core Team Issue Tracker please
http://issues.umbraco.org/issue/U4-5927

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment