Revision 59840
Added by Argiro Kokogiannaki over 3 years ago
contact.component.ts | ||
---|---|---|
10 | 10 |
import {HelperService} from "../openaireLibrary/utils/helper/helper.service"; |
11 | 11 |
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service"; |
12 | 12 |
import {AbstractControl, FormBuilder, FormGroup, ValidatorFn, Validators} from "@angular/forms"; |
13 |
import {properties} from "../../environments/environment";
|
|
13 |
import {Subscriber} from "rxjs";
|
|
14 | 14 |
|
15 | 15 |
@Component({ |
16 | 16 |
selector: 'contact', |
... | ... | |
46 | 46 |
private fb: FormBuilder, |
47 | 47 |
private helper: HelperService) { |
48 | 48 |
} |
49 |
|
|
49 |
subscriptions = []; |
|
50 |
ngOnDestroy() { |
|
51 |
this.subscriptions.forEach(subscription => { |
|
52 |
if (subscription instanceof Subscriber) { |
|
53 |
subscription.unsubscribe(); |
|
54 |
} |
|
55 |
}); |
|
56 |
} |
|
50 | 57 |
ngOnInit() { |
51 | 58 |
this._title.setTitle('OpenAIRE-Monitor | Contact Us'); |
52 |
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { |
|
59 |
this.subscriptions.push(this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
|
|
53 | 60 |
this.properties = data.envSpecific; |
54 | 61 |
this.email = {body: '', subject: '', recipients: []}; |
55 | 62 |
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { |
56 |
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.properties.piwikSiteId).subscribe();
|
|
63 |
this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle, this.properties.piwikSiteId).subscribe());
|
|
57 | 64 |
} |
58 | 65 |
this.url = this.properties.domain + this.properties.baseLink + this._router.url; |
59 | 66 |
this.seoService.createLinkForCanonicalURL(this.url); |
... | ... | |
65 | 72 |
// this.getPageContents(); |
66 | 73 |
HelperFunctions.scroll(); |
67 | 74 |
this.showLoading = false; |
68 |
}); |
|
75 |
}));
|
|
69 | 76 |
} |
70 | 77 |
|
71 | 78 |
private getPageContents() { |
72 |
this.helper.getPageHelpContents(this.properties, 'monitor', this._router.url).subscribe(contents => { |
|
79 |
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, 'monitor', this._router.url).subscribe(contents => {
|
|
73 | 80 |
this.pageContents = contents; |
74 |
}) |
|
81 |
}));
|
|
75 | 82 |
} |
76 | 83 |
|
77 | 84 |
private getDivContents() { |
78 |
this.helper.getDivHelpContents(this.properties, 'monitor', this._router.url).subscribe(contents => { |
|
85 |
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, 'monitor', this._router.url).subscribe(contents => {
|
|
79 | 86 |
this.divContents = contents; |
80 |
}) |
|
87 |
}));
|
|
81 | 88 |
} |
82 | 89 |
|
83 | 90 |
public send(event) { |
... | ... | |
114 | 121 |
|
115 | 122 |
private sendMail(admins: any) { |
116 | 123 |
this.showLoading = true; |
117 |
this._emailService.contact(this.properties, |
|
124 |
this.subscriptions.push(this._emailService.contact(this.properties,
|
|
118 | 125 |
Composer.composeEmailForMonitor(this.contactForm.value, admins), |
119 |
this.contactForm.value.recaptcha).subscribe(
|
|
126 |
this.contactForm.value.recaptcha).subscribe( |
|
120 | 127 |
res => { |
121 | 128 |
this.showLoading = false; |
122 | 129 |
if (res) { |
... | ... | |
132 | 139 |
this.showLoading = false; |
133 | 140 |
this.contactForm.get('recaptcha').setValue(''); |
134 | 141 |
} |
135 |
); |
|
142 |
));
|
|
136 | 143 |
} |
137 | 144 |
|
138 | 145 |
public modalOpen() { |
Also available in: Unified diff
[Monitor|Trunk]
- Browse page Fix: pass single stakeholder instead of list
- Code cleaning:
- remove unused files, imports, remove free guard
- unsubscribe from observables
- add timeout interceptor
- call clearSubscriptions method in App component