Revision 59816
Added by Argiro Kokogiannaki over 3 years ago
feedback.component.ts | ||
---|---|---|
19 | 19 |
import {DataProviderInfo} from "../../utils/entities/dataProviderInfo"; |
20 | 20 |
import {EmailService} from "../../utils/email/email.service"; |
21 | 21 |
import {Composer} from "../../utils/email/composer"; |
22 |
import {Subscriber} from "rxjs"; |
|
22 | 23 |
|
23 | 24 |
@Component({ |
24 | 25 |
selector: 'feedback', |
... | ... | |
44 | 45 |
public form: FormGroup; |
45 | 46 |
public url: string = null; |
46 | 47 |
public recipients: string[] = []; |
47 |
|
|
48 |
subscriptions =[]; |
|
48 | 49 |
constructor(private fb: FormBuilder, |
49 | 50 |
private emailService: EmailService) { |
50 | 51 |
} |
51 |
|
|
52 |
ngOnDestroy() { |
|
53 |
this.subscriptions.forEach(subscription => { |
|
54 |
if (subscription instanceof Subscriber) { |
|
55 |
subscription.unsubscribe(); |
|
56 |
} |
|
57 |
}); |
|
58 |
} |
|
52 | 59 |
ngOnInit(): void { |
53 | 60 |
if(typeof window !== "undefined") { |
54 | 61 |
this.url = window.location.href; |
... | ... | |
117 | 124 |
|
118 | 125 |
public sendReport() { |
119 | 126 |
this.sending = true; |
120 |
this.emailService.contact(this.properties, |
|
127 |
this.subscriptions.push(this.emailService.contact(this.properties,
|
|
121 | 128 |
Composer.composeEmailForFeedback(this.form.value, this.recipients), this.form.get('recaptcha').value).subscribe(sent => { |
122 | 129 |
this.error = !sent; |
123 | 130 |
if(sent) { |
124 | 131 |
if(this.form.get('email').value !== '') { |
125 |
this.emailService.contact(this.properties, |
|
132 |
this.subscriptions.push(this.emailService.contact(this.properties,
|
|
126 | 133 |
Composer.composeEmailForUserAfterFeedback([this.form.get('email').value])).subscribe(sent => { |
127 | 134 |
if(sent) { |
128 | 135 |
//console.log('An email has been sent to user ' + this.form.get('email').value); |
129 | 136 |
} |
130 |
}) |
|
137 |
}));
|
|
131 | 138 |
} |
132 | 139 |
this.init(); |
133 | 140 |
this.sent = true; |
... | ... | |
137 | 144 |
console.log(error); |
138 | 145 |
this.error = true; |
139 | 146 |
this.sending = false; |
140 |
}); |
|
147 |
}));
|
|
141 | 148 |
} |
142 |
} |
|
149 |
} |
Also available in: Unified diff
[Library|Trunk]
code clean up:
-remove app.* files from library
-remove unused imports, code, files (Old search pages for results, dataproviders, map search page, etc)
-remove Freeguard from modules
-unsubscribe all subscriptions
-Services: configuration, isvocabularies, user management: unsubscribe from app component or the component that uses them (clearSubscriptions())
-Fetchers: unsubscribe from the component that uses them (clearSubscriptions())