Skip to content

Commit

Permalink
Merge pull request #121 from amosproj/86-new--fixed-alert-endpoint
Browse files Browse the repository at this point in the history
fixed alert notification endpoint
  • Loading branch information
ddeli authored Dec 3, 2024
2 parents 979774b + 562b6b2 commit d31b26c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
11 changes: 4 additions & 7 deletions apps/frontend/src/app/alert/component/alert.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,16 @@ export class AlertComponent implements OnInit {
.getAllAlerts(this.DAYS)
.pipe(takeUntil(this.destroy$))
.subscribe((data: Alert[]) => {
const activeAlerts = data.filter(
(alert) => alert.alertType.user_active === true
);
this.criticalAlertsCount = activeAlerts.filter(
this.criticalAlertsCount = data.filter(
(alert) => alert.alertType.severity === SeverityType.CRITICAL
).length;
this.warningAlertsCount = activeAlerts.filter(
this.warningAlertsCount = data.filter(
(alert) => alert.alertType.severity === SeverityType.WARNING
).length;
this.infoAlertsCount = activeAlerts.filter(
this.infoAlertsCount = data.filter(
(alert) => alert.alertType.severity === SeverityType.INFO
).length;
this.alerts = activeAlerts;
this.alerts = data;
this.status = this.getStatus();
});
}
Expand Down
17 changes: 4 additions & 13 deletions apps/frontend/src/app/management/services/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,14 @@ export class NotificationService {
private readonly http: HttpClient
) {}

// Lade aktuelle Einstellungen
getNotificationSettings(): Observable<AlertType[]> {
return this.http.get<AlertType[]>(`${this.baseUrl}/alerting/type`);
}

// Speichere neue Einstellungen
updateNotificationSettings(notification: AlertType): Observable<AlertType> {
if (notification.user_active) {
return this.http.patch<AlertType>(
`${this.baseUrl}/alerting/type/${notification.id}/activate/user`,
{ params: notification }
);
} else {
return this.http.patch<AlertType>(
`${this.baseUrl}/alerting/type/${notification.id}/deactivate/user`,
{ params: notification }
);
}
return this.http.patch<AlertType>(
`${this.baseUrl}/alerting/type/${notification.id}/user`,
{ status: notification.user_active }
);
}
}

0 comments on commit d31b26c

Please sign in to comment.