Skip to content

Commit

Permalink
ErrorAlert class
Browse files Browse the repository at this point in the history
  • Loading branch information
bobcaprice committed Jan 4, 2024
1 parent 595290a commit 7137ab9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ui/src/app/shared/error/error-alert.component.ts
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()
}
}
11 changes: 11 additions & 0 deletions ui/src/app/shared/model/error-alert.ts
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
) {}
}

0 comments on commit 7137ab9

Please sign in to comment.