Skip to content

Commit

Permalink
add keydown event, remove logging ,fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
auumgn committed Jan 9, 2024
1 parent 77b6c1b commit 62ab6f3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ui/src/app/shared/error/error-alert.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component, ErrorHandler, Inject, OnInit } from '@angular/core'
import { ChangeDetectorRef, Component, ErrorHandler, HostListener, Inject, OnInit } from '@angular/core'
import { ErrorService } from '../service/error.service'
import { Subscription } from 'rxjs'
import { ErrorAlert } from '../model/error-alert'
Expand Down Expand Up @@ -27,7 +27,6 @@ export class ErrorAlertComponent implements OnInit {
toast: false,
}
this.alerts.push(alert)
this.alerts.push(alerts)
this.cdr.detectChanges()
})
}
Expand All @@ -36,9 +35,14 @@ export class ErrorAlertComponent implements OnInit {
this.sub?.unsubscribe()
}

@HostListener('document:keydown.escape', ['$event'])
closeOldestAlert() {
this.alerts.shift()
this.cdr.detectChanges()
}

close(alertToRemove: any) {
this.alerts = this.alerts.filter((alert: any) => alert !== alertToRemove)
this.cdr.detectChanges()
console.log(this.alerts)
}
}

0 comments on commit 62ab6f3

Please sign in to comment.