[Trunk | Library]:

1. community.service.ts: Mark unused method "isSubscribedToCommunity()" as "deprecated" (This service calls community API - made in Italy, not uoa-admin-tools - made in Greece).
2. connectSubscriber.guard.ts: Call "isSubscribedToCommunity()" method from "subscribe.service.ts" (not "community.service.ts").
3. curator.service.ts: getCurators(properties: EnvProperties, url: string) --> getCurators(properties: EnvProperties, emails: string): Build path for request in service.
4. email.service.ts: Build request path in service
	a. sendEmail(url: string, email: Email) --> sendEmail(properties: EnvProperties, email: Email)
	b. contact(url: string, email: Email, recaptcha: string = null) --> contact(properties: EnvProperties, email: Email, recaptcha: string = null)
	c. Create method "notifyForNewManagers(properties: EnvProperties, communityId: string, email: Email)" (sendEmail was used for everything).
5. subscribe.service.ts: 
	a. subscribeToCommunity(pid: string, email: string, url: string) --> subscribeToCommunity(properties: EnvProperties, pid: string, email: string)
	b. unSubscribeToCommunity(pid: string, email: string, url: string) --> unSubscribeToCommunity(properties: EnvProperties, pid: string, email: string)
6. layout.service.ts: getLayout(communityId: string, url: string) -->  getLayout(properties: EnvProperties, communityId: string): Build path for request in service.
7. feedback.component.ts: In method "contact" from "emailService", build request path in service.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58420 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2020-04-07 14:57:26 +00:00
parent e404f1caf5
commit 4d6d459f41
7 changed files with 29 additions and 14 deletions

View File

@ -54,6 +54,9 @@ export class CommunityService {
.pipe(map(community => (community && community.type && community.type === 'community')));
}
/**
* @deprecated
*/
isSubscribedToCommunity(pid: string, email: string, url: string) {
return this.http.get(url + '/community/' + pid + '/subscribers')
//.map(res => ((<any>res === '') ? {} : <any> res.json()))

View File

@ -9,11 +9,13 @@ import {CommunityService} from '../community/community.service';
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper';
import {UserManagementService} from "../../services/user-management.service";
import {SubscribeService} from "../../utils/subscribe/subscribe.service";
@Injectable()
export class ConnectSubscriberGuard implements CanActivate {
constructor(private router: Router,
private communityService: CommunityService,
private subscribeService: SubscribeService,
private userManagementService: UserManagementService,
private propertiesService: EnvironmentSpecificService) {}
@ -29,7 +31,7 @@ export class ConnectSubscriberGuard implements CanActivate {
if(communityDomain) {
community = communityDomain;
}
return this.communityService.isSubscribedToCommunity( community, email, properties["adminToolsAPIURL"])
return this.subscribeService.isSubscribedToCommunity(properties, community, email)
} else {
return of(false);
}

View File

@ -11,7 +11,8 @@ export class CuratorService {
constructor(private http: HttpClient) {
}
public getCurators(properties: EnvProperties, url: string): Observable<Curator[]> {
public getCurators(properties: EnvProperties, emails: string): Observable<Curator[]> {
let url: string = properties.adminToolsAPIURL + '/curator?emails='+emails;
return this.http.get<Curator[]>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
}

View File

@ -117,12 +117,12 @@ export class FeedbackComponent implements OnInit, OnChanges {
public sendReport() {
this.sending = true;
this.emailService.contact(this.properties.adminToolsAPIURL + '/contact',
this.emailService.contact(this.properties,
Composer.composeEmailForFeedback(this.form.value, this.recipients), this.form.get('recaptcha').value).subscribe(sent => {
this.error = !sent;
if(sent) {
if(this.form.get('email').value !== '') {
this.emailService.contact(this.properties.adminToolsAPIURL + '/contact',
this.emailService.contact(this.properties,
Composer.composeEmailForUserAfterFeedback([this.form.get('email').value])).subscribe(sent => {
if(sent) {
//console.log('An email has been sent to user ' + this.form.get('email').value);

View File

@ -3,6 +3,7 @@ import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {Observable, throwError} from 'rxjs';
import {CustomOptions} from './servicesUtils/customOptions.class';
import {CustomizationOptions} from '../connect/community/CustomizationOptions';
import {EnvProperties} from "../utils/properties/env-properties";
@Injectable()
export class LayoutService {
@ -26,8 +27,8 @@ export class LayoutService {
+ communityId + '/layout', layout, CustomOptions.getAuthOptionsWithBody());
}
getLayout(communityId: string, url: string): Observable<CustomizationOptions> {
return this.http.get<CustomizationOptions>(url + communityId + '/layout');
getLayout(properties: EnvProperties, communityId: string): Observable<CustomizationOptions> {
return this.http.get<CustomizationOptions>(properties.adminToolsAPIURL+"/community/" + communityId + '/layout');
}
mockLayout(): any {

View File

@ -5,6 +5,7 @@ import {Email} from './email';
import {CustomOptions} from '../../services/servicesUtils/customOptions.class';
import {EmailRecaptcha} from "../entities/EmailRecaptcha";
import {Observable} from "rxjs";
import {EnvProperties} from "../properties/env-properties";
@Injectable()
export class EmailService {
@ -12,18 +13,25 @@ export class EmailService {
constructor(private http:HttpClient) {
}
sendEmail(url: string, email: Email) {
notifyForNewManagers(properties: EnvProperties, communityId: string, email: Email) {
let body = JSON.stringify(email);
return this.http.post(properties.adminToolsAPIURL + "/notifyForNewSubscribers/" + communityId, body, CustomOptions.getAuthOptionsWithBody());
//.map(request => request.json());
}
sendEmail(properties: EnvProperties, email: Email) {
let body = JSON.stringify(email);
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody());
return this.http.post(properties.adminToolsAPIURL + "/sendMail/", body, CustomOptions.getAuthOptionsWithBody());
//.map(request => request.json());
}
contact(url: string, email: Email, recaptcha: string = null):Observable<boolean> {
contact(properties: EnvProperties, email: Email, recaptcha: string = null):Observable<boolean> {
const data: EmailRecaptcha = new EmailRecaptcha();
data.email = email;
data.recaptcha = recaptcha;
return this.http.post<boolean>(url, data);
return this.http.post<boolean>(properties.adminToolsAPIURL + '/contact', data);
}
}

View File

@ -35,13 +35,13 @@ export class SubscribeService {
}));
}
subscribeToCommunity(pid: string, email: string, url: string) {
subscribeToCommunity(properties: EnvProperties, pid: string, email: string) {
let subscriber = {"email": email};
return this.http.post<any>(url + "/community/" + pid + "/subscribers", JSON.stringify(subscriber), CustomOptions.getAuthOptionsWithBody());
return this.http.post<any>(properties.adminToolsAPIURL + "/community/" + pid + "/subscribers", JSON.stringify(subscriber), CustomOptions.getAuthOptionsWithBody());
}
unSubscribeToCommunity(pid: string, email: string, url: string) {
return this.http.post<any>(url + "/community/" + pid + "/subscribers/delete", JSON.stringify([email]), CustomOptions.getAuthOptionsWithBody());
unSubscribeToCommunity(properties: EnvProperties, pid: string, email: string) {
return this.http.post<any>(properties.adminToolsAPIURL + "/community/" + pid + "/subscribers/delete", JSON.stringify([email]), CustomOptions.getAuthOptionsWithBody());
}
getCommunitiesSubscribedTo(properties: EnvProperties, email: string) {