From a3fb03b41bf22eae3bd5bc9a3b8ff068c13ecab1 Mon Sep 17 00:00:00 2001 From: amentis Date: Fri, 5 Jan 2024 11:34:21 +0200 Subject: [PATCH] fix contact support UI --- .../contactsupport/email/body.en.html | 14 +++++++++ .../contactsupport/email/subject.en.txt | 1 + .../publiccontactsupport/email/body.en.html | 14 +++++++++ .../publiccontactsupport/email/subject.en.txt | 1 + dmp-frontend/src/app/app-routing.module.ts | 2 +- ...model.ts => contact-support-form-model.ts} | 15 +++++++--- .../contact-support.service.ts | 29 ++++++++++++++----- .../contact-content.component.html | 3 +- .../contact-content.component.ts | 5 ++-- .../sidebar-footer.component.ts | 4 +-- 10 files changed, 70 insertions(+), 18 deletions(-) create mode 100644 dmp-backend/notification-service/notification-web/target/classes/notification_templates/contactsupport/email/body.en.html create mode 100644 dmp-backend/notification-service/notification-web/target/classes/notification_templates/contactsupport/email/subject.en.txt create mode 100644 dmp-backend/notification-service/notification-web/target/classes/notification_templates/publiccontactsupport/email/body.en.html create mode 100644 dmp-backend/notification-service/notification-web/target/classes/notification_templates/publiccontactsupport/email/subject.en.txt rename dmp-frontend/src/app/core/model/contact/{contact-email-form-model.ts => contact-support-form-model.ts} (67%) diff --git a/dmp-backend/notification-service/notification-web/target/classes/notification_templates/contactsupport/email/body.en.html b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/contactsupport/email/body.en.html new file mode 100644 index 000000000..b7607774e --- /dev/null +++ b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/contactsupport/email/body.en.html @@ -0,0 +1,14 @@ + + + + + + Simple Transactional Email + + +{description} +
+
+Send by user: {email} + + \ No newline at end of file diff --git a/dmp-backend/notification-service/notification-web/target/classes/notification_templates/contactsupport/email/subject.en.txt b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/contactsupport/email/subject.en.txt new file mode 100644 index 000000000..052f2db8c --- /dev/null +++ b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/contactsupport/email/subject.en.txt @@ -0,0 +1 @@ +ARGOS - {subject} \ No newline at end of file diff --git a/dmp-backend/notification-service/notification-web/target/classes/notification_templates/publiccontactsupport/email/body.en.html b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/publiccontactsupport/email/body.en.html new file mode 100644 index 000000000..b7607774e --- /dev/null +++ b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/publiccontactsupport/email/body.en.html @@ -0,0 +1,14 @@ + + + + + + Simple Transactional Email + + +{description} +
+
+Send by user: {email} + + \ No newline at end of file diff --git a/dmp-backend/notification-service/notification-web/target/classes/notification_templates/publiccontactsupport/email/subject.en.txt b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/publiccontactsupport/email/subject.en.txt new file mode 100644 index 000000000..052f2db8c --- /dev/null +++ b/dmp-backend/notification-service/notification-web/target/classes/notification_templates/publiccontactsupport/email/subject.en.txt @@ -0,0 +1 @@ +ARGOS - {subject} \ No newline at end of file diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index 9857bb448..797d49a70 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -227,7 +227,7 @@ const appRoutes: Routes = [ loadChildren: () => import('./ui/supportive-material-editor/supportive-material-editor.module').then(m => m.SupportiveMaterialEditorModule), data: { authContext: { - permissions: [AppPermission.ViewLanguagePage] + permissions: [AppPermission.ViewSupportiveMaterialPage] }, ...BreadcrumbService.generateRouteDataConfiguration({ title: 'GENERAL.TITLES.SUPPORTIVE-MATERIAL' diff --git a/dmp-frontend/src/app/core/model/contact/contact-email-form-model.ts b/dmp-frontend/src/app/core/model/contact/contact-support-form-model.ts similarity index 67% rename from dmp-frontend/src/app/core/model/contact/contact-email-form-model.ts rename to dmp-frontend/src/app/core/model/contact/contact-support-form-model.ts index 00cace99b..10c76e52d 100644 --- a/dmp-frontend/src/app/core/model/contact/contact-email-form-model.ts +++ b/dmp-frontend/src/app/core/model/contact/contact-support-form-model.ts @@ -1,17 +1,24 @@ import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -export interface ContactEmail { - subject: string; +export interface ContactSupportPersist{ + subject: string, description: string; } -export class ContactEmailFormModel { +export interface PublicContactSupportPersist{ + fullName: string, + email: string, + affiliation: string; + message: string +} + +export class ContactEmailFormModel implements ContactSupportPersist{ subject: string; description: string; public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); - fromModel(item: ContactEmail): ContactEmailFormModel { + fromModel(item: ContactSupportPersist): ContactEmailFormModel { this.subject = item.subject; this.description = item.description; return this; diff --git a/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts b/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts index 9105f77b4..3c4f7e246 100644 --- a/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts +++ b/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts @@ -1,20 +1,33 @@ import { Injectable } from "@angular/core"; -import { Observable } from "rxjs"; -import { ContactEmail } from "../../model/contact/contact-email-form-model"; +import { Observable, throwError } from "rxjs"; +import { ContactSupportPersist, PublicContactSupportPersist } from "../../model/contact/contact-support-form-model"; import { ConfigurationService } from '../configuration/configuration.service'; import { BaseHttpV2Service } from "../http/base-http-v2.service"; +import { catchError } from "rxjs/operators"; @Injectable() export class ContactSupportService { - private actionUrl: string; - constructor(private http: BaseHttpV2Service, - private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'contactEmail/'; + constructor(private http: BaseHttpV2Service, private configurationService: ConfigurationService) { } - postEmail(contentEmail: ContactEmail): Observable { - return this.http.post(this.actionUrl, contentEmail); + private get apiBase(): string { return `${this.configurationService.server}contact-support`; } + + send(item: ContactSupportPersist): Observable { + const url = `${this.apiBase}/send`; + + return this.http + .post(url, item).pipe( + catchError((error: any) => throwError(error))); } + + sendPublic(item: PublicContactSupportPersist): Observable { + const url = `${this.apiBase}/public/send`; + + return this.http + .post(url, item).pipe( + catchError((error: any) => throwError(error))); + } + } diff --git a/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.html b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.html index 059ed608b..611c28e7a 100644 --- a/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.html +++ b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.html @@ -15,7 +15,8 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + +
diff --git a/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.ts b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.ts index 71f6531d3..b79641261 100644 --- a/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.ts +++ b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.ts @@ -1,7 +1,7 @@ import { Location } from '@angular/common'; import { Component, Input, OnInit } from '@angular/core'; import { AbstractControl, FormArray, FormControl, UntypedFormGroup } from '@angular/forms'; -import { ContactEmailFormModel } from '@app/core/model/contact/contact-email-form-model'; +import { ContactEmailFormModel, ContactSupportPersist } from '@app/core/model/contact/contact-support-form-model'; import { ContactSupportService } from '@app/core/services/contact-support/contact-support.service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { BaseComponent } from '@common/base/base.component'; @@ -51,7 +51,8 @@ export class ContactContentComponent extends BaseComponent implements OnInit { } send() { - this.contactSupportService.postEmail(this.formGroup.value) + const formData = this.formService.getValue(this.formGroup.getRawValue()) as ContactSupportPersist; + this.contactSupportService.send(formData) .pipe(takeUntil(this._destroyed)) .subscribe( complete => this.onCallbackSuccess(), diff --git a/dmp-frontend/src/app/ui/sidebar/sidebar-footer/sidebar-footer.component.ts b/dmp-frontend/src/app/ui/sidebar/sidebar-footer/sidebar-footer.component.ts index cc159042a..29e0ebdc6 100644 --- a/dmp-frontend/src/app/ui/sidebar/sidebar-footer/sidebar-footer.component.ts +++ b/dmp-frontend/src/app/ui/sidebar/sidebar-footer/sidebar-footer.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { UntypedFormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; -import { ContactEmailFormModel } from '@app/core/model/contact/contact-email-form-model'; +import { ContactEmailFormModel } from '@app/core/model/contact/contact-support-form-model'; import { ContactSupportService } from '@app/core/services/contact-support/contact-support.service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { ContactDialogComponent } from '@app/ui/contact/contact-dialog/contact-dialog.component'; @@ -63,7 +63,7 @@ export class SidebarFooterComponent extends BaseComponent implements OnInit { }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => { if (data) { - this.contactSupportService.postEmail(data.value) + this.contactSupportService.send(data.value) .pipe(takeUntil(this._destroyed)) .subscribe( complete => this.onCallbackSuccess(),