Merge remote-tracking branch 'origin/develop' into recommendations-functionality

This commit is contained in:
Konstantina Galouni 2024-09-24 12:18:09 +03:00
commit 2f53fffa0f
1 changed files with 16 additions and 64 deletions

View File

@ -54,14 +54,6 @@ export class HelpContentService {
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// toggleEntity(selectedCommunityId: string, id : string,status : boolean) {
// let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers});
//
// return this.http.post(helpContentUrl + 'community/'+selectedCommunityId+'/entity/toggle?status='+ status.toString()+'&entityId='+id.toString(), options)
// .catch(this.handleError);
// }
getCommunityEntities(pid: string) { getCommunityEntities(pid: string) {
return this.http.get<Array<Entity>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/entities') return this.http.get<Array<Entity>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/entities')
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
@ -81,27 +73,8 @@ export class HelpContentService {
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// getDivIdsFull(page_id: string, helpContentUrl:string, pid: string = null) {
// let parameters: string = "";
// if(page_id || pid) {
// parameters = "?";
// if(page_id) {
// parameters += "&page="+page_id;
// }
// if(pid) {
// parameters += "&portal="+pid;
// }
// }
//
// return this.http.get<Array<DivId>>(helpContentUrl + 'div/full'+parameters)
// //.map(res => <Array<DivId>> res.json())
// .pipe(catchError(this.handleError));
// }
// Replacing getDivIdsFull
getAllDivIdsFull() { getAllDivIdsFull() {
return this.http.get<Array<DivId>>(properties.adminToolsAPIURL + 'div/full') return this.http.get<Array<DivId>>(properties.adminToolsAPIURL + 'div/full')
//.map(res => <Array<DivId>> res.json())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
@ -111,7 +84,6 @@ export class HelpContentService {
return this.http.get<Array<DivId>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid + '/div/full'+parameters) return this.http.get<Array<DivId>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid + '/div/full'+parameters)
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// End of replacing getDivIdsFull
// unused // unused
getDivId(divId: string, helpContentUrl:string) { getDivId(divId: string, helpContentUrl:string) {
@ -119,6 +91,7 @@ export class HelpContentService {
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// unused
getDivIdFull(divId: string, helpContentUrl:string, pid: string) { getDivIdFull(divId: string, helpContentUrl:string, pid: string) {
return this.http.get<DivId>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/div/'+divId+"/full") return this.http.get<DivId>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/div/'+divId+"/full")
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
@ -173,7 +146,6 @@ export class HelpContentService {
} }
toggleDivHelpContents(ids : string[], status : boolean, pid: string) { toggleDivHelpContents(ids : string[], status : boolean, pid: string) {
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/divhelpcontent/toggle?status='+ status.toString(), return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/divhelpcontent/toggle?status='+ status.toString(),
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
@ -196,7 +168,6 @@ export class HelpContentService {
} }
getPageHelpContent(id : string, helpContentUrl:string, pid: string) { getPageHelpContent(id : string, helpContentUrl:string, pid: string) {
return this.http.get<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/' + id) return this.http.get<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/' + id)
//.map(res => <PageHelpContent> res.json())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
@ -208,6 +179,7 @@ export class HelpContentService {
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// unused
updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string, pid: string) { updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string, pid: string) {
HelpContentService.removeNulls(pageHelpContent); HelpContentService.removeNulls(pageHelpContent);
@ -216,50 +188,43 @@ export class HelpContentService {
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
deletePageHelpContents(ids : string[], pid: string) { deletePageHelpContents(ids: string[], pid: string) {
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/delete', return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/delete',
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
togglePageHelpContents(ids : string[],status : boolean, pid: string) { togglePageHelpContents(ids : string[], status : boolean, pid: string) {
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/toggle?status='+ status.toString(), return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/toggle?status='+ status.toString(),
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// unused
getCommunityPagesWithDivId(pid: string, helpContentUrl:string) { getCommunityPagesWithDivId(pid: string, helpContentUrl:string) {
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?div=true') return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?div=true')
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// getCommunityPages(pid: string, params: string, helpContentUrl:string) {
// return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages'+params, CustomOptions.getAuthOptions())
// //.map(res => <Array<Page>> res.json())
// .pipe(catchError(this.handleError));
// }
getCommunityPagesByRoute(pid: string, route: string) { getCommunityPagesByRoute(pid: string, route: string) {
return this.http.get<Array<Page>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/pages' return this.http.get<Array<Page>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/pages'
+ (route ? '?page_route='+route : '')) + (route ? '?page_route='+route : ''))
.pipe(map(pages => (pages.length>0?pages[0]:null)), catchError(this.handleError)); .pipe(map(pages => (pages.length>0?pages[0]:null)), catchError(this.handleError));
} }
// Replacing getCommunityPages
getCommunityPagesByType(pid: string, type: string) { getCommunityPagesByType(pid: string, type: string) {
return this.http.get<Array<Page>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/pages' return this.http.get<Array<Page>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/pages'
+ (type ? '?page_type='+type : '')) + (type ? '?page_type='+type : ''))
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// End of replacing getCommunityPages
// Replacing part of getPages (now getAllPages) // unused
getCommunityPagesWithPositions(pid: string, helpContentUrl:string) { getCommunityPagesWithPositions(pid: string, helpContentUrl:string) {
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?with_positions=true') return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?with_positions=true')
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// End of replacing part of getPages (now getAllPages)
//TODO double check with konstantina - there is no param that we are asking the community pages. without pid we get all portalTypes // TODO: double check with konstantina - there is no param that we are asking the community pages. without pid we get all portalTypes
getAllPages(pid:string = null) {//with_positions:boolean=null) { getAllPages(pid:string = null) {//with_positions:boolean=null) {
// let parameters: string = ""; // let parameters: string = "";
// if(pid || with_positions == true || with_positions == false) { // if(pid || with_positions == true || with_positions == false) {
@ -278,7 +243,6 @@ export class HelpContentService {
getAllPagesFull() { getAllPagesFull() {
return this.http.get<Array<Page>>(properties.adminToolsAPIURL + 'page/full')//+(pid?("?pid="+pid):"")) return this.http.get<Array<Page>>(properties.adminToolsAPIURL + 'page/full')//+(pid?("?pid="+pid):""))
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
@ -286,10 +250,13 @@ export class HelpContentService {
return this.http.get<Page>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/page/'+pageId) return this.http.get<Page>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/page/'+pageId)
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
getPageById(pageId:string) { getPageById(pageId:string) {
return this.http.get<Page>(properties.adminToolsAPIURL + 'page/' + pageId) return this.http.get<Page>(properties.adminToolsAPIURL + 'page/' + pageId)
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// unused
getCommunityPageByRoute(route:string, helpContentUrl:string, pid: string) { getCommunityPageByRoute(route:string, helpContentUrl:string, pid: string) {
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType +'/' + pid + '/page/?page_route='+route) return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType +'/' + pid + '/page/?page_route='+route)
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
@ -299,12 +266,10 @@ export class HelpContentService {
HelpContentService.removeNulls(page); HelpContentService.removeNulls(page);
return this.http.post<Page>(properties.adminToolsAPIURL + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) return this.http.post<Page>(properties.adminToolsAPIURL + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Page> res.json())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
updatePage(page: Page) { updatePage(page: Page) {
HelpContentService.removeNulls(page); HelpContentService.removeNulls(page);
return this.http.post<Page>(properties.adminToolsAPIURL + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) return this.http.post<Page>(properties.adminToolsAPIURL + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
@ -312,14 +277,12 @@ export class HelpContentService {
} }
togglePages(selectedPortalPid: string, ids : string[], status: boolean) { togglePages(selectedPortalPid: string, ids : string[], status: boolean) {
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + selectedPortalPid + '/page/toggle?status='+ status.toString(), return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + selectedPortalPid + '/page/toggle?status='+ status.toString(),
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
deletePages(ids : string[]) { deletePages(ids : string[]) {
return this.http.post(properties.adminToolsAPIURL + 'page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(properties.adminToolsAPIURL + 'page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
@ -364,18 +327,19 @@ export class HelpContentService {
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// unused // unused
getCommunities( helpContentUrl:string) { getCommunities( helpContentUrl:string) {
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType) return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType)
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// unused
getCommunity(pid: string, helpContentUrl:string) { getCommunity(pid: string, helpContentUrl:string) {
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+pid) return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+pid)
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// unused
getCommunitiesFull( helpContentUrl:string) { getCommunitiesFull( helpContentUrl:string) {
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType + '/full') return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType + '/full')
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
@ -383,18 +347,16 @@ export class HelpContentService {
getPortalsFull() { getPortalsFull() {
return this.http.get<Array<Portal>>(properties.adminToolsAPIURL + 'portal/full') return this.http.get<Array<Portal>>(properties.adminToolsAPIURL + 'portal/full')
//.map(res => <Array<Portal>> res.json())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
// unused
getCommunityFull(portal_pid: string, helpContentUrl:string) { getCommunityFull(portal_pid: string, helpContentUrl:string) {
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/full') return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/full')
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
saveCommunity(portal: Portal) { saveCommunity(portal: Portal) {
// let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(portal); HelpContentService.removeNulls(portal);
return this.http.post<Portal>(properties.adminToolsAPIURL + portal.type + '/save', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody()) return this.http.post<Portal>(properties.adminToolsAPIURL + portal.type + '/save', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
@ -402,19 +364,13 @@ export class HelpContentService {
} }
updateCommunity(portal: Portal) { updateCommunity(portal: Portal) {
// let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(portal); HelpContentService.removeNulls(portal);
return this.http.post<Portal>(properties.adminToolsAPIURL + portal.type + '/update', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody()) return this.http.post<Portal>(properties.adminToolsAPIURL + portal.type + '/update', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Portal> res.json())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
deleteCommunities(ids : string[], portalType:string) { deleteCommunities(ids: string[], portalType:string) {
// let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers});
return this.http.post(properties.adminToolsAPIURL + portalType + '/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(properties.adminToolsAPIURL + portalType + '/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
@ -426,10 +382,6 @@ export class HelpContentService {
return throwError(error.error || 'Server error'); return throwError(error.error || 'Server error');
} }
// getDataProviders() {
// return this.http.get('https://beta.services.openaire.eu/search/v2/api/datasources?format=json').map(res => <any> res.json()).map(res => res.results).do(res => {console.log(res)}).catch(this.handleError);
// }
getCommunityStatistics(apiUrl: string, portalId: string): Observable<StatisticsSummary> { getCommunityStatistics(apiUrl: string, portalId: string): Observable<StatisticsSummary> {
const url = `${apiUrl}communities/${portalId}`; const url = `${apiUrl}communities/${portalId}`;
//console.log(`getting statistics summary from: ${url}`); //console.log(`getting statistics summary from: ${url}`);