Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ron G 41 posts 137 karma points
    Sep 07, 2016 @ 18:19
    Ron G
    0

    Create Custom Message Notification on a Custom Data Type

    I've created a custom data type that saves files to the web server. I have an API JsonController to save the files.

    [PluginController("FileSaver")]
       public class FileSaverApiController : UmbracoAuthorizedJsonController
       {
           public async Task<HttpResponseMessage> SaveFiles()
           {
              try
              {
                 // Do stuff
              }
              catch (Exception ex)
              {
                CREATE NOTIFCATION FOR UMBRACO BACKOFFICE
              }
           }
       }
    

    When there is an error, I would like to display a message in the Umbraco back-office UI.

    Is this possible? Thank you!

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Sep 07, 2016 @ 21:26
    Marc Goodson
    101

    Hi Ron

    There is an Umbraco angular service, called the notificationsService that you can inject into your property editor controller:

    https://our.umbraco.org/apidocs/ui/#/api/umbraco.services.notificationsService

    and use to raise messages in the backoffice.

    So you will need your controller to return the details of the error to your request, and then use the notifications service to send the message about the problem to the backoffice...

    notificationsService.error("title", "message");
    

    regards

    Marc

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Sep 07, 2016 @ 21:33
    Alex Skrypnyk
    3

    Hi Ron,

    Just return from server some message and show it with angular "notificationsService".

    Example:

    angular.module('umbraco').controller('MyController',
        function ($scope, notificationsService) {
            notificationsService.add({
                            headline : 'Custom notification',
                            message : 'My custom notification message',
                            url: 'http://www.colours.nl',
                            sticky : true,
                            type : 'custom'
                        });         
        });
    

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft