mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-31 00:23:57 +00:00
Fix wrong toaster position for error/success, Fixes: #291
This commit is contained in:
parent
d772a0d9df
commit
b00604cc39
@ -2,6 +2,7 @@ import { TestBed, inject } from '@angular/core/testing';
|
|||||||
import { MatSnackBar } from '@angular/material';
|
import { MatSnackBar } from '@angular/material';
|
||||||
|
|
||||||
import { ToasterService } from './toaster.service';
|
import { ToasterService } from './toaster.service';
|
||||||
|
import { NgZone } from '@angular/core';
|
||||||
|
|
||||||
export class MockedToasterService {
|
export class MockedToasterService {
|
||||||
public errors: string[];
|
public errors: string[];
|
||||||
@ -40,7 +41,9 @@ class MockedSnackBar {
|
|||||||
describe('ToasterService', () => {
|
describe('ToasterService', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
providers: [ToasterService, { provide: MatSnackBar, useClass: MockedSnackBar }]
|
providers: [
|
||||||
|
ToasterService,
|
||||||
|
{ provide: MatSnackBar, useClass: MockedSnackBar }]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable, NgZone } from '@angular/core';
|
||||||
import { MatSnackBar } from '@angular/material';
|
import { MatSnackBar } from '@angular/material';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -15,13 +15,19 @@ export class ToasterService {
|
|||||||
MatSnackBarHorizontalPosition: 'center',
|
MatSnackBarHorizontalPosition: 'center',
|
||||||
MatSnackBarVerticalPosition: 'bottom'
|
MatSnackBarVerticalPosition: 'bottom'
|
||||||
};
|
};
|
||||||
constructor(private snackbar: MatSnackBar) {}
|
constructor(
|
||||||
|
private snackbar: MatSnackBar,
|
||||||
|
private zone: NgZone) {}
|
||||||
|
|
||||||
public error(message: string) {
|
public error(message: string) {
|
||||||
this.snackbar.open(message, 'Close', this.snackBarConfigForError);
|
this.zone.run(() => {
|
||||||
|
this.snackbar.open(message, 'Close', this.snackBarConfigForError);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public success(message: string) {
|
public success(message: string) {
|
||||||
this.snackbar.open(message, 'Close', this.snackBarConfigForSuccess);
|
this.zone.run(() => {
|
||||||
|
this.snackbar.open(message, 'Close', this.snackBarConfigForSuccess);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user