From 9ee09f1f3ad87182c0fd0602be7314821d17df29 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Thu, 1 Apr 2021 14:25:15 +0000 Subject: [PATCH] [Connect | Trunk]: Delete properties resolver. Delete query param community id git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@60772 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/app-routing.module.ts | 292 ++++++++++++------ src/app/app.component.ts | 85 ++--- src/app/app.module.ts | 18 +- src/app/htmlPages/htmlPage.component.ts | 43 ++- .../dataProvider/dataProvider.component.ts | 31 +- .../landingPages/dataset/dataset.component.ts | 34 +- .../htmlProjectReport.component.ts | 44 +-- .../organization/organization.component.ts | 29 +- src/app/landingPages/orp/orp.component.ts | 47 +-- .../landingPages/project/project.component.ts | 29 +- .../publication/publication.component.ts | 24 +- .../landingPages/result/result.component.ts | 42 +-- .../software/software.component.ts | 31 +- .../advancedSearchDataProviders.component.ts | 61 ++-- .../advancedSearchOrganizations.component.ts | 46 +-- .../advancedSearchProjects.component.ts | 65 ++-- src/app/searchPages/find/search.component.ts | 51 +-- .../simple/searchOrganizations.component.ts | 28 +- 18 files changed, 434 insertions(+), 566 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index d2ee143..6761a1e 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,99 +1,211 @@ -import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; - -import { EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver'; -import { EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service'; - -import { OpenaireErrorPageComponent } from './error/errorPage.component'; +import {NgModule} from '@angular/core'; +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"; const routes: Routes = [ - // Other Pages - { path: '', loadChildren: './communitywrapper/communityWrapper.module#CommunityWrapperModule'}, - - { path: 'about', redirectTo: 'about/learn-how', pathMatch: 'full'}, - { path: 'about/learn-how', loadChildren: './learn-how/learn-how.module#LearnHowModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, - { path: 'about/learn-in-depth', loadChildren: './learn-how/learnInDepth/learn-in-depth.module#LearnInDepthModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, - { path: 'about/faq', loadChildren: './learn-how/faqs/faqs.module#FaqsModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, - { path: 'contact-us', loadChildren: './contact/contact.module#ContactModule'}, - { path: 'invite', loadChildren: './utils/subscribe/invite/invite.module#InviteModule'}, - { path: 'content', loadChildren: './content/contentPage.module#ContentPageModule', canActivate:[IsCommunity]}, - { path: 'organizations', loadChildren: './htmlPages/organizations/organizationsPage.module#OrganizationsPageModule', canActivate:[IsCommunity]}, - { path: 'publications', loadChildren: './htmlPages/publications/publications-page.module#PublicationsPageModule', canActivate:[IsCommunity]}, - { path: 'projects', loadChildren: './htmlPages/projects/projectsPage.module#ProjectsPageModule', canActivate:[IsCommunity]}, - { path: 'national-bulletins', loadChildren: './htmlPages/nationalBulletins/nationalBulletinsPage.module#NaionalBulletinPageModule', canActivate:[IsCommunity]}, - { path: 'curators', loadChildren: './curators/curators.module#CuratorsModule', canActivate:[IsCommunity]}, - { path: 'subjects', loadChildren: './subjects/subjects.module#SubjectsModule', canActivate:[IsCommunity]}, - - { path: 'myCommunities', loadChildren: './my-communities/my-communities.module#MyCommunitiesModule'}, - - // Testing Page for help contents - { path: 'helper-test', loadChildren: './helper-test/helper-test.module#HelperTestModule'}, - - // Landing Pages - { path: 'search/result', loadChildren: './landingPages/result/libResult.module#LibResultModule', canActivate:[IsCommunity]}, - { path: 'search/publication', loadChildren: './landingPages/publication/libPublication.module#LibPublicationModule', canActivate:[IsCommunity]}, - { path: 'search/dataset', loadChildren: './landingPages/dataset/libDataset.module#LibDatasetModule', canActivate:[IsCommunity]}, - { path: 'search/software', loadChildren: './landingPages/software/libSoftware.module#LibSoftwareModule', canActivate:[IsCommunity]}, - { path: 'search/other', loadChildren: './landingPages/orp/libOrp.module#LibOrpModule', canActivate:[IsCommunity]}, - { path: 'search/project', loadChildren: './landingPages/project/libProject.module#LibProjectModule', canActivate:[IsCommunity]}, - { path: 'search/dataprovider', loadChildren: '././landingPages/dataProvider/libDataProvider.module#LibDataProviderModule', canActivate:[IsCommunity]}, - { path: 'search/organization', loadChildren: './landingPages/organization/libOrganization.module#LibOrganizationModule', canActivate:[IsCommunity]}, - - { path: 'project-report', loadChildren: './landingPages/htmlProjectReport/libHtmlProjectReport.module#LibHtmlProjectReportModule'}, - - // Search Pages - { path: 'search/find', redirectTo: 'search/find/research-outcomes', pathMatch: 'full'}, - - { path: 'search/find/communities', loadChildren: './searchPages/communities/searchCommunities.module#SearchCommunitiesModule'}, - { path: 'search/find/research-outcomes', loadChildren: './searchPages/simple/searchResearchResults.module#OpenaireSearchResearchResultsModule', canActivate:[IsCommunity]}, - { path: 'search/find/publications', component: PageURLResolverComponent, canActivate:[IsCommunity]}, - { path: 'search/find/datasets', component: PageURLResolverComponent, canActivate:[IsCommunity]}, - { path: 'search/find/software', component: PageURLResolverComponent, canActivate:[IsCommunity]}, - { path: 'search/find/other', component: PageURLResolverComponent, canActivate:[IsCommunity]}, - { path: 'search/find/projects', loadChildren: './searchPages/simple/searchProjects.module#LibSearchProjectsModule', canActivate:[IsCommunity]}, - { path: 'search/find/dataproviders', loadChildren: './searchPages/simple/searchDataProviders.module#LibSearchDataProvidersModule', canActivate:[IsCommunity]}, - - // Advanced Search Pages - { path: 'search/advanced/research-outcomes', loadChildren: './searchPages/advanced/searchResearchResults.module#OpenaireAdvancedSearchResearchResultsModule', canActivate:[IsCommunity]}, - { path: 'search/advanced/publications', component: PageURLResolverComponent, canActivate:[IsCommunity]}, - { path: 'search/advanced/datasets', component: PageURLResolverComponent, canActivate:[IsCommunity]}, - { path: 'search/advanced/software', component: PageURLResolverComponent, canActivate:[IsCommunity]}, - { path: 'search/advanced/other', component: PageURLResolverComponent, canActivate:[IsCommunity]}, - { path: 'search/advanced/organizations', loadChildren: './searchPages/advanced/advancedSearchOrganizations.module#LibAdvancedSearchOrganizationsModule', canActivate:[IsCommunity]}, - { path: 'search/advanced/dataproviders', loadChildren: './searchPages/advanced/advancedSearchDataProviders.module#LibAdvancedSearchDataProvidersModule', canActivate:[IsCommunity]}, - { path: 'search/advanced/projects', loadChildren: './searchPages/advanced/advancedSearchProjects.module#LibAdvancedSearchProjectsModule', canActivate:[IsCommunity]}, - - // Deposit Pages - { path: 'participate/deposit-datasets', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full', canActivate:[IsCommunity]}, - { path: 'participate/deposit-datasets-result', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full', canActivate:[IsCommunity]}, - { path: 'participate/deposit-subject-result', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full', canActivate:[IsCommunity]}, - { path: 'participate/deposit-publications', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full', canActivate:[IsCommunity]}, - { path: 'participate/deposit-publications-result', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full', canActivate:[IsCommunity]}, - { path: 'participate/share-zenodo', redirectTo: '/participate/deposit/zenodo', pathMatch: 'full', canActivate:[IsCommunity]}, - - { path: 'participate/deposit/learn-how', loadChildren: './deposit/deposit.module#LibDepositModule', canActivate:[IsCommunity]}, - { path: 'participate/deposit/search', loadChildren: './deposit/searchDataprovidersToDeposit.module#LibSearchDataprovidersToDepositModule', canActivate:[IsCommunity]}, - { path: 'participate/deposit/zenodo', loadChildren: './deposit/zenodo/shareInZenodo.module#ShareInZenodoModule', canActivate:[IsCommunity]}, - - // Linking Pages - { path: 'myclaims', loadChildren: './claims/myClaims/myClaims.module#LibMyClaimsModule', canActivate:[IsCommunity]}, - { path: 'participate/claim', loadChildren: './claims/linking/linkingGeneric.module#LibLinkingGenericModule', canActivate:[IsCommunity]}, - { path: 'participate/direct-claim', loadChildren: './claims/directLinking/directLinking.module#LibDirectLinkingModule', canActivate:[IsCommunity]}, - - - // help pages - do not exist in Admin portal/api/db - { path: 'reload', loadChildren: './reload/libReload.module#LibReloadModule'}, - { path: 'user-info', loadChildren: './login/libUser.module#LibUserModule'}, - { path: 'error', component: OpenaireErrorPageComponent}, - { path: 'theme', loadChildren: './openaireLibrary/utils/theme/theme.module#ThemeModule'}, - { path: '**',pathMatch: 'full',component: OpenaireErrorPageComponent} + /** Other Pages */ + {path: '', loadChildren: './communitywrapper/communityWrapper.module#CommunityWrapperModule'}, + {path: 'about', redirectTo: 'about/learn-how', pathMatch: 'full'}, + {path: 'about/learn-how', loadChildren: './learn-how/learn-how.module#LearnHowModule'}, + {path: 'about/learn-in-depth', loadChildren: './learn-how/learnInDepth/learn-in-depth.module#LearnInDepthModule'}, + {path: 'about/faq', loadChildren: './learn-how/faqs/faqs.module#FaqsModule'}, + {path: 'contact-us', loadChildren: './contact/contact.module#ContactModule'}, + {path: 'invite', loadChildren: './utils/subscribe/invite/invite.module#InviteModule'}, + {path: 'content', loadChildren: './content/contentPage.module#ContentPageModule', canActivate: [IsCommunity]}, + { + path: 'organizations', + loadChildren: './htmlPages/organizations/organizationsPage.module#OrganizationsPageModule', + canActivate: [IsCommunity] + }, + { + path: 'publications', + loadChildren: './htmlPages/publications/publications-page.module#PublicationsPageModule', + canActivate: [IsCommunity] + }, + { + path: 'projects', + loadChildren: './htmlPages/projects/projectsPage.module#ProjectsPageModule', + canActivate: [IsCommunity] + }, + { + path: 'national-bulletins', + loadChildren: './htmlPages/nationalBulletins/nationalBulletinsPage.module#NaionalBulletinPageModule', + canActivate: [IsCommunity] + }, + {path: 'curators', loadChildren: './curators/curators.module#CuratorsModule', canActivate: [IsCommunity]}, + {path: 'subjects', loadChildren: './subjects/subjects.module#SubjectsModule', canActivate: [IsCommunity]}, + {path: 'myCommunities', loadChildren: './my-communities/my-communities.module#MyCommunitiesModule'}, + /** Testing Page for help contents */ + {path: 'helper-test', loadChildren: './helper-test/helper-test.module#HelperTestModule'}, + /** Landing Pages */ + { + path: 'search/result', + loadChildren: './landingPages/result/libResult.module#LibResultModule', + canActivate: [IsCommunity] + }, + { + path: 'search/publication', + loadChildren: './landingPages/publication/libPublication.module#LibPublicationModule', + canActivate: [IsCommunity] + }, + { + path: 'search/dataset', + loadChildren: './landingPages/dataset/libDataset.module#LibDatasetModule', + canActivate: [IsCommunity] + }, + { + path: 'search/software', + loadChildren: './landingPages/software/libSoftware.module#LibSoftwareModule', + canActivate: [IsCommunity] + }, + {path: 'search/other', loadChildren: './landingPages/orp/libOrp.module#LibOrpModule', canActivate: [IsCommunity]}, + { + path: 'search/project', + loadChildren: './landingPages/project/libProject.module#LibProjectModule', + canActivate: [IsCommunity] + }, + { + path: 'search/dataprovider', + loadChildren: '././landingPages/dataProvider/libDataProvider.module#LibDataProviderModule', + canActivate: [IsCommunity] + }, + { + path: 'search/organization', + loadChildren: './landingPages/organization/libOrganization.module#LibOrganizationModule', + canActivate: [IsCommunity] + }, + { + path: 'project-report', + loadChildren: './landingPages/htmlProjectReport/libHtmlProjectReport.module#LibHtmlProjectReportModule' + }, + /** Search Pages */ + {path: 'search/find', redirectTo: 'search/find/research-outcomes', pathMatch: 'full'}, + + { + path: 'search/find/communities', + loadChildren: './searchPages/communities/searchCommunities.module#SearchCommunitiesModule' + }, + { + path: 'search/find/research-outcomes', + loadChildren: './searchPages/simple/searchResearchResults.module#OpenaireSearchResearchResultsModule', + canActivate: [IsCommunity] + }, + {path: 'search/find/publications', component: PageURLResolverComponent, canActivate: [IsCommunity]}, + {path: 'search/find/datasets', component: PageURLResolverComponent, canActivate: [IsCommunity]}, + {path: 'search/find/software', component: PageURLResolverComponent, canActivate: [IsCommunity]}, + {path: 'search/find/other', component: PageURLResolverComponent, canActivate: [IsCommunity]}, + { + path: 'search/find/projects', + loadChildren: './searchPages/simple/searchProjects.module#LibSearchProjectsModule', + canActivate: [IsCommunity] + }, + { + path: 'search/find/dataproviders', + loadChildren: './searchPages/simple/searchDataProviders.module#LibSearchDataProvidersModule', + canActivate: [IsCommunity] + }, + /** Advanced Search Pages */ + { + path: 'search/advanced/research-outcomes', + loadChildren: './searchPages/advanced/searchResearchResults.module#OpenaireAdvancedSearchResearchResultsModule', + canActivate: [IsCommunity] + }, + {path: 'search/advanced/publications', component: PageURLResolverComponent, canActivate: [IsCommunity]}, + {path: 'search/advanced/datasets', component: PageURLResolverComponent, canActivate: [IsCommunity]}, + {path: 'search/advanced/software', component: PageURLResolverComponent, canActivate: [IsCommunity]}, + {path: 'search/advanced/other', component: PageURLResolverComponent, canActivate: [IsCommunity]}, + { + path: 'search/advanced/organizations', + loadChildren: './searchPages/advanced/advancedSearchOrganizations.module#LibAdvancedSearchOrganizationsModule', + canActivate: [IsCommunity] + }, + { + path: 'search/advanced/dataproviders', + loadChildren: './searchPages/advanced/advancedSearchDataProviders.module#LibAdvancedSearchDataProvidersModule', + canActivate: [IsCommunity] + }, + { + path: 'search/advanced/projects', + loadChildren: './searchPages/advanced/advancedSearchProjects.module#LibAdvancedSearchProjectsModule', + canActivate: [IsCommunity] + }, + /** Deposit Pages */ + { + path: 'participate/deposit-datasets', + redirectTo: 'participate/deposit/learn-how', + pathMatch: 'full', + canActivate: [IsCommunity] + }, + { + path: 'participate/deposit-datasets-result', + redirectTo: 'participate/deposit/learn-how', + pathMatch: 'full', + canActivate: [IsCommunity] + }, + { + path: 'participate/deposit-subject-result', + redirectTo: 'participate/deposit/learn-how', + pathMatch: 'full', + canActivate: [IsCommunity] + }, + { + path: 'participate/deposit-publications', + redirectTo: 'participate/deposit/learn-how', + pathMatch: 'full', + canActivate: [IsCommunity] + }, + { + path: 'participate/deposit-publications-result', + redirectTo: 'participate/deposit/learn-how', + pathMatch: 'full', + canActivate: [IsCommunity] + }, + { + path: 'participate/share-zenodo', + redirectTo: '/participate/deposit/zenodo', + pathMatch: 'full', + canActivate: [IsCommunity] + }, + { + path: 'participate/deposit/learn-how', + loadChildren: './deposit/deposit.module#LibDepositModule', + canActivate: [IsCommunity] + }, + { + path: 'participate/deposit/search', + loadChildren: './deposit/searchDataprovidersToDeposit.module#LibSearchDataprovidersToDepositModule', + canActivate: [IsCommunity] + }, + { + path: 'participate/deposit/zenodo', + loadChildren: './deposit/zenodo/shareInZenodo.module#ShareInZenodoModule', + canActivate: [IsCommunity] + }, + /** Linking Pages */ + {path: 'myclaims', loadChildren: './claims/myClaims/myClaims.module#LibMyClaimsModule', canActivate: [IsCommunity]}, + { + path: 'participate/claim', + loadChildren: './claims/linking/linkingGeneric.module#LibLinkingGenericModule', + canActivate: [IsCommunity] + }, + { + path: 'participate/direct-claim', + loadChildren: './claims/directLinking/directLinking.module#LibDirectLinkingModule', + canActivate: [IsCommunity] + }, + /** help pages - do not exist in Admin portal/api/db */ + {path: 'reload', loadChildren: './reload/libReload.module#LibReloadModule'}, + {path: 'user-info', loadChildren: './login/libUser.module#LibUserModule'}, + {path: 'error', component: OpenaireErrorPageComponent}, + {path: 'theme', loadChildren: './openaireLibrary/utils/theme/theme.module#ThemeModule'}, + {path: '**', pathMatch: 'full', component: OpenaireErrorPageComponent} ]; @NgModule({ imports: [RouterModule.forRoot(routes)], - exports: [RouterModule], - providers: [EnvironmentSpecificResolver, EnvironmentSpecificService] + exports: [RouterModule] }) -export class AppRoutingModule { } +export class AppRoutingModule { +} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 9b79a65..aeb8df8 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -16,6 +16,7 @@ import {Subscriber} from "rxjs"; import {CommunityService} from "./openaireLibrary/connect/community/community.service"; import {StringUtils} from "./openaireLibrary/utils/string-utils.class"; import {LoginErrorCodes} from "./openaireLibrary/login/utils/guardHelper.class"; + @Component({ //changeDetection: ChangeDetectionStrategy.Default, //encapsulation: ViewEncapsulation.Emulated, @@ -78,14 +79,14 @@ import {LoginErrorCodes} from "./openaireLibrary/login/utils/guardHelper.class"; [id]="community.id" [name]="community.name" [type]="'community'"> ` - + }) export class AppComponent { isClient: boolean = false; - + userMenuItems: MenuItem[] = []; - - + + menuItems: RootMenuItem [] = []; bottomMenuItems: MenuItem[] = []; public community = null; @@ -97,6 +98,7 @@ export class AppComponent { header: Header; logoPath: string = 'assets/common-assets/'; subscriptions = []; + constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService, private _communitiesService: CommunitiesService, private router: Router, private userManagementService: UserManagementService, @@ -119,7 +121,7 @@ export class AppComponent { this.configurationService.clearSubscriptions(); this._communityService.clearSubscriptions(); } - + ngOnInit() { this.properties = properties; this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI); @@ -132,43 +134,45 @@ export class AppComponent { this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { this.user = user; this.init(); - },error => this.init())); - + }, error => this.init())); + } get isManager() { return Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user) || (this.communityId && Session.isManager('community', this.communityId, this.user)) } - + private init() { let communityId: string = ConnectHelper.getCommunityFromDomain(this.properties.domain); this.showMenu = false; this.initAdminToolCommunity(communityId); this.buildMenu(communityId); this.communityId = communityId; - if(this.communityId === null) { + if (this.communityId === null) { this.userManagementService.fixRedirectURL = properties.afterLoginRedirectLink; } else { this.userManagementService.fixRedirectURL = null; } } - initAdminToolCommunity(communityId){ - if(communityId) { + + initAdminToolCommunity(communityId) { + if (communityId) { this.properties.adminToolsPortalType = "community"; } - this.configurationService.initCommunityInformation(this.properties, (communityId)?communityId:this.properties.adminToolsPortalType); + this.configurationService.initCommunityInformation(this.properties, (communityId) ? communityId : this.properties.adminToolsPortalType); } + public buildMenu(communityId: string) { - if(communityId) { + if (communityId) { if (!this.community || this.community.communityId !== communityId) { this.subscriptions.push(this._communityService.getCommunity(communityId).subscribe(community => { if (community && !this.isPrivate(community)) { this.community = { id: community.communityId, name: (community.shortTitle) ? community.shortTitle : community.title, - logoUrl: (community.isUpload) ? (properties.utilsService + '/download/' + community.logoUrl):(StringUtils.urlPrefix(community.logoUrl) + community.logoUrl), - description:community.description + logoUrl: (community.isUpload) ? (properties.utilsService + '/download/' + community.logoUrl) : (StringUtils.urlPrefix(community.logoUrl) + community.logoUrl), + description: community.description }; this.header = { // url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu', @@ -216,7 +220,7 @@ export class AppComponent { if (this.isManager) { this.menuItems.push( { - rootItem: new MenuItem("manage", "Manage", this.properties.adminPortalURL + '/' + community.communityId, "", false, [], [], {}), + rootItem: new MenuItem("manage", "Manage", this.properties.adminPortalURL + '/' + community.communityId, "", false, [], [], {}), items: [] }); } @@ -226,7 +230,7 @@ export class AppComponent { if (this.properties.showContent) { this.bottomMenuItems.push(new MenuItem("", "Sources and methodology", "", "/content", false, [], [], {})); } - if(this.user) { + if (this.user) { this.userMenuItems = [ /*new MenuItem("","My profile","","",false,[],[],{}),*/ new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], {}), new MenuItem("", "Invite users", "", "/invite", false, [], [], {}), @@ -237,62 +241,65 @@ export class AppComponent { } this.showMenu = true; } else { - this.showPrivateOrNoCommunity(community?community.status:null); + this.showPrivateOrNoCommunity(community ? community.status : null); } })); } else { this.showMenu = true; } } else { - this.buildConnectMenu(); + this.buildConnectMenu(); } } - isPrivate(community){ - return community && ( community.status == "hidden" || (community.status == "manager" && !(Session.isCommunityCurator(this.user) || Session.isManager("community",community.communityId,this.user)))) + + isPrivate(community) { + return community && (community.status == "hidden" || (community.status == "manager" && !(Session.isCommunityCurator(this.user) || Session.isManager("community", community.communityId, this.user)))) } - showPrivateOrNoCommunity(restrictedData:string){ + + showPrivateOrNoCommunity(restrictedData: string) { this.communityId = null; this.community = null; this.properties.adminToolsPortalType = "connect"; - this.configurationService.initCommunityInformation(this.properties,"connect"); + this.configurationService.initCommunityInformation(this.properties, "connect"); this.initAdminToolCommunity(null); this.buildConnectMenu(true); - if(restrictedData == "manager") { - if(!this.user) { + if (restrictedData == "manager") { + if (!this.user) { this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_LOGIN, "redirectUrl": this.router.url } }); - }else{ - this.router.navigate(['/error'], restrictedData ? {queryParams: {'page': -1}} : {}); + } else { + this.router.navigate(['/error'], {queryParams: {'page': -1}}); } - }else { + } else { this.router.navigate(['/error'], restrictedData ? {queryParams: {'page': -1}} : {}); } } - buildConnectMenu(restrictedData:boolean=false){ - let url = "https://" + (properties.environment !="production" ? "beta." : "") + "connect.openaire.eu"; + + buildConnectMenu(restrictedData: boolean = false) { + let url = "https://" + (properties.environment != "production" ? "beta." : "") + "connect.openaire.eu"; this.header = { route: restrictedData ? "" : "/", - url: restrictedData ? url: "", + url: restrictedData ? url : "", title: 'connect', logoUrl: this.logoPath + 'logo-large-connect.png', - logoSmallUrl:this.logoPath + 'logo-small-connect.png', - position:'left', - badge:true + logoSmallUrl: this.logoPath + 'logo-small-connect.png', + position: 'left', + badge: true }; this.menuItems = []; this.menuItems.push({ - rootItem: new MenuItem("about", "About", restrictedData ? url + "/about/learn-how": "", restrictedData ? "" : "/about/learn-how", false, [], ["/about/learn-how"], {}), + rootItem: new MenuItem("about", "About", restrictedData ? url + "/about/learn-how" : "", restrictedData ? "" : "/about/learn-how", false, [], ["/about/learn-how"], {}), items: [ new MenuItem("", "Learn the process", restrictedData ? url + "/about/learn-how" : "", restrictedData ? "" : "/about/learn-how", false, [], ["/about/learn-in-depth"], {}), - new MenuItem("", "Publications", restrictedData ? url +"/publications":"", restrictedData ? "" : "/publications", false, [], ["/publications"], {}), + new MenuItem("", "Publications", restrictedData ? url + "/publications" : "", restrictedData ? "" : "/publications", false, [], ["/publications"], {}), new MenuItem("", "Roadmap", "https://trello.com/b/yfzUz0kp/openaire-connect-dashboard", "", false, [], [], {}), new MenuItem("", "FAQs", restrictedData ? url + "/about/faq" : "", restrictedData ? "" : "/about/faq", false, [], ["/about/faq"], {}) ] - + }); this.menuItems.push({ rootItem: new MenuItem("communities", "Communities", restrictedData ? url + "/about/faq" : "", restrictedData ? "" : "/search/find/communities", false, [], ['/search/find/communities'], {}), @@ -306,12 +313,12 @@ export class AppComponent { new MenuItem("", "About", "https://openaire.eu/project-factsheets", "", false, [], [], {}), new MenuItem("", "News - Events", "https://openaire.eu/news-events", "", false, [], [], {}), new MenuItem("", "Blog", "https://blogs.openaire.eu/", "", false, [], [], {}), - new MenuItem("", "Contact us", restrictedData ? url + "/contact-us" : "", restrictedData ? "" : "/contact-us", false, [], [], {}) + new MenuItem("", "Contact us", restrictedData ? url + "/contact-us" : "", restrictedData ? "" : "/contact-us", false, [], [], {}) ]; this.userMenuItems = []; if (Session.isPortalAdministrator(this.user)) { this.userMenuItems.push(new MenuItem("", "Manage Helptexts", - properties.adminPortalURL + "/connect/pages","", false, [], [], {})) + properties.adminPortalURL + "/connect/pages", "", false, [], [], {})) } if (this.user) { this.userMenuItems.push(new MenuItem("my-communities", "My Communities", restrictedData ? url + "/myCommunities" : "", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3718269..1d988e9 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -14,9 +14,6 @@ import {CookieLawModule} from './openaireLibrary/sharedComponents/cookie-law/coo import {BottomModule} from './openaireLibrary/sharedComponents/bottom.module'; import {ErrorModule} from './openaireLibrary/error/error.module'; import {NavigationBarModule} from './openaireLibrary/sharedComponents/navigationBar.module'; - -import {EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver'; - import {CommunitiesService} from './openaireLibrary/connect/communities/communities.service'; import {LayoutService} from "./openaireLibrary/services/layout.service"; import {SubscribeModule} from './utils/subscribe/subscribe.module'; @@ -50,10 +47,10 @@ import {RoleVerificationModule} from "./openaireLibrary/role-verification/role-v BrowserAnimationsModule, PageURLResolverModule, Schema2jsonldModule, RoleVerificationModule ], - declarations: [ AppComponent, OpenaireErrorPageComponent], - exports: [ AppComponent ], - providers:[ - EnvironmentSpecificResolver, CommunitiesService, LayoutService, IsCommunity, SubscribeService, + declarations: [AppComponent, OpenaireErrorPageComponent], + exports: [AppComponent], + providers: [ + CommunitiesService, LayoutService, IsCommunity, SubscribeService, { provide: HTTP_INTERCEPTORS, useClass: HttpInterceptorService, @@ -64,10 +61,11 @@ import {RoleVerificationModule} from "./openaireLibrary/role-verification/role-v useClass: ErrorInterceptorService, multi: true }, - [{ provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true }], - [{ provide: DEFAULT_TIMEOUT, useValue: 30000 }] + [{provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true}], + [{provide: DEFAULT_TIMEOUT, useValue: 30000}] ], bootstrap: [AppComponent] }) -export class AppModule {} +export class AppModule { +} diff --git a/src/app/htmlPages/htmlPage.component.ts b/src/app/htmlPages/htmlPage.component.ts index c314922..9906528 100644 --- a/src/app/htmlPages/htmlPage.component.ts +++ b/src/app/htmlPages/htmlPage.component.ts @@ -14,41 +14,34 @@ import {properties} from "../../environments/environment"; selector: 'html-page', template: ` - -` + + ` }) export class HtmlPageComponent { - - properties: EnvProperties; + properties: EnvProperties = properties; public pageContents = null; public divContents = null; - + @Input() url: string = null; @Input() pageTitle: string; @Input() description: string; - private subscriptions = []; + private subscriptions = []; communityId; - + constructor(private route: ActivatedRoute, private _router: Router, private _meta: Meta, private _title: Title, private seoService: SEOService, private _piwikService: PiwikService, - private helper: HelperService) {} - + private helper: HelperService) { + } + public ngOnInit() { - - this.properties = properties; - if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle, this.properties.piwikSiteId).subscribe()); } this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); - if (this.properties.environment == "development") { - this.subscriptions.push(this.route.queryParams.subscribe(params => { - this.communityId = (params['communityId']) ? params['communityId'] : ConnectHelper.getCommunityFromDomain(this.properties.domain); - })); - } //TODO set the proper URL this.url = this.properties.domain + this._router.url; this.seoService.createLinkForCanonicalURL(this.url); @@ -56,9 +49,9 @@ export class HtmlPageComponent { this.updateTitle(this.pageTitle); this.updateDescription(this.description); this.getPageContents(); - + } - + ngOnDestroy() { this.subscriptions.forEach(subscription => { if (subscription instanceof Subscriber) { @@ -66,25 +59,25 @@ export class HtmlPageComponent { } }); } - - + + private updateDescription(description: string) { this._meta.updateTag({content: description}, "name='description'"); this._meta.updateTag({content: description}, "property='og:description'"); } - + private updateTitle(title: string) { var _title = ((title.length > 50) ? title.substring(0, 50) : title); this._title.setTitle(_title); this._meta.updateTag({content: _title}, "property='og:title'"); } - + private updateUrl(url: string) { this._meta.updateTag({content: url}, "property='og:url'"); } - + private getPageContents() { - this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId?this.communityId:"connect", this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId ? this.communityId : "connect", this._router.url).subscribe(contents => { this.pageContents = contents; })); } diff --git a/src/app/landingPages/dataProvider/dataProvider.component.ts b/src/app/landingPages/dataProvider/dataProvider.component.ts index 6bfce44..44af100 100644 --- a/src/app/landingPages/dataProvider/dataProvider.component.ts +++ b/src/app/landingPages/dataProvider/dataProvider.component.ts @@ -1,8 +1,6 @@ -import {Component} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; +import {Component, OnInit} from '@angular/core'; import {PiwikHelper} from '../../utils/piwikHelper'; import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; -import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; @Component({ @@ -10,28 +8,15 @@ import {properties} from "../../../environments/environment"; template: ` `, }) -export class OpenaireDataProviderComponent { - piwikSiteId = null; - communityId = null; - private sub; - constructor(private route: ActivatedRoute) { - this.sub = this.route.queryParams.subscribe(params => { - this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - if (!this.communityId) { - this.communityId = params['communityId']; - } - this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); - }); - +export class OpenaireDataProviderComponent implements OnInit { + piwikSiteId; + communityId; + + constructor() { } ngOnInit() { - + this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); } - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); - } - } - } diff --git a/src/app/landingPages/dataset/dataset.component.ts b/src/app/landingPages/dataset/dataset.component.ts index 3650595..2cd409c 100644 --- a/src/app/landingPages/dataset/dataset.component.ts +++ b/src/app/landingPages/dataset/dataset.component.ts @@ -1,8 +1,6 @@ -import {Component} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; +import {Component, OnInit} from '@angular/core'; import {PiwikHelper} from '../../utils/piwikHelper'; import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; -import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; @Component({ @@ -11,29 +9,15 @@ import {properties} from "../../../environments/environment"; `, }) -export class OpenaireDatasetComponent { - piwikSiteId = null; - communityId = null; - private sub; - constructor(private route: ActivatedRoute) { - this.sub = this.route.queryParams.subscribe(params => { - this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - if (!this.communityId) { - this.communityId = params['communityId']; - } - this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); - }); - +export class OpenaireDatasetComponent implements OnInit { + piwikSiteId; + communityId; + + constructor() { } - + ngOnInit() { - + this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); } - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); - } - } - - } diff --git a/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts b/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts index 4adfa64..34006e4 100644 --- a/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts +++ b/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts @@ -1,38 +1,22 @@ -import {Component, ViewChild, ElementRef} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; +import {Component} from '@angular/core'; import {PiwikHelper} from '../../utils/piwikHelper'; import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; -import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; + @Component({ - selector: 'openaire-htmlProjectReport', - template: ``, - }) -export class OpenaireHtmlProjectReportComponent{ - piwikSiteId = null; - communityId = null; - private sub; - - constructor(private route: ActivatedRoute) { - this.sub = this.route.queryParams.subscribe(params => { - this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - if (!this.communityId) { - this.communityId = params['communityId']; - } - this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); - }); - + selector: 'openaire-htmlProjectReport', + template: ` + `, +}) +export class OpenaireHtmlProjectReportComponent { + piwikSiteId; + communityId; + + constructor() { } - + ngOnInit() { - + this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); } - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); - } - } - - - } diff --git a/src/app/landingPages/organization/organization.component.ts b/src/app/landingPages/organization/organization.component.ts index c733d2c..09270dd 100644 --- a/src/app/landingPages/organization/organization.component.ts +++ b/src/app/landingPages/organization/organization.component.ts @@ -1,8 +1,6 @@ import {Component} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; import {PiwikHelper} from '../../utils/piwikHelper'; import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; -import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; @Component({ @@ -11,27 +9,14 @@ import {properties} from "../../../environments/environment"; `, }) export class OpenaireOrganizationComponent { - piwikSiteId = null; - communityId = null; - private sub; - - constructor(private route: ActivatedRoute) { - this.sub = this.route.queryParams.subscribe(params => { - this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - if (!this.communityId) { - this.communityId = params['communityId']; - } - this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); - }); - + piwikSiteId; + communityId; + + constructor() { } - - + ngOnInit() { - } - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); - } + this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); } } diff --git a/src/app/landingPages/orp/orp.component.ts b/src/app/landingPages/orp/orp.component.ts index 4aeb4ba..fc97428 100644 --- a/src/app/landingPages/orp/orp.component.ts +++ b/src/app/landingPages/orp/orp.component.ts @@ -1,40 +1,25 @@ -import {Component} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {ActivatedRoute} from '@angular/router'; -import {PiwikHelper} from '../../utils/piwikHelper'; -import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; +import {PiwikHelper} from '../../utils/piwikHelper'; +import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; @Component({ - selector: 'openaire-orp', - template: ` - - `, + selector: 'openaire-orp', + template: ` + + `, }) -export class OpenaireOrpComponent { - piwikSiteId = null; - communityId = null; - private sub; - - constructor(private route: ActivatedRoute) { - this.sub = this.route.queryParams.subscribe(params => { - this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - if (!this.communityId) { - this.communityId = params['communityId']; - } - this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); - }); - - } - - - ngOnInit() { - } - - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); - } +export class OpenaireOrpComponent implements OnInit { + piwikSiteId = null; + communityId = null; + + constructor() {} + + ngOnInit() { + this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); } } diff --git a/src/app/landingPages/project/project.component.ts b/src/app/landingPages/project/project.component.ts index a2c49b4..01d0051 100644 --- a/src/app/landingPages/project/project.component.ts +++ b/src/app/landingPages/project/project.component.ts @@ -1,8 +1,6 @@ -import {Component} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; +import {Component, OnInit} from '@angular/core'; import {PiwikHelper} from '../../utils/piwikHelper'; import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; -import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; @Component({ @@ -10,28 +8,15 @@ import {properties} from "../../../environments/environment"; template: ` `, }) -export class OpenaireProjectComponent { - piwikSiteId = null; - communityId = null; - private sub; - - constructor(private route: ActivatedRoute) { - this.sub = this.route.queryParams.subscribe(params => { - this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - if (!this.communityId) { - this.communityId = params['communityId']; - } - this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); - }); +export class OpenaireProjectComponent implements OnInit { + piwikSiteId; + communityId; + constructor() { } ngOnInit() { + this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); } - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); - } - } - } diff --git a/src/app/landingPages/publication/publication.component.ts b/src/app/landingPages/publication/publication.component.ts index 328b6f9..ec3c314 100644 --- a/src/app/landingPages/publication/publication.component.ts +++ b/src/app/landingPages/publication/publication.component.ts @@ -1,8 +1,6 @@ import {Component} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; import {PiwikHelper} from '../../utils/piwikHelper'; import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; -import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; @Component({ @@ -14,25 +12,11 @@ import {properties} from "../../../environments/environment"; export class OpenairePublicationComponent { piwikSiteId = null; communityId = null; - private sub; - - constructor(private route: ActivatedRoute) { - this.sub = this.route.queryParams.subscribe(params => { - this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - if (!this.communityId) { - this.communityId = params['communityId']; - } - this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); - }); - } - + constructor() {} + ngOnInit() { + this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); } - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); - } - } - } diff --git a/src/app/landingPages/result/result.component.ts b/src/app/landingPages/result/result.component.ts index 99e2c23..462b00c 100644 --- a/src/app/landingPages/result/result.component.ts +++ b/src/app/landingPages/result/result.component.ts @@ -1,37 +1,21 @@ -import {Component} from '@angular/core'; -import {ActivatedRoute} from "@angular/router"; +import {Component, OnInit} from '@angular/core'; import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper"; import {PiwikHelper} from "../../utils/piwikHelper"; -import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; @Component({ - selector: 'openaire-publication', - template: ``, - }) -export class OpenaireResultComponent{ - piwikSiteId = null; - communityId = null; - private sub; - - constructor(private route: ActivatedRoute) { - this.sub = this.route.queryParams.subscribe(params => { - this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - if (!this.communityId) { - this.communityId = params['communityId']; - } - this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); - }); - - } - - + selector: 'openaire-publication', + template: ` + `, +}) +export class OpenaireResultComponent implements OnInit{ + piwikSiteId; + communityId; + + constructor() {} + ngOnInit() { + this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); } - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); - } - } - } diff --git a/src/app/landingPages/software/software.component.ts b/src/app/landingPages/software/software.component.ts index 8578f18..e6425ed 100644 --- a/src/app/landingPages/software/software.component.ts +++ b/src/app/landingPages/software/software.component.ts @@ -1,8 +1,6 @@ -import {Component} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; +import {Component, OnInit} from '@angular/core'; import {PiwikHelper} from '../../utils/piwikHelper'; import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; -import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; @Component({ @@ -11,30 +9,15 @@ import {properties} from "../../../environments/environment"; `, }) -export class OpenaireSoftwareComponent { - piwikSiteId = null; - communityId = null; - private sub; - - constructor(private route: ActivatedRoute) { - this.sub = - this.route.queryParams.subscribe(params => { - this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - if (!this.communityId) { - this.communityId = params['communityId']; - } - this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); - }); +export class OpenaireSoftwareComponent implements OnInit { + piwikSiteId; + communityId; + constructor() { } - ngOnInit() { + this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, properties.environment); } - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); - } - } - } diff --git a/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts b/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts index 2521834..eb4a9af 100644 --- a/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts +++ b/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts @@ -1,55 +1,32 @@ -import {Component, Input, ViewChild} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; -import {ActivatedRoute} from "@angular/router"; import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper"; import {PiwikHelper} from "../../utils/piwikHelper"; -import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; - @Component({ - selector: 'openaire-advanced-search-dataprovider', - template: ` - + selector: 'openaire-advanced-search-dataprovider', + template: ` + - - ` - }) - -export class OpenaireAdvancedSearchDataProvidersComponent { - connectCommunityId:string; + ` +}) +export class OpenaireAdvancedSearchDataProvidersComponent implements OnInit { + communityId: string; piwikSiteId = null; customFilter: SearchCustomFilter = null; - constructor ( private route: ActivatedRoute) { + + constructor() { } - sub; - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); + + ngOnInit() { + let communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + if (communityId) { + this.piwikSiteId = PiwikHelper.getSiteId(communityId, properties.environment); + this.communityId = communityId; + this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, ""); + this.customFilter.isHiddenFilter = false; } } - ngOnInit() { - - - var communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - - this.piwikSiteId = PiwikHelper.getSiteId(communityId, properties.environment); - - if(communityId){ - this.connectCommunityId = communityId; - this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); - this.customFilter.isHiddenFilter = false; - } else{ - this.sub = this.route.queryParams.subscribe(params => { - - if(params['communityId'] && params['communityId']!=""){ - this.connectCommunityId = params['communityId']; - this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId, properties.environment); - this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); - this.customFilter.isHiddenFilter = false; - } - }); - } - - } } diff --git a/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts b/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts index 7d48492..6b62f80 100644 --- a/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts +++ b/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, ViewChild} from '@angular/core'; +import {Component, Input, OnInit, ViewChild} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {ActivatedRoute} from "@angular/router"; import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper"; @@ -12,47 +12,23 @@ import {properties} from "../../../environments/environment"; template: ` - ` }) - -export class OpenaireAdvancedSearchOrganizationsComponent { - connectCommunityId:string; - piwikSiteId = null; - customFilter: SearchCustomFilter = null; - constructor ( private route: ActivatedRoute) { - } - sub; - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); - } +export class OpenaireAdvancedSearchOrganizationsComponent implements OnInit { + communityId:string; + piwikSiteId; + customFilter: SearchCustomFilter; + + constructor () { } + ngOnInit() { - - - var communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - + let communityId = ConnectHelper.getCommunityFromDomain(properties.domain); this.piwikSiteId = PiwikHelper.getSiteId(communityId, properties.environment); - if(communityId){ - this.connectCommunityId = communityId; - this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); + this.communityId = communityId; + this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, ""); this.customFilter.isHiddenFilter = false; - - } else{ - this.sub = this.route.queryParams.subscribe(params => { - - if(params['communityId'] && params['communityId']!=""){ - this.connectCommunityId = params['communityId']; - this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId, properties.environment); - this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); - this.customFilter.isHiddenFilter = false; - - } - }); } - } - } diff --git a/src/app/searchPages/advanced/advancedSearchProjects.component.ts b/src/app/searchPages/advanced/advancedSearchProjects.component.ts index 8c6e05f..17894f0 100644 --- a/src/app/searchPages/advanced/advancedSearchProjects.component.ts +++ b/src/app/searchPages/advanced/advancedSearchProjects.component.ts @@ -1,53 +1,34 @@ -import {Component} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; -import {ActivatedRoute} from "@angular/router"; import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper"; import {PiwikHelper} from "../../utils/piwikHelper"; -import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; + @Component({ - selector: 'openaire-advanced-search-projects', - template: ` - - + selector: 'openaire-advanced-search-projects', + template: ` + + + + ` +}) - ` - }) - -export class OpenaireAdvancedSearchProjectsComponent { - connectCommunityId:string; - piwikSiteId = null; +export class OpenaireAdvancedSearchProjectsComponent implements OnInit { + communityId: string; + piwikSiteId; customFilter: SearchCustomFilter = null; - constructor ( private route: ActivatedRoute) { + + constructor() { } - sub; - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); + + ngOnInit() { + let communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + if (communityId) { + this.communityId = communityId; + this.piwikSiteId = PiwikHelper.getSiteId(communityId, properties.environment); + this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, ""); + this.customFilter.isHiddenFilter = false; } } - ngOnInit() { - - - var communityId = ConnectHelper.getCommunityFromDomain(properties.domain); - - this.piwikSiteId = PiwikHelper.getSiteId(communityId, properties.environment); - - if(communityId){ - this.connectCommunityId = communityId; - this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); - this.customFilter.isHiddenFilter = false; - } else{ - this.route.queryParams.subscribe(params => { - - if(params['communityId'] && params['communityId']!=""){ - this.connectCommunityId = params['communityId']; - this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId, properties.environment); - this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); - this.customFilter.isHiddenFilter = false; - } - }); - } - - } } diff --git a/src/app/searchPages/find/search.component.ts b/src/app/searchPages/find/search.component.ts index 5a25efa..d3a96b7 100644 --- a/src/app/searchPages/find/search.component.ts +++ b/src/app/searchPages/find/search.component.ts @@ -1,49 +1,32 @@ import {Component} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; import {PiwikHelper} from '../../utils/piwikHelper'; import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {properties} from "../../../environments/environment"; import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties"; -import {Subscriber} from "rxjs"; @Component({ - selector: 'openaire-search-find', - template: ` - - `, - }) -export class OpenaireSearchComponent{ - connectCommunityId:string; + selector: 'openaire-search-find', + template: ` + + `, +}) +export class OpenaireSearchComponent { + communityId: string; customFilter: SearchCustomFilter = null; piwikSiteId = null; - properties:EnvProperties; - constructor ( private route: ActivatedRoute) { - } - sub; - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); - } + properties: EnvProperties = properties; + + constructor() { } + ngOnInit() { - this.properties = properties; - let communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); - this.piwikSiteId = PiwikHelper.getSiteId(communityId,this.properties.environment); - if(communityId){ - this.connectCommunityId = communityId; - this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); - }else{ - this.sub = this.route.queryParams.subscribe(params => { - if(params['communityId'] && params['communityId']!=""){ - this.connectCommunityId = params['communityId']; - this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId,this.properties.environment); - this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); - } - }); + let communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); + if (communityId) { + this.communityId = communityId; + this.piwikSiteId = PiwikHelper.getSiteId(communityId, this.properties.environment); + this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, ""); } - } - - } diff --git a/src/app/searchPages/simple/searchOrganizations.component.ts b/src/app/searchPages/simple/searchOrganizations.component.ts index 9f496ee..a04213a 100644 --- a/src/app/searchPages/simple/searchOrganizations.component.ts +++ b/src/app/searchPages/simple/searchOrganizations.component.ts @@ -1,43 +1,25 @@ -import {Component, OnDestroy, OnInit} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; +import {Component, OnInit} from '@angular/core'; import {PiwikHelper} from '../../utils/piwikHelper'; import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; -import {Subscriber} from "rxjs"; import {properties} from "../../../environments/environment"; @Component({ selector: 'openaire-search-organizations', template: ` - - - + ` }) -export class OpenaireSearchOrganizationsComponent implements OnInit, OnDestroy { +export class OpenaireSearchOrganizationsComponent implements OnInit { piwikSiteId = null; - sub; - constructor(private route: ActivatedRoute) { + constructor() { } ngOnInit() { - var communityId = ConnectHelper.getCommunityFromDomain(properties.domain); + let communityId = ConnectHelper.getCommunityFromDomain(properties.domain); if (communityId) { this.piwikSiteId = PiwikHelper.getSiteId(communityId, properties.environment); - } else { - this.sub = this.route.queryParams.subscribe(params => { - if (params['communityId'] && params['communityId'] != "") { - communityId = params['communityId']; - this.piwikSiteId = PiwikHelper.getSiteId(communityId, properties.environment); - } - }); - } - } - - ngOnDestroy() { - if (this.sub instanceof Subscriber) { - this.sub.unsubscribe(); } } }