Revision 53748
Added by Sofia Baltzi almost 6 years ago
modules/uoa-connect-portal/trunk/src/app/community/community.component.html | ||
---|---|---|
170 | 170 |
|
171 | 171 |
</div> |
172 | 172 |
|
173 |
<invite longView=false></invite> |
|
173 |
<invite [longView]=false></invite> |
modules/uoa-connect-portal/trunk/src/app/utils/subscribe/invite/invite.component.html | ||
---|---|---|
25 | 25 |
<tr> |
26 | 26 |
<td for="email.recipients[0]" class="uk-text-bold uk-text-right">To <span class="uk-text-danger uk-text-bold">*</span> :</td> |
27 | 27 |
<td class="uk-text-left"> |
28 |
|
|
29 |
<!-- <div *ngIf="!email.recipients[1].match('^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$')" |
|
30 |
class="uk-width-large uk-text-danger uk-text-small uk-margin-top"> Please add a valid email. </div> --> |
|
28 |
<!-- <div *ngIf="email.recipients && email.recipients[0] != ''"> |
|
29 |
<div > |
|
30 |
</div> |
|
31 |
<div *ngFor='let emailsss of email.recipients.split(,), let index; trackBy:trackByFn'> --> |
|
32 |
<!-- <div *ngIf="!email[i].match('^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$')" |
|
33 |
class="uk-width-large uk-text-danger uk-text-small uk-margin-top"> Please add a valid email. </div> --> |
|
34 |
<!-- </div> |
|
35 |
</div> --> |
|
31 | 36 |
<input placeholder="email" type="text" |
32 |
class="form-control uk-input uk-width-large@l uk-width-medium@s" [(ngModel)] = "email.recipients[0]" id="recipients" |
|
33 |
required > |
|
34 |
{{email.recipients}} |
|
37 |
class="form-control uk-input uk-width-large@l uk-width-medium@s" [(ngModel)] = "recipients" id="recipients" |
|
38 |
required> |
|
35 | 39 |
<div class="uk-width-medium uk-text-muted uk-text-small style=display:none">separate multiple emails with a comma</div> |
36 | 40 |
</td> |
37 | 41 |
|
... | ... | |
69 | 73 |
<!--[config]="{uiColor: '#99000'}"--> |
70 | 74 |
<!--(blur)="onBlur($event)"--> |
71 | 75 |
<!--(change)="onChange($event)"--> |
72 |
</ckeditor>
|
|
76 |
</ckeditor> |
|
73 | 77 |
<!-- <textarea type="text" |
74 | 78 |
class="form-control uk-input uk-width-large@l uk-width-medium@s" [(ngModel)] = "email.body" id="message"> |
75 | 79 |
</textarea> --> |
... | ... | |
131 | 135 |
</div> |
132 | 136 |
</div> |
133 | 137 |
</div> |
134 |
<div *ngIf="longView =='false'">
|
|
138 |
<div *ngIf="longView == false">
|
|
135 | 139 |
<div class="uk-width-large@m uk-width-1-1@s"> |
136 | 140 |
<div class="uk-card uk-card-default uk-card-body"> |
137 | 141 |
<div class="uk-text-center uk-text-large"> |
modules/uoa-connect-portal/trunk/src/app/utils/subscribe/invite/invite.component.ts | ||
---|---|---|
21 | 21 |
private properties: EnvProperties = null; |
22 | 22 |
public email: Email; |
23 | 23 |
public body: Body; |
24 |
public recipients: string; |
|
24 | 25 |
|
25 | 26 |
private ckeditorContent: string; |
26 | 27 |
|
... | ... | |
40 | 41 |
this.properties = data.envSpecific; |
41 | 42 |
this.body = {salutation: "Dear Sir/Madame,", fromMessage: "On behalf of ", fromName: "", paragraphs: this.defaultBody, closing: "Kind regards,", signature: "OpenAIRE team"}; |
42 | 43 |
this.email = {body: "", subject: "", recipients: []}; |
44 |
this.recipients = ""; |
|
43 | 45 |
|
44 | 46 |
}); |
45 | 47 |
} |
46 | 48 |
|
47 | 49 |
public invite() { |
48 |
if (this.email.recipients != null) { |
|
49 |
this.composeEmail(); |
|
50 |
console.log(this.email.body); |
|
50 |
if (this.recipients != "") { |
|
51 |
if (this.validateEmails()) { |
|
52 |
this.composeEmail(); |
|
53 |
console.log(this.email.body); |
|
51 | 54 |
|
52 |
this._emailService.sendEmail(this.properties.sendMailUrl, this.email).subscribe( |
|
53 |
res => console.log("Mail has been sent successfully!") |
|
54 |
, |
|
55 |
error => console.log(error) |
|
56 |
); |
|
55 |
this._emailService.sendEmail(this.properties.sendMailUrl, this.email).subscribe( |
|
56 |
res => console.log("The email has been sent successfully!") |
|
57 |
, |
|
58 |
error => console.log(error) |
|
59 |
); |
|
60 |
} |
|
57 | 61 |
} |
58 | 62 |
} |
59 | 63 |
|
64 |
public validateEmails(): boolean { |
|
65 |
if (this.parseEmails()) { |
|
66 |
if (this.hasValidEmails()) { |
|
67 |
return true; |
|
68 |
} |
|
69 |
} |
|
70 |
return false; |
|
71 |
} |
|
72 |
|
|
73 |
public parseEmails(): boolean { |
|
74 |
let email = new Array<string>(); |
|
75 |
|
|
76 |
// remove spaces |
|
77 |
this.recipients = this.recipients.replace(/\s/g, ''); |
|
78 |
|
|
79 |
// remove commas |
|
80 |
email = this.recipients.split(","); |
|
81 |
|
|
82 |
// remove empty fields |
|
83 |
for (let i = 0; i < email.length; i++) { |
|
84 |
if (!(email[i] == "")) { |
|
85 |
this.email.recipients.push(email[i]); |
|
86 |
} |
|
87 |
} |
|
88 |
console.log(this.email.recipients); |
|
89 |
return true; |
|
90 |
} |
|
91 |
|
|
92 |
private hasValidEmails(): boolean { |
|
93 |
let length = this.email.recipients.length; |
|
94 |
|
|
95 |
for(let i = 0; i < length; i++) { |
|
96 |
if (!this.emailValidator(this.email.recipients[i])){ |
|
97 |
// TODO remove console message after final testing |
|
98 |
console.log("INVALID EMAIL"); |
|
99 |
return false; |
|
100 |
} |
|
101 |
} |
|
102 |
// TODO remove console message after final testing |
|
103 |
console.log("ALL EMAILS ARE VALID"); |
|
104 |
return true; |
|
105 |
} |
|
106 |
|
|
107 |
private emailValidator(email : any): boolean { |
|
108 |
if (email.match("^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$")) |
|
109 |
return true; |
|
110 |
else |
|
111 |
return false; |
|
112 |
} |
|
113 |
|
|
60 | 114 |
public composeEmail() { |
61 |
this.email.subject = "Argiro is going to tell me about the subject";
|
|
115 |
this.email.subject = "[OpenAIRE-Connect] Community_name";
|
|
62 | 116 |
this.email.body = this.formatEmailBody(); |
63 | 117 |
} |
64 | 118 |
|
Also available in: Unified diff
Check if input emails are valid and Send inviatation to multiple emails