[Trunk|Connect]: 1. AppComponent: comment is SubscribedToCommunity. 2. SearchCommunities: Add condition if user is logged in before get subscription and managing infomation

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@55393 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-04-17 10:37:49 +00:00
parent c50740f7c6
commit 4e6b258a3d
2 changed files with 24 additions and 17 deletions

View File

@ -74,7 +74,6 @@ export class AppComponent {
var community = null;
this.community = null;
this.showMenu = false;
this._communitiesService.getCommunities(this.properties, this.properties.communitiesAPI).subscribe (
communities => {
@ -95,7 +94,7 @@ export class AppComponent {
this.managerOfCommunities = true;
}else if(com.managers.indexOf(Session.getUserEmail())!=-1){
this.managerOfCommunities = true;
}else if(!this.subscriberOfCommunities){
}/*else if(!this.subscriberOfCommunities){
// check if subscriber
this._subscribeService.isSubscribedToCommunity(com.communityId, Session.getUserEmail(), this.properties.adminToolsAPIURL).subscribe (
isSubscriber => {
@ -107,7 +106,7 @@ export class AppComponent {
console.error("Error fetching your subscribed communities")
});
}
}*/
}

View File

@ -107,32 +107,40 @@ export class SearchCommunitiesComponent {
let observables: Observable<boolean>[] = [];
for(let i = 0; i < data.length; i++) {
this.totalResults[i] = data[i];
this.totalResults[i].isManager = false;
this.totalResults[i].isSubscribed = false;
// For Test do not delete them.
//this.results[i].description = "EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation."
//this.results[i].date = new Date(new Date(2012, 0, 1).getTime() + Math.random() * (new Date().getTime() - new Date(2012, 0, 1).getTime()));
let observable: Observable<boolean> = this._subscribeService.isSubscribedToCommunity(this.totalResults[i].communityId, Session.getUserEmail(), this.properties["adminToolsAPIURL"]);
observables.push(observable.pipe(catchError(err => {
return of(false);
})));
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
if(Session.isLoggedIn()) {
let observable: Observable<boolean> = this._subscribeService.isSubscribedToCommunity(this.totalResults[i].communityId, Session.getUserEmail(), this.properties["adminToolsAPIURL"]);
observables.push(observable.pipe(catchError(err => {
return of(false);
})));
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
}
}
Observable.forkJoin(observables).subscribe(
res => {
for(let i = 0; i < res.length; i++) {
this.totalResults[i].isSubscribed = res[i];
if (observables.length > 0) {
Observable.forkJoin(observables).subscribe(
res => {
for (let i = 0; i < res.length; i++) {
this.totalResults[i].isSubscribed = res[i];
}
this._getResults(params);
}
this._getResults(params);
}
);
);
}
else {
this._getResults(params);
}
},
err => {
//console.log(err);
this.handleError('Error getting communities', err);
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
this.disableForms = false;
this.scroll();
}
);
);
}