[Trunk|Connect]: Search Communities: failed at subscription service, fetch the results
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@55324 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
752228d106
commit
47c003bb04
|
@ -21,7 +21,7 @@ import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
|
||||||
template: `
|
template: `
|
||||||
<search-page pageTitle="OpenAIRE Connect|Search Communities"
|
<search-page pageTitle="OpenAIRE Connect|Search Communities"
|
||||||
formPlaceholderText="Search for Research Communities and Initiatives"
|
formPlaceholderText="Search for Research Communities and Initiatives"
|
||||||
type="results" entityType="community" [filters]="filters"
|
type="communities" entityType="community" [filters]="filters"
|
||||||
[results]="results" [searchUtils]="searchUtils"
|
[results]="results" [searchUtils]="searchUtils"
|
||||||
[showResultCount]=true [baseUrl]="baseUrl"
|
[showResultCount]=true [baseUrl]="baseUrl"
|
||||||
(queryChange)="queryChanged($event)"
|
(queryChange)="queryChanged($event)"
|
||||||
|
@ -120,7 +120,7 @@ export class SearchCommunitiesComponent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all communities from Communities API and apply permission access validator,
|
* Get all communities from Communities API and apply permission access validator,
|
||||||
* if a keyword is included, filter, paging and sorting.
|
* keyword searching, filter, paging and sorting.
|
||||||
*
|
*
|
||||||
* @param params
|
* @param params
|
||||||
* @private
|
* @private
|
||||||
|
@ -147,39 +147,11 @@ export class SearchCommunitiesComponent {
|
||||||
for(let i = 0; i < res.length; i++) {
|
for(let i = 0; i < res.length; i++) {
|
||||||
this.results[i].isSubscribed = res[i];
|
this.results[i].isSubscribed = res[i];
|
||||||
}
|
}
|
||||||
this.showCommunities();
|
this.applyParams(params, this.errorCodes.DONE);
|
||||||
if(this.searchUtils.keyword && this.searchUtils.keyword != '') {
|
|
||||||
this.searchForKeywords();
|
|
||||||
}
|
|
||||||
this.checkFilters(params);
|
|
||||||
this.sort();
|
|
||||||
this.searchUtils.totalResults = this.results.length;
|
|
||||||
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 = this.errorCodes.DONE;
|
|
||||||
if(this.searchUtils.totalResults == 0 ){
|
|
||||||
this.searchUtils.status = this.errorCodes.NONE;
|
|
||||||
}
|
|
||||||
this.disableForms = false;
|
|
||||||
if(this.searchUtils.status == this.errorCodes.DONE) {
|
|
||||||
// Page out of limit!!!
|
|
||||||
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
|
||||||
if(!(Number.isInteger(totalPages))) {
|
|
||||||
totalPages = (parseInt(totalPages, 10) + 1);
|
|
||||||
}
|
|
||||||
if(totalPages < this.searchUtils.page) {
|
|
||||||
this.searchUtils.totalResults = 0;
|
|
||||||
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.scroll();
|
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
this.handleError('Error getting if user is subscribed', err);
|
this.handleError('Error getting if user is subscribed', err);
|
||||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
this.applyParams(params, this.errorCodes.MISSING_CONTENT);
|
||||||
this.disableForms = false;
|
|
||||||
this.scroll();
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -193,6 +165,47 @@ export class SearchCommunitiesComponent {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply permission access validator,
|
||||||
|
* keyword searching, filter, paging and sorting.
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @param status
|
||||||
|
*/
|
||||||
|
public applyParams(params: Map<string, string>, status: number) {
|
||||||
|
this.showCommunities();
|
||||||
|
if(this.searchUtils.keyword && this.searchUtils.keyword != '') {
|
||||||
|
this.searchForKeywords();
|
||||||
|
}
|
||||||
|
this.checkFilters(params);
|
||||||
|
this.sort();
|
||||||
|
this.searchUtils.totalResults = this.results.length;
|
||||||
|
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;
|
||||||
|
if(this.searchUtils.totalResults == 0 ){
|
||||||
|
this.searchUtils.status = this.errorCodes.NONE;
|
||||||
|
}
|
||||||
|
else if(this.searchUtils.totalResults == 1 ){
|
||||||
|
this.searchPage.type = this.searchPage.entityType;
|
||||||
|
}
|
||||||
|
this.disableForms = false;
|
||||||
|
if(this.searchUtils.status == status) {
|
||||||
|
// Page out of limit!!!
|
||||||
|
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
||||||
|
if(!(Number.isInteger(totalPages))) {
|
||||||
|
totalPages = (parseInt(totalPages, 10) + 1);
|
||||||
|
}
|
||||||
|
if(totalPages < this.searchUtils.page) {
|
||||||
|
this.searchUtils.totalResults = 0;
|
||||||
|
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.scroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the given keywords into array and check if any of the requirements field of a community includes
|
* Parse the given keywords into array and check if any of the requirements field of a community includes
|
||||||
* one of the given words.
|
* one of the given words.
|
||||||
|
|
Loading…
Reference in New Issue