@tehw0lf/contact-form 0.0.1 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -4
- package/{esm2015/index.js → esm2020/index.mjs} +0 -0
- package/esm2020/lib/contact-form/contact-form.component.mjs +54 -0
- package/{esm2015/lib/contact-form.module.js → esm2020/lib/contact-form.module.mjs} +5 -5
- package/{esm2015/lib/email-api.service.js → esm2020/lib/email-api.service.mjs} +4 -4
- package/{esm2015/tehw0lf-contact-form.js → esm2020/tehw0lf-contact-form.mjs} +0 -0
- package/fesm2015/tehw0lf-contact-form.mjs +103 -0
- package/fesm2015/tehw0lf-contact-form.mjs.map +1 -0
- package/fesm2020/tehw0lf-contact-form.mjs +103 -0
- package/fesm2020/tehw0lf-contact-form.mjs.map +1 -0
- package/lib/contact-form/contact-form.component.d.ts +2 -1
- package/package.json +38 -10
- package/bundles/tehw0lf-contact-form.umd.js +0 -136
- package/bundles/tehw0lf-contact-form.umd.js.map +0 -1
- package/esm2015/lib/contact-form/contact-form.component.js +0 -56
- package/fesm2015/tehw0lf-contact-form.js +0 -105
- package/fesm2015/tehw0lf-contact-form.js.map +0 -1
package/README.md
CHANGED
|
@@ -5,14 +5,43 @@ The component takes as input an API-URL.
|
|
|
5
5
|
|
|
6
6
|
Default is 'https://forwardmethis.com/tehwolf@pm.me' - please change it, as you will need to confirm the API access for the first email you will receive.
|
|
7
7
|
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
### Peer Dependencies
|
|
11
|
+
|
|
12
|
+
The following dependencies are needed:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
@angular/animations
|
|
16
|
+
@angular/cdk
|
|
17
|
+
@angular/common
|
|
18
|
+
@angular/core
|
|
19
|
+
@angular/flex-layout
|
|
20
|
+
@angular/forms
|
|
21
|
+
@angular/material
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Module
|
|
25
|
+
|
|
26
|
+
If it's not added already, please run `ng add @angular/material` prior to adding this module.
|
|
27
|
+
Run `ng add @tehw0lf/contact-form` in the workspace root of your angular application.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
The contact form component takes an apiURL and an email as input. By default, this is set to [ForwardMeThis](https://forwardmethis.com) and the email address is blank. You can set the variables on the component tag:
|
|
32
|
+
|
|
8
33
|
```html
|
|
9
|
-
<contact-form
|
|
34
|
+
<contact-form
|
|
35
|
+
[apiURL]="emailBackendURL"
|
|
36
|
+
[email]="yourEmailAddress"
|
|
37
|
+
></contact-form>
|
|
10
38
|
```
|
|
11
39
|
|
|
12
|
-
In your component, set the `emailBackendURL`
|
|
40
|
+
In your component, set the `emailBackendURL` and `yourEmailAddress` properties. The naming of these variables is arbitrary:
|
|
13
41
|
|
|
14
42
|
```ts
|
|
15
|
-
emailBackendURL = 'https://forwardmethis.com/
|
|
43
|
+
emailBackendURL = 'https://forwardmethis.com/';
|
|
44
|
+
yourEmailAddress = 'my@mail.com'; //this is optional, if your API URL doesn't require an email address parameter
|
|
16
45
|
```
|
|
17
46
|
|
|
18
47
|
This contact form will send a POST request to the API, containing the following data structure:
|
|
@@ -25,4 +54,41 @@ This contact form will send a POST request to the API, containing the following
|
|
|
25
54
|
}
|
|
26
55
|
```
|
|
27
56
|
|
|
28
|
-
You can of course use your own backend with this data structure, as the API-URL can be overridden as shown above.
|
|
57
|
+
You can of course use your own backend with this data structure, as the API-URL and E-Mail address can be overridden as shown above.
|
|
58
|
+
|
|
59
|
+
## Theming
|
|
60
|
+
|
|
61
|
+
The colors of card background, button and text as well as the backdrop filter can be customized with optional input parameters:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
backgroundColor; //default: 'rgba(34, 34, 34, 0.75)';
|
|
65
|
+
backdropFilter; //default: 'blur(50px)';
|
|
66
|
+
buttonColor; //default: '#cc7832';
|
|
67
|
+
buttonBackgroundColor; //default: ''
|
|
68
|
+
buttonTextColor; //default: '#cc7832';
|
|
69
|
+
labelColor; //default: 'lightgray';
|
|
70
|
+
textColor; //default: 'lightgray';
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Development
|
|
74
|
+
|
|
75
|
+
### Serve
|
|
76
|
+
|
|
77
|
+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
|
|
78
|
+
|
|
79
|
+
### Build
|
|
80
|
+
|
|
81
|
+
Run `ng build contact-form` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build (e.g. when building to publish to npm).
|
|
82
|
+
|
|
83
|
+
### Running unit tests
|
|
84
|
+
|
|
85
|
+
Run `ng test` to execute the unit tests via [Jest](https://jestjs.io).
|
|
86
|
+
|
|
87
|
+
## To Do
|
|
88
|
+
|
|
89
|
+
Apply Material Design
|
|
90
|
+
Extract CSS variables
|
|
91
|
+
|
|
92
|
+
## Contributing
|
|
93
|
+
|
|
94
|
+
Contributions are welcome, although the library is still in an alpha stage. Feel free to open a PR and I'll have a look!
|
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
import { FormBuilder, FormControl, Validators } from '@angular/forms';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
import { takeUntil, tap } from 'rxjs/operators';
|
|
5
|
+
import { EmailApiService } from '../email-api.service';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
import * as i1 from "@angular/forms";
|
|
8
|
+
import * as i2 from "../email-api.service";
|
|
9
|
+
import * as i3 from "@angular/common";
|
|
10
|
+
export class ContactFormComponent {
|
|
11
|
+
constructor(builder, emailService) {
|
|
12
|
+
this.builder = builder;
|
|
13
|
+
this.emailService = emailService;
|
|
14
|
+
this.apiURL = 'https://forwardmethis.com/';
|
|
15
|
+
this.email = '';
|
|
16
|
+
this.emailSent = new Subject();
|
|
17
|
+
this.emailSent$ = this.emailSent.asObservable();
|
|
18
|
+
this.unsubscribe$ = new Subject();
|
|
19
|
+
this.emailSent.next(null);
|
|
20
|
+
this.formGroup = this.builder.group({
|
|
21
|
+
name: new FormControl('', [Validators.required]),
|
|
22
|
+
email: new FormControl('', [Validators.required, Validators.email]),
|
|
23
|
+
message: new FormControl('', [Validators.required])
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
ngOnDestroy() {
|
|
27
|
+
this.unsubscribe$.next();
|
|
28
|
+
this.unsubscribe$.complete();
|
|
29
|
+
}
|
|
30
|
+
submitFormData(formData) {
|
|
31
|
+
this.emailService
|
|
32
|
+
.sendEmail(`${this.apiURL}${this.email}`, formData.value)
|
|
33
|
+
.pipe(tap((response) => {
|
|
34
|
+
if (response === 'OK') {
|
|
35
|
+
this.emailSent.next(true);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.emailSent.next(false);
|
|
39
|
+
}
|
|
40
|
+
}), takeUntil(this.unsubscribe$))
|
|
41
|
+
.subscribe();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
ContactFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormComponent, deps: [{ token: i1.FormBuilder }, { token: i2.EmailApiService }], target: i0.ɵɵFactoryTarget.Component });
|
|
45
|
+
ContactFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.0", type: ContactFormComponent, selector: "contact-form", inputs: { apiURL: "apiURL", email: "email" }, ngImport: i0, template: "<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n", styles: [".contact-form{background-color:#fff;max-width:500px;margin:auto;padding:40px;box-shadow:0 2px 10px #00000013;box-sizing:border-box}.form-button{display:block;border:1px solid #ced4da;border-radius:.25rem;width:96%;padding:.375rem .75rem}.form-control{display:block;width:90%;padding:.375rem .75rem;font-size:1rem;font-weight:400;line-height:1.5;color:#282b2e;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;margin-top:.5rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.form-group{margin-bottom:1rem}.form-status{margin-top:2rem}textarea{overflow:auto;resize:vertical}\n"], directives: [{ type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i3.AsyncPipe } });
|
|
46
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormComponent, decorators: [{
|
|
47
|
+
type: Component,
|
|
48
|
+
args: [{ selector: 'contact-form', template: "<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n", styles: [".contact-form{background-color:#fff;max-width:500px;margin:auto;padding:40px;box-shadow:0 2px 10px #00000013;box-sizing:border-box}.form-button{display:block;border:1px solid #ced4da;border-radius:.25rem;width:96%;padding:.375rem .75rem}.form-control{display:block;width:90%;padding:.375rem .75rem;font-size:1rem;font-weight:400;line-height:1.5;color:#282b2e;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;margin-top:.5rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.form-group{margin-bottom:1rem}.form-status{margin-top:2rem}textarea{overflow:auto;resize:vertical}\n"] }]
|
|
49
|
+
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: i2.EmailApiService }]; }, propDecorators: { apiURL: [{
|
|
50
|
+
type: Input
|
|
51
|
+
}], email: [{
|
|
52
|
+
type: Input
|
|
53
|
+
}] } });
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGFjdC1mb3JtLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29udGFjdC1mb3JtL3NyYy9saWIvY29udGFjdC1mb3JtL2NvbnRhY3QtZm9ybS5jb21wb25lbnQudHMiLCIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvbnRhY3QtZm9ybS9zcmMvbGliL2NvbnRhY3QtZm9ybS9jb250YWN0LWZvcm0uY29tcG9uZW50Lmh0bWwiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxLQUFLLEVBQWEsTUFBTSxlQUFlLENBQUM7QUFDNUQsT0FBTyxFQUFFLFdBQVcsRUFBRSxXQUFXLEVBQWEsVUFBVSxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFDakYsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUMvQixPQUFPLEVBQUUsU0FBUyxFQUFFLEdBQUcsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBRWhELE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQzs7Ozs7QUFRdkQsTUFBTSxPQUFPLG9CQUFvQjtJQVUvQixZQUNVLE9BQW9CLEVBQ3BCLFlBQTZCO1FBRDdCLFlBQU8sR0FBUCxPQUFPLENBQWE7UUFDcEIsaUJBQVksR0FBWixZQUFZLENBQWlCO1FBWDlCLFdBQU0sR0FBRyw0QkFBNEIsQ0FBQztRQUN0QyxVQUFLLEdBQUcsRUFBRSxDQUFDO1FBR3BCLGNB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0+XG4iXX0=
|
|
@@ -7,10 +7,10 @@ import { EmailApiService } from './email-api.service';
|
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
8
8
|
export class ContactFormModule {
|
|
9
9
|
}
|
|
10
|
-
ContactFormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
11
|
-
ContactFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
|
|
12
|
-
ContactFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
13
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
10
|
+
ContactFormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
11
|
+
ContactFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, declarations: [ContactFormComponent], imports: [CommonModule, HttpClientModule, ReactiveFormsModule], exports: [ContactFormComponent] });
|
|
12
|
+
ContactFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, providers: [EmailApiService], imports: [[CommonModule, HttpClientModule, ReactiveFormsModule]] });
|
|
13
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, decorators: [{
|
|
14
14
|
type: NgModule,
|
|
15
15
|
args: [{
|
|
16
16
|
imports: [CommonModule, HttpClientModule, ReactiveFormsModule],
|
|
@@ -19,4 +19,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImpo
|
|
|
19
19
|
providers: [EmailApiService],
|
|
20
20
|
}]
|
|
21
21
|
}] });
|
|
22
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
22
|
+
//# sourceMapping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FTLEVBQUUsQ0FBQyxlQUFlLENBQUM7aUJBQzdCIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQ29tbW9uTW9kdWxlIH0gZnJvbSAnQGFuZ3VsYXIvY29tbW9uJztcbmltcG9ydCB7IEh0dHBDbGllbnRNb2R1bGUgfSBmcm9tICdAYW5ndWxhci9jb21tb24vaHR0cCc7XG5pbXBvcnQgeyBOZ01vZHVsZSB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuaW1wb3J0IHsgUmVhY3RpdmVGb3Jtc01vZHVsZSB9IGZyb20gJ0Bhbmd1bGFyL2Zvcm1zJztcblxuaW1wb3J0IHsgQ29udGFjdEZvcm1Db21wb25lbnQgfSBmcm9tICcuL2NvbnRhY3QtZm9ybS9jb250YWN0LWZvcm0uY29tcG9uZW50JztcbmltcG9ydCB7IEVtYWlsQXBpU2VydmljZSB9IGZyb20gJy4vZW1haWwtYXBpLnNlcnZpY2UnO1xuXG5ATmdNb2R1bGUoe1xuICBpbXBvcnRzOiBbQ29tbW9uTW9kdWxlLCBIdHRwQ2xpZW50TW9kdWxlLCBSZWFjdGl2ZUZvcm1zTW9kdWxlXSxcbiAgZGVjbGFyYXRpb25zOiBbQ29udGFjdEZvcm1Db21wb25lbnRdLFxuICBleHBvcnRzOiBbQ29udGFjdEZvcm1Db21wb25lbnRdLFxuICBwcm92aWRlcnM6IFtFbWFpbEFwaVNlcnZpY2VdLFxufSlcbmV4cG9ydCBjbGFzcyBDb250YWN0Rm9ybU1vZHVsZSB7fVxuIl19
|
|
@@ -21,12 +21,12 @@ export class EmailApiService {
|
|
|
21
21
|
}));
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
EmailApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
25
|
-
EmailApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
26
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
24
|
+
EmailApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: EmailApiService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
25
|
+
EmailApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: EmailApiService, providedIn: 'root' });
|
|
26
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: EmailApiService, decorators: [{
|
|
27
27
|
type: Injectable,
|
|
28
28
|
args: [{
|
|
29
29
|
providedIn: 'root'
|
|
30
30
|
}]
|
|
31
31
|
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW1haWwtYXBpLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9saWJzL2NvbnRhY3QtZm9ybS9zcmMvbGliL2VtYWlsLWFwaS5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsV0FBVyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDL0QsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUMzQyxPQUFPLEVBQWMsRUFBRSxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBQ3RDLE9BQU8sRUFBRSxVQUFVLEVBQUUsR0FBRyxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7OztBQUtqRCxNQUFNLE9BQU8sZUFBZTtJQU0xQixZQUFvQixJQUFnQjtRQUFoQixTQUFJLEdBQUosSUFBSSxDQUFZO1FBTHBDLGdCQUFXLEdBQUc7WUF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WFpbEFwaVNlcnZpY2Uge1xuICBodHRwT3B0aW9ucyA9IHtcbiAgICBoZWFkZXJzOiBuZXcgSHR0cEhlYWRlcnMoe1xuICAgICAgJ0NvbnRlbnQtVHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJ1xuICAgIH0pXG4gIH07XG4gIGNvbnN0cnVjdG9yKHByaXZhdGUgaHR0cDogSHR0cENsaWVudCkge31cblxuICBzZW5kRW1haWwoYXBpVVJMOiBzdHJpbmcsIGRhdGE6IGFueSk6IE9ic2VydmFibGU8YW55PiB7XG4gICAgcmV0dXJuIHRoaXMuaHR0cC5wb3N0KGFwaVVSTCwgSlNPTi5zdHJpbmdpZnkoZGF0YSksIHRoaXMuaHR0cE9wdGlvbnMpLnBpcGUoXG4gICAgICBtYXAoKHJlc3BvbnNlOiBhbnkpID0+IHtcbiAgICAgICAgcmV0dXJuIHJlc3BvbnNlO1xuICAgICAgfSksXG4gICAgICBjYXRjaEVycm9yKChlcnJvcjogYW55KSA9PiB7XG4gICAgICAgIHJldHVybiBvZihlcnJvci5zdGF0dXNUZXh0KTtcbiAgICAgIH0pXG4gICAgKTtcbiAgfVxufVxuIl19
|
|
File without changes
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as i3 from '@angular/common';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import * as i1 from '@angular/common/http';
|
|
4
|
+
import { HttpHeaders, HttpClientModule } from '@angular/common/http';
|
|
5
|
+
import * as i0 from '@angular/core';
|
|
6
|
+
import { Injectable, Component, Input, NgModule } from '@angular/core';
|
|
7
|
+
import * as i1$1 from '@angular/forms';
|
|
8
|
+
import { FormControl, Validators, ReactiveFormsModule } from '@angular/forms';
|
|
9
|
+
import { of, Subject } from 'rxjs';
|
|
10
|
+
import { map, catchError, tap, takeUntil } from 'rxjs/operators';
|
|
11
|
+
|
|
12
|
+
class EmailApiService {
|
|
13
|
+
constructor(http) {
|
|
14
|
+
this.http = http;
|
|
15
|
+
this.httpOptions = {
|
|
16
|
+
headers: new HttpHeaders({
|
|
17
|
+
'Content-Type': 'application/json'
|
|
18
|
+
})
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
sendEmail(apiURL, data) {
|
|
22
|
+
return this.http.post(apiURL, JSON.stringify(data), this.httpOptions).pipe(map((response) => {
|
|
23
|
+
return response;
|
|
24
|
+
}), catchError((error) => {
|
|
25
|
+
return of(error.statusText);
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
EmailApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: EmailApiService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
30
|
+
EmailApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: EmailApiService, providedIn: 'root' });
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: EmailApiService, decorators: [{
|
|
32
|
+
type: Injectable,
|
|
33
|
+
args: [{
|
|
34
|
+
providedIn: 'root'
|
|
35
|
+
}]
|
|
36
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
|
|
37
|
+
|
|
38
|
+
class ContactFormComponent {
|
|
39
|
+
constructor(builder, emailService) {
|
|
40
|
+
this.builder = builder;
|
|
41
|
+
this.emailService = emailService;
|
|
42
|
+
this.apiURL = 'https://forwardmethis.com/';
|
|
43
|
+
this.email = '';
|
|
44
|
+
this.emailSent = new Subject();
|
|
45
|
+
this.emailSent$ = this.emailSent.asObservable();
|
|
46
|
+
this.unsubscribe$ = new Subject();
|
|
47
|
+
this.emailSent.next(null);
|
|
48
|
+
this.formGroup = this.builder.group({
|
|
49
|
+
name: new FormControl('', [Validators.required]),
|
|
50
|
+
email: new FormControl('', [Validators.required, Validators.email]),
|
|
51
|
+
message: new FormControl('', [Validators.required])
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
ngOnDestroy() {
|
|
55
|
+
this.unsubscribe$.next();
|
|
56
|
+
this.unsubscribe$.complete();
|
|
57
|
+
}
|
|
58
|
+
submitFormData(formData) {
|
|
59
|
+
this.emailService
|
|
60
|
+
.sendEmail(`${this.apiURL}${this.email}`, formData.value)
|
|
61
|
+
.pipe(tap((response) => {
|
|
62
|
+
if (response === 'OK') {
|
|
63
|
+
this.emailSent.next(true);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.emailSent.next(false);
|
|
67
|
+
}
|
|
68
|
+
}), takeUntil(this.unsubscribe$))
|
|
69
|
+
.subscribe();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
ContactFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormComponent, deps: [{ token: i1$1.FormBuilder }, { token: EmailApiService }], target: i0.ɵɵFactoryTarget.Component });
|
|
73
|
+
ContactFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.0", type: ContactFormComponent, selector: "contact-form", inputs: { apiURL: "apiURL", email: "email" }, ngImport: i0, template: "<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n", styles: [".contact-form{background-color:#fff;max-width:500px;margin:auto;padding:40px;box-shadow:0 2px 10px #00000013;box-sizing:border-box}.form-button{display:block;border:1px solid #ced4da;border-radius:.25rem;width:96%;padding:.375rem .75rem}.form-control{display:block;width:90%;padding:.375rem .75rem;font-size:1rem;font-weight:400;line-height:1.5;color:#282b2e;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;margin-top:.5rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.form-group{margin-bottom:1rem}.form-status{margin-top:2rem}textarea{overflow:auto;resize:vertical}\n"], directives: [{ type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i3.AsyncPipe } });
|
|
74
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormComponent, decorators: [{
|
|
75
|
+
type: Component,
|
|
76
|
+
args: [{ selector: 'contact-form', template: "<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n", styles: [".contact-form{background-color:#fff;max-width:500px;margin:auto;padding:40px;box-shadow:0 2px 10px #00000013;box-sizing:border-box}.form-button{display:block;border:1px solid #ced4da;border-radius:.25rem;width:96%;padding:.375rem .75rem}.form-control{display:block;width:90%;padding:.375rem .75rem;font-size:1rem;font-weight:400;line-height:1.5;color:#282b2e;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;margin-top:.5rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.form-group{margin-bottom:1rem}.form-status{margin-top:2rem}textarea{overflow:auto;resize:vertical}\n"] }]
|
|
77
|
+
}], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: EmailApiService }]; }, propDecorators: { apiURL: [{
|
|
78
|
+
type: Input
|
|
79
|
+
}], email: [{
|
|
80
|
+
type: Input
|
|
81
|
+
}] } });
|
|
82
|
+
|
|
83
|
+
class ContactFormModule {
|
|
84
|
+
}
|
|
85
|
+
ContactFormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
86
|
+
ContactFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, declarations: [ContactFormComponent], imports: [CommonModule, HttpClientModule, ReactiveFormsModule], exports: [ContactFormComponent] });
|
|
87
|
+
ContactFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, providers: [EmailApiService], imports: [[CommonModule, HttpClientModule, ReactiveFormsModule]] });
|
|
88
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, decorators: [{
|
|
89
|
+
type: NgModule,
|
|
90
|
+
args: [{
|
|
91
|
+
imports: [CommonModule, HttpClientModule, ReactiveFormsModule],
|
|
92
|
+
declarations: [ContactFormComponent],
|
|
93
|
+
exports: [ContactFormComponent],
|
|
94
|
+
providers: [EmailApiService],
|
|
95
|
+
}]
|
|
96
|
+
}] });
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Generated bundle index. Do not edit.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
export { ContactFormComponent, ContactFormModule };
|
|
103
|
+
//# sourceMappingURL=tehw0lf-contact-form.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tehw0lf-contact-form.mjs","sources":["../../../../libs/contact-form/src/lib/email-api.service.ts","../../../../libs/contact-form/src/lib/contact-form/contact-form.component.ts","../../../../libs/contact-form/src/lib/contact-form/contact-form.component.html","../../../../libs/contact-form/src/lib/contact-form.module.ts","../../../../libs/contact-form/src/tehw0lf-contact-form.ts"],"sourcesContent":["import { HttpClient, HttpHeaders } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Observable, of } from 'rxjs';\nimport { catchError, map } from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class EmailApiService {\n httpOptions = {\n headers: new HttpHeaders({\n 'Content-Type': 'application/json'\n })\n };\n constructor(private http: HttpClient) {}\n\n sendEmail(apiURL: string, data: any): Observable<any> {\n return this.http.post(apiURL, JSON.stringify(data), this.httpOptions).pipe(\n map((response: any) => {\n return response;\n }),\n catchError((error: any) => {\n return of(error.statusText);\n })\n );\n }\n}\n","import { Component, Input, OnDestroy } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';\nimport { Subject } from 'rxjs';\nimport { takeUntil, tap } from 'rxjs/operators';\n\nimport { EmailApiService } from '../email-api.service';\n\n@Component({\n // eslint-disable-next-line @angular-eslint/component-selector\n selector: 'contact-form',\n templateUrl: './contact-form.component.html',\n styleUrls: ['./contact-form.component.scss']\n})\nexport class ContactFormComponent implements OnDestroy {\n @Input() apiURL = 'https://forwardmethis.com/';\n @Input() email = '';\n\n formGroup: FormGroup;\n emailSent: Subject<boolean | null> = new Subject();\n emailSent$ = this.emailSent.asObservable();\n\n private unsubscribe$: Subject<void> = new Subject();\n\n constructor(\n private builder: FormBuilder,\n private emailService: EmailApiService\n ) {\n this.emailSent.next(null);\n this.formGroup = this.builder.group({\n name: new FormControl('', [Validators.required]),\n email: new FormControl('', [Validators.required, Validators.email]),\n message: new FormControl('', [Validators.required])\n });\n }\n\n ngOnDestroy(): void {\n this.unsubscribe$.next();\n this.unsubscribe$.complete();\n }\n\n submitFormData(formData: FormGroup) {\n this.emailService\n .sendEmail(`${this.apiURL}${this.email}`, formData.value)\n .pipe(\n tap((response: string) => {\n if (response === 'OK') {\n this.emailSent.next(true);\n } else {\n this.emailSent.next(false);\n }\n }),\n takeUntil(this.unsubscribe$)\n )\n .subscribe();\n }\n}\n","<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n","import { CommonModule } from '@angular/common';\nimport { HttpClientModule } from '@angular/common/http';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { ContactFormComponent } from './contact-form/contact-form.component';\nimport { EmailApiService } from './email-api.service';\n\n@NgModule({\n imports: [CommonModule, HttpClientModule, ReactiveFormsModule],\n declarations: [ContactFormComponent],\n exports: [ContactFormComponent],\n providers: [EmailApiService],\n})\nexport class ContactFormModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;MAQa,eAAe;IAM1B,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;QALpC,gBAAW,GAAG;YACZ,OAAO,EAAE,IAAI,WAAW,CAAC;gBACvB,cAAc,EAAE,kBAAkB;aACnC,CAAC;SACH,CAAC;KACsC;IAExC,SAAS,CAAC,MAAc,EAAE,IAAS;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC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AY;aACd,SAAS,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC;aACxD,IAAI,CACH,GAAG,CAAC,CAAC,QAAgB;YACnB,IAAI,QAAQ,KAAK,IAAI,EAAE;gBACrB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC3B;iBAAM;gBACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC5B;SACF,CAAC,EACF,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAC7B;aACA,SAAS,EAAE,CAAC;KAChB;;iHAzCU,oBAAoB;qGAApB,oBAAoB,kGCbjC,soCAwCA;2FD3Ba,oBAAoB;kBANhC,SAAS;+BAEE,cAAc;+HAKf,MAAM;sBAAd,KAAK;gBACG,KAAK;sBAAb,KAAK;;;MEDK,iBAAiB;;8GAAjB,iBAAiB;+GAAjB,iBAAiB,iBAJb,oBAAoB,aADzB,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,aAEnD,oBAAoB;+GAGnB,iBAAiB,aAFjB,CAAC,eAAe,CAAC,YAHnB,CAAC,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,CAAC;2FAKnD,iBAAiB;kBAN7B,QAAQ;mBAAC;oBACR,OAAO,EAAE,CAAC,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,CAAC;oBAC9D,YAAY,EAAE,CAAC,oBAAoB,CAAC;oBACpC,OAAO,EAAE,CAAC,oBAAoB,CAAC;oBAC/B,SAAS,EAAE,CAAC,eAAe,CAAC;iBAC7B;;;ACbD;;;;;;"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as i3 from '@angular/common';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import * as i1 from '@angular/common/http';
|
|
4
|
+
import { HttpHeaders, HttpClientModule } from '@angular/common/http';
|
|
5
|
+
import * as i0 from '@angular/core';
|
|
6
|
+
import { Injectable, Component, Input, NgModule } from '@angular/core';
|
|
7
|
+
import * as i1$1 from '@angular/forms';
|
|
8
|
+
import { FormControl, Validators, ReactiveFormsModule } from '@angular/forms';
|
|
9
|
+
import { of, Subject } from 'rxjs';
|
|
10
|
+
import { map, catchError, tap, takeUntil } from 'rxjs/operators';
|
|
11
|
+
|
|
12
|
+
class EmailApiService {
|
|
13
|
+
constructor(http) {
|
|
14
|
+
this.http = http;
|
|
15
|
+
this.httpOptions = {
|
|
16
|
+
headers: new HttpHeaders({
|
|
17
|
+
'Content-Type': 'application/json'
|
|
18
|
+
})
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
sendEmail(apiURL, data) {
|
|
22
|
+
return this.http.post(apiURL, JSON.stringify(data), this.httpOptions).pipe(map((response) => {
|
|
23
|
+
return response;
|
|
24
|
+
}), catchError((error) => {
|
|
25
|
+
return of(error.statusText);
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
EmailApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: EmailApiService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
30
|
+
EmailApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: EmailApiService, providedIn: 'root' });
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: EmailApiService, decorators: [{
|
|
32
|
+
type: Injectable,
|
|
33
|
+
args: [{
|
|
34
|
+
providedIn: 'root'
|
|
35
|
+
}]
|
|
36
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
|
|
37
|
+
|
|
38
|
+
class ContactFormComponent {
|
|
39
|
+
constructor(builder, emailService) {
|
|
40
|
+
this.builder = builder;
|
|
41
|
+
this.emailService = emailService;
|
|
42
|
+
this.apiURL = 'https://forwardmethis.com/';
|
|
43
|
+
this.email = '';
|
|
44
|
+
this.emailSent = new Subject();
|
|
45
|
+
this.emailSent$ = this.emailSent.asObservable();
|
|
46
|
+
this.unsubscribe$ = new Subject();
|
|
47
|
+
this.emailSent.next(null);
|
|
48
|
+
this.formGroup = this.builder.group({
|
|
49
|
+
name: new FormControl('', [Validators.required]),
|
|
50
|
+
email: new FormControl('', [Validators.required, Validators.email]),
|
|
51
|
+
message: new FormControl('', [Validators.required])
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
ngOnDestroy() {
|
|
55
|
+
this.unsubscribe$.next();
|
|
56
|
+
this.unsubscribe$.complete();
|
|
57
|
+
}
|
|
58
|
+
submitFormData(formData) {
|
|
59
|
+
this.emailService
|
|
60
|
+
.sendEmail(`${this.apiURL}${this.email}`, formData.value)
|
|
61
|
+
.pipe(tap((response) => {
|
|
62
|
+
if (response === 'OK') {
|
|
63
|
+
this.emailSent.next(true);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.emailSent.next(false);
|
|
67
|
+
}
|
|
68
|
+
}), takeUntil(this.unsubscribe$))
|
|
69
|
+
.subscribe();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
ContactFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormComponent, deps: [{ token: i1$1.FormBuilder }, { token: EmailApiService }], target: i0.ɵɵFactoryTarget.Component });
|
|
73
|
+
ContactFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.0", type: ContactFormComponent, selector: "contact-form", inputs: { apiURL: "apiURL", email: "email" }, ngImport: i0, template: "<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n", styles: [".contact-form{background-color:#fff;max-width:500px;margin:auto;padding:40px;box-shadow:0 2px 10px #00000013;box-sizing:border-box}.form-button{display:block;border:1px solid #ced4da;border-radius:.25rem;width:96%;padding:.375rem .75rem}.form-control{display:block;width:90%;padding:.375rem .75rem;font-size:1rem;font-weight:400;line-height:1.5;color:#282b2e;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;margin-top:.5rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.form-group{margin-bottom:1rem}.form-status{margin-top:2rem}textarea{overflow:auto;resize:vertical}\n"], directives: [{ type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i3.AsyncPipe } });
|
|
74
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormComponent, decorators: [{
|
|
75
|
+
type: Component,
|
|
76
|
+
args: [{ selector: 'contact-form', template: "<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n", styles: [".contact-form{background-color:#fff;max-width:500px;margin:auto;padding:40px;box-shadow:0 2px 10px #00000013;box-sizing:border-box}.form-button{display:block;border:1px solid #ced4da;border-radius:.25rem;width:96%;padding:.375rem .75rem}.form-control{display:block;width:90%;padding:.375rem .75rem;font-size:1rem;font-weight:400;line-height:1.5;color:#282b2e;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;margin-top:.5rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.form-group{margin-bottom:1rem}.form-status{margin-top:2rem}textarea{overflow:auto;resize:vertical}\n"] }]
|
|
77
|
+
}], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: EmailApiService }]; }, propDecorators: { apiURL: [{
|
|
78
|
+
type: Input
|
|
79
|
+
}], email: [{
|
|
80
|
+
type: Input
|
|
81
|
+
}] } });
|
|
82
|
+
|
|
83
|
+
class ContactFormModule {
|
|
84
|
+
}
|
|
85
|
+
ContactFormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
86
|
+
ContactFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, declarations: [ContactFormComponent], imports: [CommonModule, HttpClientModule, ReactiveFormsModule], exports: [ContactFormComponent] });
|
|
87
|
+
ContactFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, providers: [EmailApiService], imports: [[CommonModule, HttpClientModule, ReactiveFormsModule]] });
|
|
88
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.0", ngImport: i0, type: ContactFormModule, decorators: [{
|
|
89
|
+
type: NgModule,
|
|
90
|
+
args: [{
|
|
91
|
+
imports: [CommonModule, HttpClientModule, ReactiveFormsModule],
|
|
92
|
+
declarations: [ContactFormComponent],
|
|
93
|
+
exports: [ContactFormComponent],
|
|
94
|
+
providers: [EmailApiService],
|
|
95
|
+
}]
|
|
96
|
+
}] });
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Generated bundle index. Do not edit.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
export { ContactFormComponent, ContactFormModule };
|
|
103
|
+
//# sourceMappingURL=tehw0lf-contact-form.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tehw0lf-contact-form.mjs","sources":["../../../../libs/contact-form/src/lib/email-api.service.ts","../../../../libs/contact-form/src/lib/contact-form/contact-form.component.ts","../../../../libs/contact-form/src/lib/contact-form/contact-form.component.html","../../../../libs/contact-form/src/lib/contact-form.module.ts","../../../../libs/contact-form/src/tehw0lf-contact-form.ts"],"sourcesContent":["import { HttpClient, HttpHeaders } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Observable, of } from 'rxjs';\nimport { catchError, map } from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class EmailApiService {\n httpOptions = {\n headers: new HttpHeaders({\n 'Content-Type': 'application/json'\n })\n };\n constructor(private http: HttpClient) {}\n\n sendEmail(apiURL: string, data: any): Observable<any> {\n return this.http.post(apiURL, JSON.stringify(data), this.httpOptions).pipe(\n map((response: any) => {\n return response;\n }),\n catchError((error: any) => {\n return of(error.statusText);\n })\n );\n }\n}\n","import { Component, Input, OnDestroy } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';\nimport { Subject } from 'rxjs';\nimport { takeUntil, tap } from 'rxjs/operators';\n\nimport { EmailApiService } from '../email-api.service';\n\n@Component({\n // eslint-disable-next-line @angular-eslint/component-selector\n selector: 'contact-form',\n templateUrl: './contact-form.component.html',\n styleUrls: ['./contact-form.component.scss']\n})\nexport class ContactFormComponent implements OnDestroy {\n @Input() apiURL = 'https://forwardmethis.com/';\n @Input() email = '';\n\n formGroup: FormGroup;\n emailSent: Subject<boolean | null> = new Subject();\n emailSent$ = this.emailSent.asObservable();\n\n private unsubscribe$: Subject<void> = new Subject();\n\n constructor(\n private builder: FormBuilder,\n private emailService: EmailApiService\n ) {\n this.emailSent.next(null);\n this.formGroup = this.builder.group({\n name: new FormControl('', [Validators.required]),\n email: new FormControl('', [Validators.required, Validators.email]),\n message: new FormControl('', [Validators.required])\n });\n }\n\n ngOnDestroy(): void {\n this.unsubscribe$.next();\n this.unsubscribe$.complete();\n }\n\n submitFormData(formData: FormGroup) {\n this.emailService\n .sendEmail(`${this.apiURL}${this.email}`, formData.value)\n .pipe(\n tap((response: string) => {\n if (response === 'OK') {\n this.emailSent.next(true);\n } else {\n this.emailSent.next(false);\n }\n }),\n takeUntil(this.unsubscribe$)\n )\n .subscribe();\n }\n}\n","<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n","import { CommonModule } from '@angular/common';\nimport { HttpClientModule } from '@angular/common/http';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { ContactFormComponent } from './contact-form/contact-form.component';\nimport { EmailApiService } from './email-api.service';\n\n@NgModule({\n imports: [CommonModule, HttpClientModule, ReactiveFormsModule],\n declarations: [ContactFormComponent],\n exports: [ContactFormComponent],\n providers: [EmailApiService],\n})\nexport class ContactFormModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;MAQa,eAAe;IAM1B,YAAoB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BACpC,OAAO,EAAE,CAAC,oBAAoB,CAAC;oBAC/B,SAAS,EAAE,CAAC,eAAe,CAAC;iBAC7B;;;ACbD;;;;;;"}
|
|
@@ -7,6 +7,7 @@ export declare class ContactFormComponent implements OnDestroy {
|
|
|
7
7
|
private builder;
|
|
8
8
|
private emailService;
|
|
9
9
|
apiURL: string;
|
|
10
|
+
email: string;
|
|
10
11
|
formGroup: FormGroup;
|
|
11
12
|
emailSent: Subject<boolean | null>;
|
|
12
13
|
emailSent$: import("rxjs").Observable<boolean | null>;
|
|
@@ -15,5 +16,5 @@ export declare class ContactFormComponent implements OnDestroy {
|
|
|
15
16
|
ngOnDestroy(): void;
|
|
16
17
|
submitFormData(formData: FormGroup): void;
|
|
17
18
|
static ɵfac: i0.ɵɵFactoryDeclaration<ContactFormComponent, never>;
|
|
18
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ContactFormComponent, "contact-form", never, { "apiURL": "apiURL"; }, {}, never, never>;
|
|
19
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ContactFormComponent, "contact-form", never, { "apiURL": "apiURL"; "email": "email"; }, {}, never, never>;
|
|
19
20
|
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tehw0lf/contact-form",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"homepage": "https://github.com/tehw0lf/tehwol.fi.git",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/tehw0lf/tehwol.fi.git"
|
|
9
|
+
},
|
|
4
10
|
"peerDependencies": {
|
|
5
|
-
"@angular/
|
|
6
|
-
"@angular/
|
|
7
|
-
"@angular/
|
|
8
|
-
"
|
|
11
|
+
"@angular/animations": "^13.1.0",
|
|
12
|
+
"@angular/cdk": "^13.1.0",
|
|
13
|
+
"@angular/common": "^13.1.0",
|
|
14
|
+
"@angular/core": "^13.1.0",
|
|
15
|
+
"@angular/flex-layout": "^13.0.0-beta.36",
|
|
16
|
+
"@angular/forms": "^13.1.0",
|
|
17
|
+
"@angular/material": "^13.1.0",
|
|
18
|
+
"rxjs": "~7.4.0",
|
|
19
|
+
"@angular/platform-browser-dynamic": "13.1.0"
|
|
9
20
|
},
|
|
10
21
|
"dependencies": {
|
|
11
22
|
"tslib": "^2.2.0"
|
|
12
23
|
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
24
|
+
"schematics": "./schematics/collection.json",
|
|
25
|
+
"ng-add": {
|
|
26
|
+
"save": "dependencies"
|
|
27
|
+
},
|
|
28
|
+
"module": "fesm2015/tehw0lf-contact-form.mjs",
|
|
29
|
+
"es2020": "fesm2020/tehw0lf-contact-form.mjs",
|
|
30
|
+
"esm2020": "esm2020/tehw0lf-contact-form.mjs",
|
|
31
|
+
"fesm2020": "fesm2020/tehw0lf-contact-form.mjs",
|
|
32
|
+
"fesm2015": "fesm2015/tehw0lf-contact-form.mjs",
|
|
18
33
|
"typings": "tehw0lf-contact-form.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
"./package.json": {
|
|
36
|
+
"default": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./tehw0lf-contact-form.d.ts",
|
|
40
|
+
"esm2020": "./esm2020/tehw0lf-contact-form.mjs",
|
|
41
|
+
"es2020": "./fesm2020/tehw0lf-contact-form.mjs",
|
|
42
|
+
"es2015": "./fesm2015/tehw0lf-contact-form.mjs",
|
|
43
|
+
"node": "./fesm2015/tehw0lf-contact-form.mjs",
|
|
44
|
+
"default": "./fesm2020/tehw0lf-contact-form.mjs"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
19
47
|
"sideEffects": false
|
|
20
48
|
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/common/http'), require('@angular/core'), require('@angular/forms'), require('rxjs'), require('rxjs/operators')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@tehw0lf/contact-form', ['exports', '@angular/common', '@angular/common/http', '@angular/core', '@angular/forms', 'rxjs', 'rxjs/operators'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.tehw0lf = global.tehw0lf || {}, global.tehw0lf['contact-form'] = {}), global.ng.common, global.ng.common.http, global.ng.core, global.ng.forms, global.rxjs, global.rxjs.operators));
|
|
5
|
-
}(this, (function (exports, i3, i1, i0, i1$1, rxjs, operators) { 'use strict';
|
|
6
|
-
|
|
7
|
-
function _interopNamespace(e) {
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return e[k];
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n['default'] = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
|
|
28
|
-
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
29
|
-
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
30
|
-
var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
|
|
31
|
-
|
|
32
|
-
var EmailApiService = /** @class */ (function () {
|
|
33
|
-
function EmailApiService(http) {
|
|
34
|
-
this.http = http;
|
|
35
|
-
this.httpOptions = {
|
|
36
|
-
headers: new i1.HttpHeaders({
|
|
37
|
-
'Content-Type': 'application/json'
|
|
38
|
-
})
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
EmailApiService.prototype.sendEmail = function (apiURL, data) {
|
|
42
|
-
return this.http.post(apiURL, JSON.stringify(data), this.httpOptions).pipe(operators.map(function (response) {
|
|
43
|
-
return response;
|
|
44
|
-
}), operators.catchError(function (error) {
|
|
45
|
-
return rxjs.of(error.statusText);
|
|
46
|
-
}));
|
|
47
|
-
};
|
|
48
|
-
return EmailApiService;
|
|
49
|
-
}());
|
|
50
|
-
EmailApiService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: EmailApiService, deps: [{ token: i1__namespace.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
51
|
-
EmailApiService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: EmailApiService, providedIn: 'root' });
|
|
52
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: EmailApiService, decorators: [{
|
|
53
|
-
type: i0.Injectable,
|
|
54
|
-
args: [{
|
|
55
|
-
providedIn: 'root'
|
|
56
|
-
}]
|
|
57
|
-
}], ctorParameters: function () { return [{ type: i1__namespace.HttpClient }]; } });
|
|
58
|
-
|
|
59
|
-
var ContactFormComponent = /** @class */ (function () {
|
|
60
|
-
function ContactFormComponent(builder, emailService) {
|
|
61
|
-
this.builder = builder;
|
|
62
|
-
this.emailService = emailService;
|
|
63
|
-
this.apiURL = 'https://forwardmethis.com/tehwolf@pm.me';
|
|
64
|
-
this.emailSent = new rxjs.Subject();
|
|
65
|
-
this.emailSent$ = this.emailSent.asObservable();
|
|
66
|
-
this.unsubscribe$ = new rxjs.Subject();
|
|
67
|
-
this.emailSent.next(null);
|
|
68
|
-
this.formGroup = this.builder.group({
|
|
69
|
-
name: new i1$1.FormControl('', [i1$1.Validators.required]),
|
|
70
|
-
email: new i1$1.FormControl('', [i1$1.Validators.required, i1$1.Validators.email]),
|
|
71
|
-
message: new i1$1.FormControl('', [i1$1.Validators.required])
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
ContactFormComponent.prototype.ngOnDestroy = function () {
|
|
75
|
-
this.unsubscribe$.next();
|
|
76
|
-
this.unsubscribe$.complete();
|
|
77
|
-
};
|
|
78
|
-
ContactFormComponent.prototype.submitFormData = function (formData) {
|
|
79
|
-
var _this = this;
|
|
80
|
-
this.emailService
|
|
81
|
-
.sendEmail(this.apiURL, formData.value)
|
|
82
|
-
.pipe(operators.tap(function (response) {
|
|
83
|
-
if (response === 'OK') {
|
|
84
|
-
_this.emailSent.next(true);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
_this.emailSent.next(false);
|
|
88
|
-
}
|
|
89
|
-
}), operators.takeUntil(this.unsubscribe$))
|
|
90
|
-
.subscribe();
|
|
91
|
-
};
|
|
92
|
-
return ContactFormComponent;
|
|
93
|
-
}());
|
|
94
|
-
ContactFormComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: ContactFormComponent, deps: [{ token: i1__namespace$1.FormBuilder }, { token: EmailApiService }], target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
95
|
-
ContactFormComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.11", type: ContactFormComponent, selector: "contact-form", inputs: { apiURL: "apiURL" }, ngImport: i0__namespace, template: "<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n", styles: [".contact-form{background-color:#fff;max-width:500px;margin:auto;padding:40px;box-shadow:0 2px 10px #00000013;box-sizing:border-box}.form-button{display:block;border:1px solid #ced4da;border-radius:.25rem;width:96%;padding:.375rem .75rem}.form-control{display:block;width:90%;padding:.375rem .75rem;font-size:1rem;font-weight:400;line-height:1.5;color:#282b2e;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;margin-top:.5rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.form-group{margin-bottom:1rem}.form-status{margin-top:2rem}textarea{overflow:auto;resize:vertical}\n"], directives: [{ type: i1__namespace$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1__namespace$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1__namespace$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1__namespace$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1__namespace$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1__namespace$1.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i3__namespace.AsyncPipe } });
|
|
96
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: ContactFormComponent, decorators: [{
|
|
97
|
-
type: i0.Component,
|
|
98
|
-
args: [{
|
|
99
|
-
// eslint-disable-next-line @angular-eslint/component-selector
|
|
100
|
-
selector: 'contact-form',
|
|
101
|
-
templateUrl: './contact-form.component.html',
|
|
102
|
-
styleUrls: ['./contact-form.component.scss']
|
|
103
|
-
}]
|
|
104
|
-
}], ctorParameters: function () { return [{ type: i1__namespace$1.FormBuilder }, { type: EmailApiService }]; }, propDecorators: { apiURL: [{
|
|
105
|
-
type: i0.Input
|
|
106
|
-
}] } });
|
|
107
|
-
|
|
108
|
-
var ContactFormModule = /** @class */ (function () {
|
|
109
|
-
function ContactFormModule() {
|
|
110
|
-
}
|
|
111
|
-
return ContactFormModule;
|
|
112
|
-
}());
|
|
113
|
-
ContactFormModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: ContactFormModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
114
|
-
ContactFormModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: ContactFormModule, declarations: [ContactFormComponent], imports: [i3.CommonModule, i1.HttpClientModule, i1$1.ReactiveFormsModule], exports: [ContactFormComponent] });
|
|
115
|
-
ContactFormModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: ContactFormModule, providers: [EmailApiService], imports: [[i3.CommonModule, i1.HttpClientModule, i1$1.ReactiveFormsModule]] });
|
|
116
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0__namespace, type: ContactFormModule, decorators: [{
|
|
117
|
-
type: i0.NgModule,
|
|
118
|
-
args: [{
|
|
119
|
-
imports: [i3.CommonModule, i1.HttpClientModule, i1$1.ReactiveFormsModule],
|
|
120
|
-
declarations: [ContactFormComponent],
|
|
121
|
-
exports: [ContactFormComponent],
|
|
122
|
-
providers: [EmailApiService],
|
|
123
|
-
}]
|
|
124
|
-
}] });
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Generated bundle index. Do not edit.
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
exports.ContactFormComponent = ContactFormComponent;
|
|
131
|
-
exports.ContactFormModule = ContactFormModule;
|
|
132
|
-
|
|
133
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
134
|
-
|
|
135
|
-
})));
|
|
136
|
-
//# sourceMappingURL=tehw0lf-contact-form.umd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tehw0lf-contact-form.umd.js","sources":["../../../../libs/contact-form/src/lib/email-api.service.ts","../../../../libs/contact-form/src/lib/contact-form/contact-form.component.ts","../../../../libs/contact-form/src/lib/contact-form/contact-form.component.html","../../../../libs/contact-form/src/lib/contact-form.module.ts","../../../../libs/contact-form/src/tehw0lf-contact-form.ts"],"sourcesContent":["import { HttpClient, HttpHeaders } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Observable, of } from 'rxjs';\nimport { catchError, map } from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class EmailApiService {\n httpOptions = {\n headers: new HttpHeaders({\n 'Content-Type': 'application/json'\n })\n };\n constructor(private http: HttpClient) {}\n\n sendEmail(apiURL: string, data: any): Observable<any> {\n return this.http.post(apiURL, JSON.stringify(data), this.httpOptions).pipe(\n map((response: any) => {\n return response;\n }),\n catchError((error: any) => {\n return of(error.statusText);\n })\n );\n }\n}\n","import { Component, Input, OnDestroy } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';\nimport { Subject } from 'rxjs';\nimport { takeUntil, tap } from 'rxjs/operators';\n\nimport { EmailApiService } from '../email-api.service';\n\n@Component({\n // eslint-disable-next-line @angular-eslint/component-selector\n selector: 'contact-form',\n templateUrl: './contact-form.component.html',\n styleUrls: ['./contact-form.component.scss']\n})\nexport class ContactFormComponent implements OnDestroy {\n @Input() apiURL = 'https://forwardmethis.com/tehwolf@pm.me';\n\n formGroup: FormGroup;\n emailSent: Subject<boolean | null> = new Subject();\n emailSent$ = this.emailSent.asObservable();\n\n private unsubscribe$: Subject<void> = new Subject();\n\n constructor(\n private builder: FormBuilder,\n private emailService: EmailApiService\n ) {\n this.emailSent.next(null);\n this.formGroup = this.builder.group({\n name: new FormControl('', [Validators.required]),\n email: new FormControl('', [Validators.required, Validators.email]),\n message: new FormControl('', [Validators.required])\n });\n }\n\n ngOnDestroy(): void {\n this.unsubscribe$.next();\n this.unsubscribe$.complete();\n }\n\n submitFormData(formData: FormGroup) {\n this.emailService\n .sendEmail(this.apiURL, formData.value)\n .pipe(\n tap((response: string) => {\n if (response === 'OK') {\n this.emailSent.next(true);\n } else {\n this.emailSent.next(false);\n }\n }),\n takeUntil(this.unsubscribe$)\n )\n .subscribe();\n }\n}\n","<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n","import { CommonModule } from '@angular/common';\nimport { HttpClientModule } from '@angular/common/http';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { ContactFormComponent } from './contact-form/contact-form.component';\nimport { EmailApiService } from './email-api.service';\n\n@NgModule({\n imports: [CommonModule, HttpClientModule, ReactiveFormsModule],\n declarations: [ContactFormComponent],\n exports: [ContactFormComponent],\n providers: [EmailApiService],\n})\nexport class ContactFormModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["HttpHeaders","map","catchError","of","Injectable","Subject","FormControl","Validators","tap","takeUntil","Component","Input","CommonModule","HttpClientModule","ReactiveFormsModule","NgModule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAQA;QAME,yBAAoB,IAAgB;YAAhB,SAAI,GAAJ,IAAI,CAAY;YALpC,gBAAW,GAAG;gBACZ,OAAO,EAAE,IAAIA,cAAW,CAAC;oBACvB,cAAc,EAAE,kBAAkB;iBACnC,CAAC;aACH,CAAC;SACsC;QAExC,mCAAS,GAAT,UAAU,MAAc,EAAE,IAAS;YACjC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CACxEC,aAAG,CAAC,UAAC,QAAa;gBAChB,OAAO,QAAQ,CAAC;aACjB,CAAC,EACFC,oBAAU,CAAC,UAAC,KAAU;gBACpB,OAAOC,OAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;aAC7B,CAAC,CACH,CAAC;SACH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CAAC,CAAC;iBAC3B;qBAAM;oBACL,KAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBAC5B;aACF,CAAC,EACFC,mBAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAC7B;iBACA,SAAS,EAAE,CAAC;SAChB;;;4IAxCU,oBAAoB;qHAApB,oBAAoB,6FCbjC,soCAwCA;sHD3Ba,oBAAoB;sBANhCC,YAAS;uBAAC;;wBAET,QAAQ,EAAE,cAAc;wBACxB,WAAW,EAAE,+BAA+B;wBAC5C,SAAS,EAAE,CAAC,+BAA+B,CAAC;qBAC7C;8IAEU,MAAM;0BAAdC,QAAK;;;;QEAR;;;;yIAAa,iBAAiB;0IAAjB,iBAAiB,iBAJb,oBAAoB,aADzBC,eAAY,EAAEC,mBAAgB,EAAEC,wBAAmB,aAEnD,oBAAoB;0IAGnB,iBAAiB,aAFjB,CAAC,eAAe,CAAC,YAHnB,CAACF,eAAY,EAAEC,mBAAgB,EAAEC,wBAAmB,CAAC;sHAKnD,iBAAiB;sBAN7BC,WAAQ;uBAAC;wBACR,OAAO,EAAE,CAACH,eAAY,EAAEC,mBAAgB,EAAEC,wBAAmB,CAAC;wBAC9D,YAAY,EAAE,CAAC,oBAAoB,CAAC;wBACpC,OAAO,EAAE,CAAC,oBAAoB,CAAC;wBAC/B,SAAS,EAAE,CAAC,eAAe,CAAC;qBAC7B;;;ICbD;;;;;;;;;;;;;"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Component, Input } from '@angular/core';
|
|
2
|
-
import { FormBuilder, FormControl, Validators } from '@angular/forms';
|
|
3
|
-
import { Subject } from 'rxjs';
|
|
4
|
-
import { takeUntil, tap } from 'rxjs/operators';
|
|
5
|
-
import { EmailApiService } from '../email-api.service';
|
|
6
|
-
import * as i0 from "@angular/core";
|
|
7
|
-
import * as i1 from "@angular/forms";
|
|
8
|
-
import * as i2 from "../email-api.service";
|
|
9
|
-
import * as i3 from "@angular/common";
|
|
10
|
-
export class ContactFormComponent {
|
|
11
|
-
constructor(builder, emailService) {
|
|
12
|
-
this.builder = builder;
|
|
13
|
-
this.emailService = emailService;
|
|
14
|
-
this.apiURL = 'https://forwardmethis.com/tehwolf@pm.me';
|
|
15
|
-
this.emailSent = new Subject();
|
|
16
|
-
this.emailSent$ = this.emailSent.asObservable();
|
|
17
|
-
this.unsubscribe$ = new Subject();
|
|
18
|
-
this.emailSent.next(null);
|
|
19
|
-
this.formGroup = this.builder.group({
|
|
20
|
-
name: new FormControl('', [Validators.required]),
|
|
21
|
-
email: new FormControl('', [Validators.required, Validators.email]),
|
|
22
|
-
message: new FormControl('', [Validators.required])
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
ngOnDestroy() {
|
|
26
|
-
this.unsubscribe$.next();
|
|
27
|
-
this.unsubscribe$.complete();
|
|
28
|
-
}
|
|
29
|
-
submitFormData(formData) {
|
|
30
|
-
this.emailService
|
|
31
|
-
.sendEmail(this.apiURL, formData.value)
|
|
32
|
-
.pipe(tap((response) => {
|
|
33
|
-
if (response === 'OK') {
|
|
34
|
-
this.emailSent.next(true);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
this.emailSent.next(false);
|
|
38
|
-
}
|
|
39
|
-
}), takeUntil(this.unsubscribe$))
|
|
40
|
-
.subscribe();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
ContactFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0, type: ContactFormComponent, deps: [{ token: i1.FormBuilder }, { token: i2.EmailApiService }], target: i0.ɵɵFactoryTarget.Component });
|
|
44
|
-
ContactFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.11", type: ContactFormComponent, selector: "contact-form", inputs: { apiURL: "apiURL" }, ngImport: i0, template: "<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n", styles: [".contact-form{background-color:#fff;max-width:500px;margin:auto;padding:40px;box-shadow:0 2px 10px #00000013;box-sizing:border-box}.form-button{display:block;border:1px solid #ced4da;border-radius:.25rem;width:96%;padding:.375rem .75rem}.form-control{display:block;width:90%;padding:.375rem .75rem;font-size:1rem;font-weight:400;line-height:1.5;color:#282b2e;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;margin-top:.5rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.form-group{margin-bottom:1rem}.form-status{margin-top:2rem}textarea{overflow:auto;resize:vertical}\n"], directives: [{ type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i3.AsyncPipe } });
|
|
45
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0, type: ContactFormComponent, decorators: [{
|
|
46
|
-
type: Component,
|
|
47
|
-
args: [{
|
|
48
|
-
// eslint-disable-next-line @angular-eslint/component-selector
|
|
49
|
-
selector: 'contact-form',
|
|
50
|
-
templateUrl: './contact-form.component.html',
|
|
51
|
-
styleUrls: ['./contact-form.component.scss']
|
|
52
|
-
}]
|
|
53
|
-
}], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: i2.EmailApiService }]; }, propDecorators: { apiURL: [{
|
|
54
|
-
type: Input
|
|
55
|
-
}] } });
|
|
56
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGFjdC1mb3JtLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29udGFjdC1mb3JtL3NyYy9saWIvY29udGFjdC1mb3JtL2NvbnRhY3QtZm9ybS5jb21wb25lbnQudHMiLCIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvbnRhY3QtZm9ybS9zcmMvbGliL2NvbnRhY3QtZm9ybS9jb250YWN0LWZvcm0uY29tcG9uZW50Lmh0bWwiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxLQUFLLEVBQWEsTUFBTSxlQUFlLENBQUM7QUFDNUQsT0FBTyxFQUFFLFdBQVcsRUFBRSxXQ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1cImZvcm0tYnV0dG9uXCIgdHlwZT1cInN1Ym1pdFwiIFtkaXNhYmxlZF09XCIhZm9ybUdyb3VwLnZhbGlkXCI+XG4gICAgU2VuZGVuXG4gIDwvYnV0dG9uPlxuICA8ZGl2IGNsYXNzPVwiZm9ybS1zdGF0dXNcIiAqbmdJZj1cIihlbWFpbFNlbnQkIHwgYXN5bmMpID09PSB0cnVlXCI+XG4gICAgRS1NYWlsIGVyZm9sZ3JlaWNoIHZlcnNlbmRldCFcbiAgPC9kaXY+XG4gIDxkaXYgY2xhc3M9XCJmb3JtLXN0YXR1c1wiICpuZ0lmPVwiKGVtYWlsU2VudCQgfCBhc3luYykgPT09IGZhbHNlXCI+XG4gICAgRmVobGVyOiBFLU1haWwga29ubnRlIG5pY2h0IHZlcnNlbmRldCB3ZXJkZW5cbiAgPC9kaXY+XG48L2Zvcm0+XG4iXX0=
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import * as i3 from '@angular/common';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import * as i1 from '@angular/common/http';
|
|
4
|
-
import { HttpHeaders, HttpClientModule } from '@angular/common/http';
|
|
5
|
-
import * as i0 from '@angular/core';
|
|
6
|
-
import { Injectable, Component, Input, NgModule } from '@angular/core';
|
|
7
|
-
import * as i1$1 from '@angular/forms';
|
|
8
|
-
import { FormControl, Validators, ReactiveFormsModule } from '@angular/forms';
|
|
9
|
-
import { of, Subject } from 'rxjs';
|
|
10
|
-
import { map, catchError, tap, takeUntil } from 'rxjs/operators';
|
|
11
|
-
|
|
12
|
-
class EmailApiService {
|
|
13
|
-
constructor(http) {
|
|
14
|
-
this.http = http;
|
|
15
|
-
this.httpOptions = {
|
|
16
|
-
headers: new HttpHeaders({
|
|
17
|
-
'Content-Type': 'application/json'
|
|
18
|
-
})
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
sendEmail(apiURL, data) {
|
|
22
|
-
return this.http.post(apiURL, JSON.stringify(data), this.httpOptions).pipe(map((response) => {
|
|
23
|
-
return response;
|
|
24
|
-
}), catchError((error) => {
|
|
25
|
-
return of(error.statusText);
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
EmailApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0, type: EmailApiService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
30
|
-
EmailApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0, type: EmailApiService, providedIn: 'root' });
|
|
31
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0, type: EmailApiService, decorators: [{
|
|
32
|
-
type: Injectable,
|
|
33
|
-
args: [{
|
|
34
|
-
providedIn: 'root'
|
|
35
|
-
}]
|
|
36
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
|
|
37
|
-
|
|
38
|
-
class ContactFormComponent {
|
|
39
|
-
constructor(builder, emailService) {
|
|
40
|
-
this.builder = builder;
|
|
41
|
-
this.emailService = emailService;
|
|
42
|
-
this.apiURL = 'https://forwardmethis.com/tehwolf@pm.me';
|
|
43
|
-
this.emailSent = new Subject();
|
|
44
|
-
this.emailSent$ = this.emailSent.asObservable();
|
|
45
|
-
this.unsubscribe$ = new Subject();
|
|
46
|
-
this.emailSent.next(null);
|
|
47
|
-
this.formGroup = this.builder.group({
|
|
48
|
-
name: new FormControl('', [Validators.required]),
|
|
49
|
-
email: new FormControl('', [Validators.required, Validators.email]),
|
|
50
|
-
message: new FormControl('', [Validators.required])
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
ngOnDestroy() {
|
|
54
|
-
this.unsubscribe$.next();
|
|
55
|
-
this.unsubscribe$.complete();
|
|
56
|
-
}
|
|
57
|
-
submitFormData(formData) {
|
|
58
|
-
this.emailService
|
|
59
|
-
.sendEmail(this.apiURL, formData.value)
|
|
60
|
-
.pipe(tap((response) => {
|
|
61
|
-
if (response === 'OK') {
|
|
62
|
-
this.emailSent.next(true);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
this.emailSent.next(false);
|
|
66
|
-
}
|
|
67
|
-
}), takeUntil(this.unsubscribe$))
|
|
68
|
-
.subscribe();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
ContactFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0, type: ContactFormComponent, deps: [{ token: i1$1.FormBuilder }, { token: EmailApiService }], target: i0.ɵɵFactoryTarget.Component });
|
|
72
|
-
ContactFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.11", type: ContactFormComponent, selector: "contact-form", inputs: { apiURL: "apiURL" }, ngImport: i0, template: "<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n", styles: [".contact-form{background-color:#fff;max-width:500px;margin:auto;padding:40px;box-shadow:0 2px 10px #00000013;box-sizing:border-box}.form-button{display:block;border:1px solid #ced4da;border-radius:.25rem;width:96%;padding:.375rem .75rem}.form-control{display:block;width:90%;padding:.375rem .75rem;font-size:1rem;font-weight:400;line-height:1.5;color:#282b2e;background-color:#fff;background-clip:padding-box;border:1px solid #ced4da;border-radius:.25rem;margin-top:.5rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.form-group{margin-bottom:1rem}.form-status{margin-top:2rem}textarea{overflow:auto;resize:vertical}\n"], directives: [{ type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["disabled", "formControlName", "ngModel"], outputs: ["ngModelChange"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i3.AsyncPipe } });
|
|
73
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0, type: ContactFormComponent, decorators: [{
|
|
74
|
-
type: Component,
|
|
75
|
-
args: [{
|
|
76
|
-
// eslint-disable-next-line @angular-eslint/component-selector
|
|
77
|
-
selector: 'contact-form',
|
|
78
|
-
templateUrl: './contact-form.component.html',
|
|
79
|
-
styleUrls: ['./contact-form.component.scss']
|
|
80
|
-
}]
|
|
81
|
-
}], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: EmailApiService }]; }, propDecorators: { apiURL: [{
|
|
82
|
-
type: Input
|
|
83
|
-
}] } });
|
|
84
|
-
|
|
85
|
-
class ContactFormModule {
|
|
86
|
-
}
|
|
87
|
-
ContactFormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0, type: ContactFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
88
|
-
ContactFormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0, type: ContactFormModule, declarations: [ContactFormComponent], imports: [CommonModule, HttpClientModule, ReactiveFormsModule], exports: [ContactFormComponent] });
|
|
89
|
-
ContactFormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0, type: ContactFormModule, providers: [EmailApiService], imports: [[CommonModule, HttpClientModule, ReactiveFormsModule]] });
|
|
90
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.11", ngImport: i0, type: ContactFormModule, decorators: [{
|
|
91
|
-
type: NgModule,
|
|
92
|
-
args: [{
|
|
93
|
-
imports: [CommonModule, HttpClientModule, ReactiveFormsModule],
|
|
94
|
-
declarations: [ContactFormComponent],
|
|
95
|
-
exports: [ContactFormComponent],
|
|
96
|
-
providers: [EmailApiService],
|
|
97
|
-
}]
|
|
98
|
-
}] });
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Generated bundle index. Do not edit.
|
|
102
|
-
*/
|
|
103
|
-
|
|
104
|
-
export { ContactFormComponent, ContactFormModule };
|
|
105
|
-
//# sourceMappingURL=tehw0lf-contact-form.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tehw0lf-contact-form.js","sources":["../../../../libs/contact-form/src/lib/email-api.service.ts","../../../../libs/contact-form/src/lib/contact-form/contact-form.component.ts","../../../../libs/contact-form/src/lib/contact-form/contact-form.component.html","../../../../libs/contact-form/src/lib/contact-form.module.ts","../../../../libs/contact-form/src/tehw0lf-contact-form.ts"],"sourcesContent":["import { HttpClient, HttpHeaders } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Observable, of } from 'rxjs';\nimport { catchError, map } from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class EmailApiService {\n httpOptions = {\n headers: new HttpHeaders({\n 'Content-Type': 'application/json'\n })\n };\n constructor(private http: HttpClient) {}\n\n sendEmail(apiURL: string, data: any): Observable<any> {\n return this.http.post(apiURL, JSON.stringify(data), this.httpOptions).pipe(\n map((response: any) => {\n return response;\n }),\n catchError((error: any) => {\n return of(error.statusText);\n })\n );\n }\n}\n","import { Component, Input, OnDestroy } from '@angular/core';\nimport { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';\nimport { Subject } from 'rxjs';\nimport { takeUntil, tap } from 'rxjs/operators';\n\nimport { EmailApiService } from '../email-api.service';\n\n@Component({\n // eslint-disable-next-line @angular-eslint/component-selector\n selector: 'contact-form',\n templateUrl: './contact-form.component.html',\n styleUrls: ['./contact-form.component.scss']\n})\nexport class ContactFormComponent implements OnDestroy {\n @Input() apiURL = 'https://forwardmethis.com/tehwolf@pm.me';\n\n formGroup: FormGroup;\n emailSent: Subject<boolean | null> = new Subject();\n emailSent$ = this.emailSent.asObservable();\n\n private unsubscribe$: Subject<void> = new Subject();\n\n constructor(\n private builder: FormBuilder,\n private emailService: EmailApiService\n ) {\n this.emailSent.next(null);\n this.formGroup = this.builder.group({\n name: new FormControl('', [Validators.required]),\n email: new FormControl('', [Validators.required, Validators.email]),\n message: new FormControl('', [Validators.required])\n });\n }\n\n ngOnDestroy(): void {\n this.unsubscribe$.next();\n this.unsubscribe$.complete();\n }\n\n submitFormData(formData: FormGroup) {\n this.emailService\n .sendEmail(this.apiURL, formData.value)\n .pipe(\n tap((response: string) => {\n if (response === 'OK') {\n this.emailSent.next(true);\n } else {\n this.emailSent.next(false);\n }\n }),\n takeUntil(this.unsubscribe$)\n )\n .subscribe();\n }\n}\n","<form\n class=\"contact-form\"\n [formGroup]=\"formGroup\"\n (ngSubmit)=\"submitFormData(formGroup)\"\n>\n <div class=\"form-group\">\n <label for=\"name\">Ihr Name</label>\n <input\n class=\"form-control\"\n type=\"text\"\n name=\"name\"\n placeholder=\"Name\"\n formControlName=\"name\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"email\">Ihre E-Mail Adresse</label>\n <input\n class=\"form-control\"\n type=\"email\"\n name=\"email\"\n placeholder=\"ihre@mail.de\"\n formControlName=\"email\"\n />\n </div>\n <div class=\"form-group\">\n <label for=\"message\">Ihre Nachricht</label>\n <textarea class=\"form-control\" formControlName=\"message\" name=\"message\">\n </textarea>\n </div>\n <button class=\"form-button\" type=\"submit\" [disabled]=\"!formGroup.valid\">\n Senden\n </button>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === true\">\n E-Mail erfolgreich versendet!\n </div>\n <div class=\"form-status\" *ngIf=\"(emailSent$ | async) === false\">\n Fehler: E-Mail konnte nicht versendet werden\n </div>\n</form>\n","import { CommonModule } from '@angular/common';\nimport { HttpClientModule } from '@angular/common/http';\nimport { NgModule } from '@angular/core';\nimport { ReactiveFormsModule } from '@angular/forms';\n\nimport { ContactFormComponent } from './contact-form/contact-form.component';\nimport { EmailApiService } from './email-api.service';\n\n@NgModule({\n imports: [CommonModule, HttpClientModule, ReactiveFormsModule],\n declarations: [ContactFormComponent],\n exports: [ContactFormComponent],\n providers: [EmailApiService],\n})\nexport class ContactFormModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;MAQa,eAAe;IAM1B,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;QALpC,gBAAW,GAAG;YACZ,OAAO,EAAE,IAAI,WAAW,CAAC;gBACvB,cAAc,EAAE,kBAAkB;aACnC,CAAC;SACH,CAAC;KACsC;IAExC,SAAS,CAAC,MAAc,EAAE,IAAS;QACjC,OAAO,I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