-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
595290a
commit 7137ab9
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Component } from '@angular/core' | ||
import { ErrorService } from '../service/error.service' | ||
import { Subscription } from 'rxjs/internal/Subscription' | ||
import { ErrorAlert } from '../model/error-alert' | ||
|
||
@Component({ | ||
selector: 'app-error-alert', | ||
templateUrl: './error-alert.component.html', | ||
styleUrls: ['./error-alert.component.scss'], | ||
}) | ||
export class ErrorAlertComponent { | ||
sub: Subscription | undefined | ||
|
||
alerts: any[] | ||
|
||
constructor(private errorService: ErrorService) { | ||
// subscribe to error handler | ||
// find 400 errors | ||
// look for translation key - if present somehow translate the fucker | ||
// set error fields in component for template to read | ||
// make it show | ||
|
||
// build list of alerts called alerts | ||
|
||
this.alerts = [] | ||
|
||
this.sub = this.errorService.on().subscribe((e) => { | ||
const alert: ErrorAlert = { | ||
type: 'danger', | ||
msg: message, | ||
params: data, | ||
toast: this.alertService.isToast(), | ||
scoped: true, | ||
} | ||
|
||
this.alerts.push(alert) | ||
}) | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.sub?.unsubscribe() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { EventType } from 'src/app/app.constants' | ||
|
||
export class ErrorAlert { | ||
constructor( | ||
public type: 'danger', | ||
public msg: string, | ||
public params: string, | ||
public toast: boolean, | ||
public scoped: boolean | ||
) {} | ||
} |