mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-02-22 02:16:37 +00:00
Merge pull request #533 from GNS3/Show-errors-&-warnings-as-notifications
Show errors & warnings as notifications
This commit is contained in:
commit
052eab0367
@ -87,6 +87,9 @@
|
|||||||
<mat-checkbox [ngModel]="isTopologySummaryVisible" (change)="toggleShowTopologySummary($event.checked)">
|
<mat-checkbox [ngModel]="isTopologySummaryVisible" (change)="toggleShowTopologySummary($event.checked)">
|
||||||
Show topology/servers summary
|
Show topology/servers summary
|
||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
|
<mat-checkbox [ngModel]="notificationsVisibility" (change)="toggleNotifications($event.checked)">
|
||||||
|
Show notifications
|
||||||
|
</mat-checkbox>
|
||||||
</div>
|
</div>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
public isConsoleVisible: boolean = false;
|
public isConsoleVisible: boolean = false;
|
||||||
public isTopologySummaryVisible: boolean = false;
|
public isTopologySummaryVisible: boolean = false;
|
||||||
public isInterfaceLabelVisible: boolean = false;
|
public isInterfaceLabelVisible: boolean = false;
|
||||||
|
public notificationsVisibility: boolean = false;
|
||||||
|
|
||||||
tools = {
|
tools = {
|
||||||
selection: true,
|
selection: true,
|
||||||
@ -222,6 +223,21 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.subscriptions.push(this.projectWebServiceHandler.errorNotificationEmitter.subscribe((message) => {
|
||||||
|
this.showMessage({
|
||||||
|
type: 'error',
|
||||||
|
message: message
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
this.subscriptions.push(this.projectWebServiceHandler.warningNotificationEmitter.subscribe((message) => {
|
||||||
|
this.showMessage({
|
||||||
|
type: 'warning',
|
||||||
|
message: message
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
this.notificationsVisibility = localStorage.getItem('notificationsVisibility') === 'true' ? true : false;
|
||||||
this.addKeyboardListeners();
|
this.addKeyboardListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,6 +470,22 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
this.mapSettingsService.toggleTopologySummary(this.isTopologySummaryVisible);
|
this.mapSettingsService.toggleTopologySummary(this.isTopologySummaryVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public toggleNotifications(visible: boolean) {
|
||||||
|
this.notificationsVisibility = visible;
|
||||||
|
if (this.notificationsVisibility) {
|
||||||
|
localStorage.setItem('notificationsVisibility', 'true');
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem('notificationsVisibility');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private showMessage(msg) {
|
||||||
|
if (this.notificationsVisibility) {
|
||||||
|
if (msg.type === 'error') this.toasterService.error(msg.message);
|
||||||
|
if (msg.type === 'warning') this.toasterService.warning(msg.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public hideMenu() {
|
public hideMenu() {
|
||||||
this.projectMapMenuComponent.resetDrawToolChoice()
|
this.projectMapMenuComponent.resetDrawToolChoice()
|
||||||
this.isProjectMapMenuVisible = false;
|
this.isProjectMapMenuVisible = false;
|
||||||
|
@ -9,12 +9,21 @@ export class ToasterService {
|
|||||||
MatSnackBarHorizontalPosition: 'center',
|
MatSnackBarHorizontalPosition: 'center',
|
||||||
MatSnackBarVerticalPosition: 'bottom'
|
MatSnackBarVerticalPosition: 'bottom'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
snackBarConfigForWarning = {
|
||||||
|
duration: 2000,
|
||||||
|
panelClass: ['snackabar-warning'],
|
||||||
|
MatSnackBarHorizontalPosition: 'center',
|
||||||
|
MatSnackBarVerticalPosition: 'bottom'
|
||||||
|
};
|
||||||
|
|
||||||
snackBarConfigForError = {
|
snackBarConfigForError = {
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
panelClass: ['snackabar-error'],
|
panelClass: ['snackabar-error'],
|
||||||
MatSnackBarHorizontalPosition: 'center',
|
MatSnackBarHorizontalPosition: 'center',
|
||||||
MatSnackBarVerticalPosition: 'bottom'
|
MatSnackBarVerticalPosition: 'bottom'
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private snackbar: MatSnackBar,
|
private snackbar: MatSnackBar,
|
||||||
private zone: NgZone) {}
|
private zone: NgZone) {}
|
||||||
@ -25,6 +34,12 @@ export class ToasterService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public warning(message: string) {
|
||||||
|
this.zone.run(() => {
|
||||||
|
this.snackbar.open(message, 'Close', this.snackBarConfigForWarning);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public success(message: string) {
|
public success(message: string) {
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
this.snackbar.open(message, 'Close', this.snackBarConfigForSuccess);
|
this.snackbar.open(message, 'Close', this.snackBarConfigForSuccess);
|
||||||
|
@ -11,6 +11,11 @@ a.table-link {
|
|||||||
color: white!important;
|
color: white!important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.snackbar-warning {
|
||||||
|
background: rgb(197, 199, 64)!important;
|
||||||
|
color: white!important;
|
||||||
|
}
|
||||||
|
|
||||||
.snackbar-error {
|
.snackbar-error {
|
||||||
background: #B00020!important;
|
background: #B00020!important;
|
||||||
color: white!important;
|
color: white!important;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user