From 9a70d02fb27cb7a09ce86cad80c944bb78c8e1db Mon Sep 17 00:00:00 2001 From: Christoph Klingenberg Date: Wed, 11 Dec 2024 21:09:27 +0100 Subject: [PATCH 01/25] initial email receiver component Signed-off-by: Christoph Klingenberg --- .../email-receiver-settings.component.css | 0 .../email-receiver-settings.component.html | 108 ++++++++++++++++++ .../email-receiver-settings.component.spec.ts | 23 ++++ .../email-receiver-settings.component.ts | 86 ++++++++++++++ 4 files changed, 217 insertions(+) create mode 100644 apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.css create mode 100644 apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html create mode 100644 apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.spec.ts create mode 100644 apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.ts diff --git a/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.css b/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.css new file mode 100644 index 00000000..e69de29b diff --git a/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html b/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html new file mode 100644 index 00000000..7b78e132 --- /dev/null +++ b/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html @@ -0,0 +1,108 @@ + + +

Email Alert Recipients

+ +
+ + +
+ +
+
+

All Backups:

+ + + + + Email + + + + + + + + + + + + ID + + + + + + + + + + We couldn't find any backups! + + {{ email.mail }} + {{ email.id }} + + + + + + + +
+ + + + + + + + + + + + diff --git a/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.spec.ts b/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.spec.ts new file mode 100644 index 00000000..e34aab05 --- /dev/null +++ b/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EmailReceiverSettingsComponent } from './email-receiver-settings.component'; + +describe('EmailReceiverSettingsComponent', () => { + let component: EmailReceiverSettingsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [EmailReceiverSettingsComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(EmailReceiverSettingsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.ts b/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.ts new file mode 100644 index 00000000..af9c593f --- /dev/null +++ b/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.ts @@ -0,0 +1,86 @@ +import { Component } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { EmailType } from 'apps/frontend/src/app/shared/types/email'; +import { BehaviorSubject, Observable, Subject, takeUntil } from 'rxjs'; +import { EmailReceiverService } from '../../../services/email/email-receiver.service'; +import { CustomEmailFilter } from './emailfilter'; + +@Component({ + selector: 'app-email-receiver-settings', + templateUrl: './email-receiver-settings.component.html', + styleUrl: './email-receiver-settings.component.css', +}) +export class EmailReceiverSettingsComponent { + isLoading = false; + emailForm: FormGroup; + showEmailModal = false; + + protected emailsSubject$ = new BehaviorSubject([]); + private readonly destroy$ = new Subject(); + + protected emailFilter: CustomEmailFilter; + protected emailIdFilter: CustomEmailFilter; + + constructor( + private fb: FormBuilder, + private emailService: EmailReceiverService + ) { + this.emailFilter = new CustomEmailFilter('mail'); + this.emailIdFilter = new CustomEmailFilter('id'); + + this.emailForm = this.fb.group({ + email: ['', [Validators.required, Validators.email]], + }); + } + + ngOnInit() { + this.loadEmailReceiver(); + } + + loadEmailReceiver(): void { + this.isLoading = true; + this.emailService + .getAllEmails() + .pipe(takeUntil(this.destroy$)) + .subscribe({ + next: (emails) => { + console.log(emails); + this.emailsSubject$.next(emails); + this.isLoading = false; + }, + + error: (error) => (this.isLoading = false), + }); + } + + addEmail() { + if (this.emailForm.valid) { + // hier muss ich die communication mit backend einbauen. wiederhole eingabe, + //wenn email bereits in Liste vorhanden, oder die eingabe keine korrekte email ist + this.isLoading = true; + const newEmail = { + email: this.emailForm.get('email')?.value, + }; + + const currentEmails = this.emailsSubject$.getValue(); + + //this.emailsSubject$.next([...currentEmails, newEmail]); + this.emailForm.reset(); + this.showEmailModal = false; + } + } + + removeEmail(emailToRemove: EmailType) { + this.emailService.deleteEmail(emailToRemove); + /* this.emailsSubject$.next( + currentEmails.filter((email) => email.id !== emailToRemove.id) + ); */ + } + + saveChanges() {} + + ngOnDestroy() { + this.destroy$.next(); + this.destroy$.complete(); + } +} From 5b24a153c608475e293a639900e8315a1cfeef33 Mon Sep 17 00:00:00 2001 From: Christoph Klingenberg Date: Wed, 11 Dec 2024 21:09:56 +0100 Subject: [PATCH 02/25] navigate to email settings Signed-off-by: Christoph Klingenberg --- apps/frontend/src/app/app.component.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/frontend/src/app/app.component.html b/apps/frontend/src/app/app.component.html index 0543c1c3..ad71637e 100644 --- a/apps/frontend/src/app/app.component.html +++ b/apps/frontend/src/app/app.component.html @@ -12,6 +12,15 @@ Notifications + From 3638bdd7b911dec87546c0927fa33e6e10eb3ed5 Mon Sep 17 00:00:00 2001 From: Christoph Klingenberg Date: Wed, 11 Dec 2024 21:10:25 +0100 Subject: [PATCH 03/25] add email type Signed-off-by: Christoph Klingenberg --- apps/frontend/src/app/shared/types/email.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 apps/frontend/src/app/shared/types/email.ts diff --git a/apps/frontend/src/app/shared/types/email.ts b/apps/frontend/src/app/shared/types/email.ts new file mode 100644 index 00000000..afa5120a --- /dev/null +++ b/apps/frontend/src/app/shared/types/email.ts @@ -0,0 +1,4 @@ +export interface EmailType { + id: string; + mail: string; +} \ No newline at end of file From 499b5d906520682d880d04d7ce5860a26242db8a Mon Sep 17 00:00:00 2001 From: Christoph Klingenberg Date: Wed, 11 Dec 2024 21:10:58 +0100 Subject: [PATCH 04/25] navigate to email settings Signed-off-by: Christoph Klingenberg --- apps/frontend/src/app/app.routes.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/frontend/src/app/app.routes.ts b/apps/frontend/src/app/app.routes.ts index 20cccd76..3ffd76f8 100644 --- a/apps/frontend/src/app/app.routes.ts +++ b/apps/frontend/src/app/app.routes.ts @@ -3,9 +3,12 @@ import { TestUploadComponent } from './test-upload/component/test-upload/test-up import { FindTestDataComponent } from './test-upload/component/find-test-data/find-test-data.component'; import { BackupsComponent } from './backups-overview/backups/backups/backups.component'; import { AlertComponent } from './alert/component/alert.component'; +import { EmailReceiverSettingsComponent } from './management/components/settings/email-receiver-settings/email-receiver-settings.component'; export const appRoutes: Route[] = [ { path: 'upload', component: TestUploadComponent }, { path: 'findData', component: FindTestDataComponent }, + { path: 'email-receiver', component: EmailReceiverSettingsComponent}, { path: '', component: BackupsComponent }, + ]; From 5013600812979830ada5db60767aebbb6107ec51 Mon Sep 17 00:00:00 2001 From: Christoph Klingenberg Date: Wed, 11 Dec 2024 21:11:16 +0100 Subject: [PATCH 05/25] include more clarity icons Signed-off-by: Christoph Klingenberg --- apps/frontend/src/app/app.module.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/frontend/src/app/app.module.ts b/apps/frontend/src/app/app.module.ts index edcee333..0ac98e73 100644 --- a/apps/frontend/src/app/app.module.ts +++ b/apps/frontend/src/app/app.module.ts @@ -23,6 +23,10 @@ import { tagIcon, dataClusterIcon, filterIcon, + envelopeIcon, + plusIcon, + lockIcon, + trashIcon, } from '@cds/core/icon'; import { NgxEchartsModule } from 'ngx-echarts'; import { TestUploadComponent } from './test-upload/component/test-upload/test-upload.component'; @@ -31,6 +35,7 @@ import { BackupsComponent } from './backups-overview/backups/backups/backups.com import { BASE_URL } from './shared/types/configuration'; import { AlertComponent } from './alert/component/alert.component'; import { NotificationSettingsComponent } from './management/components/settings/notification-settings/notification-settings.component'; +import { EmailReceiverSettingsComponent } from './management/components/settings/email-receiver-settings/email-receiver-settings.component'; @NgModule({ declarations: [ @@ -40,6 +45,7 @@ import { NotificationSettingsComponent } from './management/components/settings/ BackupsComponent, AlertComponent, NotificationSettingsComponent, + EmailReceiverSettingsComponent, ], imports: [ BrowserModule, @@ -69,7 +75,11 @@ export class AppModule { angleIcon, tagIcon, dataClusterIcon, - filterIcon + filterIcon, + envelopeIcon, + plusIcon, + lockIcon, + trashIcon, ); } } From 6705502ad58f18ea3c88274f9d7f263729bb3dfe Mon Sep 17 00:00:00 2001 From: Christoph Klingenberg Date: Wed, 11 Dec 2024 21:59:40 +0100 Subject: [PATCH 06/25] edit email receiver view Signed-off-by: Christoph Klingenberg --- .../email-receiver-settings.component.html | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html b/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html index 7b78e132..eefbb624 100644 --- a/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html +++ b/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html @@ -1,27 +1,29 @@ - -

Email Alert Recipients

- -
- - -
-
-

All Backups:

+ +
+ + +
+
- + Email @@ -46,7 +48,7 @@

All Backups:

@@ -55,25 +57,20 @@

All Backups:

- We couldn't find any backups! - + We couldn't find any emails! + {{ email.mail }} {{ email.id }} - - - - +
+
- - - - - - - - - Email - - - - - - - - + Email We couldn't find any emails! Date: Tue, 17 Dec 2024 17:00:21 +0100 Subject: [PATCH 25/25] remove filter Signed-off-by: Christoph Klingenberg --- .../email-receiver-settings.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html b/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html index 09dc125d..78349d8d 100644 --- a/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html +++ b/apps/frontend/src/app/management/components/settings/email-receiver-settings/email-receiver-settings.component.html @@ -28,7 +28,7 @@

Email Alert Recipients

- Email + Email We couldn't find any emails!