From cd519aa1e5cd461d9ac9278309d17e4f4bb5c50d Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Tue, 2 Mar 2021 15:52:09 +0000 Subject: [PATCH] [Library | Trunk]: Fix admin tools pages portal type configuration. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60561 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../connectCommunityGuard.guard.ts | 17 +- .../communityGuard/connectRIGuard.guard.ts | 42 +- dashboard/entity/entities.component.html | 12 +- dashboard/entity/entities.component.ts | 4 +- .../page-help-content-form.component.html | 157 ++--- .../page-help-content-form.component.ts | 563 +++++++++--------- .../page-help-contents.component.html | 11 +- .../helpTexts/page-help-contents.component.ts | 30 +- dashboard/page/pages.component.html | 13 +- dashboard/page/pages.component.ts | 4 +- 10 files changed, 425 insertions(+), 428 deletions(-) diff --git a/connect/communityGuard/connectCommunityGuard.guard.ts b/connect/communityGuard/connectCommunityGuard.guard.ts index 3d50614a..be2b9e98 100644 --- a/connect/communityGuard/connectCommunityGuard.guard.ts +++ b/connect/communityGuard/connectCommunityGuard.guard.ts @@ -4,30 +4,35 @@ import { Router, CanActivate, ActivatedRouteSnapshot, - RouterStateSnapshot, - + RouterStateSnapshot, UrlTree, CanActivateChild, + } from '@angular/router'; import {Observable, Subscription} from 'rxjs'; import {CommunityService} from '../community/community.service'; import {properties} from "../../../../environments/environment"; @Injectable() -export class ConnectCommunityGuard implements CanActivate { +export class ConnectCommunityGuard implements CanActivate, CanActivateChild { sub: Subscription = null; constructor(private router: Router, private communityService: CommunityService) { } - check(community: string): Observable | boolean { + check(community: string, url: string): Observable | boolean { return this.communityService.isCommunityType(community).pipe(take(1), tap(isCommunity => { if (!isCommunity) { - this.router.navigate(['errorcommunity']); + this.router.navigate(['/error'], {queryParams: {'page': url}}); } })); } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { - return this.check(route.queryParams['communityId']); + return this.check(route.queryParams['communityId'], state.url); + } + + canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { + let community = childRoute.params['community']; + return community && this.check(community, state.url); } } diff --git a/connect/communityGuard/connectRIGuard.guard.ts b/connect/communityGuard/connectRIGuard.guard.ts index 7918cbde..ba28867f 100644 --- a/connect/communityGuard/connectRIGuard.guard.ts +++ b/connect/communityGuard/connectRIGuard.guard.ts @@ -1,55 +1,39 @@ import {tap} from 'rxjs/operators'; -import { Injectable } from '@angular/core'; +import {Injectable} from '@angular/core'; import { - Router, - CanActivate, ActivatedRouteSnapshot, + CanActivate, + CanActivateChild, + Router, RouterStateSnapshot, - CanLoad, - Route, UrlSegment, CanActivateChild, UrlTree + UrlTree } from '@angular/router'; import {Observable, Subscription} from 'rxjs'; import {CommunityService} from '../community/community.service'; -import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service'; -import {ConnectHelper} from '../connectHelper'; -import {properties} from "../../../../environments/environment"; @Injectable() -export class ConnectRIGuard implements CanActivate, CanLoad, CanActivateChild { +export class ConnectRIGuard implements CanActivate, CanActivateChild { sub: Subscription = null; - + constructor(private router: Router, - private communityService: CommunityService, - private propertiesService: EnvironmentSpecificService) { + private communityService: CommunityService) { } - - check(community: string): Observable | boolean { + + check(community: string, url: string): Observable | boolean { return this.communityService.isRIType(community).pipe(tap(authorized => { if (!authorized) { - this.router.navigate(['errorcommunity']); + this.router.navigate(['/error'], {queryParams: {'page': url}}); } })); } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { let community = route.params['community']; - return community && this.check(community); + return community && this.check(community, state.url); } canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { let community = childRoute.params['community']; - return community && this.check(community); - } - - canLoad(route: Route, segments: UrlSegment[]): Observable | Promise | boolean { - const path = '/' + route.path + document.location.search; - return this.check(ConnectHelper.getCommunityFromPath(path)); - } - - canDeactivate() { - if(this.sub) { - this.sub.unsubscribe(); - } - return true; + return community && this.check(community, state.url); } } diff --git a/dashboard/entity/entities.component.html b/dashboard/entity/entities.component.html index d85267a7..a5e730b5 100644 --- a/dashboard/entity/entities.component.html +++ b/dashboard/entity/entities.component.html @@ -50,7 +50,7 @@ -
{{getSelectedEntities().length}} entities selected @@ -74,7 +74,7 @@
    + title="Select at least one entity">
  • Enable
  • diff --git a/dashboard/entity/entities.component.ts b/dashboard/entity/entities.component.ts index efe36981..5047ba47 100644 --- a/dashboard/entity/entities.component.ts +++ b/dashboard/entity/entities.component.ts @@ -74,9 +74,7 @@ export class EntitiesComponent implements OnInit { })); this.userManagementService.getUserInfo().subscribe(user => { this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param]; - if(this.portal === 'connect' || this.portal === 'openaire' || this.portal === 'monitor') { - ConnectHelper.setPortalTypeFromPid(this.portal); - } + ConnectHelper.setPortalTypeFromPid(this.portal); this.applyPortalFilter(this.portal); this.isPortalAdministrator = Session.isPortalAdministrator(user) && !this.portal; }); diff --git a/dashboard/helpTexts/page-help-content-form.component.html b/dashboard/helpTexts/page-help-content-form.component.html index 0684c977..9e6caabb 100644 --- a/dashboard/helpTexts/page-help-content-form.component.html +++ b/dashboard/helpTexts/page-help-content-form.component.html @@ -1,88 +1,89 @@
    -
    -
    -
    +
    +
    +
    +
    +
    {{pageHelpContent ? 'Update ' : 'Add new '}} help text
    -
    {{pageHelpContent?'Update ':'Add new '}} help text
    -
    - {{page.name}} - (unsaved changes) -
    -
    -
    - - -
    -
    -
    -
    -
    - - - + {{page.name}} + (unsaved changes) +
    +
    + +
    +
    +
    +
    + + + +
    +
    +
    diff --git a/dashboard/helpTexts/page-help-content-form.component.ts b/dashboard/helpTexts/page-help-content-form.component.ts index cf46afc0..d609679c 100644 --- a/dashboard/helpTexts/page-help-content-form.component.ts +++ b/dashboard/helpTexts/page-help-content-form.component.ts @@ -11,293 +11,308 @@ import {properties} from '../../../../environments/environment'; import {from, Observable, Subscriber, Subscription} from 'rxjs'; import {HelperFunctions} from '../../utils/HelperFunctions.class'; import {PageHelpContent} from '../../utils/entities/adminTool/page-help-content'; +import {ConnectHelper} from "../../connect/connectHelper"; @Component({ - selector: 'page-content-form', - templateUrl: './page-help-content-form.component.html', + selector: 'page-content-form', + templateUrl: './page-help-content-form.component.html', }) - -export class PageContentFormComponent implements OnInit{ - - myForm: FormGroup; - communityPid: string; - pageId: string; - pageContentId: string; - page: Page; - placementsOptions = []; - orderOptions = []; - - private availablePages : Page[] = []; - //private errorMessage: string; - - private ckeditorContent : string; - public properties:EnvProperties = null; - - public showLoading: boolean = true; - public errorMessage: string = ''; - @Input() updateErrorMessage: string = ''; - private subs: Subscription[] = []; - private pageHelpContent: PageHelpContent; - constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, private _helpContentService: HelpContentService){} - - ngOnInit() { - - this.properties = properties; - this.subs.push(this.route.params.subscribe(params => { - this.communityPid = params['community']; - this.subs.push(this.route.queryParams.subscribe(params => { - HelperFunctions.scroll(); - this.pageId = params['pageId']; - this.myForm = this.form; - this.pageContentId = params['pageContentId']; - if (!this.pageId) { - this._router.navigate(['../'], {relativeTo: this.route}); - } - /* this.getPage(this.pageId); - if (this.pageContentId) { - this.getPageHelpContent(this.pageContentId); - }else{ - this.myForm = this.form; - - }*/ - this.getInfo(this.pageId); - - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_VALID, - "redirectUrl": this._router.url - } - }); - } - - })); - })); - } - ngOnDestroy() { - this.subs.forEach(value => { - if (value instanceof Subscriber) { - value.unsubscribe(); - } - }); - } - getInfo(pageId: string){ - this.showLoading = true; - let obs = Observable.zip(this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid), this._helpContentService.getCommunityPageHelpContents(this.communityPid, this.properties.adminToolsAPIURL, pageId)); - this.subs.push(obs.subscribe( - results => { - this.page = results[0]; - if(this.properties.adminToolsPortalType != this.page.portalType) { - this._router.navigate(['../'], {relativeTo: this.route}); - } - let countPageContents = results[1]?results[1].length:0; - console.log(results[1]); - for (let content of (results[1] as Array)) { - // if(content.page['_id'] == pageId){ - // countPageContents++; - if(this.pageContentId && this.pageContentId == content._id) { - this.pageHelpContent = content; - // this.pageHelpContent.page = pageId; - // this.pageHelpContent.portal = this.communityPid; - } - // } - } - this.setOptions(this.page, countPageContents + (this.pageHelpContent?0:1)); - if(!this.pageContentId) { - this.myForm = this.form; - this.initFormWithSelectOptions(); - }else{ - this.updateForm(this.pageHelpContent); - } - this.showLoading = false; - }, - error => this.handleError('System error retrieving page with id: '+pageId, error) - )); - - } - /*private getPage(pageId: string) { - this.subs.push(this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( - page => { - if(this.properties.adminToolsPortalType != page.portalType) { - this._router.navigate(['../'], {relativeTo: this.route}); - } else { - this.page = page; - this.getPageContents(pageId); - } - }, - error => this.handleError('System error retrieving page with id: '+pageId, error) - )); - } - private getPageContents(pageId: string) { - this.subs.push(this._helpContentService.getCommunityPageHelpContents(this.communityPid, this.properties.adminToolsAPIURL).subscribe( - pageHelpContents => { - let countPageContents = 1; - for (let content of (pageHelpContents as Array)) { - if(content.page['_id'] == pageId){ - countPageContents++; - } - } - this.setOptions(this.page, countPageContents); - if(!this.pageContentId) { - this.showLoading = false; - this.initFormWithSelectOptions(); - } - }, - error => this.handleError('System error retrieving page contents with id: ', error) - )); - } - private getPageHelpContent(pageContentId: string) { - if(!Session.isLoggedIn()){ - this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - } else { - this.showLoading = true; - this.errorMessage = ""; - this.updateErrorMessage = ""; - - this.subs.push(this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL, this.communityPid).subscribe( - pageHelpContent => { - this.updateForm(pageHelpContent); - this.showLoading = false; - }, - error => this.handleError('System error retrieving page help content', error))); - } - }*/ - private updateForm(pageHelpContent : PageHelpContent) { - this.pageHelpContent = pageHelpContent; +export class PageContentFormComponent implements OnInit { + + myForm: FormGroup; + portal: string; + pageId: string; + pageContentId: string; + page: Page; + placementsOptions = []; + orderOptions = []; + + private availablePages: Page[] = []; + //private errorMessage: string; + + private ckeditorContent: string; + public properties: EnvProperties = null; + + public showLoading: boolean = true; + public errorMessage: string = ''; + @Input() updateErrorMessage: string = ''; + private subs: Subscription[] = []; + private pageHelpContent: PageHelpContent; + + constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, private _helpContentService: HelpContentService) { + } + + ngOnInit() { + + this.properties = properties; + this.subs.push(this.route.params.subscribe(params => { + this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param]; + ConnectHelper.setPortalTypeFromPid(this.portal); + this.subs.push(this.route.queryParams.subscribe(params => { + HelperFunctions.scroll(); + this.pageId = params['pageId']; this.myForm = this.form; - if(this.pageHelpContent) { - this.myForm.patchValue((pageHelpContent)); - }else{ - this.initFormWithSelectOptions(); + this.pageContentId = params['pageContentId']; + if (!this.pageId) { + this._router.navigate(['../'], {relativeTo: this.route}); } - if(this.orderOptions.length ==1){ - this.myForm.get('order').disable() - } - if(this.placementsOptions.length ==1){ - this.myForm.get('placement').disable() - } - this.myForm.markAsPristine(); + /* this.getPage(this.pageId); + if (this.pageContentId) { + this.getPageHelpContent(this.pageContentId); + }else{ + this.myForm = this.form; - } - initFormWithSelectOptions(){ - if (this.placementsOptions.length == 1) { - this.myForm.get("placement").setValue(this.placementsOptions[0].value); - } - this.myForm.get("order").setValue(this.orderOptions[this.orderOptions.length - 1].value); - if(this.orderOptions.length ==1){ - this.myForm.get('order').disable() - } - if(this.placementsOptions.length ==1){ - this.myForm.get('placement').disable() - } - } - public setOptions(page: Page, countContents:number) { - this.placementsOptions = []; - if(page.top){ - this.placementsOptions.push({label: "top", value: "top"}); - } - if(page.bottom){ - this.placementsOptions.push({label: "bottom", value: "bottom"}); - } - if(page.left){ - this.placementsOptions.push({label: "left", value: "left"}); - } - this.orderOptions = []; - for(let i=1; i { - this._router.navigate( ['../'], { queryParams: { "pageId": this.pageId }, relativeTo: this.route } ); - this.showLoading = false; - }, - err => this.handleUpdateError('System error saving page content', err) - )); - } else { - this.showLoading = false; - this.errorMessage = "Please fill all required fields"; + }*/ + this.getInfo(this.pageId); + + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url } + }); } - } + + })); + })); + } + + ngOnDestroy() { + this.subs.forEach(value => { + if (value instanceof Subscriber) { + value.unsubscribe(); + } + }); + } + + getInfo(pageId: string) { + this.showLoading = true; + let obs = Observable.zip(this._helpContentService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.portal), this._helpContentService.getCommunityPageHelpContents(this.portal, this.properties.adminToolsAPIURL, pageId)); + this.subs.push(obs.subscribe( + results => { + this.page = results[0]; + if (this.properties.adminToolsPortalType != this.page.portalType) { + this._router.navigate(['../'], {relativeTo: this.route}); + } + let countPageContents = results[1] ? results[1].length : 0; + console.log(results[1]); + for (let content of (results[1] as Array)) { + // if(content.page['_id'] == pageId){ + // countPageContents++; + if (this.pageContentId && this.pageContentId == content._id) { + this.pageHelpContent = content; + // this.pageHelpContent.page = pageId; + // this.pageHelpContent.portal = this.communityPid; + } + // } + } + this.setOptions(this.page, countPageContents + (this.pageHelpContent ? 0 : 1)); + if (!this.pageContentId) { + this.myForm = this.form; + this.initFormWithSelectOptions(); + } else { + this.updateForm(this.pageHelpContent); + } + this.showLoading = false; + }, + error => this.handleError('System error retrieving page with id: ' + pageId, error) + )); + + } + + /*private getPage(pageId: string) { + this.subs.push(this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( + page => { + if(this.properties.adminToolsPortalType != page.portalType) { + this._router.navigate(['../'], {relativeTo: this.route}); + } else { + this.page = page; + this.getPageContents(pageId); + } + }, + error => this.handleError('System error retrieving page with id: '+pageId, error) + )); + } + private getPageContents(pageId: string) { + this.subs.push(this._helpContentService.getCommunityPageHelpContents(this.communityPid, this.properties.adminToolsAPIURL).subscribe( + pageHelpContents => { + let countPageContents = 1; + for (let content of (pageHelpContents as Array)) { + if(content.page['_id'] == pageId){ + countPageContents++; + } + } + this.setOptions(this.page, countPageContents); + if(!this.pageContentId) { + this.showLoading = false; + this.initFormWithSelectOptions(); + } + }, + error => this.handleError('System error retrieving page contents with id: ', error) + )); + } + private getPageHelpContent(pageContentId: string) { + if(!Session.isLoggedIn()){ + this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); + } else { + this.showLoading = true; + this.errorMessage = ""; + this.updateErrorMessage = ""; - public cancelCustom() { - this._router.navigate( ['../'], { queryParams: { "pageId": this.pageId }, relativeTo: this.route } ); + this.subs.push(this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL, this.communityPid).subscribe( + pageHelpContent => { + this.updateForm(pageHelpContent); + this.showLoading = false; + }, + error => this.handleError('System error retrieving page help content', error))); + } + }*/ + private updateForm(pageHelpContent: PageHelpContent) { + this.pageHelpContent = pageHelpContent; + this.myForm = this.form; + if (this.pageHelpContent) { + this.myForm.patchValue((pageHelpContent)); + } else { + this.initFormWithSelectOptions(); } - - public resetCustom() { + if (this.orderOptions.length == 1) { + this.myForm.get('order').disable() + } + if (this.placementsOptions.length == 1) { + this.myForm.get('placement').disable() + } + this.myForm.markAsPristine(); + + } + + initFormWithSelectOptions() { + if (this.placementsOptions.length == 1) { + this.myForm.get("placement").setValue(this.placementsOptions[0].value); + } + this.myForm.get("order").setValue(this.orderOptions[this.orderOptions.length - 1].value); + if (this.orderOptions.length == 1) { + this.myForm.get('order').disable() + } + if (this.placementsOptions.length == 1) { + this.myForm.get('placement').disable() + } + } + + public setOptions(page: Page, countContents: number) { + this.placementsOptions = []; + if (page.top) { + this.placementsOptions.push({label: "top", value: "top"}); + } + if (page.bottom) { + this.placementsOptions.push({label: "bottom", value: "bottom"}); + } + if (page.left) { + this.placementsOptions.push({label: "left", value: "left"}); + } + this.orderOptions = []; + for (let i = 1; i < countContents + 1; i++) { + this.orderOptions.push({label: "" + i, value: i}); + } + } + + public get form() { + return this._fb.group({ + page: [this.pageId, Validators.required], + portal: this.portal, + placement: ['', Validators.required], + content: ['', Validators.required], + order: [1, Validators.required], + isActive: true, + //isPriorTo : false, + _id: '', + }); + } + + public reset() { + this.myForm.patchValue({ + page: '', + portal: this.portal, + placement: '', + content: [''], + order: 1, + isActive: true, + //isPriorTo : false, + _id: '' + }); + this.myForm.markAsPristine(); + } + + handleError(message: string, error) { + this.errorMessage = message; + console.error('Server responded: ' + error); + + this.showLoading = false; + } + + public saveCustom() { + if (!Session.isLoggedIn()) { + this._router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_VALID, + "redirectUrl": this._router.url + } + }); + } else { + //this.errorMessage = null; + + if (this.myForm.valid) { this.showLoading = true; - this.updateForm(this.pageHelpContent); + this.updateErrorMessage = ""; + this.myForm.get('order').enable(); + this.myForm.get('placement').enable(); + let pageHelpContent: PageHelpContent = this.myForm.value; + this.subs.push(this._helpContentService.savePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.portal).subscribe( + _ => { + this._router.navigate(['../'], {queryParams: {"pageId": this.pageId}, relativeTo: this.route}); + this.showLoading = false; + }, + err => this.handleUpdateError('System error saving page content', err) + )); + } else { this.showLoading = false; + this.errorMessage = "Please fill all required fields"; + } } - - handleUpdateError(message: string, error) { - - this.updateErrorMessage = message; - console.error('Server responded: ' + error); - - this.showLoading = false; + } + + public cancelCustom() { + this._router.navigate(['../'], {queryParams: {"pageId": this.pageId}, relativeTo: this.route}); + } + + public resetCustom() { + this.showLoading = true; + this.updateForm(this.pageHelpContent); + this.showLoading = false; + } + + handleUpdateError(message: string, error) { + + this.updateErrorMessage = message; + console.error('Server responded: ' + error); + + this.showLoading = false; + } + + changeStatus() { + this.myForm.get('isActive').setValue(!this.myForm.get('isActive').value); + if (this.pageHelpContent && this.myForm.get('isActive').value != this.pageHelpContent.isActive || !this.pageHelpContent && !this.myForm.get('isActive').value) { + this.myForm.get('isActive').markAsDirty(); + } else { + this.myForm.get('isActive').markAsPristine() } - changeStatus(){ - this.myForm.get('isActive').setValue(!this.myForm.get('isActive').value); - if(this.pageHelpContent && this.myForm.get('isActive').value != this.pageHelpContent.isActive || !this.pageHelpContent && !this.myForm.get('isActive').value ){ - this.myForm.get('isActive').markAsDirty(); - }else{ - this.myForm.get('isActive').markAsPristine() - } - } - contentChanged(){ - if(this.pageHelpContent && this.myForm.get('content').value != this.pageHelpContent.content || !this.pageHelpContent && this.myForm.get('content').value != '' ){ - this.myForm.get('content').markAsDirty(); - }else{ - this.myForm.get('content').markAsPristine() - } + } + + contentChanged() { + if (this.pageHelpContent && this.myForm.get('content').value != this.pageHelpContent.content || !this.pageHelpContent && this.myForm.get('content').value != '') { + this.myForm.get('content').markAsDirty(); + } else { + this.myForm.get('content').markAsPristine() } + } } diff --git a/dashboard/helpTexts/page-help-contents.component.html b/dashboard/helpTexts/page-help-contents.component.html index 2e636f71..dfb3e606 100644 --- a/dashboard/helpTexts/page-help-contents.component.html +++ b/dashboard/helpTexts/page-help-contents.component.html @@ -8,11 +8,14 @@ {{page.name}}
    - + - - Go back to pages list + + + + Go back to pages list + +
    { - this.selectedCommunityPid = params['community']; - if(!this.selectedCommunityPid) { - this.selectedCommunityPid = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param]; - if (this.selectedCommunityPid === 'connect' || this.selectedCommunityPid === 'openaire' || this.selectedCommunityPid === 'monitor') { - ConnectHelper.setPortalTypeFromPid(this.selectedCommunityPid); - } - } + this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param]; + ConnectHelper.setPortalTypeFromPid(this.portal); this.subscriptions.push(this.route.queryParams.subscribe(params => { HelperFunctions.scroll(); this.selectedPageId = params['pageId']; - if (this.selectedCommunityPid && this.selectedPageId) { + if (this.portal && this.selectedPageId) { this.getPage(this.selectedPageId); } if(!this.selectedPageId) { @@ -124,13 +118,13 @@ export class PageHelpContentsComponent implements OnInit { this.showLoading = true; this.updateErrorMessage = ""; this.errorMessage = ""; - this.subscriptions.push(this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( + this.subscriptions.push(this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.portal).subscribe( page => { if (this.properties.adminToolsPortalType != page.portalType) { - this.router.navigate(['./pageContents'], {queryParams: {"communityId": this.selectedCommunityPid}}); + this.router.navigate(['./pageContents'], {queryParams: {"communityId": this.portal}}); } else { this.page = page; - this.getPageHelpContents(this.selectedCommunityPid); + this.getPageHelpContents(this.portal); } }, error => this.handleError('System error retrieving page', error))); @@ -154,7 +148,7 @@ export class PageHelpContentsComponent implements OnInit { this.subscriptions.push(this._helpService.getCommunityPagesWithPositions(community_pid,this.properties.adminToolsAPIURL).subscribe( pages => { this.pages = pages; - this.getPageHelpContents(this.selectedCommunityPid); + this.getPageHelpContents(this.portal); this.selectOptions = [{label:'All pages', value: ''}]; for (let page of this.pages) { this.selectOptions.push({label:page.name, value: page._id}) @@ -271,7 +265,7 @@ export class PageHelpContentsComponent implements OnInit { this.showLoading = true; this.updateErrorMessage = ""; - this.subscriptions.push(this._helpService.deletePageHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( + this.subscriptions.push(this._helpService.deletePageHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL, this.portal).subscribe( _ => { this.deletePageHelpContentsFromArray(this.selectedPageContents); this.showLoading = false; @@ -297,7 +291,7 @@ export class PageHelpContentsComponent implements OnInit { this.router.navigate(['edit/'], { queryParams: { "pageContentId": id, - "communityId": this.selectedCommunityPid, + "communityId": this.portal, "pageId": this.selectedPageId }, relativeTo: this.route }); @@ -305,7 +299,7 @@ export class PageHelpContentsComponent implements OnInit { this.router.navigate(['edit/'], { queryParams: { "pageContentId": id, - "communityId": this.selectedCommunityPid + "communityId": this.portal }, relativeTo: this.route }); } @@ -322,7 +316,7 @@ export class PageHelpContentsComponent implements OnInit { } else { this.updateErrorMessage = ""; - this.subscriptions.push(this._helpService.togglePageHelpContents(ids, status, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe( + this.subscriptions.push(this._helpService.togglePageHelpContents(ids, status, this.properties.adminToolsAPIURL, this.portal).subscribe( () => { for (let id of ids) { let i = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id); diff --git a/dashboard/page/pages.component.html b/dashboard/page/pages.component.html index e84c7642..8adcc58b 100644 --- a/dashboard/page/pages.component.html +++ b/dashboard/page/pages.component.html @@ -28,19 +28,18 @@
    - -
    {{getSelectedPages().length}} pages selected - Actions + Actions
      + title="Select at least one page">
    • Enable
    • diff --git a/dashboard/page/pages.component.ts b/dashboard/page/pages.component.ts index 96cd973a..2082c823 100644 --- a/dashboard/page/pages.component.ts +++ b/dashboard/page/pages.component.ts @@ -91,9 +91,7 @@ export class PagesComponent implements OnInit { this.filterForm.get('type').setValue(params['type']); } this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param]; - if (this.portal === 'connect' || this.portal === 'openaire' || this.portal === 'monitor') { - ConnectHelper.setPortalTypeFromPid(this.portal); - } + ConnectHelper.setPortalTypeFromPid(this.portal); this.keyword = ''; this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { this.applyPortalFilter(this.portal);