[ADF-4484] Quick notifications (#4688)

* quick notifications (info, error, warning)

* update code docs
This commit is contained in:
Denys Vuika
2019-05-07 13:25:12 +01:00
committed by GitHub
parent 5d49b494fa
commit 8db915bd2a
6 changed files with 88 additions and 1 deletions

View File

@@ -85,4 +85,40 @@ export class NotificationService {
dismissSnackMessageAction() {
return this.snackBar.dismiss();
}
protected showMessage(message: string, panelClass: string, action?: string): MatSnackBarRef<any> {
message = this.translationService.instant(message);
return this.snackBar.open(message, action, {
duration: this.DEFAULT_DURATION_MESSAGE,
panelClass
});
}
/**
* Rase error message
* @param message Text message or translation key for the message.
* @param action (optional) Action name
*/
showError(message: string, action?: string): MatSnackBarRef<any> {
return this.showMessage(message, 'adf-error-snackbar', action);
}
/**
* Rase info message
* @param message Text message or translation key for the message.
* @param action (optional) Action name
*/
showInfo(message: string, action?: string): MatSnackBarRef<any> {
return this.showMessage(message, 'adf-info-snackbar', action);
}
/**
* Rase warning message
* @param message Text message or translation key for the message.
* @param action (optional) Action name
*/
showWarning(message: string, action?: string): MatSnackBarRef<any> {
return this.showMessage(message, 'adf-warning-snackbar', action);
}
}