Files
dc/client/src/app/shared/alerts/alerts.component.ts
Mihajlo Medjedovic 6a7dd451b5
Some checks failed
Build / Build-and-ng-test (pull_request) Failing after 49s
Build / Build-and-test-development (pull_request) Failing after 47s
style: lint
2025-05-21 09:55:05 +02:00

36 lines
921 B
TypeScript

import { Component, OnInit, ViewEncapsulation } from '@angular/core'
import { Subscription } from 'rxjs'
import { Alert } from './alert'
import { AlertsService } from './alerts.service'
@Component({
selector: 'app-alerts',
templateUrl: './alerts.component.html',
styleUrls: ['./alerts.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class AlertsComponent implements OnInit {
public alerts: Array<Alert> = []
public hasOpenAlert: boolean = false
private alertsSub: Subscription = new Subscription()
constructor(private _alertsService: AlertsService) {}
ngOnInit() {
this.alertsSub = this._alertsService.alerts.subscribe((alert: Alert) => {
this.alerts.push(alert)
this.hasOpenAlert = true
if (alert.err) {
console.error(alert.err)
}
})
}
public onAlertClose() {
this.hasOpenAlert = this.alerts.some((alert) => !alert.closed)
}
}