Send email to inform for new Manager/s

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@53898 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
sofia.baltzi 2018-11-20 16:30:53 +00:00
parent e32f6cdae8
commit def7d88f0a
1 changed files with 19 additions and 3 deletions

View File

@ -46,6 +46,8 @@ export class CommunityEditFormComponent implements OnInit{
public email: Email;
public emailToInform: Email;
public properties:EnvProperties = null;
constructor (private route: ActivatedRoute,
@ -65,6 +67,7 @@ export class CommunityEditFormComponent implements OnInit{
this.communityId = communityId['communityId'];
this.email = {body: "", subject: "", recipients: []};
this.emailToInform = {body: "", subject: "", recipients: []};
if(!Session.isLoggedIn()){
console.info(this._router.url);
@ -155,6 +158,8 @@ export class CommunityEditFormComponent implements OnInit{
console.log("New managers in component: " + newManagers);
if (newManagers !== null) {
this.sendMailToNewManagers(newManagers);
console.log("Old managers in component: " + this.firstVersionOfManagers);
this.informOldManagersForTheNewOnes(this.firstVersionOfManagers);
for (let i = 0; i < newManagers.length; i++) {
console.log(newManagers[i]);
this._subscribeService.subscribeToCommunity(this.communityId, newManagers[i], this.properties.adminToolsAPIURL).subscribe(
@ -222,11 +227,15 @@ export class CommunityEditFormComponent implements OnInit{
},
error => console.log(error)
);
// console.log("Stelnei mail");
}
private informOldManagersForTheNewOnes(managers: any) {
this._emailService.sendEmail("http://scoobydoo.di.uoa.gr:8080/uoa-admin-tools/notifyForNewManagers/"+ this.communityId, this.composeEmailToInformOldManagersForTheNewOnes(this.community.title, this.communityId, this.firstVersionOfManagers)).subscribe(
res => {
console.log("The email has been sent successfully!")
},
error => console.log(error)
);
}
// TODO find the right place to write it
@ -243,8 +252,15 @@ export class CommunityEditFormComponent implements OnInit{
}
// TODO find the right place to write it
private composeEmailToInformOldManagersForTheNewOnes() {
private composeEmailToInformOldManagersForTheNewOnes(communityName: string, communityId: string, firstVersionOfManagers: any) : Email {
this.emailToInform.subject = "[OpenAIRE-Connect]" + communityName + ": New subscriber notification";
this.emailToInform.body = "<p>There is a new subscriber for " + communityName +
"community. Click <a href='https://beta.admin.connect.openaire.eu/manage-subscribers?communityId=" +
communityId + "'>here</a> to manage the subscibers list.</p><br><br>" +
"OpenAIRE team<br>"+ "<a href='https://www.openaire.eu'>www.openaire.eu</a>";
this.emailToInform.recipients = firstVersionOfManagers;
return this.emailToInform;
}
private subscribeNewManagers(newManagers: string[]): boolean {