openaire-library/connect/community/community.service.ts

212 lines
7.1 KiB
TypeScript
Raw Normal View History

import { Injectable } from '@angular/core';
import {HttpClient, HttpHeaders} from "@angular/common/http";
import { CommunityInfo } from './communityInfo';
import {EnvProperties} from '../../utils/properties/env-properties';
import {map} from "rxjs/operators";
import {BehaviorSubject, from, Subscriber} from "rxjs";
import {properties} from "../../../../environments/environment";
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
@Injectable({ providedIn: 'root' })
export class CommunityService {
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
public community: BehaviorSubject<CommunityInfo> = null;
private promise: Promise<boolean> = null;
constructor(private http: HttpClient) {
this.community = new BehaviorSubject(null);
}
sub;
ngOnDestroy() {
this.clearSubscriptions();
}
clearSubscriptions(){
if (this.sub instanceof Subscriber) {
this.sub.unsubscribe();
}
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
getCommunityByService(properties: EnvProperties, url: string) {
this.promise = new Promise<any>(resolve => {
this.sub = this.getCommunity(properties, url).subscribe(res => {
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
this.community.next(res);
resolve();
},
error => {
this.community.error(error);
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
resolve();
})
});
}
async getCommunityByStateAsync(properties: EnvProperties, url: string) {
if(!this.promise) {
this.getCommunityByService(properties, url);
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
await this.promise;
this.clearSubscriptions();
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
return this.community.getValue();
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
getCommunityByState(properties: EnvProperties, url: string) {
return from(this.getCommunityByStateAsync(properties, url));
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
getCommunity(properties: EnvProperties, url: string) {
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
.pipe(map(res => this.parseCommunity(res)));
}
updateCommunity(url: string, community: any) {
//const headers = new Headers({'Content-Type': 'application/json'});
//const options = new RequestOptions({headers: headers});
const options = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
})
};
const body = JSON.stringify(community);
return this.http.post(url, body, options);
/*.map(res => res.json())*/
}
async isCommunityManagerByStateAsync(properties: EnvProperties, url: string, manager: string) {
if(!this.promise) {
this.getCommunityByService(properties, url);
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
await this.promise;
let community: CommunityInfo = this.community.getValue();
return (community.managers.indexOf(manager) !== -1);
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
isCommunityManagerByState(properties: EnvProperties, url: string, manager: string) {
return from(this.isCommunityManagerByStateAsync(properties, url, manager));
}
/**
* @deprecated
*/
isCommunityManager(properties: EnvProperties, url: string, manager: string) {
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
//.map(res => <any> res.json())
.pipe(map(res => this.parseCommunity(res)))
.pipe(map(community => community.managers.indexOf(manager) !== -1));
}
async isTypeByStateAsync(properties: EnvProperties, url: string, type: string) {
if(!this.promise) {
this.getCommunityByService(properties, url);
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
await this.promise;
let community: CommunityInfo = this.community.getValue();
return (community && community.type && community.type === type);
}
isRITypeByState(properties: EnvProperties, url: string) {
return from(this.isTypeByStateAsync(properties, url, "ri"));
}
isCommunityTypeByState(properties: EnvProperties, url: string) {
return from(this.isTypeByStateAsync(properties, url, "community"));
}
/**
* @deprecated
*/
isRIType(properties: EnvProperties, url: string) {
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
//.map(res => <any> res.json())
.pipe(map(res => this.parseCommunity(res)))
.pipe(map(community => (community && community.type && community.type === 'ri')));
}
/**
[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
2020-04-07 16:57:26 +02:00
* @deprecated
*/
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
isCommunityType(properties: EnvProperties, url: string) {
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
//.map(res => <any> res.json())
.pipe(map(res => this.parseCommunity(res)))
.pipe(map(community => (community && community.type && community.type === 'community')));
}
/**
* @deprecated
*/
isSubscribedToCommunity(pid: string, email: string, url: string) {
return this.http.get(url + '/'+ properties.adminToolsPortalType +'/' + pid + '/subscribers')
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
//.map(res => ((<any>res === '') ? {} : <any> res.json()))
.pipe(map(res => {
if (res['subscribers'] && res['subscribers'] != null) {
for (let i = 0; i < res['subscribers'].length; i++ ) {
if (res['subscribers'][i] != null && res['subscribers'][i].email === email) {
return true;
}
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
}
return false;
}));
}
private parseCommunity(data: any): CommunityInfo {
const resData = Array.isArray(data) ? data[0] : data;
const community: CommunityInfo = new CommunityInfo();
community['title'] = resData.name;
community['shortTitle'] = resData.shortName;
community['communityId'] = resData.id;
community['queryId'] = resData.queryId;
community['logoUrl'] = resData.logoUrl;
community['description'] = resData.description;
community['date'] = resData.creationDate;
community['zenodoCommunity'] = resData.zenodoCommunity;
community['status'] = 'all';
if (resData.hasOwnProperty('status')) {
community['status'] = resData.status;
const status = ['all', 'hidden', 'manager'];
if (status.indexOf(community['status']) === -1) {
community['status'] = 'hidden';
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
}
if (resData.type != null) {
community['type'] = resData.type;
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
if (resData.managers != null) {
if (community['managers'] === undefined) {
community['managers'] = new Array<string>();
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
const managers = resData.managers;
const length = Array.isArray(managers) ? managers.length : 1;
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
for (let i = 0; i < length; i++) {
const manager = Array.isArray(managers) ? managers[i] : managers;
community.managers[i] = manager;
}
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
if (resData.subjects != null) {
if (community['subjects'] === undefined) {
community['subjects'] = new Array<string>();
}
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
const subjects = resData.subjects;
const length = Array.isArray(subjects) ? subjects.length : 1;
[Trunk | Library]: 1. community.service.ts: a. Add BehaviorSubject for community. b. Method "isCommunityManager" replaced by "isCommunityManagerByState" (filtering applied in community stored in BehaviorSubject). c. Method "isRIType" replaced by "isRITypeByState" (filtering applied in community stored in BehaviorSubject). d. Method "isCommunityType" replaced by "isCommunityTypeByState" (filtering applied in community stored in BehaviorSubject). 2. connectAdminLoginGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityManagerByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 3. connectCommunityGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isCommunityTypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 4. connectRIGuard.guard.ts: a. Get properties from environment (no service needed). b. Call method "isRITypeByState" of CommunityService. c. Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 5. isRouteEnabled.guard.ts: Add "canDeactivate" method to unsubscribe (TODO: call method from routing modules). 6. curator.service.ts: [Undo change of r59073] Use "useCache" property, not "useLongCache" for curators. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59140 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-17 01:08:10 +02:00
for (let i = 0; i < length; i++) {
const subject = Array.isArray(subjects) ? subjects[i] : subjects;
community.subjects[i] = subject;
}
}
return community;
}
}