alfresco-ng2-components/docs/core/services/notification.service.md
Eugenio Romano 5e54cd4d43
Increase timeout and modify login async (#4795)
* increase timeout and modify login async

* run e2e if testing is changed

* improve cdk fix

* fix travis update projects

* disable ghostMode lite server

* lint fix

* fix timeout

* multiple try

* Update content-services-e2e.sh

* Update search-e2e.sh

* Update process-services-e2e.sh

* Update core-e2e.sh

* Update protractor.conf.ts

* fix unit

* remove async

* increqase notification time

* 3 parallel

* dix path issue in save

* small refactor protractor ts

* fix save

* create license check first script adf cli

* modify regex check

* refactor notification history component

* decrease notification

* fix notification message problem

* fix test

* update packages wit high risk

* revert cahnge login sso e2e

* fix dep

* fix documentation duplication and issue

* fix after review

* fix after review

* try 6 parallel test

* back to 3 parallel test no real time improve with 6
2019-06-06 16:47:50 +01:00

4.9 KiB

Title, Added, Status, Last reviewed
Title Added Status Last reviewed
Notification Service v2.0.0 Active 2018-06-08

Notification Service

Shows a notification message with optional feedback.

Notification Service screenshot

Class members

Methods

  • dismissSnackMessageAction()
    dismiss the notification snackbar
  • openSnackMessage(message: string, config?: number|MatSnackBarConfig): MatSnackBarRef<any>
    Opens a SnackBar notification to show a message.
    • message: string - The message (or resource key) to show.
    • config: number|MatSnackBarConfig - (Optional) Time before notification disappears after being shown or MatSnackBarConfig object
    • Returns MatSnackBarRef<any> - Information/control object for the SnackBar
  • openSnackMessageAction(message: string, action: string, config?: number|MatSnackBarConfig): MatSnackBarRef<any>
    Opens a SnackBar notification with a message and a response button.
    • message: string - The message (or resource key) to show.
    • action: string - Caption for the response button
    • config: number|MatSnackBarConfig - (Optional) Time before notification disappears after being shown or MatSnackBarConfig object
    • Returns MatSnackBarRef<any> - Information/control object for the SnackBar
  • showError(message: string, action?: string): MatSnackBarRef<any>
    Rase error message
    • message: string - Text message or translation key for the message.
    • action: string - (Optional) Action name
    • Returns MatSnackBarRef<any> -
  • showInfo(message: string, action?: string): MatSnackBarRef<any>
    Rase info message
    • message: string - Text message or translation key for the message.
    • action: string - (Optional) Action name
    • Returns MatSnackBarRef<any> -
  • showWarning(message: string, action?: string): MatSnackBarRef<any>
    Rase warning message
    • message: string - Text message or translation key for the message.
    • action: string - (Optional) Action name
    • Returns MatSnackBarRef<any> -

Details

The Notification Service is implemented on top of the Angular Material Design snackbar. Use this service to show a notification message, and optionally get feedback from it.

import { NotificationService } from '@alfresco/adf-core';

export class MyComponent implements OnInit {

    constructor(private notificationService: NotificationService) {
    }

    ngOnInit() {
        this.notificationService
            .openSnackMessage('test', 200000)
            .afterDismissed()
            .subscribe(() => {
                console.log('The snack-bar was dismissed');
            });
    }
}
import { NotificationService } from '@alfresco/adf-core';

export class MyComponent implements OnInit {

    constructor(private notificationService: NotificationService) {
    }

    ngOnInit() {
        this.notificationService
            .openSnackMessageAction('Do you want to report this issue?', 'send', 200000)
            .afterDismissed()
            .subscribe(() => {
                console.log('The snack-bar was dismissed');
            });
    }
}
import { NotificationService } from '@alfresco/adf-core';
import { MatSnackBarConfig } from '@angular/material';

export class MyComponent implements OnInit {

    snackBarConfig: MatSnackBarConfig = new MatSnackBarConfig();

    constructor(private notificationService: NotificationService) {
    }

    ngOnInit() {
        this.notificationService
            .openSnackMessageAction('Do you want to report this issue?', 'send', snackBarConfig)
            .afterDismissed()
            .subscribe(() => {
                console.log('The snack-bar was dismissed');
            });
    }
}

The default message duration is 5000 ms that is used only if you don't pass a custom duration in the parameters of openSnackMessageAction/openSnackMessage methods. You can also change the default 5000 ms adding the following configuration in the app.config.json:

    "notificationDefaultDuration" : "7000"