NotificationCenter - AFS

AFS Integration Guide

Product
AFS
AFS_Version
7.9
Category
Reference Guide

The NotificationCenter widget catches all notifications that the other widgets emit.

A notification consists in three information:

  • a type among the following values: INFO, WARN, ERROR, FATAL, OTHER
  • a code that defines the kind of signaled event, like "afs.qm_unreachable"
  • a localized message that describes the event (these messages can be parameterized)

The NotificationCenter brings a default behavior that simply displays received notifications with colors relative to their type.

This widget gives the user the capability to ignore notifications based on types, on codes, or even on code patterns.

It is also possible to install a custom behavior for notifications with the same criteria.

NotificationCenter - Widget that catches notifications emitted from installed widgets

Parameter

Type

Card

Default

Description

ignoreTypeList

String array

Optional

[]

List of notification types to ignore.

typeRedirections

Object array

Optional

[]

List of notification types with custom handling.

ignoreCodeList

String array

Optional

[]

List of notification code patterns to ignore.

codeRedirections

Object array

Optional

[]

List of notification code patterns with custom handling.

fadeOutDelay

Integer

Optional

10000

Duration in ms before the notification fades out (concerns only default notification handler).

<div data-type="AFSWidget" data-name="NotificationCenter">
<script type="application/json">
{
"ignoreTypeList": ["INFO", "OTHER"],
"ignoreCodeList": ["afs.qm_unavailable", "cks.*"],
"fadeOutDelay": 5000
}
</script>
</div>

Type-based redirections

It is possible to customize handling behavior by redirecting all notifications of one or many types to a personal JavaScript function.

Parameter Narme

Type

Card

Description

types

String array

Mandatory

List of notification types that have to be handled by the specified callback.

callback

String/Function

Mandatory

Name of an existing function (or inline function) that will handle notifications of the specified types.

keepDefaultBehavior

Boolean

Optional (false)

When used, the notification is redirected to the custom handler but the default behavior is also executed

<div data-type="AFSWidget" data-name="NotificationCenter">
<script type="application/json">
{
"typeRedirections": [{
"types": ["FATAL", "ERROR"],
"callback": "errorHandler"
}, {
"types": ["WARN"],
"callback": "warningHandler"
}]
}
</script>
</div>

Code-based redirections

It is possible to customize handling behavior by redirecting all notifications of one or many codes to a personal JavaScript function.

These codes can be given as strings or as regular expression patterns.

Parameter Name

Type

Card

Description

codes

String array

Mandatory

List of notification code patterns that have to be handled by the specified callback.

callback

String

Mandatory

Name of an existing function (or inline function) that will handle notifications of the specified codes.

<div data-type="AFSWidget" data-name="NotificationCenter">
<script type="application/json">
{
"codeRedirections": [{
"codes": ["cks.schedsearch_.*", "cks.bookmarks_.*"],
"callback": "cksElemsNotifHandler"
}, {
"codes": ["afs.*"],
"callback": "afsNotifHandler"
}]
}
</script>
</div>

Callback implementations

Hereafter is given an example of a callback to handle notifications:

<script type="text/javascript">
function errorHandler(element, data)
{
// custom code
}
</script>

Or inlined in configuration:

var AFSWidgetNotificationCenter = {
typeRedirections: [{
types: ["FATAL", "ERROR"],
callback: function errorHandler(element, data){
// custom code
}
}]
};

The first element parameter is the reserved section of the NotificationCenter where information can be added.

It also can be left unused.

The last parameter contains data of the received notification as a JSON object, like in the example below:

{
"type": "ERROR",
"code": "afs.qm_unreachable",
"message": "The query manager is unreachable."
}

In case where the message contains dynamic informations, another field field is given:

{
"type": "INFO",
"code": "cks.schedsearch_savesucceed",
"message": "The search 'Foobar' was saved.",
"params": {"schedSearchName": "Foobar"}
}

How to know emitted notifications

Some of the widgets used for the integration can emit notifications.

All unhandled notifications are printed on the browser Developer Console. It can be useful to set logLevel to DEBUG in order to see all of them.

Here is an example of a JSON notification serialized to string and visible in a Console:

2014-07-10 15:24:27,922 [INFO ] {type=INFO, code="cks.logout", message="You have been logged out", params}}

The NotificationCenter considers that:
- a redirection instruction has priority over an ignore instruction;
- a code redirection has priority over a type redirection;
- a redirection declared before an other has priority over the following.

The notifications presented on this page do not reflect the reality...