marcorinck / angular-growl

growl-like notifications for angularJS projects
MIT License
477 stars 191 forks source link

support to set global severity when server sent messages don't have severity field. #10

Open xmlking opened 10 years ago

xmlking commented 10 years ago

In Grails applications we get error messages as fallows:

wonder if you can make messageSeverityKey optional so that we can globally set Severity if there is no Severity field in server send message.

app.config(["growlProvider", "$httpProvider", function(growlProvider, $httpProvider) {
    growlProvider.messagesKey("errors");
    growlProvider.messageTextKey("message");
    $httpProvider.responseInterceptors.push(growlProvider.serverMessagesInterceptor);
}]);

Grails error message

{"errors":
[{"object":"com.cb.cmp.console.Address","field":"state","rejected-value":"2","message":"Property[state]ofclass[classcom.cb.cmp.console.Address]withvalue[2]doesnotfallwithinthevalidsizerangefrom[2]to[2]"},
{"object":"com.cb.cmp.console.Address","field":"zip","rejected-value":"q","message":"Property[zip]ofclass[classcom.cb.cmp.console.Address]withvalue[q]doesnotfallwithinthevalidsizerangefrom[5]to[5]"},
{"object":"com.cb.cmp.console.Address","field":"zip","rejected-value":"q","message":"Property[zip]ofclass[classcom.cb.cmp.console.Address]withvalue[q]doesnotpasscustomvalidation"}]
}