From 63c4309c585362d10be6086da854baf447a391eb Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Tue, 18 May 2021 07:29:16 +0000 Subject: [PATCH] [Connect|Trunk] -completing commit 61006 + clean up code fixing issues with private/ hidden communities show modal for verification code - remove preload modules - community home page - add check for community status before load it git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@61012 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/app-routing.module.ts | 3 +-- src/app/app.component.ts | 24 ++++++++-------------- src/app/community/community.component.html | 5 +++++ src/app/community/community.component.ts | 8 ++++---- src/app/community/community.module.ts | 3 ++- src/app/error/errorPage.component.ts | 5 ++--- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 0bc6430..4cbbad4 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,5 +1,5 @@ import {NgModule} from '@angular/core'; -import {PreloadAllModules, RouterModule, Routes} from '@angular/router'; +import { RouterModule, Routes} from '@angular/router'; import {OpenaireErrorPageComponent} from './error/errorPage.component'; import {PageURLResolverComponent} from "./openaireLibrary/utils/pageURLResolver.component"; import {IsCommunity} from "./openaireLibrary/connect/communityGuard/isCommunity.guard"; @@ -214,7 +214,6 @@ const routes: Routes = [ @NgModule({ imports: [RouterModule.forRoot(routes, { - preloadingStrategy: PreloadAllModules, onSameUrlNavigation: "reload", relativeLinkResolution: 'corrected' })], diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 508dca2..6186e4f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -120,7 +120,6 @@ export class AppComponent { } ngOnInit() { - console.log("aaap init") if (this.properties.environment == "production" || this.properties.environment == "development") { this.subscriptions.push(this.route.queryParams.subscribe(data => { this._meta.updateTag({content: 'all', name: 'robots'}); @@ -135,10 +134,8 @@ export class AppComponent { } this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { this.user = user; - console.log(user, "call init") this.init(); }, error => { - console.log(" user error call init") this.init()})); } @@ -191,9 +188,7 @@ export class AppComponent { } public buildMenu(communityId: string) { if (communityId) { - console.log(communityId) if (!this.community || this.communityId !== communityId) { - console.log("new") this.subscriptions.push(this._communityService.getCommunity(communityId).subscribe(community => { if (community) { /* this.community = { @@ -211,7 +206,6 @@ export class AppComponent { this.buildCommunityMenu(); })); } else { - console.log("same") this.buildCommunityMenu(); } } else { @@ -290,7 +284,6 @@ export class AppComponent { } this.showMenu = true; } else { - console.log(this.community && this.community.status?this.community.status:"no community"); this.communityId = null; this.properties.adminToolsPortalType = "connect"; this.configurationService.initCommunityInformation(this.properties, "connect"); @@ -298,14 +291,15 @@ export class AppComponent { this.buildConnectMenu(true); if (this.community && this.community.status == "manager") { if (!this.user && typeof location !== 'undefined') { - console.log("no user") - this.router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_LOGIN, - "redirectUrl": location.pathname+ location.search + location.hash - }, queryParamsHandling: "merge" - }); - } else { + if(location.pathname.indexOf("user-info") == -1) { + this.router.navigate(['/user-info'], { + queryParams: { + "errorCode": LoginErrorCodes.NOT_LOGIN, + "redirectUrl": location.pathname + location.search + location.hash + } + }); + } + } else { this.router.navigate(['/'], { queryParamsHandling: "merge" }); } }else if (this.community && this.community.status == "hidden") { diff --git a/src/app/community/community.component.html b/src/app/community/community.component.html index 76b3cbe..74018c8 100644 --- a/src/app/community/community.component.html +++ b/src/app/community/community.component.html @@ -190,6 +190,7 @@ +
@@ -633,4 +634,8 @@
+
+ + +
diff --git a/src/app/community/community.component.ts b/src/app/community/community.component.ts index 7587cbd..141382f 100644 --- a/src/app/community/community.component.ts +++ b/src/app/community/community.component.ts @@ -146,15 +146,12 @@ export class CommunityComponent { this._meta.updateTag({content: this.url}, "property='og:url'"); this.subs.push(this.userManagementService.getUserInfo().subscribe(user => { this.user = user; - if(this.community && ConnectHelper.isPrivate(this.community, this.user)){ - this.community = null; - } })); this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, ""); this.subs.push(this._communityService.getCommunityAsObservable().subscribe( community => { + this.community = community; if(community && !ConnectHelper.isPrivate(community, this.user)) { - this.community = community; if (community.description != null && (community.description.length - this.thresholdDescription <= this.descriptionDiff)) { this.thresholdDescription = community.description.length; } @@ -540,4 +537,7 @@ export class CommunityComponent { } } } + isPrivate(){ + return ConnectHelper.isPrivate(this.community, this.user); + } } diff --git a/src/app/community/community.module.ts b/src/app/community/community.module.ts index faf03dc..ca95580 100644 --- a/src/app/community/community.module.ts +++ b/src/app/community/community.module.ts @@ -28,6 +28,7 @@ import {TabsModule} from "../openaireLibrary/utils/tabs/tabs.module"; import {SearchTabModule} from "../openaireLibrary/utils/tabs/contents/search-tab.module"; import {ErrorMessagesModule} from "../openaireLibrary/utils/errorMessages.module"; import {SafeHtmlPipeModule} from '../openaireLibrary/utils/pipes/safeHTMLPipe.module'; +import {ErrorModule} from "../openaireLibrary/error/error.module"; @NgModule({ imports: [ @@ -37,7 +38,7 @@ import {SafeHtmlPipeModule} from '../openaireLibrary/utils/pipes/safeHTMLPipe.mo SearchResearchResultsServiceModule, SearchResultsModule, CuratorsModule, AffiliationsModule, SEOServiceModule, MatSelectModule, EntitiesSelectionModule, TabsModule, SearchTabModule, ErrorMessagesModule - , SafeHtmlPipeModule + , SafeHtmlPipeModule, ErrorModule ], declarations: [ CommunityComponent diff --git a/src/app/error/errorPage.component.ts b/src/app/error/errorPage.component.ts index e6d51bd..7d28869 100644 --- a/src/app/error/errorPage.component.ts +++ b/src/app/error/errorPage.component.ts @@ -1,12 +1,11 @@ -import {Component, Input} from '@angular/core'; +import {Component} from '@angular/core'; @Component({ selector: 'openaire-error', template: ` - + ` }) export class OpenaireErrorPageComponent { - @Input() public page: string; }