Copied to clipboard

Flag this post as spam?

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


  • Adriano Fabri 459 posts 1602 karma points
    May 05, 2017 @ 10:35
    Adriano Fabri
    0

    How to increase notification message duration

    Hi to all,

    I need to increase the notification message display time.

    In my controller I set this notification message:

    notificationsService.success(localizationService.localize("MYPJ_UsersManager.SelectedUsersSuccessMessage"));
    

    I read API documentation (https://our.umbraco.org/apidocs/ui/#/api/umbraco.services.notificationsService) but I found only that "by default when a notification is added, it is automaticly removed 7 seconds after. This can be changed on add()"

    But I didn't found an example on how and where I can set the timeout.

    Anyone can help me?

    Thank you in advance

    Adriano

  • Daniel 60 posts 174 karma points
    May 06, 2017 @ 03:14
    Daniel
    0

    Without having digged too deeply in it, I'm pretty sure it refers to the "sticky" parameter.

    This will keep your notification up until the backoffice user manually closes it with no timeout at all.

    This also means you need to make a new notification object (not using the success one) - and setting the sticky to true for that notification object. You can still set the type to success of course, so it'll mimic the standard one completely by looks.

  • Adriano Fabri 459 posts 1602 karma points
    May 06, 2017 @ 16:38
    Adriano Fabri
    0

    I don't think to understand.

    What "sticky" parameter?

  • Daniel 60 posts 174 karma points
    May 06, 2017 @ 16:43
    Daniel
    100

    One example is this:

        $scope.downloadNotification = {
            'type': 'info',
            'sticky': true
        };
    
        [.....]
    
        $scope.downloadNotification.headline = "Hello";
        $scope.downloadNotification.message = "I will stay open until I'm closed";
        notificationsService.add($scope.downloadNotification);
    

    I hope it's somewhat self-explanatory!

  • Adriano Fabri 459 posts 1602 karma points
    May 06, 2017 @ 18:29
    Adriano Fabri
    0

    Yeah!!! Sorry but I'm newbie with AngularJs and I'm discovering a new world.

    Thank you...I will try it soon and I'll tell you if I succeeded

  • Adriano Fabri 459 posts 1602 karma points
    May 12, 2017 @ 14:25
    Adriano Fabri
    1

    It works like a charm.

    This is a version with localizationService (the "sticky" parameter set to false, disable the "always on" alert message):

    $scope.userSuccessNotification = {
        'type': 'success',
        'sticky': false
    };
    localizationService.localize("MYPJ_UsersManager.SelectedUsersSuccessHeadline").then(function (value) {
        $scope.userSuccessNotification.headline = value;
    });
    localizationService.localize("MYPJ_UsersManager.SelectedUsersSuccessMessage").then(function (value) {
        $scope.userSuccessNotification.message = value;
    });
    

    Thank you very much!!! ;-)

  • Daniel 60 posts 174 karma points
    May 08, 2017 @ 21:32
    Daniel
    1

    No worries man, you're asking good questions! Hope it works out. :)

Please Sign in or register to post replies

Write your reply to:

Draft