Send email to inform managers for a new subscriber
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@53922 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
ebed6e2b83
commit
8a9f632e51
|
@ -4,9 +4,13 @@ import {ActivatedRoute} from '@angular/router';
|
|||
import { EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
|
||||
import {AlertModal} from '../../openaireLibrary/utils/modal/alert';
|
||||
|
||||
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
|
||||
import {SubscribeService} from '../../openaireLibrary/utils/subscribe/subscribe.service';
|
||||
import {EmailService} from "../../openaireLibrary/utils/email/email.service";
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
|
||||
import {Email} from "../../openaireLibrary/utils/email/email";
|
||||
|
||||
declare var UIkit: any;
|
||||
|
||||
@Component({
|
||||
|
@ -35,6 +39,9 @@ export class SubscribeComponent {
|
|||
@Input() showNumbers:boolean;
|
||||
@Input() communityId:string;
|
||||
|
||||
public community = null;
|
||||
public emailToInformManagers: Email;
|
||||
|
||||
loading: boolean = false;
|
||||
subscribed:boolean = null;
|
||||
properties:EnvProperties;
|
||||
|
@ -42,7 +49,9 @@ export class SubscribeComponent {
|
|||
showLoginAlert:Boolean = false;
|
||||
@ViewChild(AlertModal) alert;
|
||||
constructor (private route: ActivatedRoute,
|
||||
private _subscribeService: SubscribeService
|
||||
private _subscribeService: SubscribeService,
|
||||
private _emailService: EmailService,
|
||||
private _communityService: CommunityService
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -65,9 +74,18 @@ export class SubscribeComponent {
|
|||
res => {
|
||||
|
||||
this.subscribers = (res && res.subscribers && res.subscribers.length )?res.subscribers.length:0;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
this.emailToInformManagers = {body: "", subject: "", recipients: []};
|
||||
|
||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe (
|
||||
community => {
|
||||
this.community = community;
|
||||
console.log(this.community);
|
||||
},
|
||||
error => console.log('System error retrieving community profile', error)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
@ -95,12 +113,38 @@ export class SubscribeComponent {
|
|||
} else {
|
||||
if(!this.subscribed){
|
||||
this.subscribed = true;
|
||||
this.composeEmailToInformManagers(this.community.title, this.communityId, this.community.managers);
|
||||
this._emailService.sendEmail("http://scoobydoo.di.uoa.gr:8080/uoa-admin-tools/notifyForNewSubscribers/"+ this.communityId, this.composeEmailToInformManagers(this.community.title, this.communityId, this.community.managers)).subscribe(
|
||||
res => {
|
||||
console.log("The email has been sent successfully!")
|
||||
},
|
||||
error => console.log(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// TODO find the right place to write it
|
||||
composeEmailToInformManagers(communityName: string, communityId: string, managers: any): Email {
|
||||
this.emailToInformManagers.subject = "[OpenAIRE-Connect] " + communityName + ": Managers";
|
||||
this.emailToInformManagers.body = "<p>You are receiving this e-mail as you were assigned as manager of the community <a href='https://beta."
|
||||
+ communityId + ".openaire.eu/'>" + communityName + "</a> dashboard. "
|
||||
+ "In order to access the administration section of your community you must first login using one of the available options. "
|
||||
+ "<br>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 <a href='mailto:helpdesk@openaire.eu'>contact us</a>"
|
||||
+ " or your colleagues, that already have access to the administration tool, to update your e-mail. <br>"
|
||||
+ "You can access the administration tool by clicking the \"Manage\" button that will be available in the top right corner of the dashboard."
|
||||
+ "</p><br><br>"
|
||||
+ "OpenAIRE team<br>" + "<a href='https://www.openaire.eu'>www.openaire.eu</a>";
|
||||
|
||||
this.emailToInformManagers.recipients = managers;
|
||||
console.log(this.emailToInformManagers);
|
||||
|
||||
return this.emailToInformManagers;
|
||||
}
|
||||
|
||||
unsubscribe(){
|
||||
var email = Session.getUserEmail();
|
||||
if(email == null){
|
||||
|
|
|
@ -3,6 +3,9 @@ import { CommonModule } from '@angular/common';
|
|||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { SubscribeService } from '../../openaireLibrary/utils/subscribe/subscribe.service';
|
||||
import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
|
||||
|
||||
import {EmailService} from "../../openaireLibrary/utils/email/email.service";
|
||||
import {SubscribeComponent} from './subscribe.component';
|
||||
import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module';
|
||||
|
||||
|
@ -14,7 +17,7 @@ import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.mod
|
|||
SubscribeComponent
|
||||
],
|
||||
providers:[
|
||||
SubscribeService
|
||||
SubscribeService, EmailService, CommunityService
|
||||
],
|
||||
exports: [
|
||||
SubscribeComponent
|
||||
|
|
Loading…
Reference in New Issue