Hide snackbar on navigate (CC-81)

pull/51/head
HardiReady 2019-02-10 08:53:39 +01:00
parent 2fffad3c60
commit 9de759805a
2 changed files with 7 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import {SpinnerService} from './services/user-interface/spinner/spinner.service'
import {TranslateService} from '@ngx-translate/core';
import {SettingsService} from './services/settings.service';
import {environment} from '../environments/environment';
import {SnackBarService} from './services/user-interface/snack-bar/snack-bar.service';
declare function require(url: string);
@ -84,6 +85,7 @@ export class AppComponent implements OnInit {
private spinnerService: SpinnerService,
private translate: TranslateService,
private settingsService: SettingsService,
private snackBarService: SnackBarService,
@Inject(DOCUMENT) private document) {
this.initMaterialSvgIcons();
@ -92,6 +94,7 @@ export class AppComponent implements OnInit {
router.events.subscribe(event => {
if (event instanceof NavigationStart) {
this.spinnerService.activate();
this.snackBarService.dismiss();
}
if (event instanceof NavigationEnd) {
this.spinnerService.deactivate();

View File

@ -29,6 +29,10 @@ export class SnackBarService {
return this.snackbar.open(message, action, config);
}
dismiss() {
this.snackbar.dismiss();
}
showSuccess(i18n: string) {
this.translate.get(i18n).subscribe((translated) => {
return this.show(translated, undefined, 2500, ['custom-snack-bar', 'label-success']);