diff --git a/apps/frontend/src/app/backups-overview/backups/backups/backupfilter.ts b/apps/frontend/src/app/backups-overview/backups/backups/backupfilter.ts index 6b2d8c1..345173b 100644 --- a/apps/frontend/src/app/backups-overview/backups/backups/backupfilter.ts +++ b/apps/frontend/src/app/backups-overview/backups/backups/backupfilter.ts @@ -8,25 +8,29 @@ export class CustomFilter implements ClrDatagridFilterInterface { toDate: string | null; fromSizeMB: number | null; toSizeMB: number | null; + id: string | null; } = { fromDate: null, toDate: null, fromSizeMB: null, toSizeMB: null, + id: null, }; public changes = new Subject(); - public filterType: 'date' | 'size'; + public filterType: 'date' | 'size' | 'id'; - constructor(filterType: 'date' | 'size') { + constructor(filterType: 'date' | 'size' | 'id') { this.filterType = filterType; } isActive(): boolean { if (this.filterType === 'date') { return !!(this.ranges.fromDate || this.ranges.toDate); - } else { + } else if (this.filterType === 'size') { return !!(this.ranges.fromSizeMB || this.ranges.toSizeMB); + } else { + return !!this.ranges.id; } } diff --git a/apps/frontend/src/app/backups-overview/backups/backups/backups.component.html b/apps/frontend/src/app/backups-overview/backups/backups/backups.component.html index 82d6ef7..4e1bc3a 100644 --- a/apps/frontend/src/app/backups-overview/backups/backups/backups.component.html +++ b/apps/frontend/src/app/backups-overview/backups/backups/backups.component.html @@ -6,20 +6,29 @@

Backups Overview

On this page, you can:

    -
  • See Alerts: View the current status and details of any alerts that have been triggered. - Alerts are categorized by their severity. +
  • + See Alerts: View the current status and details of + any alerts that have been triggered. Alerts are categorized by their + severity.
  • -
  • See all backups with basic data: Browse through a list of all backups, including - essential information such as Backup ID, size and creation date. +
  • + See all backups with basic data: Browse through a + list of all backups, including essential information such as Backup + ID, size and creation date.
  • -
  • See how the size of the backup evolved over time: Visualize the changes in backup sizes - over time through the Recent Backup Timeline chart, helping you understand the growth and - trends in your backup data. +
  • + See how the size of the backup evolved over time: + Visualize the changes in backup sizes over time through the + Recent Backup Timeline chart, helping you + understand the growth and trends in your backup data.
  • -
  • See Recent Backup Size Distribution: Analyze the recent distribution of backup sizes - through the +
  • + See Recent Backup Size Distribution: Analyze the + recent distribution of backup sizes through the Recent Backup Size Distribution chart. +
+

More insights will follow.

@@ -54,8 +63,6 @@

Recent Backup Size Distribution:

- -
@@ -65,7 +72,21 @@

All Backups:

(clrDgRefresh)="refresh($event)" [clrDgLoading]="loading" > - Backup ID + + + Backup ID + + + + + + Size (MB) @@ -165,4 +186,4 @@

All Backups:

-
\ No newline at end of file + diff --git a/apps/frontend/src/app/backups-overview/backups/backups/backups.component.spec.ts b/apps/frontend/src/app/backups-overview/backups/backups/backups.component.spec.ts index 939bea8..fd47ac4 100644 --- a/apps/frontend/src/app/backups-overview/backups/backups/backups.component.spec.ts +++ b/apps/frontend/src/app/backups-overview/backups/backups/backups.component.spec.ts @@ -123,6 +123,7 @@ describe('BackupsComponent', () => { dateFilter.ranges = { fromDate: new Date('2023-01-01').toISOString(), toDate: new Date('2023-12-31').toISOString(), + id: null, fromSizeMB: null, toSizeMB: null, }; @@ -143,6 +144,7 @@ describe('BackupsComponent', () => { toDate: null, fromSizeMB: 100, toSizeMB: 500, + id: null, }; (sizeFilter.ranges as any)['_isActive'] = true; @@ -153,6 +155,24 @@ describe('BackupsComponent', () => { expect(params.fromSizeMB).toBe(sizeFilter.ranges.fromSizeMB); expect(params.toSizeMB).toBe(sizeFilter.ranges.toSizeMB); }); + + it('should build filter params with active id filter', () => { + const idFilter = new CustomFilter('id'); + idFilter.ranges = { + fromDate: null, + toDate: null, + fromSizeMB: null, + toSizeMB: null, + id: '000d88', + }; + (idFilter.ranges as any)['_isActive'] = true; + + component['backupIdFilter'] = idFilter; + + const params = component['buildFilterParams'](); + + expect(params.id).toBe(idFilter.ranges.id); + }); }); describe('Lifecycle Hooks', () => { diff --git a/apps/frontend/src/app/backups-overview/backups/backups/backups.component.ts b/apps/frontend/src/app/backups-overview/backups/backups/backups.component.ts index 1dd0d31..c225fc9 100644 --- a/apps/frontend/src/app/backups-overview/backups/backups/backups.component.ts +++ b/apps/frontend/src/app/backups-overview/backups/backups/backups.component.ts @@ -50,6 +50,7 @@ export class BackupsComponent implements AfterViewInit, OnDestroy, OnInit { pageSize = 10; backupSizeFilter: CustomFilter; backupDateFilter: CustomFilter; + backupIdFilter: CustomFilter; readonly backups$: Observable>; readonly chartBackups$: Observable>; @@ -65,6 +66,7 @@ export class BackupsComponent implements AfterViewInit, OnDestroy, OnInit { ) { this.backupSizeFilter = new CustomFilter('size'); this.backupDateFilter = new CustomFilter('date'); + this.backupIdFilter = new CustomFilter('id'); this.backups$ = this.filterOptions$.pipe( switchMap((params) => this.backupService.getAllBackups(params)), @@ -108,6 +110,7 @@ export class BackupsComponent implements AfterViewInit, OnDestroy, OnInit { combineLatest([ this.backupDateFilter.changes.pipe(startWith(null)), this.backupSizeFilter.changes.pipe(startWith(null)), + this.backupIdFilter.changes.pipe(startWith(null)), ]) .pipe( map(() => this.buildFilterParams()), @@ -169,6 +172,10 @@ export class BackupsComponent implements AfterViewInit, OnDestroy, OnInit { params.toSizeMB = this.backupSizeFilter.ranges.toSizeMB; } + if (this.backupIdFilter.isActive()) { + params.id = this.backupIdFilter.ranges.id; + } + return params; } diff --git a/apps/frontend/src/app/management/components/settings/notification-settings/notification-settings.component.spec.ts b/apps/frontend/src/app/management/components/settings/notification-settings/notification-settings.component.spec.ts index 45deac9..eff61e4 100644 --- a/apps/frontend/src/app/management/components/settings/notification-settings/notification-settings.component.spec.ts +++ b/apps/frontend/src/app/management/components/settings/notification-settings/notification-settings.component.spec.ts @@ -4,6 +4,7 @@ import { of, throwError } from 'rxjs'; import { NotificationSettingsComponent } from './notification-settings.component'; import { NotificationService } from '../../../services/notification.service'; +import { mock } from 'node:test'; describe('NotificationSettingsComponent', () => { let component: NotificationSettingsComponent; @@ -11,6 +12,11 @@ describe('NotificationSettingsComponent', () => { getNotificationSettings: ReturnType; updateNotificationSettings: ReturnType; }; + let mockAlertService: { + getAllAlerts: ReturnType; + refreshAlerts: ReturnType; + getRefreshObservable: ReturnType; + }; let mockFormBuilder: FormBuilder; const mockNotificationSettings = [ @@ -28,11 +34,17 @@ describe('NotificationSettingsComponent', () => { getNotificationSettings: vi.fn(), updateNotificationSettings: vi.fn(), }; + mockAlertService = { + getAllAlerts: vi.fn(), + refreshAlerts: vi.fn(), + getRefreshObservable: vi.fn(), + }; mockFormBuilder = new FormBuilder(); component = new NotificationSettingsComponent( mockNotificationService as any, + mockAlertService as any, mockFormBuilder ); }); diff --git a/apps/frontend/src/app/management/services/notification.service.spec.ts b/apps/frontend/src/app/management/services/notification.service.spec.ts index f71d05e..a5d8461 100644 --- a/apps/frontend/src/app/management/services/notification.service.spec.ts +++ b/apps/frontend/src/app/management/services/notification.service.spec.ts @@ -2,7 +2,8 @@ import { describe, it, expect, beforeEach, vi } from 'vitest'; import { HttpClient } from '@angular/common/http'; import { NotificationService } from './notification.service'; import { of } from 'rxjs'; -import { NotificationSettings } from '../../shared/types/notifications'; +import { AlertType } from '../../shared/types/alertType'; +import { SeverityType } from '../../shared/enums/severityType'; describe('NotificationService', () => { let service: NotificationService; @@ -49,11 +50,11 @@ describe('NotificationService', () => { // Unit Tests for updateNotificationSettings describe('updateNotificationSettings', () => { it('should activate user notifications', async () => { - const mockNotification: NotificationSettings = { + const mockNotification: AlertType = { id: '1', user_active: true, name: 'Email Notifications', - severity: '', + severity: SeverityType.INFO, master_active: false, }; @@ -64,18 +65,18 @@ describe('NotificationService', () => { .toPromise(); expect(httpClientMock.patch).toHaveBeenCalledWith( - `${mockBaseUrl}/alerting/type/1/activate/user`, - { params: mockNotification } + `${mockBaseUrl}/alerting/type/1/user`, + { status: mockNotification.user_active } ); expect(result).toEqual(mockNotification); }); it('should deactivate user notifications', async () => { - const mockNotification: NotificationSettings = { + const mockNotification: AlertType = { id: '1', user_active: false, name: 'Email Notifications', - severity: '', + severity: SeverityType.WARNING, master_active: false, }; @@ -86,8 +87,8 @@ describe('NotificationService', () => { .toPromise(); expect(httpClientMock.patch).toHaveBeenCalledWith( - `${mockBaseUrl}/alerting/type/1/deactivate/user`, - { params: mockNotification } + `${mockBaseUrl}/alerting/type/1/user`, + { status: mockNotification.user_active } ); expect(result).toEqual(mockNotification); }); @@ -102,7 +103,7 @@ describe('NotificationService', () => { id: '1', user_active: false, name: 'Email Notifications', - severity: '', + severity: SeverityType.WARNING, master_active: false, }, ]; @@ -115,7 +116,7 @@ describe('NotificationService', () => { expect(fetchedSettings).toEqual(initialSettings); // Update settings - const updatedNotification: NotificationSettings = { + const updatedNotification: AlertType = { ...initialSettings[0], user_active: true, }; diff --git a/apps/frontend/src/app/shared/types/backup-filter-type.ts b/apps/frontend/src/app/shared/types/backup-filter-type.ts index eb10a96..82d3b14 100644 --- a/apps/frontend/src/app/shared/types/backup-filter-type.ts +++ b/apps/frontend/src/app/shared/types/backup-filter-type.ts @@ -7,4 +7,5 @@ export type BackupFilterParams = { toDate?: string | null; fromSizeMB?: number | null; toSizeMB?: number | null; + id?: string | null; };