[Trunk|Connect]: Search Communities: on Error retrieving subscribers isSubscribed set to false

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@55355 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-04-15 10:48:18 +00:00
parent 8ed77aef1e
commit 3b74d41b88
1 changed files with 13 additions and 13 deletions

View File

@ -10,11 +10,12 @@ import {SearchFields} from "../../openaireLibrary/utils/properties/searchFields"
import {CommunitiesService} from "../../openaireLibrary/connect/communities/communities.service";
import {Session} from "../../openaireLibrary/login/utils/helper.class";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {SearchResult} from "../../openaireLibrary/utils/entities/searchResult";
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
import {Observable} from "rxjs";
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
import {catchError} from "rxjs/operators";
import {of} from "rxjs/observable/of";
@Component({
selector: 'search-communities',
@ -109,7 +110,10 @@ export class SearchCommunitiesComponent {
// 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()));
observables.push(this._subscribeService.isSubscribedToCommunity(this.totalResults[i].communityId, Session.getUserEmail(), this.properties["adminToolsAPIURL"]));
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(
@ -117,11 +121,7 @@ export class SearchCommunitiesComponent {
for(let i = 0; i < res.length; i++) {
this.totalResults[i].isSubscribed = res[i];
}
this._getResults(params, this.errorCodes.DONE);
},
err => {
this.handleError('Error getting if user is subscribed', err);
this._getResults(params, this.errorCodes.MISSING_CONTENT);
this._getResults(params);
}
);
},
@ -143,12 +143,12 @@ export class SearchCommunitiesComponent {
* @param params, status
* @private
*/
private _getResults(params: Map<string, string>, status: number){
private _getResults(params: Map<string, string>){
this.searchUtils.status = this.errorCodes.LOADING;
this.disableForms = true;
this.results = this.totalResults;
this.searchUtils.totalResults = 0;
this.applyParams(params, status);
this.applyParams(params);
}
/**
@ -182,7 +182,7 @@ export class SearchCommunitiesComponent {
* @param params
* @param status
*/
public applyParams(params: Map<string, string>, status: number) {
public applyParams(params: Map<string, string>) {
this.showCommunities();
if(this.searchUtils.keyword && this.searchUtils.keyword != '') {
this.searchForKeywords();
@ -193,12 +193,12 @@ export class SearchCommunitiesComponent {
this.searchPage.checkSelectedFilters(this.filters);
this.searchPage.updateBaseUrlWithParameters(this.filters);
this.results = this.results.slice((this.searchUtils.page-1)*this.searchUtils.size, (this.searchUtils.page*this.searchUtils.size));
this.searchUtils.status = status;
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
this.disableForms = false;
if(this.searchUtils.status == status) {
if(this.searchUtils.status == this.errorCodes.DONE) {
// Page out of limit!!!
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
if(!(Number.isInteger(totalPages))) {
@ -427,7 +427,7 @@ export class SearchCommunitiesComponent {
}
public queryChanged($event) {
this._getResults($event.params, this.errorCodes.DONE);
this._getResults($event.params);
}
/**