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),
data: {
authContext: {
permissions: [AppPermission.ViewLanguagePage]
permissions: [AppPermission.ViewSupportiveMaterialPage]
},
...BreadcrumbService.generateRouteDataConfiguration({
title: 'GENERAL.TITLES.SUPPORTIVE-MATERIAL'

View File

@ -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;

View File

@ -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<ContactEmail> {
return this.http.post<ContactEmail>(this.actionUrl, contentEmail);
private get apiBase(): string { return `${this.configurationService.server}contact-support`; }
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')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-md-12">
<mat-form-field class="full-width">
<textarea matInput placeholder="{{'CONTACT.SUPPORT.DESCRIPTION' | translate}}" type="text" name="description" formControlName="description" required></textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')">

View File

@ -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(),

View File

@ -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(),