1
|
import {Email} from "./email";
|
2
|
import {Body} from "./body";
|
3
|
import {FormArray} from "@angular/forms";
|
4
|
|
5
|
export class Composer {
|
6
|
private static noteBodySize = "14px";
|
7
|
private static noteFontSize = "11px";
|
8
|
|
9
|
// TODO move to properties
|
10
|
private static openaireEmail = "mailto:openaire.test@gmail.com";
|
11
|
private static subjectPrefix = "[OpenAIRE-Connect] ";
|
12
|
private static closing = "OpenAIRE team";
|
13
|
private static openaireAddress = "<a href='https://www.openaire.eu'>www.openaire.eu</a><br>";
|
14
|
private static signature = Composer.closing + "<br>" + Composer.openaireAddress;
|
15
|
|
16
|
private static ifYouAreNotResponsible(mail): string {
|
17
|
return "If you are not responsible for this community, please "
|
18
|
+ "<a href=\mailto:'" + mail + "\'>contact us</a>. ";
|
19
|
}
|
20
|
|
21
|
private static manageNotificationSettings(communityId: string): string {
|
22
|
return "Click <a href='https://beta.admin.connect.openaire.eu/manage-user-notifications?communityId="
|
23
|
+ communityId + "'>here</a> to manage your notification settings. ";
|
24
|
}
|
25
|
|
26
|
private static youAreManagerOfTheCommunity(communityId: string, communityName: string): string {
|
27
|
return "You are receiving this e-mail as manager of the community "
|
28
|
+ "<a href='https://beta." + communityId + ".openaire.eu/'>" + communityName + "</a>. ";
|
29
|
}
|
30
|
|
31
|
public static composeEmailForNewManager(communityId: string, communityName: string, newCommunityManagers: any, mail: string): Email {
|
32
|
let email: Email = new Email();
|
33
|
|
34
|
email.subject = this.subjectPrefix + communityName + ": Welcome new manager";
|
35
|
email.body = "<div style='font-size:" + this.noteBodySize + "'><p>Welcome to OpenAIRE Connect!</p>"
|
36
|
+ "<p>You are receiving this e-mail as you were assigned as manager of the community <a href='https://beta."
|
37
|
+ communityId + ".openaire.eu/'>" + communityName + "</a> dashboard. "
|
38
|
+ "In order to access the administration section of your community you must first login using one of the available options. "
|
39
|
+ "<br>The administrative rights are associated to the e-mail address, that was used to send you this message."
|
40
|
+ " If you login with an account associated to a different email, please <a href='mailto:helpdesk@openaire.eu'>contact us</a>"
|
41
|
+ " or your colleagues, that already have access to the administration tool, to update your e-mail. <br>"
|
42
|
+ "You can access the administration tool by clicking the \"Manage\" button that will be available in the top right corner of the dashboard."
|
43
|
+ "</p>"
|
44
|
+ this.signature
|
45
|
+ "<p style='font-size:" + this.noteFontSize + "'>" + this.ifYouAreNotResponsible(mail) + "<p>"
|
46
|
+ "</div>";
|
47
|
email.recipients = newCommunityManagers;
|
48
|
|
49
|
return email;
|
50
|
}
|
51
|
|
52
|
public static composeEmailForNewCommunity(contactForm: any, admins: any): Email {
|
53
|
let email: Email = new Email();
|
54
|
|
55
|
email.subject = "RCD: Request for new community";
|
56
|
email.body = "<div style='font-size:" + this.noteBodySize + "'>"
|
57
|
+ "<span><b>Name</b>: " + contactForm.name + "</span><br>"
|
58
|
+ "<span><b>Surname</b>: " + contactForm.surname + "</span><br>"
|
59
|
+ "<span><b>Email</b>: " + contactForm.email + "</span><br>"
|
60
|
+ "<span><b>Affiliation</b>: " + contactForm.affiliation + "</span><br>"
|
61
|
+ "<span><b>Community Name</b>: " + contactForm.community + "</span>"
|
62
|
+ "<p>" + contactForm.message + "</p>"
|
63
|
+ "</div>";
|
64
|
email.recipients = admins;
|
65
|
return email;
|
66
|
}
|
67
|
|
68
|
public static composeEmailForFeedback(info: {name: string, url: string, email: string, issues: any[]}, recipients: string[]): Email {
|
69
|
let email: Email = new Email();
|
70
|
email.subject = 'Feedback report for ' + info.name;
|
71
|
email.body = "<div style='font-size:" + this.noteBodySize + "'>"
|
72
|
+ "<p>A user" + ((info.email)?(" with email " + info.email):"") + " has reported the following issue(s) for "
|
73
|
+ "<a href=\'" + info.url + "\'>" + info.name + "</a></p><ul>";
|
74
|
info.issues.forEach((issue, index) => {
|
75
|
email.body += "<br><li><span><b><u>" + issue.field + "</u>: </b></span>" + issue.report + "</li>";
|
76
|
});
|
77
|
email.body += "</ul></div>";
|
78
|
email.recipients = recipients;
|
79
|
return email;
|
80
|
}
|
81
|
|
82
|
public static composeEmailForUserAfterFeedback(recipients: string[]): Email {
|
83
|
let email: Email = new Email();
|
84
|
email.subject = 'Feedback report received';
|
85
|
email.body = "<div style='font-size:" + this.noteBodySize + "'>"
|
86
|
+ "<p>This is an automated message to let you know that your feedback has been successfully received. Our graph experts will get back to you as soon as possible.</p><br>"
|
87
|
+ "Thank you for contacting OpenAIRE."
|
88
|
+ "</div>";
|
89
|
email.recipients = recipients;
|
90
|
return email;
|
91
|
}
|
92
|
|
93
|
public static composeEmailToInformOldManagersForTheNewOnes(communityName: string, communityId: string, firstVersionOfManagers: any, managers: any, mail: string) : Email {
|
94
|
let email: Email = new Email();
|
95
|
|
96
|
email.subject = this.subjectPrefix + communityName + ": Managers list notification";
|
97
|
email.body = "<div style='font-size:" + this.noteBodySize + "'>"
|
98
|
+ "<p>There are updates in the managers list for \"" + communityName + "\" community.<br>"
|
99
|
+ "The list of managers is: " + managers.join(', ') + "</p>"
|
100
|
+ this.signature
|
101
|
+ "<p style='font-size:" + this.noteFontSize + "'>"
|
102
|
+ this.youAreManagerOfTheCommunity(communityId, communityName)
|
103
|
+ this.ifYouAreNotResponsible(mail)
|
104
|
+ "<br>"
|
105
|
+ this.manageNotificationSettings(communityId)
|
106
|
+ "</p>"
|
107
|
+ "</div>";
|
108
|
email.recipients = firstVersionOfManagers;
|
109
|
|
110
|
return email;
|
111
|
}
|
112
|
|
113
|
public static composeEmailToInformManagers(communityName: string, communityId: string, managers: any, subscriberMail: any, adminPortalURL: string): Email {
|
114
|
let email: Email = new Email();
|
115
|
|
116
|
email.subject = this.subjectPrefix + communityName + ": New subscriber notification";
|
117
|
email.body = "<div style='font-size" + this.noteBodySize + "'>"
|
118
|
+ "<p>There is a new subscriber ("+subscriberMail+") for \"" + communityName + "\" community. Click "
|
119
|
+ "<a href='" + adminPortalURL + "/manage-subscribers?communityId="
|
120
|
+ communityId + "'>here</a> to manage the subscribers list. </p>"
|
121
|
+ this.signature
|
122
|
+ "<p style='font-size:" + this.noteFontSize + "'>"
|
123
|
+ this.youAreManagerOfTheCommunity(communityId, communityName)
|
124
|
+ "<br>"
|
125
|
+ this.manageNotificationSettings(communityId)
|
126
|
+ "</p>"
|
127
|
+ "</div>";
|
128
|
email.recipients = managers;
|
129
|
|
130
|
return email;
|
131
|
}
|
132
|
|
133
|
public static formatEmailBodyForInvitation(body: Body): string {
|
134
|
let fromMessageAndName = "";
|
135
|
|
136
|
if (body.fromName != "") {
|
137
|
fromMessageAndName = "<span>" + body.fromMessage + body.fromName + "</span>";
|
138
|
}
|
139
|
|
140
|
let formattedEmail = "<div style='font-size:" + this.noteBodySize + "'>"
|
141
|
+ body.paragraphs
|
142
|
+ "<p>" + body.signature + fromMessageAndName + "<br>"
|
143
|
+ this.openaireAddress
|
144
|
+ "</p>"
|
145
|
+ "</div>";
|
146
|
|
147
|
return formattedEmail;
|
148
|
}
|
149
|
|
150
|
// TODO remove this after adding this on admin
|
151
|
public static initializeInvitationsBody(communityId: string, communityTitle: string, fullname: string): Body {
|
152
|
let body: Body = new Body();
|
153
|
let defaultMainBody;
|
154
|
if(communityId !== 'covid-19') {
|
155
|
defaultMainBody ='<p>You are invited to subscribe to <a href="https://beta.' + communityId + '.openaire.eu/">'
|
156
|
+ communityTitle + '</a> dashboard.<br>'
|
157
|
+ 'The purpose of this dashboard is to gather, link & monitor the research results related to your community.</p>'
|
158
|
+ '<p>The community dashboard is part of the <a href="https://connect.openaire.eu/">OpenAIRE-Connect</a> '
|
159
|
+ 'project and currently is in BETA version.'
|
160
|
+ '</p>';
|
161
|
} else {
|
162
|
defaultMainBody = '<p>This is a dashboard that gathers, links & monitors research results related COVID-19 (multi-disciplinary) from authoritative OA sources around the world. ' +
|
163
|
'We have a community of experts moderating and curating the content.</p> ' +
|
164
|
'<p>What you can do:</p>' +
|
165
|
'<ul>' +
|
166
|
'<li>navigate in a linked open data space, a contextual discovery</li>' +
|
167
|
'<li>automatically deposit in Zenodo designated communities</li>' +
|
168
|
'<li>link research results among themselves and to projects</li>' +
|
169
|
'<li>join the team of experts to curate/moderate the traffic, mining, links to the data</li>' +
|
170
|
'</ul> ' +
|
171
|
'<p>The community dashboard is part of the<a href="https://connect.openaire.eu/"> OpenAIRE-Connect</a> project.</p>'
|
172
|
}
|
173
|
|
174
|
return body = {fromMessage: ", on behalf of ", fromName: fullname, paragraphs: defaultMainBody, signature: this.closing, note: ""};
|
175
|
}
|
176
|
|
177
|
public static initializeInvitationsEmail(communityTitle: string) {
|
178
|
let email: Email = new Email();
|
179
|
|
180
|
return email = {body: "", subject: this.subjectPrefix + communityTitle, recipients: []};
|
181
|
}
|
182
|
}
|