From 62ab6f37d1e8cceb541fd650602557299ae020bb Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Tue, 9 Jan 2024 18:52:43 +0200 Subject: [PATCH] add keydown event, remove logging ,fix bug --- ui/src/app/shared/error/error-alert.component.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/src/app/shared/error/error-alert.component.ts b/ui/src/app/shared/error/error-alert.component.ts index 322d284d0..b3abf4316 100644 --- a/ui/src/app/shared/error/error-alert.component.ts +++ b/ui/src/app/shared/error/error-alert.component.ts @@ -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' @@ -27,7 +27,6 @@ export class ErrorAlertComponent implements OnInit { toast: false, } this.alerts.push(alert) - this.alerts.push(alerts) this.cdr.detectChanges() }) } @@ -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) } }