[Trunk | Library]: Merging branch 'use-UoaAdminToolsLibrary' into trunk for revisions 58402:59464

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59465 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2020-09-24 11:18:24 +00:00
parent 021e7063d7
commit 9261419e2d
33 changed files with 615 additions and 521 deletions

View File

@ -4,6 +4,7 @@ import { CommunityInfo } from './communityInfo';
import {EnvProperties} from '../../utils/properties/env-properties';
import {map} from "rxjs/operators";
import {BehaviorSubject, from} from "rxjs";
import {properties} from "../../../../environments/environment";
@Injectable({ providedIn: 'root' })
export class CommunityService {
@ -127,7 +128,7 @@ export class CommunityService {
* @deprecated
*/
isSubscribedToCommunity(pid: string, email: string, url: string) {
return this.http.get(url + '/community/' + pid + '/subscribers')
return this.http.get(url + '/'+ properties.adminToolsPortalType +'/' + pid + '/subscribers')
//.map(res => ((<any>res === '') ? {} : <any> res.json()))
.pipe(map(res => {
if (res['subscribers'] && res['subscribers'] != null) {

View File

@ -1,4 +1,5 @@
import {HttpParams} from '@angular/common/http';
import {properties} from "../../../environments/environment";
export class ConnectHelper {
@ -30,4 +31,14 @@ export class ConnectHelper {
return null;
}
}
public static setPortalTypeFromPid(pid: string): void {
if(pid == "openaire") {
properties.adminToolsPortalType = "explore";
} else if(pid == "connect") {
properties.adminToolsPortalType = "connect";
} else {
properties.adminToolsPortalType = "community";
}
}
}

View File

@ -56,6 +56,7 @@
<th><input id="allDivIdCheckbox" type="checkbox" (change)="toggleCheckBoxes($event)"></th>
<th>Name</th>
<th>Page</th>
<th *ngIf="selectedCommunityPid">Portal Type</th>
<th>Actions</th>
</tr>
</thead>
@ -67,7 +68,9 @@
<td>
<div class="name" href="#">{{check.divId.name}}</div>
</td>
<td *ngIf="!selectedCommunityPid">
<div class="portalType" href="#">{{check.divId.portalType}}</div>
</td>
<td>
<div class="pages" href="#">
<span *ngFor="let page of check.divId.pages let i=index">{{page.name}}<span
@ -133,28 +136,47 @@
</mat-autocomplete>
</mat-form-field>
<div class="form-group uk-margin-small-left">
<div class="uk-text-muted"> Select if this class exists in:</div>
<span dashboard-input class="" [formInput]="myForm.get('openaire')"
type="checkbox"
label="Explore Portal">
</span>
<span dashboard-input class="uk-margin-small-left" [formInput]="myForm.get('connect')"
type="checkbox"
label="Connect Portal">
</span>
<span dashboard-input class="uk-margin-small-left" [formInput]="myForm.get('communities')"
type="checkbox"
label="Communities Dashboards">
</span>
<!-- <mat-checkbox [formControl]="myForm.get('openaire')" >Explore Portal</mat-checkbox>-->
<!-- <input type="checkbox" id="openaire" formControlName="openaire"/> Explore Portal-->
<!-- <input type="checkbox" [formControl]="myForm.get('connect')" formControlName="connect"/> Connect Portal-->
<!-- <input type="checkbox" [formControl]="myForm.controls.communities"-->
<!-- formControlName="communities"/>Communities Dashboards-->
<div [ngClass]="{'has-error':!myForm.controls.portalType.valid && myForm.controls.portalType.dirty}" class="form-group" uk-grid>
<label class="uk-width-1-1 uk-margin-small-bottom">
Class exists in:
</label>
<label class="uk-width-1-1 radio uk-margin-large-left">
<span class="uk-margin-small-right" style="font-weight: normal;">OpenAIRE portal</span>
<input type="radio" value="explore" formControlName="portalType">
</label>
<label class="uk-width-1-1 radio uk-margin-large-left">
<span class="uk-margin-small-right" style="font-weight: normal;">OpenAIRE Connect portal</span>
<input type="radio" value="connect" formControlName="portalType">
</label>
<label class="uk-width-1-1 radio uk-margin-large-left">
<span class="uk-margin-small-right" style="font-weight: normal;">Communities' Gateway</span>
<input type="radio" value="community" formControlName="portalType">
</label>
</div>
<!-- <div class="form-group uk-margin-small-left">-->
<!-- <div class="uk-text-muted"> Select if this class exists in:</div>-->
<!-- <span dashboard-input class="" [formInput]="myForm.get('openaire')"-->
<!-- type="checkbox"-->
<!-- label="Explore Portal">-->
<!-- </span>-->
<!-- <span dashboard-input class="uk-margin-small-left" [formInput]="myForm.get('connect')"-->
<!-- type="checkbox"-->
<!-- label="Connect Portal">-->
<!-- </span>-->
<!-- <span dashboard-input class="uk-margin-small-left" [formInput]="myForm.get('communities')"-->
<!-- type="checkbox"-->
<!-- label="Communities Dashboards">-->
<!-- </span>-->
<!--&lt;!&ndash; <mat-checkbox [formControl]="myForm.get('openaire')" >Explore Portal</mat-checkbox>&ndash;&gt;-->
<!--&lt;!&ndash; <input type="checkbox" id="openaire" formControlName="openaire"/> Explore Portal&ndash;&gt;-->
<!--&lt;!&ndash; <input type="checkbox" [formControl]="myForm.get('connect')" formControlName="connect"/> Connect Portal&ndash;&gt;-->
<!--&lt;!&ndash; <input type="checkbox" [formControl]="myForm.controls.communities"&ndash;&gt;-->
<!--&lt;!&ndash; formControlName="communities"/>Communities Dashboards&ndash;&gt;-->
<!-- </div>-->
<input type="hidden" formControlName="_id">
</form>

View File

@ -58,9 +58,7 @@ export class DivIdsComponent implements OnInit {
_id: '',
name: ['', Validators.required],
pages: this.pagesCtrl,
openaire: true,
connect: false,
communities: true
portalType: ['', Validators.required]
});
this.route.data
@ -199,10 +197,10 @@ export class DivIdsComponent implements OnInit {
_id: divId._id,
name: [divId.name,Validators.required],
pages: this.pagesCtrl,
openaire: divId.openaire,
connect: divId.connect,
communities: divId.communities
portalType: [divId.portalType, Validators.required]
});
this.myForm.controls['portalType'].disable();
for(let i = 0; i < divId.pages.length; i++) {
this.pagesCtrl.push(this._fb.control(divId.pages[i]));
}
@ -213,14 +211,15 @@ export class DivIdsComponent implements OnInit {
}
public newDivId() {
this.myForm.controls['portalType'].enable();
this.pagesCtrl = this._fb.array([]);
this.myForm = this._fb.group({
_id: '',
name: ['', Validators.required],
pages: this.pagesCtrl,
openaire: this._fb.control(true),
connect: false,
communities: true
//openaire: this._fb.control(true),
portalType: ['', Validators.required]
});
this.filteredPages = this.pageSearchCtrl.valueChanges.pipe(startWith(''),
map(page => this._filter(page)));
@ -257,6 +256,8 @@ export class DivIdsComponent implements OnInit {
} else {
console.log(this.myForm.value)
if (this.myForm.value['_id'].length == 0) {
this.myForm.controls['portalType'].enable();
this.modalErrorMessage = "";
this._helpContentService.saveDivId(<DivId>this.myForm.value, this.properties.adminToolsAPIURL).subscribe(
@ -300,7 +301,7 @@ export class DivIdsComponent implements OnInit {
}
public filterDivIds(divId: DivId): boolean {
let textFlag = this.searchText.toString() == '' || (divId.name).match(this.searchText) != null;
let textFlag = this.searchText.toString() == '' || (divId.name + ' ' + divId.portalType).match(this.searchText) != null;
return textFlag;
}

View File

@ -136,7 +136,7 @@ export class DivContentFormComponent implements OnInit{
divId: ['', Validators.required],
content: ['', Validators.required],
isActive: true,
community: '',
portal: '',
_id : '',
});
}
@ -146,7 +146,7 @@ export class DivContentFormComponent implements OnInit{
divId: '',
content: '',
isActive: true,
community: '',
portal: '',
_id : ''
});
this.myForm.markAsPristine();

View File

@ -8,7 +8,7 @@ import {
DivHelpContentFilterOptions
} from "../../utils/entities/adminTool/div-help-content";
import {Page} from "../../utils/entities/adminTool/page";
import {Community} from "../../utils/entities/adminTool/community";
import {Portal} from "../../utils/entities/adminTool/portal";
import {DivId} from "../../utils/entities/adminTool/divId";
import {EnvProperties} from '../../utils/properties/env-properties';
@ -45,13 +45,13 @@ export class DivHelpContentsComponent implements OnInit {
public counter = {all: 0, active: 0, inactive: 0};
public communities: Community[] = [];
public communities: Portal[] = [];
public selectedCommunityPid: string;
public selectedPageId: string;
public community: Community;
public community: Portal;
public page: Page;
public properties: EnvProperties = null;
@ -122,9 +122,7 @@ export class DivHelpContentsComponent implements OnInit {
this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
page => {
if ((this.selectedCommunityPid == 'openaire' && !page.openaire)
|| (this.selectedCommunityPid == 'connect' && !page.connect)
|| (this.selectedCommunityPid != 'openaire' && this.selectedCommunityPid != 'connect' && !page.communities)) {
if (this.properties.adminToolsPortalType != page.portalType) {
this.router.navigate(['/classContents'], {queryParams: {"communityId": this.selectedCommunityPid}});
} else {
this.page = page;

View File

@ -80,9 +80,7 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{
private getPage(pageId: string) {
this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe(
page => {
if( (this.communityPid == 'openaire' && !page.openaire)
|| (this.communityPid == 'connect' && !page.connect)
|| (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) {
if(this.properties.adminToolsPortalType != page.portalType) {
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid} });
} else {
this.page = page;

View File

@ -62,9 +62,7 @@ export class NewDivHelpContentComponent {
private getPage(pageId: string) {
this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe(
page => {
if( (this.communityPid == 'openaire' && !page.openaire)
|| (this.communityPid == 'connect' && !page.connect)
|| (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) {
if(this.properties.adminToolsPortalType != page.portalType) {
this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid} });
} else {
this.page = page;

View File

@ -3,7 +3,7 @@ import {ActivatedRoute, Router} from '@angular/router';
import {HelpContentService} from '../../services/help-content.service';
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
import {CheckEntity, Entity} from '../../utils/entities/adminTool/entity';
import {Community} from '../../utils/entities/adminTool/community';
import {Portal} from '../../utils/entities/adminTool/portal';
import {EnvProperties} from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
@ -31,7 +31,7 @@ export class EntitiesComponent implements OnInit {
private searchText: RegExp = new RegExp('');
public keyword = '';
public communities: Community[] = [];
public communities: Portal[] = [];
public selectedCommunityPid: string;
@ViewChild('AlertModalRelatedPages') alertModalRelatedPages;

View File

@ -82,9 +82,7 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{
private getPage(pageId: string) {
this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe(
page => {
if( (this.communityPid == 'openaire' && !page.openaire)
|| (this.communityPid == 'connect' && !page.connect)
|| (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) {
if(this.properties.adminToolsPortalType != page.portalType) {
this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} });
} else {
this.page = page;

View File

@ -62,9 +62,7 @@ export class NewPageHelpContentComponent {
private getPage(pageId: string) {
this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe(
page => {
if( (this.communityPid == 'openaire' && !page.openaire)
|| (this.communityPid == 'connect' && !page.connect)
|| (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) {
if(this.properties.adminToolsPortalType != page.portalType) {
this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} });
} else {
this.page = page;

View File

@ -74,7 +74,7 @@ export class PageContentFormComponent implements OnInit{
public get form() {
return this._fb.group({
page : [this.pageId, Validators.required],
community : this.communityPid,
portal : this.communityPid,
placement : ['', Validators.required],
content : ['', Validators.required],
order : [1, Validators.required],
@ -87,7 +87,7 @@ export class PageContentFormComponent implements OnInit{
public reset() {
this.myForm.patchValue({
page : '',
community : this.communityPid,
portal : this.communityPid,
placement : '',
content : [''],
order : 1,

View File

@ -100,7 +100,7 @@
<div class="page" href="#">{{check.pageHelpContent.page.name}}</div>
</td>
<td *ngIf="!selectedPageId">
<div class="community" href="#">{{check.pageHelpContent.community.name}}</div>
<div class="community" href="#">{{check.pageHelpContent.portal.name}}</div>
</td>
<td>
<!-- <div class="content" [innerHtml]="check.pageHelpContent.content | safeHtml"></div>-->

View File

@ -8,7 +8,7 @@ import {
PageHelpContentFilterOptions
} from "../../utils/entities/adminTool/page-help-content";
import {Page} from "../../utils/entities/adminTool/page";
import {Community} from "../../utils/entities/adminTool/community";
import {Portal} from "../../utils/entities/adminTool/portal";
import {EnvProperties} from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
@ -41,13 +41,13 @@ export class PageHelpContentsComponent implements OnInit {
public counter = {all: 0, active: 0, inactive: 0};
public communities: Community[] = [];
public communities: Portal[] = [];
public selectedCommunityPid: string;
public selectedPageId: string;
public community: Community;
public community: Portal;
public page: Page;
public properties: EnvProperties = null;
@ -115,9 +115,7 @@ export class PageHelpContentsComponent implements OnInit {
this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
page => {
if ((this.selectedCommunityPid == 'openaire' && !page.openaire)
|| (this.selectedCommunityPid == 'connect' && !page.connect)
|| (this.selectedCommunityPid != 'openaire' && this.selectedCommunityPid != 'connect' && !page.communities)) {
if (this.properties.adminToolsPortalType != page.portalType) {
this.router.navigate(['/pageContents'], {queryParams: {"communityId": this.selectedCommunityPid}});
} else {
this.page = page;

View File

@ -69,6 +69,7 @@
<th *ngIf="!pagesType">Type</th>
<th *ngIf="!isPortalAdministrator">Related Entities</th>
<th>Route</th>
<th *ngIf="!selectedCommunityPid">Portal Type</th>
<th *ngIf="isPortalAdministrator">Actions</th>
<th *ngIf="!isPortalAdministrator" class="uk-text-center">Page help texts</th>
<th *ngIf="!isPortalAdministrator && (pageWithDivIds && pageWithDivIds.length > 0)"
@ -100,6 +101,9 @@
<td>
<div class="route" href="#">{{check.page.route}}</div>
</td>
<td *ngIf="!selectedCommunityPid">
<div class="portalType" href="#">{{check.page.portalType}}</div>
</td>
<td *ngIf="isPortalAdministrator">
<div class="actions" href="#">
@ -257,21 +261,42 @@
</span>
</div>
<div class="form-group">
<!-- <div class="form-group">-->
<div class="uk-text-muted"> Select if this page exists in:</div>
<span dashboard-input class="" [formInput]="myForm.get('openaire')"
type="checkbox"
label="Explore Portal">
</span>
<span dashboard-input class="uk-margin-small-left" [formInput]="myForm.get('connect')"
type="checkbox"
label="Connect Portal">
</span>
<span dashboard-input class="uk-margin-small-left" [formInput]="myForm.get('communities')"
type="checkbox"
label="Communities Dashboards">
</span>
<!-- <div class="uk-text-muted"> Select if this page exists in:</div>-->
<!-- <span dashboard-input class="" [formInput]="myForm.get('openaire')"-->
<!-- type="checkbox"-->
<!-- label="Explore Portal">-->
<!-- </span>-->
<!-- <span dashboard-input class="uk-margin-small-left" [formInput]="myForm.get('connect')"-->
<!-- type="checkbox"-->
<!-- label="Connect Portal">-->
<!-- </span>-->
<!-- <span dashboard-input class="uk-margin-small-left" [formInput]="myForm.get('communities')"-->
<!-- type="checkbox"-->
<!-- label="Communities Dashboards">-->
<!-- </span>-->
<!-- </div>-->
<div [ngClass]="{'has-error':!myForm.controls.portalType.valid && myForm.controls.portalType.dirty}" class="form-group" uk-grid>
<label class="uk-width-1-1 uk-margin-small-bottom">
Page exists in:
</label>
<label class="uk-width-1-1 radio uk-margin-large-left">
<span class="uk-margin-small-right" style="font-weight: normal;">OpenAIRE portal</span>
<!-- <input tabindex="0" type="checkbox" formControlName="openaire">-->
<input type="radio" value="explore" formControlName="portalType">
</label>
<label class="uk-width-1-1 radio uk-margin-large-left">
<span class="uk-margin-small-right" style="font-weight: normal;">OpenAIRE Connect portal</span>
<!-- <input tabindex="0" type="checkbox" formControlName="connect">-->
<input type="radio" value="connect" formControlName="portalType">
</label>
<label class="uk-width-1-1 radio uk-margin-large-left">
<span class="uk-margin-small-right" style="font-weight: normal;">Communities' Gateway</span>
<!-- <input tabindex="0" type="checkbox" formControlName="communities">-->
<input type="radio" value="community" formControlName="portalType">
</label>
</div>
<input type="hidden" formControlName="_id">

View File

@ -3,7 +3,7 @@ import {ActivatedRoute, Router} from '@angular/router';
import {HelpContentService} from '../../services/help-content.service';
import {FormArray, FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
import {CheckPage, Page} from '../../utils/entities/adminTool/page';
import {Community} from '../../utils/entities/adminTool/community';
import {Portal} from '../../utils/entities/adminTool/portal';
import {Entity} from '../../utils/entities/adminTool/entity';
import {EnvProperties} from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class';
@ -37,7 +37,7 @@ export class PagesComponent implements OnInit {
private searchText: RegExp = new RegExp('');
public keyword: string = '';
public communities: Community[] = [];
public communities: Portal[] = [];
public selectedCommunityPid: string;
@ -81,9 +81,7 @@ export class PagesComponent implements OnInit {
route: ['', Validators.required],
name: ['', Validators.required],
isEnabled: true,
openaire: true,
connect: false,
communities: true,
portalType: ['', Validators.required],
top: true,
bottom: true,
left: true,
@ -299,9 +297,7 @@ export class PagesComponent implements OnInit {
route: [page.route, Validators.required],
name: [page.name, Validators.required],
isEnabled: page.isEnabled,
openaire: page.openaire,
connect: page.connect,
communities: page.communities,
portalType: ['', Validators.required],
top: page.top,
bottom: page.bottom,
left: page.left,
@ -310,6 +306,7 @@ export class PagesComponent implements OnInit {
entities: this.entitiesCtrl,
_id: page._id,
});
this.myForm.controls['portalType'].disable();
for (let i = 0; i < page.entities.length; i++) {
this.entitiesCtrl.push(this._fb.control(page.entities[i]));
@ -330,14 +327,14 @@ export class PagesComponent implements OnInit {
}
public newPage() {
this.myForm.controls['portalType'].enable();
this.entitiesCtrl = this._fb.array([]);
this.myForm = this._fb.group({
route: ['', Validators.required],
name: ['', Validators.required],
isEnabled: true,
openaire: true,
connect: false,
communities: true,
portalType: ['', Validators.required],
top: true,
bottom: true,
left: true,
@ -381,6 +378,8 @@ export class PagesComponent implements OnInit {
} else {
console.log(this.myForm.value)
if (this.myForm.value['_id'].length == 0) {
this.myForm.controls['portalType'].enable();
this.modalErrorMessage = '';
this._helpContentService.savePage(<Page>this.myForm.value, this.properties.adminToolsAPIURL).subscribe(
page => {
@ -441,7 +440,7 @@ export class PagesComponent implements OnInit {
}
public filterPages(page: Page): boolean {
let textFlag = this.searchText.toString() == '' || (page.route + ' ' + page.name).match(this.searchText) != null;
let textFlag = this.searchText.toString() == '' || (page.route + ' ' + page.name + ' ' + page.portalType).match(this.searchText) != null;
return textFlag;
}
@ -463,9 +462,7 @@ export class PagesComponent implements OnInit {
route: ['', Validators.required],
name: ['', Validators.required],
isEnabled: true,
openaire: true,
connect: false,
communities: true,
portalType: ['', Validators.required],
top: true,
bottom: true,
left: true,

View File

@ -37,7 +37,7 @@
<div uk-dropdown="mode: click">
<ul class="uk-nav uk-navbar-dropdown-nav"
[attr.uk-tooltip]="getSelectedCommunities().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
title="Select at least one community">
title="Select at least one portal">
<li><a [class]="getSelectedCommunities().length == 0 ? 'uk-disabled' : ''"
(click)="confirmDeleteSelectedCommunities()"><i></i> Delete </a></li>
</ul>
@ -55,6 +55,7 @@
<tr>
<th><input id="allCommunityCheckbox" type="checkbox" (change)="toggleCheckBoxes($event)"></th>
<th>Name</th>
<th>Type</th>
<th>Actions</th>
</tr>
</thead>
@ -66,6 +67,9 @@
<td>
<div class="name" href="#">{{check.community.name}}</div>
</td>
<td>
<div class="type" href="#">{{check.community.type}}</div>
</td>
<td>
<div class="actions" href="#">
<i class="md-icon material-icons" (click)="editCommunity(i)"></i>
@ -86,7 +90,7 @@
<div *ngIf="checkboxes.length==0" class="col-md-12">
<div class="uk-alert-warning" uk-alert>No communities found</div>
<div class="uk-alert-warning" uk-alert>No portals found</div>
</div>
</div>
</div>
@ -105,11 +109,20 @@
<form [formGroup]="portalFG">
<div dashboard-input class="uk-margin-small-left" [formInput]="portalFG.controls.name"
type="text"
label="Community Name">
label="Portal Name">
</div>
<div [ngClass]="{'has-error':!portalFG.controls.type.valid && portalFG.controls.type.dirty}">
<label for="portalTypeTag">*Portal Type</label>
<select formControlName="type" id="portalTypeTag" class="form-control uk-select">
<option [value]="'explore'">OpenAIRE Explore Portal</option>
<option [value]="'connect'">OpenAIRE Connect Portal</option>
<option [value]="'monitor'">OpenAIRE Monitor Portal</option>
<option [value]="'community'">OpenAIRE Community Gateway</option>
</select>
</div>
<div dashboard-input class="uk-margin-small-left " [formInput]="portalFG.controls.pid"
type="text"
label="Community persistent id for portal">
label="Portal persistent id for portal">
</div>
<input type="hidden" formControlName="_id">
</form>

View File

@ -2,7 +2,7 @@ import {Component, ViewChild, OnInit, ElementRef} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {HelpContentService} from '../../services/help-content.service';
import {FormBuilder, FormControl, FormGroup} from '@angular/forms';
import {CheckCommunity, Community} from '../../utils/entities/adminTool/community';
import {CheckPortal, Portal} from '../../utils/entities/adminTool/portal';
import {EnvProperties} from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class';
@ -21,8 +21,8 @@ export class CommunitiesComponent implements OnInit {
@ViewChild('AlertModalDeleteCommunities') alertModalDeleteCommunities;
private selectedCommunities: string[] = [];
public checkboxes: CheckCommunity[] = [];
public communities: Community[] = [];
public checkboxes: CheckPortal[] = [];
public communities: Portal[] = [];
public portalFG: FormGroup;
public formControl: FormControl;
@ -42,7 +42,8 @@ export class CommunitiesComponent implements OnInit {
this.portalFG = this._fb.group({
name: '',
_id: '',
pid: ''
pid: '',
type: ''
});
this.formControl = this._fb.control('');
this.subscriptions.push(this.formControl.valueChanges.subscribe(value => {
@ -88,7 +89,7 @@ export class CommunitiesComponent implements OnInit {
communities => {
this.communities = communities;
communities.forEach(_ => {
this.checkboxes.push(<CheckCommunity>{community: _, checked: false});
this.checkboxes.push(<CheckPortal>{community: _, checked: false});
});
this.showLoading = false;
},
@ -162,20 +163,24 @@ export class CommunitiesComponent implements OnInit {
}
public editCommunity(i: number) {
const community: Community = this.checkboxes[i].community;
const community: Portal = this.checkboxes[i].community;
this.portalFG = this._fb.group({
name: community.name,
_id: community._id,
type: community.type,
pid: community.pid
});
this.portalFG.controls['type'].disable();
this.modalErrorMessage = '';
this.communitiesModalOpen(this.alertModalSaveCommunity, 'Update', 'Update Community');
}
public newCommunity() {
this.portalFG.controls['type'].enable();
this.portalFG = this._fb.group({
name: '',
_id: '',
type: '',
pid: ''
});
this.modalErrorMessage = '';
@ -205,7 +210,8 @@ export class CommunitiesComponent implements OnInit {
this.modalErrorMessage = '';
if (this.portalFG.getRawValue()['_id'].length > 0) {
this._helpContentService.updateCommunity(<Community>this.portalFG.value,
this.portalFG.controls['type'].enable();
this._helpContentService.updateCommunity(<Portal>this.portalFG.value,
this.properties.adminToolsAPIURL).subscribe(
community => {
this.communityUpdatedSuccessfully(community);
@ -213,7 +219,7 @@ export class CommunitiesComponent implements OnInit {
error => this.handleUpdateError('System error updating portal', error)
);
}else{
this._helpContentService.saveCommunity(<Community>this.portalFG.value,
this._helpContentService.saveCommunity(<Portal>this.portalFG.value,
this.properties.adminToolsAPIURL).subscribe(
community => {
this.communitySavedSuccessfully(community);
@ -231,7 +237,8 @@ export class CommunitiesComponent implements OnInit {
queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
});
} else {
this._helpContentService.updateCommunity(<Community>this.portalFG.value,
this.portalFG.controls['type'].enable();
this._helpContentService.updateCommunity(<Portal>this.portalFG.value,
this.properties.adminToolsAPIURL).subscribe(
community => {
this.communityUpdatedSuccessfully(community);
@ -241,12 +248,12 @@ export class CommunitiesComponent implements OnInit {
}
}
public communitySavedSuccessfully(community: Community) {
this.checkboxes.push(<CheckCommunity>{community: community, checked: false});
public communitySavedSuccessfully(community: Portal) {
this.checkboxes.push(<CheckPortal>{community: community, checked: false});
this.applyCheck(false);
}
public communityUpdatedSuccessfully(community: Community) {
public communityUpdatedSuccessfully(community: Portal) {
this.checkboxes.find(checkItem => checkItem.community._id === community._id).community = community;
this.applyCheck(false);
}
@ -259,12 +266,12 @@ export class CommunitiesComponent implements OnInit {
public applyFilter() {
this.checkboxes = [];
this.communities.filter(item => this.filterCommunities(item)).forEach(
_ => this.checkboxes.push(<CheckCommunity>{community: _, checked: false})
_ => this.checkboxes.push(<CheckPortal>{community: _, checked: false})
);
}
public filterCommunities(community: Community): boolean {
const textFlag = this.searchText.toString() === '' || (community.name).match(this.searchText) != null;
public filterCommunities(community: Portal): boolean {
const textFlag = this.searchText.toString() === '' || (community.name || community.type).match(this.searchText) != null;
return textFlag;
}
@ -273,7 +280,8 @@ export class CommunitiesComponent implements OnInit {
this.portalFG = this._fb.group({
name: '',
_id: '',
pid: ''
pid: '',
type: ''
});
} else {
this.updateErrorMessage = message;

View File

@ -5,6 +5,7 @@ import {Title, Meta} from '@angular/platform-browser';
import {RESPONSE} from "@nguniversal/express-engine/tokens";
import {EnvProperties} from "../utils/properties/env-properties";
import {SEOService} from "../sharedComponents/SEO/SEO.service";
import {properties} from "../../../environments/environment";
@Component({
selector: 'error',
@ -60,9 +61,9 @@ export class ErrorPageComponent {
this.response.statusCode = 404;
this.response.statusMessage = '404 - Page not found';
}
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
let properties = data.envSpecific;
//this.route.data
//.subscribe((data: { envSpecific: EnvProperties }) => {
//let properties = data.envSpecific;
this.seoService.createLinkForCanonicalURL(properties.domain + properties.baseLink + "/error");
this.route.queryParams.subscribe(data => {
@ -97,6 +98,6 @@ export class ErrorPageComponent {
}
}
});
});
//});
}
}

View File

@ -0,0 +1,18 @@
import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {properties} from "../../../environments/environment";
@Injectable({
providedIn: 'root'
})
export class ClearCacheService {
constructor(private http: HttpClient) {}
clearCache(message: string = null) {
this.http.get(properties.deleteCacheUrl).subscribe(
res => console.log((message ? message+": " : "") + "Cache cleared!"),
err => console.log((message ? message+": " : "") + "Cache could not be cleared ", err)
);
}
}

View File

@ -6,393 +6,399 @@ import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http";
import { Observable } from 'rxjs';
import { Page } from "../utils/entities/adminTool/page";
import { PageHelpContent } from "../utils/entities/adminTool/page-help-content";
import { Community } from "../utils/entities/adminTool/community";
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";
import {StatisticsDisplay, StatisticsSummary} from '../connect/statistics/statisticsEntities';
import { CustomOptions } from './servicesUtils/customOptions.class';
import {catchError, map} from "rxjs/operators";
import {properties} from "../../../environments/environment";
@Injectable()
export class HelpContentService {
constructor(private http:HttpClient) {
}
constructor(private http:HttpClient) {
}
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]);
}
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]);
}
}
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 += "&communityId="+pid;
}
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 + '/divFull'+parameters)
//.map(res => <Array<DivId>> res.json())
.pipe(catchError(this.handleError));
}
updateDivId(divId: DivId, helpContentUrl:string) {
HelpContentService.removeNulls(divId);
return this.http.get<Array<DivId>>(helpContentUrl + 'divFull'+parameters)
//.map(res => <Array<DivId>> res.json())
.pipe(catchError(this.handleError));
}
return this.http.post<DivId>(helpContentUrl + '/div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
getDivId(divId: string, helpContentUrl:string) {
return this.http.get<DivId>(helpContentUrl + '/div/'+divId)
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
getDivIdFull(divId: string, helpContentUrl:string) {
return this.http.get<DivId>(helpContentUrl + '/divFull/'+divId)
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
saveDivId(divId: DivId, helpContentUrl:string) {
HelpContentService.removeNulls(divId);
return this.http.post<DivId>(helpContentUrl + '/div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
/*
getCommunitiesWithDivId(helpContentUrl:string) {
return this.http.get(helpContentUrl + 'community?div=true')
.map(res => <Array<Community>> res.json())
.catch(this.handleError);
}
*/
getCommunityPagesWithDivId(community_pid: string, helpContentUrl:string) {
return this.http.get<Array<Page>>(helpContentUrl + '/community/'+community_pid+'/pages?div=true')
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
getCommunityDivHelpContents(community_pid: string, helpContentUrl:string) {
return this.http.get<Array<DivHelpContent>>(helpContentUrl + '/divhelpcontent?community='+community_pid)
//.map(res => <Array<DivHelpContent>> res.json())
.pipe(catchError(this.handleError));
}
getDivHelpContent(id : string, helpContentUrl:string) {
return this.http.get<DivHelpContent>(helpContentUrl + '/divhelpcontent/' + id)
//.map(res => <DivHelpContent> res.json())
.pipe(catchError(this.handleError));
}
insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string) {
HelpContentService.removeNulls(divHelpContent);
return this.http.post<DivHelpContent>(helpContentUrl + '/divhelpcontent', JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody())
//.map(res => <DivHelpContent> res.json())
.pipe(catchError(this.handleError));
}
deleteDivIds(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + '/div/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
deleteDivHelpContents(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + '/divhelpcontent/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
toggleDivHelpContents(ids : string[],status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl + '/divhelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json())
.pipe(catchError(this.handleError));
}
getPagesWithDivIds(community_pid: string, helpContentUrl:string) {
let parameters = (community_pid ? "?communityId="+community_pid : "");
return this.http.get<Array<string>>(helpContentUrl + '/div/pages'+parameters)
//.map(res => <Map<string, Set<string>>> res.json())
.pipe(catchError(this.handleError));
}
getPages(helpContentUrl:string,pid:string,with_positions:boolean=null) {
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;
}
}
return this.http.get<Array<Page>>(helpContentUrl + '/page'+parameters)
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
getPagesFull(helpContentUrl:string,pid:string) {
return this.http.get<Array<Page>>(helpContentUrl + '/pageFull'+(pid?("?pid="+pid):""))
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
getPage(pageId:string, helpContentUrl:string) {
return this.http.get<Page>(helpContentUrl + '/page/'+pageId)
//.map(res => <Page> res.json())
.pipe(catchError(this.handleError));
}
getPageByRoute(route:string, helpContentUrl:string) {
return this.http.get<Page>(helpContentUrl + '/page/?page_route='+route)
.pipe(catchError(this.handleError));
}
getCommunities( helpContentUrl:string) {
return this.http.get<Array<Community>>(helpContentUrl + '/community')
//.map(res => <Array<Community>> res.json())
.pipe(catchError(this.handleError));
}
getCommunity(community_pid: string, helpContentUrl:string) {
return this.http.get<Community>(helpContentUrl + '/community/'+community_pid)
//.map(res => <Community> res.json())
.pipe(catchError(this.handleError));
}
getCommunitiesFull( helpContentUrl:string) {
return this.http.get<Array<Community>>(helpContentUrl + '/communityFull')
//.map(res => <Array<Community>> res.json())
.pipe(catchError(this.handleError));
}
getCommunityFull(community_pid: string, helpContentUrl:string) {
return this.http.get<Community>(helpContentUrl + '/communityFull/'+community_pid)
//.map(res => <Community> res.json())
.pipe(catchError(this.handleError));
}
saveCommunity(community: Community, helpContentUrl:string) {
// let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(community);
return this.http.post<Community>(helpContentUrl + '/community/save', JSON.stringify(community), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Community> res.json())
.pipe(catchError(this.handleError));
}
updateCommunity(community: Community, helpContentUrl:string) {
// let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(community);
return this.http.post<Community>(helpContentUrl + '/community/update', JSON.stringify(community), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Community> res.json())
.pipe(catchError(this.handleError));
}
deleteCommunities(ids : string[], helpContentUrl:string) {
// let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers});
return this.http.post(helpContentUrl + '/community/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
getCommunityPages(community_pid: string, params: string, helpContentUrl:string) {
return this.http.get<Array<Page>>(helpContentUrl + '/community/'+community_pid+'/pages'+params)
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
getEntities(helpContentUrl:string) {
return this.http.get<Array<Entity>>(helpContentUrl + '/entity')
//.map(res => <Array<Entity>> res.json())
.pipe(catchError(this.handleError));
}
getCommunityEntities(community_pid: string, helpContentUrl:string) {
return this.http.get<Array<Entity>>(helpContentUrl + '/community/'+community_pid+'/entities')
//.map(res => <Array<Entity>> res.json())
.pipe(catchError(this.handleError));
}
saveEntity(entity: Entity, helpContentUrl:string) {
HelpContentService.removeNulls(entity);
return this.http.post<Entity>(helpContentUrl + '/entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Entity> res.json())
.pipe(catchError(this.handleError));
}
updateEntity(entity: Entity, helpContentUrl:string) {
HelpContentService.removeNulls(entity);
return this.http.post<Entity>(helpContentUrl + '/entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Entity> res.json())
.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);
// }
toggleEntities(selectedCommunityPid: string, ids : string[],status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl +'/community/'+selectedCommunityPid+ '/entity/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json())
.pipe(catchError(this.handleError));
}
deleteEntities(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + '/entity/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
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));
}
savePage(page: Page, helpContentUrl:string) {
HelpContentService.removeNulls(page);
return this.http.post<Page>(helpContentUrl + '/page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Page> res.json())
.pipe(catchError(this.handleError));
}
updatePage(page: Page, helpContentUrl:string) {
HelpContentService.removeNulls(page);
return this.http.post<Page>(helpContentUrl + '/page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Page> res.json())
.pipe(catchError(this.handleError));
}
togglePages(selectedCommunityPid: string, ids : string[],status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl + '/community/'+selectedCommunityPid+'/page/toggle?status='+ status.toString(),JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
deletePages(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + '/page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
getPageHelpContents(helpContentUrl:string) {
return this.http.get<Array<PageHelpContent>>(helpContentUrl + 'pagehelpcontent')
//.map(res => <Array<PageHelpContent>> res.json())
.pipe(catchError(this.handleError));
}
getCommunityPageHelpContents(community_pid: string, helpContentUrl:string) {
return this.http.get<Array<PageHelpContent>>(helpContentUrl + '/pagehelpcontent?community='+community_pid)
//.map(res => <Array<PageHelpContent>> res.json())
.pipe(catchError(this.handleError));
}
getPageHelpContent(id : string, helpContentUrl:string) {
return this.http.get<PageHelpContent>(helpContentUrl + '/pagehelpcontent/' + id)
//.map(res => <PageHelpContent> res.json())
.pipe(catchError(this.handleError));
}
savePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) {
HelpContentService.removeNulls(pageHelpContent);
return this.http.post<PageHelpContent>(helpContentUrl + '/pagehelpcontent/save', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
//.map(res => <PageHelpContent> res.json())
.pipe(catchError(this.handleError));
}
updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) {
HelpContentService.removeNulls(pageHelpContent);
return this.http.post<PageHelpContent>(helpContentUrl + '/pagehelpcontent/update', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
//.map(res => <PageHelpContent> res.json())
.pipe(catchError(this.handleError));
}
deletePageHelpContents(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + 'pagehelpcontent/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
togglePageHelpContents(ids : string[],status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl + '/pagehelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json())
.pipe(catchError(this.handleError));
}
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);
return Observable.throw(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, communityId: string): Observable<StatisticsSummary> {
const url = `${apiUrl}communities/${communityId}`;
//console.log(`getting statistics summary from: ${url}`);
return this.http.get(url)
//.map(res => <any>res.json())
.pipe(map(res => res['statistics']));
}
getCommunityAdminStatisticsChoices(apiUrl: string, communityId: string): Observable<StatisticsDisplay> {
const url = `${apiUrl}/statistics/${communityId}`;
//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,
communityId: string,
entity: string,
chartsOrNumbers: string,
title: string,
status: boolean,
monitor: boolean): Observable<any> {
const url = `${apiUrl}/statistics/${communityId}/${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));
updateDivId(divId: DivId, helpContentUrl:string) {
HelpContentService.removeNulls(divId);
return this.http.post<DivId>(helpContentUrl + 'div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
getDivId(divId: string, helpContentUrl:string) {
return this.http.get<DivId>(helpContentUrl + 'div/'+divId)
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
getDivIdFull(divId: string, helpContentUrl:string) {
return this.http.get<DivId>(helpContentUrl + 'divFull/'+divId)
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
saveDivId(divId: DivId, helpContentUrl:string) {
HelpContentService.removeNulls(divId);
return this.http.post<DivId>(helpContentUrl + 'div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
/*
getCommunitiesWithDivId(helpContentUrl:string) {
return this.http.get(helpContentUrl + 'community?div=true')
.map(res => <Array<Portal>> res.json())
.catch(this.handleError);
}
*/
getCommunityPagesWithDivId(portal_pid: string, helpContentUrl:string) {
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/pages?div=true')
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
getCommunityDivHelpContents(portal_pid: string, helpContentUrl:string) {
return this.http.get<Array<DivHelpContent>>(helpContentUrl + 'divhelpcontent?portal='+portal_pid)
//.map(res => <Array<DivHelpContent>> res.json())
.pipe(catchError(this.handleError));
}
getDivHelpContent(id : string, helpContentUrl:string) {
return this.http.get<DivHelpContent>(helpContentUrl + 'divhelpcontent/' + id)
//.map(res => <DivHelpContent> res.json())
.pipe(catchError(this.handleError));
}
insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string) {
HelpContentService.removeNulls(divHelpContent);
return this.http.post<DivHelpContent>(helpContentUrl + 'divhelpcontent', JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody())
//.map(res => <DivHelpContent> res.json())
.pipe(catchError(this.handleError));
}
deleteDivIds(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + 'div/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
deleteDivHelpContents(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + 'divhelpcontent/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
toggleDivHelpContents(ids : string[],status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl + 'divhelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json())
.pipe(catchError(this.handleError));
}
getPagesWithDivIds(portal_pid: string, helpContentUrl:string) {
let parameters = (portal_pid ? "?portal="+portal_pid : "");
return this.http.get<Array<string>>(helpContentUrl + 'div/pages'+parameters)
//.map(res => <Map<string, Set<string>>> res.json())
.pipe(catchError(this.handleError));
}
getPages(helpContentUrl:string,pid:string,with_positions:boolean=null) {
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;
}
}
return this.http.get<Array<Page>>(helpContentUrl + 'page'+parameters)
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
getPagesFull(helpContentUrl:string,pid:string) {
return this.http.get<Array<Page>>(helpContentUrl + 'pageFull'+(pid?("?pid="+pid):""))
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
getPage(pageId:string, helpContentUrl:string) {
return this.http.get<Page>(helpContentUrl + 'page/'+pageId)
//.map(res => <Page> res.json())
.pipe(catchError(this.handleError));
}
getPageByRoute(route:string, helpContentUrl:string) {
return this.http.get<Page>(helpContentUrl + 'page/?page_route='+route)
.pipe(catchError(this.handleError));
}
getCommunities( helpContentUrl:string) {
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType)
//.map(res => <Array<Portal>> res.json())
.pipe(catchError(this.handleError));
}
getCommunity(portal_pid: string, helpContentUrl:string) {
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid)
//.map(res => <Portal> res.json())
.pipe(catchError(this.handleError));
}
getCommunitiesFull( helpContentUrl:string) {
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType + '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 + 'Full/'+portal_pid)
//.map(res => <Portal> res.json())
.pipe(catchError(this.handleError));
}
saveCommunity(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 + '/save', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Portal> res.json())
.pipe(catchError(this.handleError));
}
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())
.pipe(catchError(this.handleError));
}
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())
.pipe(catchError(this.handleError));
}
getCommunityPages(portal_pid: string, params: string, helpContentUrl:string) {
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/pages'+params)
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
getEntities(helpContentUrl:string) {
return this.http.get<Array<Entity>>(helpContentUrl + 'entity')
//.map(res => <Array<Entity>> res.json())
.pipe(catchError(this.handleError));
}
getCommunityEntities(portal_pid: string, helpContentUrl:string) {
return this.http.get<Array<Entity>>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/entities')
//.map(res => <Array<Entity>> res.json())
.pipe(catchError(this.handleError));
}
saveEntity(entity: Entity, helpContentUrl:string) {
HelpContentService.removeNulls(entity);
return this.http.post<Entity>(helpContentUrl + 'entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Entity> res.json())
.pipe(catchError(this.handleError));
}
updateEntity(entity: Entity, helpContentUrl:string) {
HelpContentService.removeNulls(entity);
return this.http.post<Entity>(helpContentUrl + 'entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Entity> res.json())
.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);
// }
toggleEntities(selectedPortalPid: string, ids : string[],status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/'+selectedPortalPid+ '/entity/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json())
.pipe(catchError(this.handleError));
}
deleteEntities(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + 'entity/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
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));
}
savePage(page: Page, helpContentUrl:string) {
HelpContentService.removeNulls(page);
return this.http.post<Page>(helpContentUrl + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Page> res.json())
.pipe(catchError(this.handleError));
}
updatePage(page: Page, helpContentUrl:string) {
HelpContentService.removeNulls(page);
return this.http.post<Page>(helpContentUrl + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Page> res.json())
.pipe(catchError(this.handleError));
}
togglePages(selectedPortalPid: string, ids : string[],status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/'+selectedPortalPid+'/page/toggle?status='+ status.toString(),JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
deletePages(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + 'page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
getPageHelpContents(helpContentUrl:string) {
return this.http.get<Array<PageHelpContent>>(helpContentUrl + 'pagehelpcontent')
//.map(res => <Array<PageHelpContent>> res.json())
.pipe(catchError(this.handleError));
}
getCommunityPageHelpContents(portal_pid: string, helpContentUrl:string) {
return this.http.get<Array<PageHelpContent>>(helpContentUrl + 'pagehelpcontent?portal='+portal_pid)
//.map(res => <Array<PageHelpContent>> res.json())
.pipe(catchError(this.handleError));
}
getPageHelpContent(id : string, helpContentUrl:string) {
return this.http.get<PageHelpContent>(helpContentUrl + 'pagehelpcontent/' + id)
//.map(res => <PageHelpContent> res.json())
.pipe(catchError(this.handleError));
}
savePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) {
HelpContentService.removeNulls(pageHelpContent);
return this.http.post<PageHelpContent>(helpContentUrl + 'pagehelpcontent/save', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
//.map(res => <PageHelpContent> res.json())
.pipe(catchError(this.handleError));
}
updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) {
HelpContentService.removeNulls(pageHelpContent);
return this.http.post<PageHelpContent>(helpContentUrl + 'pagehelpcontent/update', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
//.map(res => <PageHelpContent> res.json())
.pipe(catchError(this.handleError));
}
deletePageHelpContents(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + 'pagehelpcontent/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
togglePageHelpContents(ids : string[],status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl + 'pagehelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json())
.pipe(catchError(this.handleError));
}
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);
return Observable.throw(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> {
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']));
}
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));
}
statisticsIsActiveToggle(apiURL: string, id: string): Observable<boolean> {
const url = apiURL + '/statistics/' + encodeURIComponent(id) + '/toggle';

View File

@ -4,6 +4,7 @@ import {Observable, throwError} from 'rxjs';
import {CustomOptions} from './servicesUtils/customOptions.class';
import {CustomizationOptions} from '../connect/community/CustomizationOptions';
import {EnvProperties} from "../utils/properties/env-properties";
import {properties} from "../../../environments/environment";
@Injectable()
export class LayoutService {
@ -23,12 +24,13 @@ export class LayoutService {
saveLayout(properties: EnvProperties, pid: string, layout: CustomizationOptions): Observable<CustomizationOptions> {
LayoutService.removeNulls(layout);
return this.http.post<CustomizationOptions>(properties.adminToolsAPIURL + 'community/'
return this.http.post<CustomizationOptions>(properties.adminToolsAPIURL + '/' + properties.adminToolsPortalType + '/'
+ pid + '/layout', layout, CustomOptions.getAuthOptionsWithBody());
}
getLayout(properties: EnvProperties, pid: string): Observable<CustomizationOptions> {
return this.http.get<CustomizationOptions>(properties.adminToolsAPIURL+"/community/" + pid + '/layout');
return this.http.get<CustomizationOptions>(properties.adminToolsAPIURL+"/" + properties.adminToolsPortalType + '/'
+ pid + '/layout');
}
mockLayout(): any {

View File

@ -21,7 +21,7 @@ export class CustomOptions {
};
}
public static getAuthOptions():any {
public static getAuthOptions():{} {
const httpOptions = {
headers: new HttpHeaders({
'X-XSRF-TOKEN': (COOKIE.getCookie(COOKIE.cookieName_id))?COOKIE.getCookie(COOKIE.cookieName_id):''

View File

@ -8,14 +8,14 @@ import {BehaviorSubject, from, Observable, Subscription} from 'rxjs';
// import 'rxjs/add/operator/share';
import {map, mapTo} from 'rxjs/operators';
import {EnvProperties} from "../properties/env-properties";
import {Community} from "../entities/adminTool/community";
import {Portal} from "../entities/adminTool/portal";
import {Page} from "../entities/adminTool/page";
@Injectable({ providedIn: 'root' })
export class ConfigurationService {
private communityInformation: BehaviorSubject<Community> = new BehaviorSubject(null);
private communityInformation: BehaviorSubject<Portal> = new BehaviorSubject(null);
private sub: Subscription = null;
private source: Observable<Community> = null;
private source: Observable<Portal> = null;
private promise: Promise<boolean> = null;
constructor(private http: HttpClient ) {}
@ -30,7 +30,7 @@ export class ConfigurationService {
* @deprecated
*/
getCommunityInformation(properties:EnvProperties, community:string){
let url = properties.adminToolsAPIURL +"/communityFull/" + community;
let url = properties.adminToolsAPIURL +"/"+properties.adminToolsPortalType+"/" + community + '/full';
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
//.map(res => res.json());
}
@ -38,13 +38,13 @@ export class ConfigurationService {
public initCommunityInformation(properties:EnvProperties, community:string) {
if(community == null) return;
let url = properties.adminToolsAPIURL +"/communityFull/" + community;
let url = properties.adminToolsAPIURL +"/" + properties.adminToolsPortalType + "/" + community + "/full";
this.promise = new Promise<any>((resolve => {
this.source = this.http.get<Community>((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
this.source = this.http.get<Portal>((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
this.sub = this.source
.subscribe(
(communityInformation: Community) => {
(communityInformation: Portal) => {
this.communityInformation.next(communityInformation);
resolve();
},
@ -56,7 +56,7 @@ export class ConfigurationService {
}
public get communityInformationState(): Observable<Community> {
public get communityInformationState(): Observable<Portal> {
return this.communityInformation.asObservable();
}
@ -81,7 +81,7 @@ export class ConfigurationService {
isPageEnabled(properties:EnvProperties, community:string,router: string){
let page_route: string = router.split('?')[0].substring(1);
let url = properties.adminToolsAPIURL + "/community/" + community+"/pages?page_route="+page_route;
let url = properties.adminToolsAPIURL + "/"+properties.adminToolsPortalType+"/" + community+"/pages?page_route="+page_route;
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
//.map(res => res.json())
.pipe(map(res => {
@ -109,7 +109,7 @@ export class ConfigurationService {
}
filtering(page_route: string) {
let community: Community = this.communityInformation.getValue();
let community: Portal = this.communityInformation.getValue();
let pages: Page[] = <Page[]>community.pages;
pages = pages.filter(function (page: Page) {

View File

@ -1,10 +1,10 @@
import { DivId } from './divId';
import {Community} from './community';
import {Portal} from './portal';
export interface DivHelpContent {
_id: string;
divId: DivId | string;
community: string | Community;
portal: string | Portal;
content: string;
isActive: boolean;
}

View File

@ -4,9 +4,7 @@ export interface DivId {
_id: string;
name: string;
pages: Page[] | String[];
connect: boolean;
communities: boolean;
openaire: boolean;
portalType: string;
}
export interface CheckDivId {

View File

@ -1,10 +1,10 @@
import { Page } from "./page";
import { Community } from "./community";
import { Portal } from "./portal";
export interface HtmlPageContent {
_id: string;
page: Page | string;
community: Community | string;
portal: Portal | string;
content: string;
}

View File

@ -2,12 +2,12 @@
* Created by stefania on 7/13/17.
*/
import { Page } from './page';
import { Community } from './community';
import {Portal} from "./portal";
export interface PageHelpContent {
_id: string;
page: Page | string;
community: Community | string;
portal: Portal | string;
placement: string;
order: number;
content: string;

View File

@ -6,9 +6,7 @@ export interface Page {
name: string;
type: string;
isEnabled: boolean;
connect: boolean;
communities: boolean;
openaire: boolean;
portalType: string;
entities: Entity[] | string[];
top: boolean;
bottom: boolean;

View File

@ -1,15 +1,16 @@
import {Page} from './page';
import {Entity} from './entity';
export interface Community {
export interface Portal {
_id: string;
pid: string;
name: string;
type: string;
entities: string[] | Entity[];
pages: string[] | Page[];
}
export interface CheckCommunity {
community: Community;
export interface CheckPortal {
community: Portal;
checked: boolean;
}

View File

@ -35,7 +35,7 @@ export class HelperService {
}
let page_route: string = router.split('?')[0].substring(0);
let url = properties.adminToolsAPIURL;
url += '/community/' + communityId + '/pagehelpcontent?active=true&page='+page_route;
url += '/'+properties.adminToolsPortalType+'/' + communityId + '/pagehelpcontent/grouped?active=true&page='+page_route;
return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
}
@ -45,7 +45,7 @@ export class HelperService {
}
let page_route: string = router.split('?')[0].substring(0);
let url = properties.adminToolsAPIURL;
url += '/community/' + communityId + '/divhelpcontent?active=true&page='+page_route;
url += '/'+properties.adminToolsPortalType+'/' + communityId + '/divhelpcontent/grouped?active=true&page='+page_route;
return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
}

View File

@ -1,8 +1,10 @@
export type Environment = "development" | "test" | "beta" | "production";
export type Dashboard = "explore" | "connect" | "monitor";
export type PortalType = "explore" | "connect" | "community" | "monitor";
export interface EnvProperties {
environment?: Environment;
adminToolsPortalType?: PortalType;
dashboard?: Dashboard;
isDashboard?: boolean;
domain?: string;
@ -57,6 +59,7 @@ export interface EnvProperties {
feedbackmail?: string;
feedbackmailForMissingEntities?: string;
cacheUrl?: string;
deleteCacheUrl?: string;
monitorServiceAPIURL?: string;
adminToolsAPIURL?: string;
adminToolsCommunity?: string;

View File

@ -5,6 +5,7 @@ import {CustomOptions} from "../../services/servicesUtils/customOptions.class";
import {EnvProperties} from "../properties/env-properties";
import {COOKIE} from "../../login/utils/helper.class";
import {BehaviorSubject, Observable} from "rxjs";
import {properties} from "../../../../environments/environment";
@Injectable()
export class SubscribeService {
@ -13,7 +14,7 @@ export class SubscribeService {
constructor(private http: HttpClient) {}
public initIsSubscribedToCommunity(properties: EnvProperties, pid: string) {
let url = properties.adminToolsAPIURL + "/community/" + pid + "/is-subscriber/";
let url = properties.adminToolsAPIURL + "/"+ properties.adminToolsPortalType +"/" + pid + "/is-subscriber/";
this.http.get<boolean>(url, CustomOptions.getAuthOptionsWithBody()).subscribe((isSubscribed) => {
this.isSubscribedSubject.next(isSubscribed);
}, error => {
@ -26,17 +27,17 @@ export class SubscribeService {
}
getCommunitySubscribers(properties: EnvProperties, pid: string) {
let url = properties.adminToolsAPIURL + "/community/" + pid + "/subscribers";
let url = properties.adminToolsAPIURL + "/" + properties.adminToolsPortalType + "/" + pid + "/subscribers";
return this.http.get<any>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
}
getNumberOfCommunitySubscribers(properties: EnvProperties, pid: string) {
let url = properties.adminToolsAPIURL + "/community/" + pid + "/subscribers/count";
let url = properties.adminToolsAPIURL + "/"+ properties.adminToolsPortalType +"/" + pid + "/subscribers/count";
return this.http.get<any>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
}
isSubscribedToCommunity(properties: EnvProperties, pid: string) {
let url = properties.adminToolsAPIURL + "/community/" + pid + "/is-subscriber/";
let url = properties.adminToolsAPIURL + "/"+ properties.adminToolsPortalType +"/" + pid + "/is-subscriber/";
return this.http.get<boolean>(url, CustomOptions.getAuthOptionsWithBody())
.pipe(map(res => {
// if (res['status'] && res['status'] != 200) {
@ -56,24 +57,24 @@ export class SubscribeService {
}
subscribeToCommunity(properties: EnvProperties, pid: string) {
return this.http.post<any>(properties.adminToolsAPIURL + "/community/" + pid + "/subscriber", {}, CustomOptions.getAuthOptionsWithBody())
return this.http.post<any>(properties.adminToolsAPIURL + "/"+ properties.adminToolsPortalType +"/" + pid + "/subscriber", {}, CustomOptions.getAuthOptionsWithBody())
.pipe(tap(isSubscribed => {
this.isSubscribedSubject.next(isSubscribed);}));
}
unSubscribeToCommunity(properties: EnvProperties, pid: string) {
return this.http.post<any>(properties.adminToolsAPIURL + "/community/" + pid + "/subscriber/delete", {}, CustomOptions.getAuthOptionsWithBody())
return this.http.post<any>(properties.adminToolsAPIURL + "/"+ properties.adminToolsPortalType+"/" + pid + "/subscriber/delete", {}, CustomOptions.getAuthOptionsWithBody())
.pipe(tap(unSubscribed => {
this.isSubscribedSubject.next(!unSubscribed);}));
}
subscribeToCommunityByEmail(properties: EnvProperties, pid: string, email: string) {
let subscriber = {"email": email};
return this.http.post<any>(properties.adminToolsAPIURL + "/community/" + pid + "/subscribers", JSON.stringify(subscriber), CustomOptions.getAuthOptionsWithBody());
return this.http.post<any>(properties.adminToolsAPIURL + "/"+ properties.adminToolsPortalType+"/" + pid + "/subscribers", JSON.stringify(subscriber), CustomOptions.getAuthOptionsWithBody());
}
unSubscribeToCommunityByEmail(properties: EnvProperties, pid: string, email: string) {
return this.http.post<any>(properties.adminToolsAPIURL + "/community/" + pid + "/subscribers/delete", JSON.stringify([email]), CustomOptions.getAuthOptionsWithBody());
return this.http.post<any>(properties.adminToolsAPIURL + "/"+ properties.adminToolsPortalType+"/" + pid + "/subscribers/delete", JSON.stringify([email]), CustomOptions.getAuthOptionsWithBody());
}
getCommunitiesSubscribedTo(properties: EnvProperties/*, email: string*/) {