JanStevens / angular-growl-2

growl-like notifications for angularJS projects
MIT License
285 stars 97 forks source link

Server Side Notifications with referenceID? #122

Open razblack opened 7 years ago

razblack commented 7 years ago

Hello,

I have been using growl 2 and it is wonderful; however, I have a case where it would be nice to be able to control the referenceId from server side notifications.

In order for me to do this, I had to modify growl 2 (angular-growl.js line#275) and add a simple assignment such as:

config.referenceId = message['referenceId'];

It's a bit hacky, but seems to work.

In ASP.NET MVC, my model looks such as:

public class GrowlMessages
{
    public List<GrowlMessage> growlmessages;
    public GrowlMessages()
    {
        growlmessages = new List<GrowlMessage>();
    }
}

public class GrowlMessage
{
    public string growltext { get; set; }
    public string growlseverity { get; set; }
    public string growltitle { get; set; }
    public int referenceId { get; set; }

    public GrowlMessage()
    {
        referenceId = 0;
    }
}

and my app.js sets it up as:

    growlProvider.messagesKey("growlmessages");
    growlProvider.messageTextKey("growltext");
    growlProvider.messageSeverityKey("growlseverity");
    growlProvider.messageTitleKey("growltitle");

Would be great to be able to define a growlProvider.messageId in the app to integrate better with your schema.

maybe this is a feature request? :D

flaviocysne commented 7 years ago

This is already implemented. I think the code you are looking for is:

growlProvider.messageReferenceIdKey("growlReferenceId");

The default value for the messageReferenceIdKey id referenceId.