diff --git a/package.json b/package.json index da89f6a..4a4fe3d 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "@angular/router": "7.2.14", "@nguniversal/express-engine": "^6.0.0", "@types/express": "^4.16.1", - "@types/node": "^6.0.101", "angular-datatables": "^4.4.1", "citation-js": "^0.3.4", "ng2-ckeditor": "1.1.9", @@ -54,7 +53,7 @@ "@types/jasmine": "~2.8.8", "@types/jasminewd2": "~2.0.3", "@types/jquery": "^3.3.29", - "@types/node": "~6.14.6", + "@types/node": "^8.0.30", "codelyzer": "~4.5.0", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", diff --git a/src/app/app.component.html b/src/app/app.component.html index 406dc9c..d2688fb 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,5 +1,5 @@ diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 95f809e..cc824bd 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -11,6 +11,7 @@ import {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; import {Session, User} from './openaireLibrary/login/utils/helper.class'; import {HelperFunctions} from './openaireLibrary/utils/HelperFunctions.class'; import {UserManagementService} from './openaireLibrary/services/user-management.service'; +import {ConnectHelper} from "./openaireLibrary/connect/connectHelper"; declare var UIkit: any; @@ -75,6 +76,7 @@ export class AppComponent implements OnInit { this._communitiesService.updateCommunities(this.properties, this.properties.communityAPI + 'communities'); this.route.queryParams.subscribe(params => { this.communityId = (params['communityId']) ? params['communityId'] : ''; + ConnectHelper.setPortalTypeFromPid(this.communityId); this.communityType = null; this.menuItems = []; diff --git a/src/app/domain/div-help-content.ts b/src/app/domain/div-help-content.ts index ed948a1..b93d530 100644 --- a/src/app/domain/div-help-content.ts +++ b/src/app/domain/div-help-content.ts @@ -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; } diff --git a/src/app/domain/divId.ts b/src/app/domain/divId.ts index 13b1342..193e5e8 100644 --- a/src/app/domain/divId.ts +++ b/src/app/domain/divId.ts @@ -4,9 +4,7 @@ export interface DivId { _id: string; name: string; pages: string[] | Page[]; - connect: boolean; - communities: boolean; - openaire: boolean; + portalType: string; } export interface CheckDivId { diff --git a/src/app/domain/html-page-content.ts b/src/app/domain/html-page-content.ts index 4064356..e21f689 100644 --- a/src/app/domain/html-page-content.ts +++ b/src/app/domain/html-page-content.ts @@ -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; + community: Portal | string; content: string; } diff --git a/src/app/domain/page-help-content.ts b/src/app/domain/page-help-content.ts index 8fe047b..082004e 100644 --- a/src/app/domain/page-help-content.ts +++ b/src/app/domain/page-help-content.ts @@ -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; diff --git a/src/app/domain/page.ts b/src/app/domain/page.ts index 6768486..e9676e8 100644 --- a/src/app/domain/page.ts +++ b/src/app/domain/page.ts @@ -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; diff --git a/src/app/domain/community.ts b/src/app/domain/portal.ts similarity index 67% rename from src/app/domain/community.ts rename to src/app/domain/portal.ts index 9dd3177..a82887d 100644 --- a/src/app/domain/community.ts +++ b/src/app/domain/portal.ts @@ -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; } diff --git a/src/app/pages/affiliations/affiliations.component.html b/src/app/pages/affiliations/affiliations.component.html index a39aad2..ea9ea75 100644 --- a/src/app/pages/affiliations/affiliations.component.html +++ b/src/app/pages/affiliations/affiliations.component.html @@ -1,7 +1,7 @@ + src="{{urlPrefix(organization.logo_url) + organization.logo_url}}" alt="{{(organization.name)?organization.name:''}} logo"> @@ -44,7 +44,7 @@ - @@ -56,7 +56,7 @@ {{_format(result.name)}} - {{_format(result.website_url)}} + {{_format(result.website_url)}} diff --git a/src/app/pages/affiliations/affiliations.component.ts b/src/app/pages/affiliations/affiliations.component.ts index 56b343d..328a7b9 100644 --- a/src/app/pages/affiliations/affiliations.component.ts +++ b/src/app/pages/affiliations/affiliations.component.ts @@ -12,6 +12,7 @@ import {UtilitiesService} from '../../openaireLibrary/services/utilities.service import {AffiliationService} from "../../openaireLibrary/connect/affiliations/affiliation.service"; import {HelpContentService} from "../../services/help-content.service"; import {Title} from '@angular/platform-browser'; +import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; @Component({ selector: 'affiliations', @@ -94,10 +95,10 @@ export class AffiliationsComponent implements OnInit { } getOrganizationsPageId() { - this._helpContentService.getPageByRoute("/organizations", this.properties.adminToolsAPIURL).subscribe( - pages => { - if(pages && pages[0]) { - this.organizationsPageId = pages[0]._id; + this._helpContentService.getCommunityPageByRoute("/organizations", this.properties.adminToolsAPIURL, this.communityId).subscribe( + page => { + if(page) { + this.organizationsPageId = page._id; } this.showLoading = false; }, @@ -280,4 +281,8 @@ export class AffiliationsComponent implements OnInit { } } + public urlPrefix(url: string): string { + return StringUtils.urlPrefix(url); + } + } diff --git a/src/app/pages/community/communities.component.html b/src/app/pages/community/communities.component.html index 61972d5..a32a641 100644 --- a/src/app/pages/community/communities.component.html +++ b/src/app/pages/community/communities.component.html @@ -8,7 +8,7 @@ - + @@ -48,6 +48,7 @@ Name + Type Actions @@ -59,6 +60,9 @@ {{check.community.name}} + + {{check.community.type}} + diff --git a/src/app/pages/community/communities.component.ts b/src/app/pages/community/communities.component.ts index caa5f33..86bf982 100644 --- a/src/app/pages/community/communities.component.ts +++ b/src/app/pages/community/communities.component.ts @@ -6,13 +6,14 @@ import { ActivatedRoute, Router } from '@angular/router'; import { HelpContentService } from '../../services/help-content.service'; import { FormGroup } from '@angular/forms'; import { CommunityFormComponent } from './community-form.component'; -import { CheckCommunity, Community } from '../../domain/community'; +import { CheckPortal, Portal } from '../../domain/portal'; import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {Title} from '@angular/platform-browser'; +import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; @Component({ selector: 'communities', @@ -38,9 +39,9 @@ export class CommunitiesComponent implements OnInit { @ViewChild(CommunityFormComponent) public formComponent: CommunityFormComponent; - public checkboxes: CheckCommunity[] = []; + public checkboxes: CheckPortal[] = []; - public communities: Community[] = []; + public communities: Portal[] = []; // public errorMessage: string; @@ -70,7 +71,8 @@ export class CommunitiesComponent implements OnInit { constructor(private element: ElementRef, private route: ActivatedRoute, private title: Title, - private _router: Router, private _helpContentService: HelpContentService) {} + private _router: Router, private _helpContentService: HelpContentService, + private _clearCacheService: ClearCacheService) {} getCommunities() { @@ -87,7 +89,7 @@ export class CommunitiesComponent implements OnInit { communities => { this.communities = communities; communities.forEach(_ => { - this.checkboxes.push({community : _, checked : false}); + this.checkboxes.push({community : _, checked : false}); }); this.showLoading = false; }, @@ -160,6 +162,7 @@ export class CommunitiesComponent implements OnInit { _ => { this.deleteCommunitiesFromArray(this.selectedCommunities); this.showLoading = false; + this._clearCacheService.clearCache("communities deleted"); }, error => this.handleUpdateError('System error deleting the selected communities', error) ); @@ -167,17 +170,19 @@ export class CommunitiesComponent implements OnInit { } public editCommunity(i: number) { - const community: Community = this.checkboxes[i].community; + const community: Portal = this.checkboxes[i].community; this.formGroup.patchValue(community); + this.formGroup.controls['type'].disable(); // this.updateModal.showModal(); this.modalErrorMessage = ''; this.communitiesModalOpen(this.alertModalUpdateCommunity, 'Update', 'Update Community'); } public newCommunity() { - this.formComponent.reset(); - this.modalErrorMessage = ''; - this.communitiesModalOpen(this.alertModalSaveCommunity, 'Save', 'Add a new Community'); + this.formGroup.controls['type'].enable(); + this.formComponent.reset(); + this.modalErrorMessage = ''; + this.communitiesModalOpen(this.alertModalSaveCommunity, 'Save', 'Add a new Community'); } private communitiesModalOpen(modal: any, title: string, yesBtn: string) { @@ -203,10 +208,11 @@ export class CommunitiesComponent implements OnInit { this.modalErrorMessage = 'Please fill in all required fields marked with *'; } else { this.modalErrorMessage = ''; - this._helpContentService.saveCommunity( this.formGroup.value, + this._helpContentService.saveCommunity( this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( community => { this.communitySavedSuccessfully(community); + this._clearCacheService.clearCache("community saved"); }, error => this.handleUpdateError('System error creating community', error) ); @@ -223,10 +229,12 @@ export class CommunitiesComponent implements OnInit { this.communitiesModalOpen(this.alertModalUpdateCommunity, 'Update', 'Update Community'); this.modalErrorMessage = 'Please fill in all required fields marked with *'; } else { - this._helpContentService.updateCommunity( this.formGroup.value, + this.formGroup.controls['type'].enable(); + this._helpContentService.updateCommunity( this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( community => { this.communityUpdatedSuccessfully(community); + this._clearCacheService.clearCache("community updated"); }, error => this.handleUpdateError('System error updating community', error) ); @@ -234,12 +242,12 @@ export class CommunitiesComponent implements OnInit { } } - public communitySavedSuccessfully(community: Community) { - this.checkboxes.push({community : community, checked : false}); + public communitySavedSuccessfully(community: Portal) { + this.checkboxes.push({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); } @@ -252,12 +260,12 @@ export class CommunitiesComponent implements OnInit { public applyFilter() { this.checkboxes = []; this.communities.filter(item => this.filterCommunities(item)).forEach( - _ => this.checkboxes.push({community: _, checked: false}) + _ => this.checkboxes.push({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; } diff --git a/src/app/pages/community/community-form.component.html b/src/app/pages/community/community-form.component.html index 81e4058..c63ec86 100644 --- a/src/app/pages/community/community-form.component.html +++ b/src/app/pages/community/community-form.component.html @@ -1,11 +1,20 @@ - - *Community Name - - - - *Community persistent id for portal - - - + + *Portal Name + + + + *Portal Type + + OpenAIRE Explore Portal + OpenAIRE Connect Portal + OpenAIRE Monitor Portal + OpenAIRE Community Gateway + + + + *Portal persistent id + + + diff --git a/src/app/pages/community/community-form.component.ts b/src/app/pages/community/community-form.component.ts index fd7ea57..8b5dfb4 100644 --- a/src/app/pages/community/community-form.component.ts +++ b/src/app/pages/community/community-form.component.ts @@ -1,6 +1,5 @@ import {Component, OnInit, Input} from '@angular/core'; -import {FormGroup, FormArray, FormBuilder, Validators} from "@angular/forms"; -import { HelpContentService } from "../../services/help-content.service"; +import {FormGroup, FormBuilder, Validators} from "@angular/forms"; @Component({ selector: 'community-form', @@ -14,30 +13,32 @@ export class CommunityFormComponent implements OnInit{ public errorMessage: string; - constructor(public _fb: FormBuilder, private _helpContentService: HelpContentService) {} + constructor(public _fb: FormBuilder) {} ngOnInit(): void {} public get form() { - return this._fb.group({ - _id : '', - pid: ['', Validators.required], - name : ['', Validators.required] - }); + return this._fb.group({ + _id: '', + pid: ['', Validators.required], + name: ['', Validators.required], + type: ['', Validators.required] + }); } public reset() { - this.myForm.patchValue({ - name : '', - _id : '', - pid: '' - }); + this.myForm.patchValue({ + name : '', + _id : '', + pid: '', + type: '' + }); } handleError(message: string, error) { - if(error == null) { - this.reset(); - } - this.errorMessage = message + ' (Server responded: ' + error + ')'; + if(error == null) { + this.reset(); + } + this.errorMessage = message + ' (Server responded: ' + error + ')'; } } diff --git a/src/app/pages/dashboard/dashboard.component.ts b/src/app/pages/dashboard/dashboard.component.ts index e028a42..ec2e9db 100644 --- a/src/app/pages/dashboard/dashboard.component.ts +++ b/src/app/pages/dashboard/dashboard.component.ts @@ -8,6 +8,7 @@ import {CommunityService} from '../../openaireLibrary/connect/community/communit import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {Title} from '@angular/platform-browser'; +import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper"; @Component({ selector: 'dashboard', @@ -30,6 +31,8 @@ export class DashboardComponent implements OnInit { this.route.queryParams.subscribe(data => { HelperFunctions.scroll(); this.communityId = ((data['communityId']) ? data['communityId'] : data['community']); + ConnectHelper.setPortalTypeFromPid(this.communityId); + this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe ( community => { this.communityType = community.type; diff --git a/src/app/pages/divId/divId-form.component.html b/src/app/pages/divId/divId-form.component.html index c96ce77..c04acc9 100644 --- a/src/app/pages/divId/divId-form.component.html +++ b/src/app/pages/divId/divId-form.component.html @@ -4,67 +4,65 @@ - - Page Name (*at least 1) - - {{page.name}}, + + + *Class exists in: + + + OpenAIRE portal + + + + + OpenAIRE Connect portal + + + + + Communities' Gateway + + + + If portal changes, selected pages will be lost + - Add / Remove pages + + Page Name (*at least 1) + + {{page.name}}, - - {{errorMessage}} - + Add / Remove pages - + + - = 0" class="activated" > + - + {{page.name}} - --> - - - - - - - - - - {{page.name}} - - - - + + + - - - Select if this class exists in OpenAIRE portal - - openaire - - - - - - Select if this class exists in connect portals - - connect - - - - - - Select if this class exists in connect portals (community specific) - - communities - - - - diff --git a/src/app/pages/divId/divId-form.component.ts b/src/app/pages/divId/divId-form.component.ts index e51a81c..1575159 100644 --- a/src/app/pages/divId/divId-form.component.ts +++ b/src/app/pages/divId/divId-form.component.ts @@ -1,12 +1,13 @@ import {Component, OnInit, Input} from '@angular/core'; import { ActivatedRoute, Router } from "@angular/router"; -import {FormGroup, FormArray, FormBuilder, Validators} from "@angular/forms"; +import {FormGroup, FormArray, FormBuilder, Validators, FormControl} from "@angular/forms"; import { HelpContentService } from "../../services/help-content.service"; import { Page } from "../../domain/page"; import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; +import {Subscription} from "rxjs"; @Component({ selector: 'divId-form', @@ -21,8 +22,8 @@ export class DivIdFormComponent implements OnInit{ @Input('formPages') formPages: Page[] = []; - //public allPages : Page[] = []; - public allPages: Map = new Map(); + public allPages : Page[] = []; + public allPagesFiltered: Map = new Map(); private gotPages: boolean = false; public properties:EnvProperties = null; @@ -30,16 +31,43 @@ export class DivIdFormComponent implements OnInit{ public showLoading: boolean = false; public errorMessage: string = ''; selectedCommunityPid = null; + + private sub: Subscription = null; + constructor(private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder, private _helpContentService: HelpContentService){} ngOnInit(): void { this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; - this.route.queryParams.subscribe(params => { - this.selectedCommunityPid = params['communityId']; - }); + // this.route.queryParams.subscribe(params => { + // this.selectedCommunityPid = params['communityId']; + // }); }); + + this. sub = this.myForm.get('portalType').valueChanges.subscribe(portalType => { + let pages = this.myForm.get('pages').value; + //pages = pages.filter(page => page.portalType == portalType); + //this.setPages(pages); + + pages.forEach((page, i) => { + if(page.portalType != portalType) { + this.pages.removeAt(i); + } + }); + + this.allPagesFiltered.clear(); + this.allPages.filter(page => page.portalType == portalType).forEach(page => { + this.allPagesFiltered.set(page, false); + }) + //this.myForm.value.pages = []; + }); + } + + ngOnDestroy() { + if(this.sub) { + this.sub.unsubscribe(); + } } public getKeys( map) { @@ -53,14 +81,16 @@ export class DivIdFormComponent implements OnInit{ this.showLoading = true; this.errorMessage = ""; - this._helpContentService.getPages(this.properties.adminToolsAPIURL,this.selectedCommunityPid).subscribe( + this._helpContentService.getAllPages(this.properties.adminToolsAPIURL).subscribe( pages => { - //this.allPages = allPages; + this.allPages = pages; + let self = this; + pages = pages.filter(page => page.portalType == self.myForm.get('portalType').value); for(let page of pages) { if(includedPages.has(page._id)) { - this.allPages.set(page, true); + this.allPagesFiltered.set(page, true); } else { - this.allPages.set(page, false); + this.allPagesFiltered.set(page, false); } } this.showLoading = false; @@ -82,14 +112,14 @@ export class DivIdFormComponent implements OnInit{ includedPages.add(pageName._id); } - let allPages = this.allPages; + let allPages = this.allPagesFiltered; let self = this; allPages.forEach(function (status, page, map) { if(includedPages.has(page._id)) { - self.allPages.set(page, true); + self.allPagesFiltered.set(page, true); } else { - self.allPages.set(page, false); + self.allPagesFiltered.set(page, false); } }); @@ -104,29 +134,25 @@ export class DivIdFormComponent implements OnInit{ } public get form() { - return this._fb.group({ - _id: '', - name : ['', Validators.required], - pages: this._fb.array([]), - openaire: true, - connect: false, - communities: true, - isCollapsed: [true] - }); + return this._fb.group({ + _id: '', + name : ['', Validators.required], + pages: this._fb.array([], Validators.required), + portalType: ['', Validators.required], + isCollapsed: [true] + }); } public reset() { - this.myForm.patchValue({ - _id : '', - name : '', - openaire: true, - connect: false, - communities: true, - isCollapsed: [true] - }); + this.myForm.patchValue({ + _id : '', + name : '', + portalType: '', + pages: [], + isCollapsed: [true] + }); - this.setPages([]); - this.formPages = []; + this.formPages = []; } public get pages(): FormArray { @@ -137,9 +163,20 @@ export class DivIdFormComponent implements OnInit{ //const pageFormArray = this._fb.array(pages); //this.myForm.setControl('pages', pageFormArray); - const pageFGs = pages.map(page => this._fb.group(page)); - const pageFormArray = this._fb.array(pageFGs); - this.myForm.setControl('pages', pageFormArray); + //const pageFGs = pages.map(page => this._fb.group(page)); + //if(pages && pages.length > 0) { + // const pageCtrls = pages.map(page => this._fb.control(page)); + // const pageFormArray = this._fb.array(pageCtrls); + // this.myForm.setControl('pages', pageFormArray); + //} + + while (this.pages.length !== 0) { + this.pages.removeAt(0) + } + pages.forEach(page => { + //array.push(new FormControl(page)); + this.pages.push(this._fb.control(page)); + }); } indexOfPageInForm(pageId: string): number { @@ -177,13 +214,13 @@ export class DivIdFormComponent implements OnInit{ } } - this.allPages.set(page, status); + this.allPagesFiltered.set(page, status); if(status && index<0) { - this.myForm.value.pages.push(page); + this.pages.push(this._fb.control(page)); } else if(!status){ if(index >= 0) { - this.myForm.value.pages.splice(index, 1); + this.pages.removeAt(index); } } } diff --git a/src/app/pages/divId/divIds.component.html b/src/app/pages/divId/divIds.component.html index a578bd2..0a8fa77 100644 --- a/src/app/pages/divId/divIds.component.html +++ b/src/app/pages/divId/divIds.component.html @@ -8,7 +8,7 @@ - + @@ -58,6 +58,7 @@ Name Page + Portal Type Actions @@ -78,6 +79,9 @@ {{page.name}}, + + {{check.divId.portalType}} + diff --git a/src/app/pages/divId/divIds.component.ts b/src/app/pages/divId/divIds.component.ts index 2f02674..1b154cf 100644 --- a/src/app/pages/divId/divIds.component.ts +++ b/src/app/pages/divId/divIds.component.ts @@ -12,6 +12,7 @@ import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {Title} from '@angular/platform-browser'; +import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; @Component({ selector: 'divIds', @@ -71,7 +72,8 @@ export class DivIdsComponent implements OnInit { constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router, private title: Title, - private _helpContentService: HelpContentService) {} + private _helpContentService: HelpContentService, + private _clearCacheService: ClearCacheService) {} getDivIds() { if(!Session.isLoggedIn()){ @@ -81,7 +83,7 @@ export class DivIdsComponent implements OnInit { this.updateErrorMessage = ""; this.errorMessage = ""; - this._helpContentService.getDivIdsFull(null, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getAllDivIdsFull(this.properties.adminToolsAPIURL).subscribe( divIds => { this.divIds = divIds; this.checkboxes = []; @@ -158,6 +160,7 @@ export class DivIdsComponent implements OnInit { _ => { this.deleteDivIdsFromArray(this.selectedDivIds); this.showLoading = false; + this._clearCacheService.clearCache("classes deleted"); }, error => this.handleUpdateError('System error deleting the selected classes', error) ); @@ -177,12 +180,14 @@ export class DivIdsComponent implements OnInit { this.formGroup.patchValue(divId); this.formComponent.setPages(divId.pages as Page[]);//pageIds); + this.formGroup.controls['portalType'].disable(); //this.updateModal.showModal(); this.divIdsModalOpen(this.alertModalUpdateDivId, "Update", "Update Class"); } public newDivId() { + this.formGroup.controls['portalType'].enable(); this.formComponent.reset(); this.modalErrorMessage = ""; this.divIdsModalOpen(this.alertModalSaveDivId, "Save", "Add a new Class"); @@ -212,6 +217,7 @@ export class DivIdsComponent implements OnInit { this._helpContentService.saveDivId( this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( divId => { this.divIdSavedSuccessfully(divId); + this._clearCacheService.clearCache("class saved"); }, error => this.handleUpdateError("System error creating class", error) ); @@ -227,9 +233,11 @@ export class DivIdsComponent implements OnInit { this.divIdsModalOpen(this.alertModalUpdateDivId, "Update", "Update Class"); this.modalErrorMessage = "Please fill in all required fields marked with *"; } else { + this.formGroup.controls['portalType'].enable(); this._helpContentService.updateDivId( this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( divId => { this.divIdUpdatedSuccessfully(divId); + this._clearCacheService.clearCache("class updated"); }, error => this.handleUpdateError("System error updating class", error) ); @@ -260,7 +268,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; } diff --git a/src/app/pages/divhelpcontent/div-help-content-form.component.html b/src/app/pages/divhelpcontent/div-help-content-form.component.html index 618a90e..c70d31b 100644 --- a/src/app/pages/divhelpcontent/div-help-content-form.component.html +++ b/src/app/pages/divhelpcontent/div-help-content-form.component.html @@ -16,7 +16,7 @@ Select Page - + {{page.name}} diff --git a/src/app/pages/divhelpcontent/div-help-content-form.component.ts b/src/app/pages/divhelpcontent/div-help-content-form.component.ts index 2fdca83..3513f71 100644 --- a/src/app/pages/divhelpcontent/div-help-content-form.component.ts +++ b/src/app/pages/divhelpcontent/div-help-content-form.component.ts @@ -116,7 +116,7 @@ export class DivContentFormComponent implements OnInit{ //this.showLoading = true; this.errorMessage = ''; - this._helpContentService.getDivIdsFull(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( + this._helpContentService.getDivIdsFullByPortal(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( divs => { this.availableDivs = divs; this.pageId = pageId; @@ -136,7 +136,7 @@ export class DivContentFormComponent implements OnInit{ divId: ['', Validators.required], content: ['', Validators.required], isActive: true, - community: '', + portal: this.communityPid, _id : '', }); } @@ -146,7 +146,7 @@ export class DivContentFormComponent implements OnInit{ divId: '', content: '', isActive: true, - community: '', + portal: this.communityPid, _id : '' }); this.myForm.markAsPristine(); diff --git a/src/app/pages/divhelpcontent/div-help-contents.component.ts b/src/app/pages/divhelpcontent/div-help-contents.component.ts index 00757eb..18d92b7 100644 --- a/src/app/pages/divhelpcontent/div-help-contents.component.ts +++ b/src/app/pages/divhelpcontent/div-help-contents.component.ts @@ -4,7 +4,7 @@ import { FormGroup } from "@angular/forms"; import { HelpContentService } from "../../services/help-content.service"; import { DivHelpContent, CheckDivHelpContent, DivHelpContentFilterOptions } from "../../domain/div-help-content"; import { Page } from "../../domain/page"; -import { Community } from "../../domain/community"; +import { Portal } from "../../domain/portal"; import { DivId } from "../../domain/divId"; import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; import {SafeHtmlPipe} from '../../openaireLibrary/utils/pipes/safeHTML.pipe'; @@ -14,6 +14,7 @@ import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.cla import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {PageHelpContent} from "../../domain/page-help-content"; import {Title} from '@angular/platform-browser'; +import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; @Component({ selector: 'div-help-contents', @@ -43,13 +44,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; @@ -81,7 +82,8 @@ export class DivHelpContentsComponent implements OnInit { constructor(private element: ElementRef, private route: ActivatedRoute, private title: Title, - private _helpService: HelpContentService, private router : Router) {} + private _helpService: HelpContentService, private router : Router, + private _clearCacheService: ClearCacheService) {} getPage(pageId: string) { if(!Session.isLoggedIn()){ @@ -90,11 +92,12 @@ export class DivHelpContentsComponent implements OnInit { this.showLoading = true; this.updateErrorMessage = ""; this.errorMessage = ""; - this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe( + this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( page => { - if( (this.selectedCommunityPid == 'openaire' && !page.openaire) - || (this.selectedCommunityPid == 'connect' && !page.connect) - || (this.selectedCommunityPid != 'openaire' && this.selectedCommunityPid != 'connect' && !page.communities)) { + // 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; @@ -217,10 +220,11 @@ export class DivHelpContentsComponent implements OnInit { this.showLoading = true; this.updateErrorMessage = ""; - this._helpService.deleteDivHelpContents(this.selectedDivContents, this.properties.adminToolsAPIURL).subscribe( + this._helpService.deleteDivHelpContents(this.selectedDivContents, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( _ => { this.deleteDivHelpContentsFromArray(this.selectedDivContents); this.showLoading = false; + this._clearCacheService.clearCache("class help contents deleted"); }, error => this.handleUpdateError('System error deleting the selected class content(s)', error) ); @@ -252,7 +256,7 @@ export class DivHelpContentsComponent implements OnInit { } else { this.updateErrorMessage = ""; - this._helpService.toggleDivHelpContents(ids,status, this.properties.adminToolsAPIURL).subscribe( + this._helpService.toggleDivHelpContents(ids,status, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( () => { for(let id of ids) { let i = this.checkboxes.findIndex(_ => _.divHelpContent._id == id); @@ -260,6 +264,7 @@ export class DivHelpContentsComponent implements OnInit { } this.countDivHelpContents(); this.applyCheck(false); + this._clearCacheService.clearCache("class help contents toggled (status: "+status+")"); }, error => this.handleUpdateError('System error changing the status of the selected page content(s)', error) ); diff --git a/src/app/pages/divhelpcontent/edit-div-help-content.component.ts b/src/app/pages/divhelpcontent/edit-div-help-content.component.ts index 0ab9410..cd0def3 100644 --- a/src/app/pages/divhelpcontent/edit-div-help-content.component.ts +++ b/src/app/pages/divhelpcontent/edit-div-help-content.component.ts @@ -11,6 +11,7 @@ import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.cla import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {Page} from "../../domain/page"; import {Title} from '@angular/platform-browser'; +import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; @Component({ selector: 'edit-div-help-content', @@ -41,7 +42,8 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{ private route: ActivatedRoute, private router: Router, private title: Title, - private _helpContentService: HelpContentService) {} + private _helpContentService: HelpContentService, + private _clearCacheService: ClearCacheService) {} ngOnInit() { this.route.data @@ -80,11 +82,12 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{ } private getPage(pageId: string) { - this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( page => { - if( (this.communityPid == 'openaire' && !page.openaire) - || (this.communityPid == 'connect' && !page.connect) - || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { + // 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; @@ -103,7 +106,7 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{ this.errorMessage = ""; this.updateErrorMessage = ""; - this._helpContentService.getDivHelpContent(divContentId, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getDivHelpContent(divContentId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( divHelpContent => { if(this.pageId) { this.getPage(this.pageId); @@ -121,7 +124,7 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{ } else { this.showLoading = true; - this._helpContentService.getDivIdFull(divId, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getDivIdFull(divId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( div => { this.formComponent.selectedDiv = div; @@ -154,7 +157,7 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{ let divHelpContent : DivHelpContent = this.formComponent.myForm.value; - this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.updateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe( _ => { if(this.pageId) { this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); @@ -162,6 +165,7 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{ this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } ); } this.showLoading = false; + this._clearCacheService.clearCache("class help content updated"); }, err => this.handleUpdateError('System error updating class content', err) ); diff --git a/src/app/pages/divhelpcontent/new-div-help-content.component.ts b/src/app/pages/divhelpcontent/new-div-help-content.component.ts index d7c30b9..2b729b6 100644 --- a/src/app/pages/divhelpcontent/new-div-help-content.component.ts +++ b/src/app/pages/divhelpcontent/new-div-help-content.component.ts @@ -10,6 +10,7 @@ import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.cla import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {Page} from "../../domain/page"; import {Title} from '@angular/platform-browser'; +import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; @Component({ selector: 'new-div-help-content', @@ -39,7 +40,8 @@ export class NewDivHelpContentComponent { private route: ActivatedRoute, private router: Router, private title: Title, - private _helpContentService: HelpContentService) {} + private _helpContentService: HelpContentService, + private _clearCacheService: ClearCacheService) {} ngOnInit() { this.route.data @@ -62,11 +64,12 @@ export class NewDivHelpContentComponent { } private getPage(pageId: string) { - this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( page => { - if( (this.communityPid == 'openaire' && !page.openaire) - || (this.communityPid == 'connect' && !page.connect) - || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { + // 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; @@ -88,7 +91,7 @@ export class NewDivHelpContentComponent { let divHelpContent : DivHelpContent = this.formComponent.myForm.value; - this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.saveDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe( _ => { if(this.pageId) { this.router.navigate( ['/classContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); @@ -96,6 +99,7 @@ export class NewDivHelpContentComponent { this.router.navigate(['/classContents'], { queryParams: { "communityId": this.communityPid } } ); } this.showLoading = false; + this._clearCacheService.clearCache("class help content saved"); }, err => this.handleUpdateError('System error saving page content', err) ); diff --git a/src/app/pages/entity/entities.component.ts b/src/app/pages/entity/entities.component.ts index 8a2debe..12b2ef7 100644 --- a/src/app/pages/entity/entities.component.ts +++ b/src/app/pages/entity/entities.component.ts @@ -4,13 +4,14 @@ import { HelpContentService } from '../../services/help-content.service'; import { FormGroup } from '@angular/forms'; import { EntityFormComponent } from './entity-form.component'; import { CheckEntity, Entity } from '../../domain/entity'; -import { Community } from '../../domain/community'; +import { Portal } from '../../domain/portal'; import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {UserManagementService} from '../../openaireLibrary/services/user-management.service'; import {Title} from '@angular/platform-browser'; +import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; @Component({ selector: 'entities', @@ -42,7 +43,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; @@ -60,7 +61,8 @@ export class EntitiesComponent implements OnInit { constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router, private title: Title, private _helpContentService: HelpContentService, - private userManagementService: UserManagementService) {} + private userManagementService: UserManagementService, + private _clearCacheService: ClearCacheService) {} ngOnInit() { this.formGroup = this.formComponent.form; @@ -178,6 +180,7 @@ export class EntitiesComponent implements OnInit { _ => { this.deleteEntitiesFromArray(this.selectedEntities); this.showLoading = false; + this._clearCacheService.clearCache("entities deleted"); }, error => this.handleUpdateError('System error deleting the selected entities', error) ); @@ -224,6 +227,7 @@ export class EntitiesComponent implements OnInit { this._helpContentService.saveEntity( this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( entity => { this.entitySavedSuccessfully(entity); + this._clearCacheService.clearCache("entity saved"); }, error => this.handleUpdateError('System error creating entity', error) ); @@ -244,6 +248,7 @@ export class EntitiesComponent implements OnInit { this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( entity => { this.entityUpdatedSuccessfully(entity); + this._clearCacheService.clearCache("entity updated"); }, error => this.handleUpdateError('System error updating entity', error) ); @@ -335,6 +340,7 @@ export class EntitiesComponent implements OnInit { this.checkboxes[i].entity.isEnabled = this.toggleStatus; } this.applyCheck(false); + this._clearCacheService.clearCache("entities toggled (status: "+this.toggleStatus+")"); }, error => this.handleUpdateError('System error changing the status of the selected entity(-ies)', error) ); diff --git a/src/app/pages/helpcontent/edit-page-help-content.component.ts b/src/app/pages/helpcontent/edit-page-help-content.component.ts index f94ce80..6b0e8cb 100644 --- a/src/app/pages/helpcontent/edit-page-help-content.component.ts +++ b/src/app/pages/helpcontent/edit-page-help-content.component.ts @@ -14,6 +14,7 @@ import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.cla import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {Page} from "../../domain/page"; import {Title} from '@angular/platform-browser'; +import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; @Component({ selector: 'edit-page-help-content', @@ -46,7 +47,8 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ private route: ActivatedRoute, private router: Router, private title: Title, - private _helpContentService: HelpContentService) {} + private _helpContentService: HelpContentService, + private _clearCacheService: ClearCacheService) {} ngOnInit() { this.route.data @@ -84,11 +86,12 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ } private getPage(pageId: string) { - this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( page => { - if( (this.communityPid == 'openaire' && !page.openaire) - || (this.communityPid == 'connect' && !page.connect) - || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { + // 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; @@ -108,7 +111,7 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ this.errorMessage = ""; this.updateErrorMessage = ""; - this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL, this.communityPid).subscribe( pageHelpContent => { if(this.pageId && this.pageId != pageHelpContent.page) { this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} }); @@ -139,7 +142,7 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ this.updateErrorMessage = ""; let pageHelpContent : PageHelpContent = this.formComponent.myForm.value; - this._helpContentService.updatePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.updatePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe( _ => { if(this.pageId) { this.router.navigate( ['/pageContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); @@ -147,6 +150,7 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{ this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} } ); } this.showLoading = false; + this._clearCacheService.clearCache("page help content updated"); }, err => this.handleUpdateError('System error updating page content', err) ); diff --git a/src/app/pages/helpcontent/new-page-help-content.component.ts b/src/app/pages/helpcontent/new-page-help-content.component.ts index 4fae6b1..b0575e6 100644 --- a/src/app/pages/helpcontent/new-page-help-content.component.ts +++ b/src/app/pages/helpcontent/new-page-help-content.component.ts @@ -13,6 +13,7 @@ import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.cla import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {Page} from "../../domain/page"; import {Title} from '@angular/platform-browser'; +import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; @Component({ selector: 'new-page-help-content', @@ -42,7 +43,8 @@ export class NewPageHelpContentComponent { private route: ActivatedRoute, private router: Router, private title: Title, - private _helpContentService: HelpContentService) {} + private _helpContentService: HelpContentService, + private _clearCacheService: ClearCacheService) {} ngOnInit() { this.route.data @@ -64,11 +66,12 @@ export class NewPageHelpContentComponent { } private getPage(pageId: string) { - this._helpContentService.getPage(pageId,this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( page => { - if( (this.communityPid == 'openaire' && !page.openaire) - || (this.communityPid == 'connect' && !page.connect) - || (this.communityPid != 'openaire' && this.communityPid != 'connect' && !page.communities)) { + // 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; @@ -93,7 +96,7 @@ export class NewPageHelpContentComponent { let pageHelpContent : PageHelpContent = this.formComponent.myForm.value; - this._helpContentService.savePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.savePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe( _ => { if(this.pageId) { this.router.navigate( ['/pageContents/'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } ); @@ -101,6 +104,7 @@ export class NewPageHelpContentComponent { this.router.navigate(['/pageContents'], { queryParams: { "communityId": this.communityPid} }); } this.showLoading = false; + this._clearCacheService.clearCache("page help content saved"); }, err => this.handleUpdateError('System error saving page content', err) ); diff --git a/src/app/pages/helpcontent/page-help-content-form.component.ts b/src/app/pages/helpcontent/page-help-content-form.component.ts index f17a54b..7bef64c 100644 --- a/src/app/pages/helpcontent/page-help-content-form.component.ts +++ b/src/app/pages/helpcontent/page-help-content-form.component.ts @@ -49,12 +49,12 @@ export class PageContentFormComponent implements OnInit{ if(!this.pageId) { this.myForm.valueChanges.subscribe(value => { let pageId = value.page; - this._helpContentService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(page => { + this._helpContentService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe(page => { this.setPlacements(page); }); }); } - this._helpContentService.getPages(this.properties.adminToolsAPIURL, this.communityPid, true).subscribe( + this._helpContentService.getCommunityPagesWithPositions(this.communityPid, this.properties.adminToolsAPIURL).subscribe( pages => { this.availablePages = pages; this.showLoading = false; @@ -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, diff --git a/src/app/pages/helpcontent/page-help-contents.component.html b/src/app/pages/helpcontent/page-help-contents.component.html index e706057..e916256 100644 --- a/src/app/pages/helpcontent/page-help-contents.component.html +++ b/src/app/pages/helpcontent/page-help-contents.component.html @@ -103,7 +103,7 @@ {{check.pageHelpContent.page.name}} - {{check.pageHelpContent.community.name}} + {{check.pageHelpContent.portal.name}} diff --git a/src/app/pages/helpcontent/page-help-contents.component.ts b/src/app/pages/helpcontent/page-help-contents.component.ts index 9462c74..cd58cf6 100644 --- a/src/app/pages/helpcontent/page-help-contents.component.ts +++ b/src/app/pages/helpcontent/page-help-contents.component.ts @@ -7,7 +7,7 @@ import { ActivatedRoute, Router } from "@angular/router"; import { HelpContentService } from "../../services/help-content.service"; import { PageHelpContent, CheckPageHelpContent, PageHelpContentFilterOptions } from "../../domain/page-help-content"; import { Page } from "../../domain/page"; -import { Community } from "../../domain/community"; +import { Portal } from "../../domain/portal"; import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; import {SafeHtmlPipe} from '../../openaireLibrary/utils/pipes/safeHTML.pipe'; @@ -15,6 +15,7 @@ import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {Title} from '@angular/platform-browser'; +import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; @Component({ selector: 'page-help-contents', @@ -55,13 +56,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; @@ -93,7 +94,8 @@ export class PageHelpContentsComponent implements OnInit { constructor(private element: ElementRef, private route: ActivatedRoute, private title: Title, - private router : Router, private _helpService: HelpContentService) {} + private router : Router, private _helpService: HelpContentService, + private _clearCacheService: ClearCacheService) {} getPage(pageId: string) { if(!Session.isLoggedIn()){ @@ -103,11 +105,12 @@ export class PageHelpContentsComponent implements OnInit { this.updateErrorMessage = ""; this.errorMessage = ""; - this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe( + this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( page => { - if( (this.selectedCommunityPid == 'openaire' && !page.openaire) - || (this.selectedCommunityPid == 'connect' && !page.connect) - || (this.selectedCommunityPid != 'openaire' && this.selectedCommunityPid != 'connect' && !page.communities)) { + // 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; @@ -127,7 +130,7 @@ export class PageHelpContentsComponent implements OnInit { this.errorMessage = ""; //this._helpService.getCommunityPages(community_pid, "", this.properties.adminToolsAPIURL).subscribe( - this._helpService.getPages(this.properties.adminToolsAPIURL, community_pid, true).subscribe( + this._helpService.getCommunityPagesWithPositions(community_pid, this.properties.adminToolsAPIURL).subscribe( pages => { this.pages = pages; this.getPageHelpContents(this.selectedCommunityPid); @@ -231,10 +234,11 @@ export class PageHelpContentsComponent implements OnInit { this.showLoading = true; this.updateErrorMessage = ""; - this._helpService.deletePageHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL).subscribe( + this._helpService.deletePageHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( _ => { this.deletePageHelpContentsFromArray(this.selectedPageContents); this.showLoading = false; + this._clearCacheService.clearCache("page help contents deleted"); }, error => this.handleUpdateError('System error deleting the selected page content(s)', error) ); @@ -266,7 +270,7 @@ export class PageHelpContentsComponent implements OnInit { } else { this.updateErrorMessage = ""; - this._helpService.togglePageHelpContents(ids,status, this.properties.adminToolsAPIURL).subscribe( + this._helpService.togglePageHelpContents(ids,status, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( () => { for(let id of ids) { let i = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id); @@ -274,6 +278,7 @@ export class PageHelpContentsComponent implements OnInit { } this.countPageHelpContents(); this.applyCheck(false); + this._clearCacheService.clearCache("page help contents toggled (status: "+status+")"); }, error => this.handleUpdateError('System error changing the status of the selected page content(s)', error) ); diff --git a/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts b/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts index 0acecba..b4ecd21 100644 --- a/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts +++ b/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts @@ -86,7 +86,7 @@ export class EditHtmlPageContentComponent implements OnInit { if(!Session.isLoggedIn()){ this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} }); } else { - this._helpContentService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe( page => { this.pageName = page.name; this.getHtmlPageContent(communityId, page.route); diff --git a/src/app/pages/page/page-form.component.html b/src/app/pages/page/page-form.component.html index c06fea2..d638274 100644 --- a/src/app/pages/page/page-form.component.html +++ b/src/app/pages/page/page-form.component.html @@ -70,23 +70,37 @@ - + - Select if this page exists in: + Page exists in: - + OpenAIRE portal - + + - + OpenAIRE Connect portal - + + - + Communities' Gateway - + + + + + + + + + + + + + diff --git a/src/app/pages/page/page-form.component.ts b/src/app/pages/page/page-form.component.ts index febd97e..1109a2d 100644 --- a/src/app/pages/page/page-form.component.ts +++ b/src/app/pages/page/page-form.component.ts @@ -104,9 +104,7 @@ export class PageFormComponent implements OnInit{ route : ['', Validators.required], name : ['', Validators.required], isEnabled: '', - openaire: true, - connect: false, - communities: true, + portalType: ['', Validators.required], top: true, bottom: true, left: true, @@ -124,9 +122,7 @@ export class PageFormComponent implements OnInit{ name : '', type: '', isEnabled: '', - openaire: true, - connect: false, - communities: true, + portalType: '', top: true, bottom: true, left: true, diff --git a/src/app/pages/page/pages.component.html b/src/app/pages/page/pages.component.html index 3454888..8479624 100644 --- a/src/app/pages/page/pages.component.html +++ b/src/app/pages/page/pages.component.html @@ -26,7 +26,7 @@ - + @@ -62,6 +62,7 @@ Type Related Entities Route + Portal Type Actions Page help texts 0)" class="uk-text-center">Class help texts @@ -91,6 +92,9 @@ {{check.page.route}} + + {{check.page.portalType}} + diff --git a/src/app/pages/page/pages.component.ts b/src/app/pages/page/pages.component.ts index 19739dc..3f0b985 100644 --- a/src/app/pages/page/pages.component.ts +++ b/src/app/pages/page/pages.component.ts @@ -7,7 +7,7 @@ import {HelpContentService} from '../../services/help-content.service'; import {FormGroup} from '@angular/forms'; import {PageFormComponent} from './page-form.component'; import {CheckPage, Page} from '../../domain/page'; -import {Community} from '../../domain/community'; +import {Portal} from '../../domain/portal'; import {Entity} from '../../domain/entity'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {Session} from '../../openaireLibrary/login/utils/helper.class'; @@ -16,6 +16,7 @@ import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class import {UserManagementService} from '../../openaireLibrary/services/user-management.service'; import {Title} from '@angular/platform-browser'; import {StringUtils} from '../../openaireLibrary/utils/string-utils.class'; +import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; @Component({ selector: 'pages', @@ -44,7 +45,7 @@ export class PagesComponent implements OnInit { private searchText: RegExp = new RegExp(''); public keyword: string = ''; - public communities: Community[] = []; + public communities: Portal[] = []; public selectedCommunityPid: string; @@ -60,7 +61,8 @@ export class PagesComponent implements OnInit { constructor(private element: ElementRef, private route: ActivatedRoute, private title: Title, private _router: Router, private _helpContentService: HelpContentService, - private userManagementService: UserManagementService) { + private userManagementService: UserManagementService, + private _clearCacheService: ClearCacheService) { } ngOnInit() { @@ -104,7 +106,7 @@ export class PagesComponent implements OnInit { parameters = '?page_type=' + this.pagesType; } if (community_pid) { - this._helpContentService.getCommunityPages(community_pid, parameters, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getCommunityPagesByType(community_pid, this.pagesType, this.properties.adminToolsAPIURL).subscribe( pages => { this.pagesReturned(pages); //if(!this.pagesType || this.pagesType == "link") { @@ -116,7 +118,7 @@ export class PagesComponent implements OnInit { error => this.handleError('System error retrieving pages', error) ); } else { - this._helpContentService.getPagesFull(this.properties.adminToolsAPIURL, null).subscribe( + this._helpContentService.getAllPagesFull(this.properties.adminToolsAPIURL).subscribe( pages => { this.pagesReturned(pages); this.showLoading = false; @@ -131,7 +133,7 @@ export class PagesComponent implements OnInit { if (!Session.isLoggedIn()) { this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}}); } else { - this._helpContentService.getPagesWithDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe( + this._helpContentService.getPageIdsFromDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe( pages => { this.pageWithDivIds = pages; this.showLoading = false; @@ -221,6 +223,7 @@ export class PagesComponent implements OnInit { _ => { this.deletePagesFromArray(this.selectedPages); this.showLoading = false; + this._clearCacheService.clearCache("pages deleted"); }, error => this.handleUpdateError('System error deleting the selected pages', error) ); @@ -231,6 +234,7 @@ export class PagesComponent implements OnInit { let page: Page = this.checkboxes[i].page; this.formGroup.patchValue(page); this.formComponent.setEntities(page.entities as Entity[]); + this.formGroup.controls['portalType'].disable(); //console.info(this.formGroup.value); //this.updateModal.showModal(); @@ -239,6 +243,7 @@ export class PagesComponent implements OnInit { } public newPage() { + this.formGroup.controls['portalType'].enable(); this.formComponent.reset(); this.modalErrorMessage = ''; this.pagesModalOpen(this.alertModalSavePage, 'Save', 'Add a new Page'); @@ -268,6 +273,7 @@ export class PagesComponent implements OnInit { this._helpContentService.savePage(this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( page => { this.pageSavedSuccessfully(page); + this._clearCacheService.clearCache("page saved"); }, error => this.handleUpdateError('System error creating page', error) ); @@ -283,9 +289,11 @@ export class PagesComponent implements OnInit { this.pagesModalOpen(this.alertModalUpdatePage, 'Update', 'Update Page'); this.modalErrorMessage = 'Please fill in all required fields marked with *'; } else { + this.formGroup.controls['portalType'].enable(); this._helpContentService.updatePage(this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( page => { this.pageUpdatedSuccessfully(page); + this._clearCacheService.clearCache("page updated"); }, error => this.handleUpdateError('System error updating page', error) ); @@ -316,7 +324,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.type + ' ' + page.portalType).match(this.searchText) != null; return textFlag; } @@ -364,6 +372,7 @@ export class PagesComponent implements OnInit { this.checkboxes[i].page.isEnabled = status; } this.applyCheck(false); + this._clearCacheService.clearCache("pages toggled (status: "+status+")"); }, error => this.handleUpdateError('System error changing the status of the selected page(s)', error) ); diff --git a/src/app/pages/stats/stats.component.ts b/src/app/pages/stats/stats.component.ts index 8b4e30d..7a44592 100644 --- a/src/app/pages/stats/stats.component.ts +++ b/src/app/pages/stats/stats.component.ts @@ -2,7 +2,7 @@ import {Component, OnInit, ElementRef} from '@angular/core'; import {HelpContentService} from '../../services/help-content.service'; import {ActivatedRoute, Router} from '@angular/router'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; -import { Community } from '../../domain/community'; +import { Portal } from '../../domain/portal'; import {DomSanitizer, Title} from '@angular/platform-browser'; import {TitleCasePipe} from '@angular/common'; import {availableEntitiesMap, StatisticsDisplay, StatisticsSummary} from '../../openaireLibrary/connect/statistics/statisticsEntities'; @@ -25,7 +25,7 @@ export class StatsComponent implements OnInit { public errorMessage: string = ''; public updateErrorMessage: string = ''; - communities: Community[] = []; + communities: Portal[] = []; communityId: string; communityInfo = null; deactivatedEntity: boolean; diff --git a/src/app/pages/usernotifications/manage-user-notifications.service.ts b/src/app/pages/usernotifications/manage-user-notifications.service.ts index 52ee09b..c604c6d 100644 --- a/src/app/pages/usernotifications/manage-user-notifications.service.ts +++ b/src/app/pages/usernotifications/manage-user-notifications.service.ts @@ -13,7 +13,7 @@ export class ManageUserNotificationsService { } getUserNotifications(properties: EnvProperties, pid: string, email: string) { - let url: string = properties.adminToolsAPIURL + 'community/'+ pid + '/notifications'; + let url: string = properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+ pid + '/notifications'; return this.http.get(url)//.map(res => res.json()) .pipe(map(res => this.parseUserNotifications(res, email))); } @@ -22,7 +22,7 @@ export class ManageUserNotificationsService { //let headers = new Headers({'Content-Type': 'application/json'}); //let options = new RequestOptions({headers: headers}); let body = JSON.stringify(userNotificationsRights); - let url: string = properties.adminToolsAPIURL + 'community/' + pid + '/notifications'; + let url: string = properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/notifications'; return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody()); //.do(request => console.log("Insert Response:"+request.status)); } diff --git a/src/app/services/help-content.service.ts b/src/app/services/help-content.service.ts index 37a64c8..d5cc46c 100644 --- a/src/app/services/help-content.service.ts +++ b/src/app/services/help-content.service.ts @@ -3,10 +3,10 @@ */ import { Injectable } from '@angular/core'; import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http"; -import { Observable } from 'rxjs'; +import {Observable, Subscription} from 'rxjs'; import { Page } from "../domain/page"; import { PageHelpContent } from "../domain/page-help-content"; -import { Community } from "../domain/community"; +import { Portal } from "../domain/portal"; import { Entity } from "../domain/entity"; import { DivId } from "../domain/divId"; import { DivHelpContent } from "../domain/div-help-content"; @@ -14,366 +14,430 @@ import {StatisticsDisplay, StatisticsSummary} from '../openaireLibrary/connect/s import { CustomOptions } from '../openaireLibrary/services/servicesUtils/customOptions.class'; import {catchError, map} from "rxjs/operators"; import {COOKIE} from "../openaireLibrary/login/utils/helper.class"; +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]); - } - } - - 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; - } + 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]); } + } - return this.http.get>(helpContentUrl + 'divFull'+parameters) - //.map(res => > res.json()) + getEntities(helpContentUrl:string) { + return this.http.get>(helpContentUrl + 'entity') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } + + saveEntity(entity: Entity, helpContentUrl:string) { + HelpContentService.removeNulls(entity); + + return this.http.post(helpContentUrl + 'entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); + } + + updateEntity(entity: Entity, helpContentUrl:string) { + HelpContentService.removeNulls(entity); + + return this.http.post(helpContentUrl + 'entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody()) + //.map(res => 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)); + } + + // toggleEntity(selectedCommunityId: string, id : string,status : boolean) { + // let headers = new Headers({'Content-Type': 'application/json'}); + // let options = new RequestOptions({headers: headers}); + // + // return this.http.post(helpContentUrl + 'community/'+selectedCommunityId+'/entity/toggle?status='+ status.toString()+'&entityId='+id.toString(), options) + // .catch(this.handleError); + // } + + getCommunityEntities(pid: string, helpContentUrl:string) { + return this.http.get>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/entities') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } + + toggleEntities(pid: string, ids : string[],status : boolean, helpContentUrl:string) { + + return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/'+pid+ '/entity/toggle?status='+ status.toString(), + JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) + //.map( res => res.json()) + .pipe(catchError(this.handleError)); + } + + // unused + toggleEntityOfPage(pageId: string, entityId : string,status : boolean, helpContentUrl:string) { + return this.http.post(helpContentUrl + 'page/'+pageId+'/entity/toggle?status='+ status.toString()+'&entityId='+entityId.toString(), + CustomOptions.getAuthOptionsWithBody()) + .pipe(catchError(this.handleError)); + } + + // getDivIdsFull(page_id: string, helpContentUrl:string, pid: string = null) { + // let parameters: string = ""; + // if(page_id || pid) { + // parameters = "?"; + // if(page_id) { + // parameters += "&page="+page_id; + // } + // if(pid) { + // parameters += "&portal="+pid; + // } + // } + // + // return this.http.get>(helpContentUrl + 'div/full'+parameters) + // //.map(res => > res.json()) + // .pipe(catchError(this.handleError)); + // } + + // Replacing getDivIdsFull + getAllDivIdsFull(helpContentUrl:string) { + return this.http.get>(helpContentUrl + 'div/full') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } + + getDivIdsFullByPortal(page_id: string, helpContentUrl:string, pid: string) { + let parameters: string = page_id ? "?&page="+page_id : ""; + + return this.http.get>(helpContentUrl + properties.adminToolsPortalType + '/'+pid + '/div/full'+parameters) + .pipe(catchError(this.handleError)); + } + // End of replacing getDivIdsFull + + // unused + getDivId(divId: string, helpContentUrl:string) { + return this.http.get(helpContentUrl + 'div/'+divId) + //.map(res => res.json()) .pipe(catchError(this.handleError)); - } + } - updateDivId(divId: DivId, helpContentUrl:string) { - HelpContentService.removeNulls(divId); + getDivIdFull(divId: string, helpContentUrl:string, pid: string) { + return this.http.get(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/div/'+divId+"/full") + //.map(res => res.json()) + .pipe(catchError(this.handleError)); + } - return this.http.post(helpContentUrl + 'div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody()) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } + updateDivId(divId: DivId, helpContentUrl:string) { + HelpContentService.removeNulls(divId); - getDivId(divId: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'div/'+divId) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } + return this.http.post(helpContentUrl + 'div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); + } - getDivIdFull(divId: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'divFull/'+divId) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } + saveDivId(divId: DivId, helpContentUrl:string) { + HelpContentService.removeNulls(divId); - saveDivId(divId: DivId, helpContentUrl:string) { - HelpContentService.removeNulls(divId); + return this.http.post(helpContentUrl + 'div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody()) + //.map(res => 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)); + } + + getPageIdsFromDivIds(pid: string, helpContentUrl:string) { + //let parameters = (pid ? "?portal="+pid : ""); + return this.http.get>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/div/pages') + //.map(res => >> res.json()) + .pipe(catchError(this.handleError)); + } - return this.http.post(helpContentUrl + 'div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody()) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } /* - getCommunitiesWithDivId(helpContentUrl:string) { - return this.http.get(helpContentUrl + 'community?div=true') - .map(res => > res.json()) - .catch(this.handleError); - } + getCommunitiesWithDivId(helpContentUrl:string) { + return this.http.get(helpContentUrl + 'community?div=true') + .map(res => > res.json()) + .catch(this.handleError); + } */ - getCommunityPagesWithDivId(community_pid: string, helpContentUrl:string) { - return this.http.get>(helpContentUrl + 'community/'+community_pid+'/pages?div=true') - //.map(res => > res.json()) - .pipe(catchError(this.handleError)); - } - getCommunityDivHelpContents(community_pid: string, helpContentUrl:string) { - return this.http.get>(helpContentUrl + 'divhelpcontent?community='+community_pid) - //.map(res => > res.json()) - .pipe(catchError(this.handleError)); - } + getCommunityDivHelpContents(pid: string, helpContentUrl:string) { + return this.http.get>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } - getDivHelpContent(id : string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'divhelpcontent/' + id) + getDivHelpContent(id : string, helpContentUrl:string, pid: string) { + return this.http.get(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent/' + id) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); + } + + // unused + insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string, pid: string) { + HelpContentService.removeNulls(divHelpContent); + + return this.http.post(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent', + JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody()) //.map(res => res.json()) .pipe(catchError(this.handleError)); - } + } - insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string) { - HelpContentService.removeNulls(divHelpContent); + saveDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string, pid: string) { + HelpContentService.removeNulls(divHelpContent); - return this.http.post(helpContentUrl + 'divhelpcontent', JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody()) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } + return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/divhelpcontent/save', + JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody()) + .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)); - } + updateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string, pid: string) { + HelpContentService.removeNulls(divHelpContent); - deleteDivHelpContents(ids : string[], helpContentUrl:string) { - return this.http.post(helpContentUrl + 'divhelpcontent/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) - .pipe(catchError(this.handleError)); - } + return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid +'/divhelpcontent/update', + JSON.stringify(divHelpContent), 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 => res.json()) - .pipe(catchError(this.handleError)); - } - - getPagesWithDivIds(community_pid: string, helpContentUrl:string) { - let parameters = (community_pid ? "?communityId="+community_pid : ""); - return this.http.get>(helpContentUrl + 'div/pages'+parameters) - //.map(res => >> 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>(helpContentUrl + 'page'+parameters) - //.map(res => > res.json()) - .pipe(catchError(this.handleError)); - } - - getPagesFull(helpContentUrl:string,pid:string) { - return this.http.get>(helpContentUrl + 'pageFull'+(pid?("?pid="+pid):"")) - //.map(res => > res.json()) + deleteDivHelpContents(ids : string[], helpContentUrl:string, pid: string) { + return this.http.post(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent/delete', + JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) .pipe(catchError(this.handleError)); - } + } - getPage(pageId:string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'page/'+pageId) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } + toggleDivHelpContents(ids : string[],status : boolean, helpContentUrl:string, pid: string) { - getPageByRoute(route:string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'page/?page_route='+route) + return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/divhelpcontent/toggle?status='+ status.toString(), + JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) + //.map( res => res.json()) + .pipe(catchError(this.handleError)); + } + + // unused + getPageHelpContents(helpContentUrl:string) { + return this.http.get>(helpContentUrl + 'pagehelpcontent') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } + + getCommunityPageHelpContents(pid: string, helpContentUrl:string) { + return this.http.get>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } + + getPageHelpContent(id : string, helpContentUrl:string, pid: string) { + return this.http.get(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/' + id) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); + } + + savePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string, pid: string) { + HelpContentService.removeNulls(pageHelpContent); + + return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/save', + JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); + } + + updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string, pid: string) { + HelpContentService.removeNulls(pageHelpContent); + + return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid +'/pagehelpcontent/update', + JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); + } + + deletePageHelpContents(ids : string[], helpContentUrl:string, pid: string) { + return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/delete', + JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) + .pipe(catchError(this.handleError)); + } + + togglePageHelpContents(ids : string[],status : boolean, helpContentUrl:string, pid: string) { + return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/toggle?status='+ status.toString(), + JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) + //.map( res => res.json()) + .pipe(catchError(this.handleError)); + } + + getCommunityPagesWithDivId(pid: string, helpContentUrl:string) { + return this.http.get>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?div=true') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } + + // getCommunityPages(pid: string, params: string, helpContentUrl:string) { + // return this.http.get>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages'+params, CustomOptions.getAuthOptions()) + // //.map(res => > res.json()) + // .pipe(catchError(this.handleError)); + // } + + // Replacing getCommunityPages + getCommunityPagesByType(pid: string, type: string, helpContentUrl:string) { + return this.http.get>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages' + + (type ? '?page_type='+type : '')) + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } + // End of replacing getCommunityPages + + // Replacing part of getPages (now getAllPages) + getCommunityPagesWithPositions(pid: string, helpContentUrl:string) { + return this.http.get>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?with_positions=true') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } + // End of replacing part of getPages (now getAllPages) + + getAllPages(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>(helpContentUrl + 'page') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } + + getAllPagesFull(helpContentUrl:string) { + return this.http.get>(helpContentUrl + 'page/full')//+(pid?("?pid="+pid):"")) + //.map(res => > res.json()) .pipe(catchError(this.handleError)); - } + } - getCommunities( helpContentUrl:string) { - return this.http.get>(helpContentUrl + 'community') - //.map(res => > res.json()) - .pipe(catchError(this.handleError)); - } + getPageByPortal(pageId:string, helpContentUrl:string, pid: string) { + return this.http.get(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/page/'+pageId) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); + } - getCommunity(community_pid: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'community/'+community_pid) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } + getCommunityPageByRoute(route:string, helpContentUrl:string, pid: string) { + return this.http.get(helpContentUrl + properties.adminToolsPortalType +'/' + pid + '/page/?page_route='+route) + .pipe(catchError(this.handleError)); + } - getCommunitiesFull( helpContentUrl:string) { - return this.http.get>(helpContentUrl + 'communityFull') - //.map(res => > res.json()) - .pipe(catchError(this.handleError)); - } + savePage(page: Page, helpContentUrl:string) { + HelpContentService.removeNulls(page); - getCommunityFull(community_pid: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'communityFull/'+community_pid) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } + return this.http.post(helpContentUrl + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) + //.map(res => 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}); + updatePage(page: Page, helpContentUrl:string) { - HelpContentService.removeNulls(community); + HelpContentService.removeNulls(page); - return this.http.post(helpContentUrl + 'community/save', JSON.stringify(community), CustomOptions.getAuthOptionsWithBody()) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } + return this.http.post(helpContentUrl + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) + //.map(res => 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}); + togglePages(selectedPortalPid: string, ids : string[],status : boolean, helpContentUrl:string) { - HelpContentService.removeNulls(community); + return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/'+selectedPortalPid+'/page/toggle?status='+ status.toString(), + JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) + .pipe(catchError(this.handleError)); + } - return this.http.post(helpContentUrl + 'community/update', JSON.stringify(community), CustomOptions.getAuthOptionsWithBody()) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } + deletePages(ids : string[], helpContentUrl:string) { - deleteCommunities(ids : string[], helpContentUrl:string) { - // let headers = new Headers({'Content-Type': 'application/json'}); - // let options = new RequestOptions({headers: headers}); + return this.http.post(helpContentUrl + 'page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) + .pipe(catchError(this.handleError)); + } - return this.http.post(helpContentUrl + 'community/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) - .pipe(catchError(this.handleError)); - } + // unused + getCommunities( helpContentUrl:string) { + return this.http.get>(helpContentUrl + properties.adminToolsPortalType) + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } - getCommunityPages(community_pid: string, params: string, helpContentUrl:string) { - return this.http.get>(helpContentUrl + 'community/'+community_pid+'/pages'+params) - //.map(res => > res.json()) - .pipe(catchError(this.handleError)); - } + getCommunity(pid: string, helpContentUrl:string) { + return this.http.get(helpContentUrl + properties.adminToolsPortalType + '/'+pid) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); + } - getEntities(helpContentUrl:string) { - return this.http.get>(helpContentUrl + 'entity') - //.map(res => > res.json()) - .pipe(catchError(this.handleError)); - } + getCommunitiesFull( helpContentUrl:string) { + return this.http.get>(helpContentUrl + properties.adminToolsPortalType + '/full') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); + } - getCommunityEntities(community_pid: string, helpContentUrl:string) { - return this.http.get>(helpContentUrl + 'community/'+community_pid+'/entities') - //.map(res => > res.json()) - .pipe(catchError(this.handleError)); - } + getCommunityFull(portal_pid: string, helpContentUrl:string) { + return this.http.get(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/full') + //.map(res => 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}); - saveEntity(entity: Entity, helpContentUrl:string) { - HelpContentService.removeNulls(entity); + HelpContentService.removeNulls(portal); - return this.http.post(helpContentUrl + 'entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody()) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } + return this.http.post(helpContentUrl + portal.type + '/save', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); + } - updateEntity(entity: Entity, helpContentUrl:string) { - HelpContentService.removeNulls(entity); + updateCommunity(portal: Portal, helpContentUrl:string) { + // let headers = new Headers({'Content-Type': 'application/json'}); + // let options = new RequestOptions({headers: headers}); - return this.http.post(helpContentUrl + 'entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody()) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } + HelpContentService.removeNulls(portal); - // 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); - // } + return this.http.post(helpContentUrl + portal.type + '/update', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); + } - toggleEntities(selectedCommunityPid: string, ids : string[],status : boolean, helpContentUrl:string) { + 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/'+selectedCommunityPid+ '/entity/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) - //.map( res => res.json()) - .pipe(catchError(this.handleError)); - } + return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) + .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(helpContentUrl + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } - - updatePage(page: Page, helpContentUrl:string) { - - HelpContentService.removeNulls(page); - - return this.http.post(helpContentUrl + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) - //.map(res => 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>(helpContentUrl + 'pagehelpcontent') - //.map(res => > res.json()) - .pipe(catchError(this.handleError)); - } - - getCommunityPageHelpContents(community_pid: string, helpContentUrl:string) { - return this.http.get>(helpContentUrl + 'pagehelpcontent?community='+community_pid) - //.map(res => > res.json()) - .pipe(catchError(this.handleError)); - } - - getPageHelpContent(id : string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'pagehelpcontent/' + id) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } - - savePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) { - HelpContentService.removeNulls(pageHelpContent); - - return this.http.post(helpContentUrl + 'pagehelpcontent/save', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody()) - //.map(res => res.json()) - .pipe(catchError(this.handleError)); - } - - updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) { - HelpContentService.removeNulls(pageHelpContent); - - return this.http.post(helpContentUrl + 'pagehelpcontent/update', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody()) - //.map(res => 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 => 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'); - } + 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 => res.json()).map(res => res.results).do(res => {console.log(res)}).catch(this.handleError); // } - getCommunityStatistics(apiUrl: string, communityId: string): Observable { - const url = `${apiUrl}communities/${communityId}`; + getCommunityStatistics(apiUrl: string, portalId: string): Observable { + const url = `${apiUrl}communities/${portalId}`; //console.log(`getting statistics summary from: ${url}`); return this.http.get(url) //.map(res => res.json()) .pipe(map(res => res['statistics'])); } - getCommunityAdminStatisticsChoices(apiUrl: string, communityId: string): Observable { - const url = `${apiUrl}statistics/${communityId}`; + getCommunityAdminStatisticsChoices(apiUrl: string, portalId: string): Observable { + const url = `${apiUrl}statistics/${portalId}`; //console.log(`getting admin choices for statistics from: ${url}`); return this.http.get(url) //.map(stats => stats.json()) @@ -381,13 +445,13 @@ export class HelpContentService { } postCommunityAdminStatisticsChoices(apiUrl: string, - communityId: string, + portalId: string, entity: string, chartsOrNumbers: string, title: string, status: boolean, monitor: boolean): Observable { - const url = `${apiUrl}statistics/${communityId}/${entity}/${chartsOrNumbers}?status=${status.toString()}&monitor=${monitor.toString()}`; + 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()) diff --git a/src/assets/env-properties.json b/src/assets/env-properties.json index dd4d7c7..6b2f905 100644 --- a/src/assets/env-properties.json +++ b/src/assets/env-properties.json @@ -1,5 +1,6 @@ { "environment":"development", + "adminToolsPortalType": "community", "enablePiwikTrack" : false, "useCache" : false, "metricsAPIURL" : "https://beta.services.openaire.eu/usagestats/", diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 8b32ef1..c640927 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -2,6 +2,7 @@ import {EnvProperties} from '../app/openaireLibrary/utils/properties/env-propert export let properties: EnvProperties = { environment:"production", + adminToolsPortalType: "community", enablePiwikTrack: false, useCache: false, metricsAPIURL: "https://services.openaire.eu/usagestats/", @@ -49,6 +50,7 @@ export let properties: EnvProperties = { feedbackmailForMissingEntities: "feedback@openaire.eu", cacheUrl:"https://explore.openaire.eu/cache/get?url=", + deleteCacheUrl: 'https://explore.openaire.eu/cache/clear', adminToolsAPIURL:"https://services.openaire.eu/uoa-admin-tools/", diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 010c77c..43f25b9 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -7,6 +7,7 @@ import {EnvProperties} from '../app/openaireLibrary/utils/properties/env-propert export let properties: EnvProperties = { environment: 'development', + adminToolsPortalType: "community", enablePiwikTrack: false, useCache: false, metricsAPIURL: 'https://beta.services.openaire.eu/usagestats/', @@ -43,16 +44,16 @@ export let properties: EnvProperties = { vocabulariesAPI: 'https://beta.services.openaire.eu/provision/mvc/vocabularies/', piwikBaseUrl: ' https://analytics.openaire.eu/piwik.php?idsite=6', - loginUrl: 'http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login', - userInfoUrl: 'http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=', registryUrl: 'http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/registry/', - logoutUrl: 'https://openaire-dev.aai-dev.grnet.gr/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=', - + loginUrl: "http://dl170.madgik.di.uoa.gr:8180/dnet-login/openid_connect_login", + userInfoUrl: "http://dl170.madgik.di.uoa.gr:8180/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=", + logoutUrl: "https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=", cookieDomain: '.di.uoa.gr', feedbackmail: 'openaire.test@gmail.com', feedbackmailForMissingEntities: 'feedback@openaire.eu', cacheUrl: 'http://scoobydoo.di.uoa.gr:3000/get?url=', + deleteCacheUrl: 'http://duffy.di.uoa.gr:3000/clear', adminToolsAPIURL: 'http://duffy.di.uoa.gr:8080/uoa-admin-tools/',
{{page.name}},