Revision 54442
Added by Sofia Baltzi over 5 years ago
modules/uoa-connect-portal/trunk/src/app/utils/subscribe/invite/invite.component.ts | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import {Email} from '../../../openaireLibrary/utils/email/email'; |
9 | 9 |
import {Body} from '../../../openaireLibrary/utils/email/body'; |
10 |
import {Validator} from '../../../openaireLibrary/utils/email/validator'; |
|
10 | 11 |
|
11 | 12 |
import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties'; |
12 | 13 |
import {EmailService} from '../../../openaireLibrary/utils/email/email.service'; |
... | ... | |
88 | 89 |
+ '<br>The purpose of this dashboard is to gather, link & monitor the research results related to your community.</p><p>The community dashboard is part of the <a href="https://connect.openaire.eu/">OpenAIRE-Connect</a> project and currently is in BETA version.</p>'; |
89 | 90 |
|
90 | 91 |
// TODO move the initialisation |
91 |
this.body = {/*salutation: "Dear Sir/Madame,",*/ fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, /*closing: "Kind regards,",*/ signature: "OpenAIRE team", note: ""};
|
|
92 |
this.body = {fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, signature: "OpenAIRE team", note: ""};
|
|
92 | 93 |
this.email = {body: "", subject: "[OpenAIRE-Connect] " + community.title, recipients: []}; |
93 | 94 |
this.recipients = ""; |
94 | 95 |
|
... | ... | |
132 | 133 |
this.successfulSentMessage = res + " email sent successfully!"; |
133 | 134 |
} |
134 | 135 |
|
135 |
this.body = {/*salutation: "Dear Sir/Madame,",*/ fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, /*closing: "Kind regards,",*/ signature: "OpenAIRE team", note: ""};
|
|
136 |
this.body = {fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, signature: "OpenAIRE team", note: ""};
|
|
136 | 137 |
this.email = {body: "", subject: "[OpenAIRE-Connect] " + this.community.title, recipients: []}; |
137 | 138 |
this.recipients = ""; |
138 | 139 |
}, |
... | ... | |
161 | 162 |
|
162 | 163 |
public validateEmails(): boolean { |
163 | 164 |
if (this.parseEmails()) { |
164 |
if (this.hasValidEmails()) {
|
|
165 |
if (Validator.hasValidEmails(this.email.recipients)) {
|
|
165 | 166 |
return this.areValid; |
166 | 167 |
} |
167 | 168 |
} |
... | ... | |
188 | 189 |
return true; |
189 | 190 |
} |
190 | 191 |
|
191 |
private hasValidEmails(): boolean { |
|
192 |
let length = this.email.recipients.length; |
|
193 |
|
|
194 |
for(let i = 0; i < length; i++) { |
|
195 |
if (!this.emailValidator(this.email.recipients[i])){ |
|
196 |
// TODO remove console message after final testing |
|
197 |
console.log("INVALID EMAIL"); |
|
198 |
return false; |
|
199 |
} |
|
200 |
} |
|
201 |
// TODO remove console message after final testing |
|
202 |
console.log("ALL EMAILS ARE VALID"); |
|
203 |
return true; |
|
204 |
} |
|
205 |
|
|
206 |
private emailValidator(email : any): boolean { |
|
207 |
if (email.match("^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$")) |
|
208 |
return true; |
|
209 |
else |
|
210 |
return false; |
|
211 |
} |
|
212 |
|
|
213 | 192 |
public composeEmail() { |
214 | 193 |
// this.email.subject = "[OpenAIRE-Connect] Community_name"; |
215 | 194 |
this.email.body = this.formatEmailBody(); |
... | ... | |
222 | 201 |
fromMessageAndName = "<span>" + this.body.fromMessage + this.body.fromName + "</span>"; |
223 | 202 |
} |
224 | 203 |
|
225 |
let formattedEmail = "<div style='font-size:14px;'>" + /*+ this.body.salutation + "<br><br>" +*/ |
|
226 |
this.body.paragraphs + |
|
227 |
"<p>" /*+ this.body.closing + "<br>"*/ + this.body.signature + fromMessageAndName + "<br>" + |
|
228 |
"<a href='https://www.openaire.eu'>www.openaire.eu</a>" + "</p></div>"; |
|
204 |
let formattedEmail = "<div style='font-size:14px;'>" |
|
205 |
+ this.body.paragraphs |
|
206 |
+ "<p>" + this.body.signature + fromMessageAndName + "<br>" |
|
207 |
+ "<a href='https://www.openaire.eu'>www.openaire.eu</a>" |
|
208 |
+ "</p>" |
|
209 |
+ "</div>"; |
|
229 | 210 |
|
230 |
|
|
231 | 211 |
return formattedEmail; |
232 | 212 |
} |
233 | 213 |
|
Also available in: Unified diff
Use email validator