From d1fba2997f9aac977f6e6566582e47d26dd23f02 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Thu, 24 Sep 2020 11:48:17 +0000 Subject: [PATCH] [Trunk | Admin]: Merging branch 'use-UoaAdminToolsLibrary' into trunk for revisions 58405:59467 git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@59468 d315682c-612b-4755-9ff5-7f18f6832af3 --- package.json | 3 +- src/app/app.component.html | 2 +- src/app/app.component.ts | 2 + src/app/domain/div-help-content.ts | 4 +- src/app/domain/divId.ts | 4 +- src/app/domain/html-page-content.ts | 4 +- src/app/domain/page-help-content.ts | 4 +- src/app/domain/page.ts | 4 +- src/app/domain/{community.ts => portal.ts} | 7 +- .../affiliations/affiliations.component.html | 6 +- .../affiliations/affiliations.component.ts | 13 +- .../community/communities.component.html | 6 +- .../pages/community/communities.component.ts | 42 +- .../community/community-form.component.html | 27 +- .../community/community-form.component.ts | 35 +- .../pages/dashboard/dashboard.component.ts | 3 + src/app/pages/divId/divId-form.component.html | 100 ++- src/app/pages/divId/divId-form.component.ts | 113 ++- src/app/pages/divId/divIds.component.html | 6 +- src/app/pages/divId/divIds.component.ts | 14 +- .../div-help-content-form.component.html | 2 +- .../div-help-content-form.component.ts | 6 +- .../div-help-contents.component.ts | 25 +- .../edit-div-help-content.component.ts | 20 +- .../new-div-help-content.component.ts | 16 +- src/app/pages/entity/entities.component.ts | 12 +- .../edit-page-help-content.component.ts | 18 +- .../new-page-help-content.component.ts | 16 +- .../page-help-content-form.component.ts | 8 +- .../page-help-contents.component.html | 2 +- .../page-help-contents.component.ts | 27 +- .../edit-htmlpage-content.component.ts | 2 +- src/app/pages/page/page-form.component.html | 30 +- src/app/pages/page/page-form.component.ts | 8 +- src/app/pages/page/pages.component.html | 6 +- src/app/pages/page/pages.component.ts | 23 +- src/app/pages/stats/stats.component.ts | 4 +- .../manage-user-notifications.service.ts | 4 +- src/app/services/help-content.service.ts | 662 ++++++++++-------- src/assets/env-properties.json | 1 + src/environments/environment.prod.ts | 2 + src/environments/environment.ts | 9 +- 42 files changed, 750 insertions(+), 552 deletions(-) rename src/app/domain/{community.ts => portal.ts} (67%) 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 @@ + +
{{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 @@
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 @@
-
+
-
+ + + + + + + + + + + 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 @@