2019-12-18 16:14:21 +01:00
|
|
|
/**
|
|
|
|
* Created by stefania on 7/13/17.
|
|
|
|
*/
|
2021-07-14 13:19:57 +02:00
|
|
|
import {Injectable} from '@angular/core';
|
2020-11-11 15:43:13 +01:00
|
|
|
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
|
2021-07-14 13:19:57 +02:00
|
|
|
import {Observable, throwError} from 'rxjs';
|
|
|
|
import {Page} from "../utils/entities/adminTool/page";
|
|
|
|
import {PageHelpContent} from "../utils/entities/adminTool/page-help-content";
|
|
|
|
import {Portal} from "../utils/entities/adminTool/portal";
|
|
|
|
import {Entity} from "../utils/entities/adminTool/entity";
|
|
|
|
import {DivId} from "../utils/entities/adminTool/divId";
|
|
|
|
import {DivHelpContent} from "../utils/entities/adminTool/div-help-content";
|
2019-12-18 16:14:21 +01:00
|
|
|
import {StatisticsDisplay, StatisticsSummary} from '../connect/statistics/statisticsEntities';
|
2021-07-14 13:19:57 +02:00
|
|
|
import {CustomOptions} from './servicesUtils/customOptions.class';
|
2019-12-18 16:14:21 +01:00
|
|
|
import {catchError, map} from "rxjs/operators";
|
2020-09-24 13:18:24 +02:00
|
|
|
import {properties} from "../../../environments/environment";
|
2021-12-23 08:22:07 +01:00
|
|
|
import { MenuItem } from '../sharedComponents/menu';
|
2019-12-18 16:14:21 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class HelpContentService {
|
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
constructor(private http:HttpClient) {
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
static removeNulls(obj){
|
|
|
|
var isArray = obj instanceof Array;
|
|
|
|
for (var k in obj){
|
|
|
|
if (obj[k]===null || obj[k]==='') isArray ? obj.splice(k,1) : delete obj[k];
|
|
|
|
else if (typeof obj[k]=="object") HelpContentService.removeNulls(obj[k]);
|
2019-12-18 16:14:21 +01:00
|
|
|
}
|
2020-09-24 13:18:24 +02:00
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getEntities(helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<Entity>>(helpContentUrl + 'entity')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
saveEntity(entity: Entity, helpContentUrl:string) {
|
|
|
|
HelpContentService.removeNulls(entity);
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
return this.http.post<Entity>(helpContentUrl + 'entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
updateEntity(entity: Entity, helpContentUrl:string) {
|
|
|
|
HelpContentService.removeNulls(entity);
|
|
|
|
|
|
|
|
return this.http.post<Entity>(helpContentUrl + 'entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
deleteEntities(ids : string[], helpContentUrl:string) {
|
|
|
|
return this.http.post(helpContentUrl + 'entity/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
// 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);
|
|
|
|
// }
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getCommunityEntities(pid: string, helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<Entity>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/entities')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2020-10-30 15:01:44 +01:00
|
|
|
|
|
|
|
toggleEntities(pid: string, ids : string[],status : boolean, helpContentUrl:string) {
|
|
|
|
|
|
|
|
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/'+pid+ '/entity/toggle?status='+ status.toString(),
|
|
|
|
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
// unused
|
|
|
|
toggleEntityOfPage(pageId: string, entityId : string,status : boolean, helpContentUrl:string) {
|
|
|
|
return this.http.post(helpContentUrl + 'page/'+pageId+'/entity/toggle?status='+ status.toString()+'&entityId='+entityId.toString(),
|
|
|
|
CustomOptions.getAuthOptionsWithBody())
|
|
|
|
.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(helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<DivId>>(helpContentUrl + 'div/full')
|
|
|
|
//.map(res => <Array<DivId>> res.json())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getDivIdsFullByPortal(page_id: string, helpContentUrl:string, pid: string) {
|
|
|
|
let parameters: string = page_id ? "?&page="+page_id : "";
|
|
|
|
|
|
|
|
return this.http.get<Array<DivId>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid + '/div/full'+parameters)
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2020-10-30 15:01:44 +01:00
|
|
|
// End of replacing getDivIdsFull
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
// unused
|
|
|
|
getDivId(divId: string, helpContentUrl:string) {
|
|
|
|
return this.http.get<DivId>(helpContentUrl + 'div/'+divId)
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getDivIdFull(divId: string, helpContentUrl:string, pid: string) {
|
|
|
|
return this.http.get<DivId>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/div/'+divId+"/full")
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
updateDivId(divId: DivId, helpContentUrl:string) {
|
|
|
|
HelpContentService.removeNulls(divId);
|
|
|
|
|
|
|
|
return this.http.post<DivId>(helpContentUrl + 'div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
saveDivId(divId: DivId, helpContentUrl:string) {
|
|
|
|
HelpContentService.removeNulls(divId);
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
return this.http.post<DivId>(helpContentUrl + 'div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
deleteDivIds(ids : string[], helpContentUrl:string) {
|
|
|
|
return this.http.post(helpContentUrl + 'div/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
|
|
|
getPageIdsFromDivIds(pid: string, helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<string>>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/div/pages')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2021-03-31 13:23:24 +02:00
|
|
|
getCommunityDivHelpContents(pid: string, helpContentUrl:string, pageId:string = null) {
|
|
|
|
return this.http.get<Array<DivHelpContent>>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + (pageId ? '/' + pageId : '') + '/divhelpcontent')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getDivHelpContent(id : string, helpContentUrl:string, pid: string) {
|
|
|
|
return this.http.get<DivHelpContent>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent/' + id)
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string, pid: string) {
|
|
|
|
HelpContentService.removeNulls(divHelpContent);
|
2021-03-31 13:23:24 +02:00
|
|
|
return this.http.post<DivHelpContent>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent/' + (divHelpContent._id ? 'update' : 'save'),
|
2020-10-30 15:01:44 +01:00
|
|
|
JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
deleteDivHelpContents(ids : string[], helpContentUrl:string, pid: string) {
|
|
|
|
return this.http.post(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent/delete',
|
|
|
|
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
toggleDivHelpContents(ids : string[],status : boolean, helpContentUrl:string, pid: string) {
|
|
|
|
|
|
|
|
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/divhelpcontent/toggle?status='+ status.toString(),
|
|
|
|
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
// unused
|
|
|
|
getPageHelpContents(helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<PageHelpContent>>(helpContentUrl + 'pagehelpcontent')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2021-03-31 13:23:24 +02:00
|
|
|
|
2021-02-26 11:36:17 +01:00
|
|
|
getCommunityPageHelpContents(pid: string, helpContentUrl:string, pageId:string = null) {
|
|
|
|
return this.http.get<Array<PageHelpContent>>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + (pageId ? '/' + pageId : '') + '/pagehelpcontent')
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2021-03-31 13:23:24 +02:00
|
|
|
countCommunityPageHelpContents(pid: string, helpContentUrl:string ,classContents:boolean=false) {
|
|
|
|
return this.http.get<Array<PageHelpContent>>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + (classContents?"/divhelpcontent":"/pagehelpcontent")+'/page/count')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2020-10-30 15:01:44 +01:00
|
|
|
getPageHelpContent(id : string, helpContentUrl:string, pid: string) {
|
|
|
|
return this.http.get<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/' + id)
|
|
|
|
//.map(res => <PageHelpContent> res.json())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
savePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string, pid: string) {
|
|
|
|
HelpContentService.removeNulls(pageHelpContent);
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2021-02-25 16:55:56 +01:00
|
|
|
return this.http.post<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/' + (pageHelpContent._id ? 'update' : 'save'),
|
2020-10-30 15:01:44 +01:00
|
|
|
JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string, pid: string) {
|
|
|
|
HelpContentService.removeNulls(pageHelpContent);
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
return this.http.post<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid +'/pagehelpcontent/update',
|
|
|
|
JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
deletePageHelpContents(ids : string[], helpContentUrl:string, pid: string) {
|
|
|
|
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/delete',
|
|
|
|
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
togglePageHelpContents(ids : string[],status : boolean, helpContentUrl:string, pid: string) {
|
|
|
|
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/toggle?status='+ status.toString(),
|
|
|
|
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getCommunityPagesWithDivId(pid: string, helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?div=true')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
// 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));
|
|
|
|
// }
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
// Replacing getCommunityPages
|
|
|
|
getCommunityPagesByType(pid: string, type: string, helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages'
|
|
|
|
+ (type ? '?page_type='+type : ''))
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2020-10-30 15:01:44 +01:00
|
|
|
// End of replacing getCommunityPages
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
// Replacing part of getPages (now getAllPages)
|
|
|
|
getCommunityPagesWithPositions(pid: string, helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?with_positions=true')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2020-10-30 15:01:44 +01:00
|
|
|
// End of replacing part of getPages (now getAllPages)
|
2021-12-17 13:06:05 +01:00
|
|
|
//TODO double check with konstantina - there is no param that we are asking the community pages. without pid we get all portalTypes
|
|
|
|
getAllPages(helpContentUrl:string, pid:string = null) {//with_positions:boolean=null) {
|
2020-10-30 15:01:44 +01:00
|
|
|
// let parameters: string = "";
|
|
|
|
// if(pid || with_positions == true || with_positions == false) {
|
|
|
|
// parameters = "?";
|
|
|
|
// if(pid) {
|
|
|
|
// parameters += "&pid="+pid;
|
|
|
|
// }
|
|
|
|
// if(with_positions == true || with_positions == false) {
|
|
|
|
// parameters += "&with_positions="+with_positions;
|
|
|
|
// }
|
|
|
|
// }
|
2021-12-23 08:22:07 +01:00
|
|
|
return this.http.get<Array<Page>>(helpContentUrl + 'page?' + (pid?"pid="+pid:""))
|
2020-10-30 15:01:44 +01:00
|
|
|
//.map(res => <Array<Page>> res.json())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getAllPagesFull(helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<Page>>(helpContentUrl + 'page/full')//+(pid?("?pid="+pid):""))
|
|
|
|
//.map(res => <Array<Page>> res.json())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getPageByPortal(pageId:string, helpContentUrl:string, pid: string) {
|
|
|
|
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/page/'+pageId)
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getCommunityPageByRoute(route:string, helpContentUrl:string, pid: string) {
|
|
|
|
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType +'/' + pid + '/page/?page_route='+route)
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
savePage(page: Page, helpContentUrl:string) {
|
|
|
|
HelpContentService.removeNulls(page);
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
return this.http.post<Page>(helpContentUrl + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
|
|
|
|
//.map(res => <Page> res.json())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
updatePage(page: Page, helpContentUrl:string) {
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
HelpContentService.removeNulls(page);
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
return this.http.post<Page>(helpContentUrl + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
togglePages(selectedPortalPid: string, ids : string[],status : boolean, helpContentUrl:string) {
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/'+selectedPortalPid+'/page/toggle?status='+ status.toString(),
|
|
|
|
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
deletePages(ids : string[], helpContentUrl:string) {
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
return this.http.post(helpContentUrl + 'page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2022-01-05 15:41:49 +01:00
|
|
|
// Menu Items
|
|
|
|
|
2021-12-23 08:22:07 +01:00
|
|
|
getMenuItems(portalPid: string) {
|
|
|
|
return this.http.get<Array<MenuItem>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/root/full")
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
2022-01-05 15:41:49 +01:00
|
|
|
saveMenuItem(menuItem: MenuItem, portalPid: string) {
|
|
|
|
HelpContentService.removeNulls(menuItem);
|
|
|
|
|
|
|
|
return this.http.post<MenuItem>(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/save", JSON.stringify(menuItem), CustomOptions.getAuthOptionsWithBody())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
|
|
|
updateMenuItem(menuItem: MenuItem, portalPid: string) {
|
|
|
|
HelpContentService.removeNulls(menuItem);
|
|
|
|
|
|
|
|
return this.http.post<MenuItem>(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/update", JSON.stringify(menuItem), CustomOptions.getAuthOptionsWithBody())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteMenuItem(menuItemId: string, portalPid: string) {
|
|
|
|
return this.http.post<MenuItem>(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/delete", menuItemId, CustomOptions.getAuthOptionsWithBody())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
// unused
|
|
|
|
getCommunities( helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType)
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getCommunity(pid: string, helpContentUrl:string) {
|
|
|
|
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+pid)
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getCommunitiesFull( helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType + '/full')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
getPortalsFull( helpContentUrl:string) {
|
|
|
|
return this.http.get<Array<Portal>>(helpContentUrl + 'portal/full')
|
|
|
|
//.map(res => <Array<Portal>> res.json())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
getCommunityFull(portal_pid: string, helpContentUrl:string) {
|
|
|
|
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/full')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
saveCommunity(portal: Portal, helpContentUrl:string) {
|
|
|
|
// let headers = new Headers({'Content-Type': 'application/json'});
|
|
|
|
// let options = new RequestOptions({headers: headers});
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
HelpContentService.removeNulls(portal);
|
|
|
|
|
|
|
|
return this.http.post<Portal>(helpContentUrl + portal.type + '/save', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
updateCommunity(portal: Portal, helpContentUrl:string) {
|
|
|
|
// let headers = new Headers({'Content-Type': 'application/json'});
|
|
|
|
// let options = new RequestOptions({headers: headers});
|
|
|
|
|
|
|
|
HelpContentService.removeNulls(portal);
|
|
|
|
|
|
|
|
return this.http.post<Portal>(helpContentUrl + portal.type + '/update', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
|
|
|
|
//.map(res => <Portal> res.json())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-10-30 15:01:44 +01:00
|
|
|
deleteCommunities(ids : string[], helpContentUrl:string) {
|
|
|
|
// let headers = new Headers({'Content-Type': 'application/json'});
|
|
|
|
// let options = new RequestOptions({headers: headers});
|
|
|
|
|
|
|
|
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
private handleError(error: HttpErrorResponse) {
|
|
|
|
// in a real world app, we may send the error to some remote logging infrastructure
|
|
|
|
// instead of just logging it to the console
|
|
|
|
console.error(error);
|
2021-07-14 13:19:57 +02:00
|
|
|
return throwError(error.error || 'Server error');
|
2020-09-24 13:18:24 +02:00
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
// 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);
|
|
|
|
// }
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
getCommunityStatistics(apiUrl: string, portalId: string): Observable<StatisticsSummary> {
|
|
|
|
const url = `${apiUrl}communities/${portalId}`;
|
|
|
|
//console.log(`getting statistics summary from: ${url}`);
|
|
|
|
return this.http.get(url)
|
|
|
|
//.map(res => <any>res.json())
|
|
|
|
.pipe(map(res => res['statistics']));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2020-09-24 13:18:24 +02:00
|
|
|
getCommunityAdminStatisticsChoices(apiUrl: string, portalId: string): Observable<StatisticsDisplay> {
|
|
|
|
const url = `${apiUrl}statistics/${portalId}`;
|
|
|
|
//console.log(`getting admin choices for statistics from: ${url}`);
|
|
|
|
return this.http.get<StatisticsDisplay>(url)
|
|
|
|
//.map(stats => <StatisticsDisplay>stats.json())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
|
|
|
postCommunityAdminStatisticsChoices(apiUrl: string,
|
|
|
|
portalId: string,
|
|
|
|
entity: string,
|
|
|
|
chartsOrNumbers: string,
|
|
|
|
title: string,
|
|
|
|
status: boolean,
|
|
|
|
monitor: boolean): Observable<any> {
|
|
|
|
const url = `${apiUrl}statistics/${portalId}/${entity}/${chartsOrNumbers}?status=${status.toString()}&monitor=${monitor.toString()}`;
|
|
|
|
//console.log(`getting admin choices for statistics from: ${url}`);
|
|
|
|
|
|
|
|
return this.http.post(url, title, CustomOptions.getAuthOptionsWithBody())
|
|
|
|
//.map(stats => <any>stats.json())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
|
|
|
statisticsIsActiveToggle(apiURL: string, id: string): Observable<boolean> {
|
|
|
|
const url = apiURL + '/statistics/' + encodeURIComponent(id) + '/toggle';
|
|
|
|
return this.http.post<boolean>(url, {}, CustomOptions.getAuthOptionsWithBody()).pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
}
|