import {Email} from "./email"; import {Body} from "./body"; import {FormArray} from "@angular/forms"; export class Composer { private static noteBodySize = "14px"; private static noteFontSize = "11px"; // TODO move to properties private static openaireEmail = "mailto:openaire.test@gmail.com"; private static subjectPrefix = "[OpenAIRE-Connect] "; private static closing = "OpenAIRE team"; private static openaireAddress = "www.openaire.eu
"; private static signature = Composer.closing + "
" + Composer.openaireAddress; private static ifYouAreNotResponsible(mail): string { return "If you are not responsible for this community, please " + "contact us. "; } private static manageNotificationSettings(communityId: string): string { return "Click here to manage your notification settings. "; } private static youAreManagerOfTheCommunity(communityId: string, communityName: string): string { return "You are receiving this e-mail as manager of the community " + "" + communityName + ". "; } public static composeEmailForNewManager(communityId: string, communityName: string, newCommunityManagers: any, mail: string): Email { let email: Email = new Email(); email.subject = this.subjectPrefix + communityName + ": Welcome new manager"; email.body = "

Welcome to OpenAIRE Connect!

" + "

You are receiving this e-mail as you were assigned as manager of the community " + communityName + " dashboard. " + "In order to access the administration section of your community you must first login using one of the available options. " + "
The administrative rights are associated to the e-mail address, that was used to send you this message." + " If you login with an account associated to a different email, please contact us" + " or your colleagues, that already have access to the administration tool, to update your e-mail.
" + "You can access the administration tool by clicking the \"Manage\" button that will be available in the top right corner of the dashboard." + "

" + this.signature + "

" + this.ifYouAreNotResponsible(mail) + "

" + "

"; email.recipients = newCommunityManagers; return email; } public static composeEmailForNewCommunity(contactForm: any, admins: any): Email { let email: Email = new Email(); email.subject = "OpenAIRE Connect | " + contactForm.subject; email.body = "
" + "Name: " + contactForm.name + "
" + "Surname: " + contactForm.surname + "
" + "Email: " + contactForm.email + "
" + "Affiliation: " + contactForm.affiliation + "
" + "Community Name: " + contactForm.community + "" + "

" + contactForm.message + "

" + "
"; email.recipients = admins; return email; } public static composeEmailForNewStakeholder(contactForm: any, admins: any): Email { let email: Email = new Email(); email.subject = "OpenAIRE Monitor | " + contactForm.subject; email.body = "
" + "Name: " + contactForm.name + "
" + "Surname: " + contactForm.surname + "
" + "Email: " + contactForm.email + "
" + "Affiliation: " + contactForm.affiliation + "
" + "Stakeholder Name: " + contactForm.stakeholder + "" + "

" + contactForm.message + "

" + "
"; email.recipients = admins; return email; } public static composeEmailForFeedback(info: {name: string, url: string, email: string, issues: any[]}, recipients: string[]): Email { let email: Email = new Email(); email.subject = 'Feedback report for ' + info.name; email.body = "
" + "

A user" + ((info.email)?(" with email " + info.email):"") + " has reported the following issue(s) for " + "" + info.name + "

"; email.recipients = recipients; return email; } public static composeEmailForUserAfterFeedback(recipients: string[]): Email { let email: Email = new Email(); email.subject = 'Feedback report received'; email.body = "
" + "

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.


" + "Thank you for contacting OpenAIRE." + "
"; email.recipients = recipients; return email; } public static composeEmailToInformOldManagersForTheNewOnes(communityName: string, communityId: string, firstVersionOfManagers: any, managers: any, mail: string) : Email { let email: Email = new Email(); email.subject = this.subjectPrefix + communityName + ": Managers list notification"; email.body = "
" + "

There are updates in the managers list for \"" + communityName + "\" community.
" + "The list of managers is: " + managers.join(', ') + "

" + this.signature + "

" + this.youAreManagerOfTheCommunity(communityId, communityName) + this.ifYouAreNotResponsible(mail) + "
" + this.manageNotificationSettings(communityId) + "

" + "
"; email.recipients = firstVersionOfManagers; return email; } public static composeEmailToInformManagers(communityName: string, communityId: string, managers: any, subscriberMail: any, adminPortalURL: string): Email { let email: Email = new Email(); email.subject = this.subjectPrefix + communityName + ": New subscriber notification"; email.body = "
" + "

There is a new subscriber ("+subscriberMail+") for \"" + communityName + "\" community. Click " + "here to manage the subscribers list.

" + this.signature + "

" + this.youAreManagerOfTheCommunity(communityId, communityName) + "
" + this.manageNotificationSettings(communityId) + "

" + "
"; email.recipients = managers; return email; } public static formatEmailBodyForInvitation(body: Body): string { let fromMessageAndName = ""; if (body.fromName != "") { fromMessageAndName = "" + body.fromMessage + body.fromName + ""; } let formattedEmail = "
" + body.paragraphs + "

" + body.signature + fromMessageAndName + "
" + this.openaireAddress + "

" + "
"; return formattedEmail; } // TODO remove this after adding this on admin public static initializeInvitationsBody(communityId: string, communityTitle: string, fullname: string): Body { let body: Body = new Body(); let defaultMainBody; if(communityId !== 'covid-19') { defaultMainBody ='

You are invited to subscribe to ' + communityTitle + ' dashboard.
' + 'The purpose of this dashboard is to gather, link & monitor the research results related to your community.

' + '

The community dashboard is part of the OpenAIRE-Connect ' + 'project and currently is in BETA version.' + '

'; } else { defaultMainBody = '

This is a dashboard that gathers, links & monitors research results related COVID-19 (multi-disciplinary) from authoritative OA sources around the world. ' + 'We have a community of experts moderating and curating the content.

' + '

What you can do:

' + ' ' + '

The community dashboard is part of the OpenAIRE-Connect project.

' } return body = {fromMessage: ", on behalf of ", fromName: fullname, paragraphs: defaultMainBody, signature: this.closing, note: ""}; } public static initializeInvitationsEmail(communityTitle: string) { let email: Email = new Email(); return email = {body: "", subject: this.subjectPrefix + communityTitle, recipients: []}; } }