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";
|
2022-07-15 12:36:55 +02:00
|
|
|
import {Menu, MenuItem, MenuItemExtended} 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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getEntities() {
|
|
|
|
return this.http.get<Array<Entity>>(properties.adminToolsAPIURL + 'entity')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
saveEntity(entity: Entity) {
|
2020-10-30 15:01:44 +01:00
|
|
|
HelpContentService.removeNulls(entity);
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post<Entity>(properties.adminToolsAPIURL + '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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
updateEntity(entity: Entity) {
|
2020-10-30 15:01:44 +01:00
|
|
|
HelpContentService.removeNulls(entity);
|
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post<Entity>(properties.adminToolsAPIURL + '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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
deleteEntities(ids: string[]) {
|
|
|
|
return this.http.post(properties.adminToolsAPIURL + '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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getCommunityEntities(pid: string) {
|
|
|
|
return this.http.get<Array<Entity>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/entities')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2020-10-30 15:01:44 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
toggleEntities(pid: string, ids: string[], status: boolean) {
|
2020-10-30 15:01:44 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+ '/entity/toggle?status='+ status.toString(),
|
2020-10-30 15:01:44 +01:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getAllDivIdsFull() {
|
|
|
|
return this.http.get<Array<DivId>>(properties.adminToolsAPIURL + 'div/full')
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getDivIdsFullByPortal(page_id: string, pid: string) {
|
2020-10-30 15:01:44 +01:00
|
|
|
let parameters: string = page_id ? "?&page="+page_id : "";
|
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.get<Array<DivId>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid + '/div/full'+parameters)
|
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
|
|
|
|
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
|
|
|
|
2024-09-24 09:52:51 +02:00
|
|
|
// unused
|
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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
updateDivId(divId: DivId) {
|
2020-10-30 15:01:44 +01:00
|
|
|
HelpContentService.removeNulls(divId);
|
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post<DivId>(properties.adminToolsAPIURL + '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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
saveDivId(divId: DivId) {
|
2020-10-30 15:01:44 +01:00
|
|
|
HelpContentService.removeNulls(divId);
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post<DivId>(properties.adminToolsAPIURL + '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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
deleteDivIds(ids : string[]) {
|
|
|
|
return this.http.post(properties.adminToolsAPIURL + 'div/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
|
2020-10-30 15:01:44 +01:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getPageIdsFromDivIds(pid: string) {
|
|
|
|
return this.http.get<Array<string>>(properties.adminToolsAPIURL + 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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getCommunityDivHelpContents(pid: string, pageId:string = null) {
|
|
|
|
return this.http.get<Array<DivHelpContent>>(properties.adminToolsAPIURL + 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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getDivHelpContent(id : string, pid: string) {
|
|
|
|
return this.http.get<DivHelpContent>(properties.adminToolsAPIURL + 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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, pid: string) {
|
2020-10-30 15:01:44 +01:00
|
|
|
HelpContentService.removeNulls(divHelpContent);
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post<DivHelpContent>(properties.adminToolsAPIURL + 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
|
|
|
|
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
deleteDivHelpContents(ids : string[], pid: string) {
|
|
|
|
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent/delete',
|
2020-10-30 15:01:44 +01:00
|
|
|
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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
toggleDivHelpContents(ids : string[], status : boolean, pid: string) {
|
|
|
|
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/divhelpcontent/toggle?status='+ status.toString(),
|
2020-10-30 15:01:44 +01:00
|
|
|
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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getCommunityPageHelpContents(pid: string, pageId:string = null) {
|
|
|
|
return this.http.get<Array<PageHelpContent>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + (pageId ? '/' + pageId : '') + '/pagehelpcontent')
|
2021-02-26 11:36:17 +01:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2024-09-12 09:49:03 +02:00
|
|
|
countCommunityPageHelpContents(pid: string, classContents:boolean = false) {
|
|
|
|
return this.http.get<Array<PageHelpContent>>(properties.adminToolsAPIURL + 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)
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
savePageHelpContent(pageHelpContent: PageHelpContent, pid: string) {
|
2020-10-30 15:01:44 +01:00
|
|
|
HelpContentService.removeNulls(pageHelpContent);
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post<PageHelpContent>(properties.adminToolsAPIURL + 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
|
|
|
|
2024-09-24 09:52:51 +02:00
|
|
|
// unused
|
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
|
|
|
|
2024-09-24 09:52:51 +02:00
|
|
|
deletePageHelpContents(ids: string[], pid: string) {
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/delete',
|
2020-10-30 15:01:44 +01:00
|
|
|
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
|
|
|
|
2024-09-24 09:52:51 +02:00
|
|
|
togglePageHelpContents(ids : string[], status : boolean, pid: string) {
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/toggle?status='+ status.toString(),
|
2020-10-30 15:01:44 +01:00
|
|
|
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
|
|
|
|
2024-09-24 09:52:51 +02:00
|
|
|
// unused
|
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
|
|
|
|
2024-09-19 09:49:03 +02:00
|
|
|
getCommunityPagesByRoute(pid: string, route: string) {
|
|
|
|
return this.http.get<Array<Page>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/pages'
|
|
|
|
+ (route ? '?page_route='+route : ''))
|
|
|
|
.pipe(map(pages => (pages.length>0?pages[0]:null)), catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getCommunityPagesByType(pid: string, type: string) {
|
|
|
|
return this.http.get<Array<Page>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/pages'
|
2020-10-30 15:01:44 +01:00
|
|
|
+ (type ? '?page_type='+type : ''))
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-24 09:52:51 +02:00
|
|
|
// unused
|
2020-10-30 15:01:44 +01:00
|
|
|
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));
|
|
|
|
}
|
2024-09-24 09:52:51 +02:00
|
|
|
|
|
|
|
// TODO: double check with konstantina - there is no param that we are asking the community pages. without pid we get all portalTypes
|
2024-09-12 09:49:03 +02:00
|
|
|
getAllPages(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;
|
|
|
|
// }
|
|
|
|
// }
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.get<Array<Page>>(properties.adminToolsAPIURL + '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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getAllPagesFull() {
|
|
|
|
return this.http.get<Array<Page>>(properties.adminToolsAPIURL + 'page/full')//+(pid?("?pid="+pid):""))
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getPageByPortal(pageId:string, pid: string) {
|
|
|
|
return this.http.get<Page>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/page/'+pageId)
|
2020-10-30 15:01:44 +01:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2024-09-24 09:52:51 +02:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getPageById(pageId:string) {
|
|
|
|
return this.http.get<Page>(properties.adminToolsAPIURL + 'page/' + pageId)
|
2024-02-02 08:33:01 +01:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2024-09-24 09:52:51 +02:00
|
|
|
|
|
|
|
// unused
|
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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
savePage(page: Page) {
|
2020-09-24 13:18:24 +02:00
|
|
|
HelpContentService.removeNulls(page);
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post<Page>(properties.adminToolsAPIURL + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
updatePage(page: Page) {
|
2020-09-24 13:18:24 +02:00
|
|
|
HelpContentService.removeNulls(page);
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post<Page>(properties.adminToolsAPIURL + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
|
2020-09-24 13:18:24 +02:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
|
2024-09-19 09:49:03 +02:00
|
|
|
togglePages(selectedPortalPid: string, ids : string[], status: boolean) {
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + selectedPortalPid + '/page/toggle?status='+ status.toString(),
|
2020-10-30 15:01:44 +01:00
|
|
|
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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
deletePages(ids : string[]) {
|
|
|
|
return this.http.post(properties.adminToolsAPIURL + 'page/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
|
|
|
|
2022-01-05 15:41:49 +01:00
|
|
|
// Menu Items
|
|
|
|
|
2021-12-23 08:22:07 +01:00
|
|
|
getMenuItems(portalPid: string) {
|
2022-07-15 12:36:55 +02:00
|
|
|
return this.http.get<Menu>(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/full")
|
2021-12-23 08:22:07 +01:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
2022-07-19 13:23:01 +02:00
|
|
|
saveMenuItem(menuItem: MenuItemExtended, portalPid: string) {
|
2022-01-05 15:41:49 +01:00
|
|
|
HelpContentService.removeNulls(menuItem);
|
|
|
|
|
2022-07-19 13:23:01 +02:00
|
|
|
return this.http.post<MenuItemExtended>(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/save", JSON.stringify(menuItem), CustomOptions.getAuthOptionsWithBody())
|
2022-01-05 15:41:49 +01:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
2022-07-19 13:23:01 +02:00
|
|
|
updateMenuItem(menuItem: MenuItemExtended, portalPid: string) {
|
2022-01-05 15:41:49 +01:00
|
|
|
HelpContentService.removeNulls(menuItem);
|
2022-07-19 13:23:01 +02:00
|
|
|
return this.http.post<MenuItemExtended>(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/update", JSON.stringify(menuItem), CustomOptions.getAuthOptionsWithBody())
|
2022-01-05 15:41:49 +01:00
|
|
|
.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));
|
|
|
|
}
|
|
|
|
|
2022-07-15 09:16:42 +02:00
|
|
|
reorderMenuItems(menuItems, portalPid: string) {
|
|
|
|
return this.http.post<Array<MenuItem>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/reorder", menuItems, CustomOptions.getAuthOptionsWithBody())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
2022-07-18 13:51:08 +02:00
|
|
|
toggleMenu(status: boolean, isFeatured: boolean, portalPid: string) {
|
|
|
|
return this.http.post<Menu>(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/toggle?status=" + status + "&featured=" + isFeatured, {}, CustomOptions.getAuthOptionsWithBody())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2022-12-09 15:43:36 +01:00
|
|
|
|
|
|
|
alignMenu(alignment: string, portalPid: string) {
|
|
|
|
return this.http.post<Menu>(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/align?alignment=" + alignment, {}, CustomOptions.getAuthOptionsWithBody())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2022-07-18 13:51:08 +02:00
|
|
|
|
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
|
|
|
|
2024-09-24 09:52:51 +02:00
|
|
|
// unused
|
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
|
|
|
|
2024-09-24 09:52:51 +02:00
|
|
|
// unused
|
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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
getPortalsFull() {
|
|
|
|
return this.http.get<Array<Portal>>(properties.adminToolsAPIURL + 'portal/full')
|
2020-10-30 15:01:44 +01:00
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
2024-09-24 09:52:51 +02:00
|
|
|
|
|
|
|
// unused
|
2020-10-30 15:01:44 +01:00
|
|
|
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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
saveCommunity(portal: Portal) {
|
2020-10-30 15:01:44 +01:00
|
|
|
HelpContentService.removeNulls(portal);
|
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post<Portal>(properties.adminToolsAPIURL + 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
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
updateCommunity(portal: Portal) {
|
2020-10-30 15:01:44 +01:00
|
|
|
HelpContentService.removeNulls(portal);
|
|
|
|
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post<Portal>(properties.adminToolsAPIURL + portal.type + '/update', 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
|
|
|
|
2024-09-24 09:52:51 +02:00
|
|
|
deleteCommunities(ids: string[], portalType:string) {
|
2024-09-12 09:49:03 +02:00
|
|
|
return this.http.post(properties.adminToolsAPIURL + portalType + '/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
|
|
|
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
|
|
|
|
2024-09-19 09:49:03 +02:00
|
|
|
getCommunityAdminStatisticsChoices(portalId: string): Observable<StatisticsDisplay> {
|
|
|
|
const url = `${properties.adminToolsAPIURL}statistics/${portalId}`;
|
2020-09-24 13:18:24 +02:00
|
|
|
//console.log(`getting admin choices for statistics from: ${url}`);
|
|
|
|
return this.http.get<StatisticsDisplay>(url)
|
|
|
|
//.map(stats => <StatisticsDisplay>stats.json())
|
|
|
|
.pipe(catchError(this.handleError));
|
|
|
|
}
|
|
|
|
|
2024-09-19 09:49:03 +02:00
|
|
|
postCommunityAdminStatisticsChoices(portalId: string,
|
2020-09-24 13:18:24 +02:00
|
|
|
entity: string,
|
|
|
|
chartsOrNumbers: string,
|
|
|
|
title: string,
|
|
|
|
status: boolean,
|
|
|
|
monitor: boolean): Observable<any> {
|
2024-09-19 09:49:03 +02:00
|
|
|
const url = `${properties.adminToolsAPIURL}statistics/${portalId}/${entity}/${chartsOrNumbers}?status=${status.toString()}&monitor=${monitor.toString()}`;
|
2020-09-24 13:18:24 +02:00
|
|
|
//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));
|
|
|
|
}
|
|
|
|
|
2024-09-19 09:49:03 +02:00
|
|
|
statisticsIsActiveToggle(id: string): Observable<boolean> {
|
|
|
|
const url = properties.adminToolsAPIURL + 'statistics/' + encodeURIComponent(id) + '/toggle';
|
2020-09-24 13:18:24 +02:00
|
|
|
return this.http.post<boolean>(url, {}, CustomOptions.getAuthOptionsWithBody()).pipe(catchError(this.handleError));
|
|
|
|
}
|
2019-12-18 16:14:21 +01:00
|
|
|
}
|