Send email to a new Manager
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@53894 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
1dd618dae7
commit
e32f6cdae8
|
@ -5,10 +5,13 @@ import {ActivatedRoute, Router} from '@angular/router';
|
|||
|
||||
import {HelpContentService} from "../../../services/help-content.service";
|
||||
import {CommunityService} from "../../../openaireLibrary/connect/community/community.service";
|
||||
import {SubscribeService} from "../../../openaireLibrary/utils/subscribe/subscribe.service"
|
||||
import {SubscribeService} from "../../../openaireLibrary/utils/subscribe/subscribe.service";
|
||||
import {EmailService} from "../../../openaireLibrary/utils/email/email.service";
|
||||
|
||||
import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {CommunityInfo} from '../../../openaireLibrary/connect/community/communityInfo';
|
||||
import {Email} from "../../../openaireLibrary/utils/email/email";
|
||||
|
||||
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
@ -41,6 +44,8 @@ export class CommunityEditFormComponent implements OnInit{
|
|||
public firstVersionOfManagers: string[];
|
||||
public newManagersToSubscribe: string[];
|
||||
|
||||
public email: Email;
|
||||
|
||||
public properties:EnvProperties = null;
|
||||
|
||||
constructor (private route: ActivatedRoute,
|
||||
|
@ -48,7 +53,8 @@ export class CommunityEditFormComponent implements OnInit{
|
|||
public _fb: FormBuilder,
|
||||
private _helpContentService: HelpContentService,
|
||||
private _communityService: CommunityService,
|
||||
private _subscribeService: SubscribeService){ }
|
||||
private _subscribeService: SubscribeService,
|
||||
private _emailService: EmailService){ }
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -58,6 +64,8 @@ export class CommunityEditFormComponent implements OnInit{
|
|||
communityId => {
|
||||
this.communityId = communityId['communityId'];
|
||||
|
||||
this.email = {body: "", subject: "", recipients: []};
|
||||
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
|
@ -146,6 +154,7 @@ export class CommunityEditFormComponent implements OnInit{
|
|||
// TODO delete after testing
|
||||
console.log("New managers in component: " + newManagers);
|
||||
if (newManagers !== null) {
|
||||
this.sendMailToNewManagers(newManagers);
|
||||
for (let i = 0; i < newManagers.length; i++) {
|
||||
console.log(newManagers[i]);
|
||||
this._subscribeService.subscribeToCommunity(this.communityId, newManagers[i], this.properties.adminToolsAPIURL).subscribe(
|
||||
|
@ -206,6 +215,38 @@ export class CommunityEditFormComponent implements OnInit{
|
|||
return newManagers;
|
||||
}
|
||||
|
||||
private sendMailToNewManagers(managers: any) {
|
||||
this._emailService.sendEmail("http://scoobydoo.di.uoa.gr:8080/uoa-admin-tools/sendMail", this.composeEmailForNewManager(this.community.title, managers)).subscribe(
|
||||
res => {
|
||||
console.log("The email has been sent successfully!")
|
||||
},
|
||||
error => console.log(error)
|
||||
);
|
||||
// console.log("Stelnei mail");
|
||||
}
|
||||
|
||||
private informOldManagersForTheNewOnes(managers: any) {
|
||||
|
||||
}
|
||||
|
||||
// TODO find the right place to write it
|
||||
private composeEmailForNewManager(communityName: string, newCommunityManagers: any): Email {
|
||||
this.email.subject = "[OpenAIRE-Connect] " + communityName + ": Managers list notification";
|
||||
this.email.body = "<p>There are updates in the managers list for" + communityName + "community.<br>"
|
||||
+ "The list of managers is: " + newCommunityManagers + "</p><br><br>" +
|
||||
"OpenAIRE team<br>"+ "<a href='https://www.openaire.eu'>www.openaire.eu</a>";
|
||||
this.email.recipients = newCommunityManagers;
|
||||
|
||||
console.log(this.email);
|
||||
|
||||
return this.email;
|
||||
}
|
||||
|
||||
// TODO find the right place to write it
|
||||
private composeEmailToInformOldManagersForTheNewOnes() {
|
||||
|
||||
}
|
||||
|
||||
private subscribeNewManagers(newManagers: string[]): boolean {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import {RouterModule} from '@angular/router';
|
|||
import {CommunityEditFormComponent} from './community-edit-form.component';
|
||||
|
||||
import {CommunityService} from '../../../openaireLibrary/connect/community/community.service';
|
||||
import {EmailService} from '../../../openaireLibrary/utils/email/email.service';
|
||||
|
||||
@NgModule({
|
||||
imports:[
|
||||
|
@ -15,7 +16,7 @@ import {CommunityService} from '../../../openaireLibrary/connect/commu
|
|||
CommunityEditFormComponent
|
||||
],
|
||||
providers:[
|
||||
CommunityService
|
||||
CommunityService, EmailService
|
||||
],
|
||||
exports: [
|
||||
CommunityEditFormComponent
|
||||
|
|
Loading…
Reference in New Issue