fix contact support UI

This commit is contained in:
amentis 2024-01-05 11:34:21 +02:00
parent c9640bcb54
commit a3fb03b41b
10 changed files with 70 additions and 18 deletions

View File

@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simple Transactional Email</title>
</head>
<body class="">
{description}
<br/>
<br/>
Send by user: {email}
</body>
</html>

View File

@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simple Transactional Email</title>
</head>
<body class="">
{description}
<br/>
<br/>
Send by user: {email}
</body>
</html>

View File

@ -227,7 +227,7 @@ const appRoutes: Routes = [
loadChildren: () => import('./ui/supportive-material-editor/supportive-material-editor.module').then(m => m.SupportiveMaterialEditorModule), loadChildren: () => import('./ui/supportive-material-editor/supportive-material-editor.module').then(m => m.SupportiveMaterialEditorModule),
data: { data: {
authContext: { authContext: {
permissions: [AppPermission.ViewLanguagePage] permissions: [AppPermission.ViewSupportiveMaterialPage]
}, },
...BreadcrumbService.generateRouteDataConfiguration({ ...BreadcrumbService.generateRouteDataConfiguration({
title: 'GENERAL.TITLES.SUPPORTIVE-MATERIAL' title: 'GENERAL.TITLES.SUPPORTIVE-MATERIAL'

View File

@ -1,17 +1,24 @@
import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
export interface ContactEmail { export interface ContactSupportPersist{
subject: string; subject: string,
description: string; description: string;
} }
export class ContactEmailFormModel { export interface PublicContactSupportPersist{
fullName: string,
email: string,
affiliation: string;
message: string
}
export class ContactEmailFormModel implements ContactSupportPersist{
subject: string; subject: string;
description: string; description: string;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
fromModel(item: ContactEmail): ContactEmailFormModel { fromModel(item: ContactSupportPersist): ContactEmailFormModel {
this.subject = item.subject; this.subject = item.subject;
this.description = item.description; this.description = item.description;
return this; return this;

View File

@ -1,20 +1,33 @@
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { Observable } from "rxjs"; import { Observable, throwError } from "rxjs";
import { ContactEmail } from "../../model/contact/contact-email-form-model"; import { ContactSupportPersist, PublicContactSupportPersist } from "../../model/contact/contact-support-form-model";
import { ConfigurationService } from '../configuration/configuration.service'; import { ConfigurationService } from '../configuration/configuration.service';
import { BaseHttpV2Service } from "../http/base-http-v2.service"; import { BaseHttpV2Service } from "../http/base-http-v2.service";
import { catchError } from "rxjs/operators";
@Injectable() @Injectable()
export class ContactSupportService { export class ContactSupportService {
private actionUrl: string;
constructor(private http: BaseHttpV2Service, constructor(private http: BaseHttpV2Service, private configurationService: ConfigurationService) {
private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'contactEmail/';
} }
postEmail(contentEmail: ContactEmail): Observable<ContactEmail> { private get apiBase(): string { return `${this.configurationService.server}contact-support`; }
return this.http.post<ContactEmail>(this.actionUrl, contentEmail);
send(item: ContactSupportPersist): Observable<ContactSupportPersist> {
const url = `${this.apiBase}/send`;
return this.http
.post<ContactSupportPersist>(url, item).pipe(
catchError((error: any) => throwError(error)));
} }
sendPublic(item: PublicContactSupportPersist): Observable<PublicContactSupportPersist> {
const url = `${this.apiBase}/public/send`;
return this.http
.post<PublicContactSupportPersist>(url, item).pipe(
catchError((error: any) => throwError(error)));
}
} }

View File

@ -15,7 +15,8 @@
<mat-error *ngIf="formGroup.get('subject').hasError('required')"> <mat-error *ngIf="formGroup.get('subject').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> {{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div>
<div class="col-md-12">
<mat-form-field class="full-width"> <mat-form-field class="full-width">
<textarea matInput placeholder="{{'CONTACT.SUPPORT.DESCRIPTION' | translate}}" type="text" name="description" formControlName="description" required></textarea> <textarea matInput placeholder="{{'CONTACT.SUPPORT.DESCRIPTION' | translate}}" type="text" name="description" formControlName="description" required></textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')"> <mat-error *ngIf="formGroup.get('description').hasError('backendError')">

View File

@ -1,7 +1,7 @@
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { AbstractControl, FormArray, FormControl, UntypedFormGroup } from '@angular/forms'; 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 { ContactSupportService } from '@app/core/services/contact-support/contact-support.service';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { BaseComponent } from '@common/base/base.component'; import { BaseComponent } from '@common/base/base.component';
@ -51,7 +51,8 @@ export class ContactContentComponent extends BaseComponent implements OnInit {
} }
send() { 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)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackSuccess(),

View File

@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms'; import { UntypedFormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router'; 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 { ContactSupportService } from '@app/core/services/contact-support/contact-support.service';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { ContactDialogComponent } from '@app/ui/contact/contact-dialog/contact-dialog.component'; 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 => { dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => {
if (data) { if (data) {
this.contactSupportService.postEmail(data.value) this.contactSupportService.send(data.value)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackSuccess(),