From 1d5c753ff65f74843257c86de47bc3aada2ac900 Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Wed, 11 Nov 2020 14:43:13 +0000 Subject: [PATCH] [Library|Trunk] code clean up: -remove app.* files from library -remove unused imports, code, files (Old search pages for results, dataproviders, map search page, etc) -remove Freeguard from modules -unsubscribe all subscriptions -Services: configuration, isvocabularies, user management: unsubscribe from app component or the component that uses them (clearSubscriptions()) -Fetchers: unsubscribe from the component that uses them (clearSubscriptions()) git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59816 d315682c-612b-4755-9ff5-7f18f6832af3 --- app-routing.module.ts | 93 --- app.component.ts | 110 --- app.module.ts | 83 --- app.server.module.ts | 20 - .../claimContextSearchForm.component.ts | 29 +- .../claimProjectSearchForm.component.ts | 10 +- .../claimResultSearchForm.component.ts | 60 +- claims/claim-utils/claimResults.component.ts | 1 - .../displayClaims/displayClaims.component.ts | 58 +- .../claimEntityFormatter.module.ts | 1 - .../claim-utils/service/contexts.service.ts | 5 +- claims/claim-utils/startOver.component.ts | 2 +- claims/claimsAdmin/claimsAdmin.component.ts | 13 +- .../claimsByToken/claimsByToken.component.ts | 31 +- claims/claimsByToken/claimsByToken.service.ts | 3 +- .../directLinking/directLinking.component.ts | 29 +- .../linking/bulkClaim/bulkClaim.component.ts | 18 +- claims/linking/bulkClaim/bulkClaim.module.ts | 2 +- .../insertClaim/insertClaim.component.ts | 29 +- claims/linking/linkingGeneric.component.ts | 18 +- claims/linking/linkingGeneric.module.ts | 1 - .../ClaimEntityProjectMetadata.component.ts | 1 - .../ClaimEntityResultMetadata.component.ts | 13 - .../selected/ClaimEntityTitle.component.ts | 24 - .../selected/selectedContexts.component.ts | 14 - .../selected/selectedContexts.module.ts | 4 +- .../selected/selectedProjects.component.ts | 15 - .../selected/selectedProjects.module.ts | 2 - .../selected/selectedResults.component.ts | 6 - claims/myClaims/myClaims.component.ts | 10 +- .../connectAdminLoginGuard.guard.ts | 6 +- .../connectCommunityGuard.guard.ts | 17 +- .../communityGuard/connectRIGuard.guard.ts | 14 +- .../communityGuard/connectSubscriber.guard.ts | 10 +- deposit/depositFirstPage.component.ts | 27 +- .../searchDataprovidersToDeposit.component.ts | 2 +- .../searchDataprovidersToDeposit.module.ts | 4 +- deposit/searchResultsInDeposit.component.ts | 11 +- error/errorPage.component.ts | 3 +- error/isRouteEnabled.guard.ts | 37 +- .../annotation/annotation.component.ts | 4 +- landingPages/annotation/annotation.service.ts | 2 - .../dataProvider/dataProvider.component.ts | 275 +------ .../dataProvider/dataProvider.module.ts | 5 +- .../dataProvider/dataProvider.service.ts | 6 +- .../dataProvider/orpsTab.component.ts | 2 - .../dataProvider/softwareTab.component.ts | 1 - .../dataProvider/statisticsTab.component.ts | 11 +- landingPages/feedback/feedback.component.ts | 21 +- .../htmlProjectReport-routing.module.ts | 15 - .../htmlProjectReport.component.ts | 47 +- .../htmlProjectReport.module.ts | 4 +- .../landing-utils/addThis.component.ts | 10 +- .../landing-utils/citeThis/citation.class.ts | 2 +- .../citeThis/citeThis.component.ts | 6 +- .../projects-in-modal.component.ts | 2 - .../resultLandingUtils.module.ts | 2 - .../landing-utils/showTitle.component.ts | 14 +- .../landing-utils/tabTable.component.ts | 1 - .../deletedByInference.component.ts | 30 +- .../organization-routing.module.ts | 18 - .../organization/organization.component.ts | 116 ++- .../organization/organization.module.ts | 7 +- landingPages/project/project.component.ts | 95 +-- landingPages/project/project.module.ts | 4 +- landingPages/project/project.service.ts | 3 +- .../deletedByInference.component.ts | 25 +- .../result/resultLanding.component.ts | 60 +- landingPages/result/resultLanding.module.ts | 4 +- landingPages/result/resultLanding.service.ts | 2 +- login/adminLoginGuard.guard.ts | 23 +- login/claimsCuratorGuard.guard.ts | 22 +- login/freeGuard.guard.ts | 2 - login/loginGuard.guard.ts | 17 +- login/user.component.ts | 27 +- login/user.module.ts | 4 +- login/userMini.component.ts | 25 +- reload/reload-routing.module.ts | 3 +- reload/reload.module.ts | 3 +- .../role-verification.component.ts | 16 +- .../advancedSearchDataProviders.component.ts | 176 ----- .../advancedSearchDataProviders.module.ts | 28 - .../advancedSearchOrganizations.component.ts | 181 ----- .../advancedSearchOrganizations.module.ts | 28 - .../advancedSearchProjects.component.ts | 180 ----- .../advanced/advancedSearchProjects.module.ts | 28 - ...advancedSearchResearchResults.component.ts | 213 ------ .../advancedSearchResearchResults.module.ts | 27 - .../compatibleDataProviders.component.ts | 206 ------ .../compatibleDataProviders.module.ts | 27 - .../compatibleDataProvidersTable.component.ts | 262 ------- .../compatibleDataProvidersTable.module.ts | 26 - .../entityRegistries.component.ts | 196 ----- .../dataProviders/entityRegistries.module.ts | 25 - .../entityRegistriesTable.component.ts | 267 ------- .../entityRegistriesTable.module.ts | 24 - .../dataProviders/journals.component.ts | 200 ----- searchPages/dataProviders/journals.module.ts | 27 - .../dataProviders/journalsTable.component.ts | 222 ------ .../dataProviders/journalsTable.module.ts | 25 - searchPages/find/mainSearch.module.ts | 39 - searchPages/find/search.component.html | 297 -------- searchPages/find/search.component.ts | 469 ------------ searchPages/find/searchAll.component.ts | 9 +- searchPages/find/searchAll.module.ts | 3 +- searchPages/searchDataProviders.component.ts | 18 +- searchPages/searchDataProviders.module.ts | 4 +- searchPages/searchOrganizations.component.ts | 21 +- searchPages/searchOrganizations.module.ts | 3 +- searchPages/searchProjects.component.ts | 21 +- searchPages/searchProjects.module.ts | 4 +- searchPages/searchResearchResults.module.ts | 3 +- .../advancedSearchForm.component.ts | 11 +- .../advancedSearchPage.component.html | 87 --- .../advancedSearchPage.component.ts | 349 --------- .../searchUtils/advancedSearchPage.module.ts | 38 - .../searchUtils/browseEntities.component.ts | 18 +- .../searchUtils/browseStatistic.component.ts | 13 +- .../entitiesSelection.component.ts | 2 - .../searchUtils/newSearchPage.component.ts | 23 +- .../searchUtils/newSearchPage.module.ts | 3 +- .../searchUtils/no-load-paging.component.ts | 2 - .../portal-search-result.component.ts | 11 +- .../portal-search-result.module.ts | 4 +- .../searchUtils/quick-selections.component.ts | 4 +- .../searchDataproviderMap.component.ts | 55 -- .../searchDataproviderMap.module.ts | 24 - .../searchUtils/searchDownload.component.ts | 33 +- .../searchUtils/searchFilter.component.ts | 13 +- .../searchFilterModal.component.ts | 3 - .../searchUtils/searchPage.component.html | 252 ------- .../searchUtils/searchPage.component.ts | 682 ------------------ searchPages/searchUtils/searchPage.module.ts | 45 -- .../searchPageTableView.component.ts | 21 +- .../searchUtils/searchPageTableView.module.ts | 3 +- .../searchUtils/searchPaging.component.ts | 3 +- .../searchUtils/searchResult.component.ts | 9 +- searchPages/searchUtils/tabResult.module.ts | 1 - .../simple/searchDataProviders.module.ts | 32 - .../simple/searchDataproviders.component.ts | 392 ---------- .../simple/searchOrganizations.component.ts | 193 ----- .../simple/searchOrganizations.module.ts | 31 - .../simple/searchProjects.component.ts | 240 ------ searchPages/simple/searchProjects.module.ts | 32 - .../simple/searchResearchResults.component.ts | 252 ------- .../simple/searchResearchResults.module.ts | 28 - services/help-content.service.ts | 2 +- services/layout.service.ts | 1 - services/metrics.service.ts | 3 +- services/organization.service.ts | 3 +- services/refineFieldResults.service.ts | 3 +- services/reports.service.ts | 3 +- services/searchDataproviders.service.ts | 2 - services/searchOrganizations.service.ts | 2 - services/searchProjects.service.ts | 2 - services/searchResearchResults.service.ts | 6 +- services/user-management.service.ts | 25 +- sharedComponents/SEO/SEOService.module.ts | 4 +- sharedComponents/feedback/feedback.module.ts | 3 - sharedComponents/metaService.module.ts | 15 - sharedComponents/metaService.ts | 220 ------ sharedComponents/navigationBar.component.ts | 2 +- .../searchBar/searchBar.component.ts | 18 +- sharedComponents/sidebar/sideBar.component.ts | 14 +- test/test-routing.module.ts | 14 - test/test.component.ts | 60 -- test/test.module.ts | 19 - utils/configuration/configuration.service.ts | 18 +- .../configurationService.module.ts | 2 - utils/email/email.service.ts | 1 - .../entitiesAutoComplete.component.ts | 5 +- .../entitySearch.service.ts | 5 +- .../fetchDataproviders.class.ts | 68 +- .../fetchOrganizations.class.ts | 9 +- .../fetchProjects.class.ts | 43 +- .../fetchResearchResults.class.ts | 46 +- .../ISVocabularies.service.ts | 26 +- .../staticAutoComplete.component.ts | 2 +- 178 files changed, 833 insertions(+), 7753 deletions(-) delete mode 100644 app-routing.module.ts delete mode 100644 app.component.ts delete mode 100755 app.module.ts delete mode 100644 app.server.module.ts delete mode 100644 landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts delete mode 100644 landingPages/organization/organization-routing.module.ts delete mode 100644 searchPages/advanced/advancedSearchDataProviders.component.ts delete mode 100644 searchPages/advanced/advancedSearchDataProviders.module.ts delete mode 100644 searchPages/advanced/advancedSearchOrganizations.component.ts delete mode 100644 searchPages/advanced/advancedSearchOrganizations.module.ts delete mode 100644 searchPages/advanced/advancedSearchProjects.component.ts delete mode 100644 searchPages/advanced/advancedSearchProjects.module.ts delete mode 100644 searchPages/advanced/advancedSearchResearchResults.component.ts delete mode 100644 searchPages/advanced/advancedSearchResearchResults.module.ts delete mode 100644 searchPages/dataProviders/compatibleDataProviders.component.ts delete mode 100644 searchPages/dataProviders/compatibleDataProviders.module.ts delete mode 100644 searchPages/dataProviders/compatibleDataProvidersTable.component.ts delete mode 100644 searchPages/dataProviders/compatibleDataProvidersTable.module.ts delete mode 100644 searchPages/dataProviders/entityRegistries.component.ts delete mode 100644 searchPages/dataProviders/entityRegistries.module.ts delete mode 100644 searchPages/dataProviders/entityRegistriesTable.component.ts delete mode 100644 searchPages/dataProviders/entityRegistriesTable.module.ts delete mode 100644 searchPages/dataProviders/journals.component.ts delete mode 100644 searchPages/dataProviders/journals.module.ts delete mode 100644 searchPages/dataProviders/journalsTable.component.ts delete mode 100644 searchPages/dataProviders/journalsTable.module.ts delete mode 100644 searchPages/find/mainSearch.module.ts delete mode 100644 searchPages/find/search.component.html delete mode 100644 searchPages/find/search.component.ts delete mode 100644 searchPages/searchUtils/advancedSearchPage.component.html delete mode 100644 searchPages/searchUtils/advancedSearchPage.component.ts delete mode 100644 searchPages/searchUtils/advancedSearchPage.module.ts delete mode 100644 searchPages/searchUtils/searchDataproviderMap.component.ts delete mode 100644 searchPages/searchUtils/searchDataproviderMap.module.ts delete mode 100644 searchPages/searchUtils/searchPage.component.html delete mode 100644 searchPages/searchUtils/searchPage.component.ts delete mode 100644 searchPages/searchUtils/searchPage.module.ts delete mode 100644 searchPages/simple/searchDataProviders.module.ts delete mode 100644 searchPages/simple/searchDataproviders.component.ts delete mode 100644 searchPages/simple/searchOrganizations.component.ts delete mode 100644 searchPages/simple/searchOrganizations.module.ts delete mode 100644 searchPages/simple/searchProjects.component.ts delete mode 100644 searchPages/simple/searchProjects.module.ts delete mode 100644 searchPages/simple/searchResearchResults.component.ts delete mode 100644 searchPages/simple/searchResearchResults.module.ts delete mode 100644 sharedComponents/metaService.module.ts delete mode 100644 sharedComponents/metaService.ts delete mode 100644 test/test-routing.module.ts delete mode 100644 test/test.component.ts delete mode 100644 test/test.module.ts diff --git a/app-routing.module.ts b/app-routing.module.ts deleted file mode 100644 index 068943f6..00000000 --- a/app-routing.module.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; - -import {IsRouteEnabled} from './error/isRouteEnabled.guard'; - -import {EnvironmentSpecificResolver} from './utils/properties/environmentSpecificResolver'; -import { EnvironmentSpecificService } from './utils/properties/environment-specific.service'; - -import { ErrorPageComponent } from './error/errorPage.component'; -import {SearchComponent} from './searchPages/find/search.component'; - -import {ResultLandingComponent} from "./landingPages/result/resultLanding.component"; -import {DataProviderComponent} from './landingPages/dataProvider/dataProvider.component'; -import {ProjectComponent} from './landingPages/project/project.component'; -import {OrganizationComponent} from './landingPages/organization/organization.component'; - - -import {SearchResearchResultsComponent} from './searchPages/simple/searchResearchResults.component'; -import {SearchDataprovidersComponent} from './searchPages/simple/searchDataproviders.component'; -import {SearchProjectsComponent} from './searchPages/simple/searchProjects.component'; -import {SearchOrganizationsComponent} from './searchPages/simple/searchOrganizations.component'; - -import {AdvancedSearchResearchResultsComponent} from './searchPages/advanced/advancedSearchResearchResults.component'; -import {AdvancedSearchDataProvidersComponent} from './searchPages/advanced/advancedSearchDataProviders.component'; -import {AdvancedSearchProjectsComponent} from './searchPages/advanced/advancedSearchProjects.component'; -import {AdvancedSearchOrganizationsComponent} from './searchPages/advanced/advancedSearchOrganizations.component'; - -import {SearchEntityRegistriesComponent} from './searchPages/dataProviders/entityRegistries.component'; -import {SearchEntityRegistriesTableComponent} from './searchPages/dataProviders/entityRegistriesTable.component'; -import {SearchJournalsTableComponent} from './searchPages/dataProviders/journalsTable.component'; -import {SearchJournalsComponent} from './searchPages/dataProviders/journals.component'; -import {SearchCompatibleDataprovidersComponent} from './searchPages/dataProviders/compatibleDataProviders.component'; -import {SearchCompatibleDataprovidersTableComponent} from './searchPages/dataProviders/compatibleDataProvidersTable.component'; - -import {ClaimsAdminComponent} from './claims/claimsAdmin/claimsAdmin.component'; -import {MyClaimsComponent} from './claims/myClaims/myClaims.component'; - -import {ClaimsByTokenComponent} from './claims/claimsByToken/claimsByToken.component'; -import {DirectLinkingComponent} from './claims/directLinking/directLinking.component'; -import {LinkingGenericComponent} from './claims/linking/linkingGeneric.component'; - -import{ HtmlProjectReportComponent} from './landingPages/htmlProjectReport/htmlProjectReport.component'; - -const routes: Routes = [ - - { path: '', component: SearchComponent, resolve: { envSpecific: EnvironmentSpecificResolver }, canActivate: [ ]}, - { path: 'home', component: SearchComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/publication', component: ResultLandingComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/dataset', component: ResultLandingComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/software', component: ResultLandingComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/other', component: ResultLandingComponent, resolve: { envSpecific: EnvironmentSpecificResolver }}, - { path: 'search/project', component: ProjectComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/dataprovider', component: DataProviderComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/organization', component: OrganizationComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/find', component: SearchComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/find/publications', component: SearchResearchResultsComponent , resolve: { envSpecific: EnvironmentSpecificResolver }, canActivate: [ ] }, - { path: 'search/find/datasets', component:SearchResearchResultsComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/find/software', component:SearchResearchResultsComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/find/other', component:SearchResearchResultsComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/find/projects', component:SearchProjectsComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/find/dataproviders', component:SearchDataprovidersComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/find/organizations', component:SearchOrganizationsComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/content-providers', component: SearchCompatibleDataprovidersComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/content-providers-table', component: SearchCompatibleDataprovidersTableComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/entity-registries',component: SearchEntityRegistriesComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/entity-registries-table', component: SearchEntityRegistriesTableComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/journals', component: SearchJournalsComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/journals-table', component: SearchJournalsTableComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/advanced/publications', component: AdvancedSearchResearchResultsComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/advanced/datasets', component: AdvancedSearchResearchResultsComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/advanced/software', component: AdvancedSearchResearchResultsComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/advanced/other', component: AdvancedSearchResearchResultsComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/advanced/organizations',component: AdvancedSearchOrganizationsComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/advanced/dataproviders', component: AdvancedSearchDataProvidersComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'search/advanced/projects', component: AdvancedSearchProjectsComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'project-report', component: HtmlProjectReportComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'myclaims',component: MyClaimsComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'claims', component: ClaimsAdminComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'participate/claim', component: LinkingGenericComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'participate/direct-claim',component: DirectLinkingComponent, resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'claims-project-manager', component: ClaimsByTokenComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'reload', loadChildren: './reload/reload.module#ReloadModule' , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'user-info', loadChildren: './login/user.module#UserModule' , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: 'error', component: ErrorPageComponent , resolve: { envSpecific: EnvironmentSpecificResolver } }, - { path: '**',pathMatch: 'full',component: ErrorPageComponent } -]; - -@NgModule({ - imports: [RouterModule.forRoot(routes)], - exports: [RouterModule], - providers: [EnvironmentSpecificResolver, EnvironmentSpecificService, IsRouteEnabled] -}) -export class AppRoutingModule { } diff --git a/app.component.ts b/app.component.ts deleted file mode 100644 index 45389fc1..00000000 --- a/app.component.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { Component, Directive, ElementRef, Renderer2, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core'; -import { ConfigurationService } from './utils/configuration/configuration.service'; -import {Observable} from 'rxjs'; -import { EnvProperties } from './utils/properties/env-properties'; -import {ActivatedRoute} from '@angular/router'; -import{EnvironmentSpecificService} from './utils/properties/environment-specific.service'; -import{MenuItem,RootMenuItem} from './sharedComponents/menu'; - -@Component({ - //changeDetection: ChangeDetectionStrategy.Default, - //encapsulation: ViewEncapsulation.Emulated, - selector: 'app-root', - styles: [` - `], - template: ` - - -

Openaire Lib Component

- - - -
-
- - -
-
- - - - OpenAIRE uses cookies in order to function properly.
- Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing experience possible. - By using the OpenAIRE portal you accept our use of cookies. Read more - - -
- - -` - -}) -export class AppComponent { - isClient:boolean = false; - public properties:EnvProperties = null; - - constructor(private config: ConfigurationService, private route: ActivatedRoute, private propertiesService:EnvironmentSpecificService) { - } - - assetsPath = "assets/"; - userMenuItems:MenuItem[] = [ new MenuItem("","My profile","","",false,[],[],{}), - new MenuItem("","My claims","","/myclaims",false,[],["/myclaims"],{}), - new MenuItem("","Manage all claims","","/claims",true,[],["/claims"],{})] - - - menuItems:RootMenuItem [] = [ - {rootItem: new MenuItem("search","Search","","/search/find",false,[],["/search/find"],{}), - items: [new MenuItem("","Publications","","/search/find/publications",false,["publication"],["/search/find/publications"],{}), - new MenuItem("","Research Data","","/search/find/datasets",false,["dataset"],["/search/find/datasets"],{}), - new MenuItem("","Software","","/search/find/software",false,["software"],["/search/find/software"],{}), - new MenuItem("","Other Research Products","","/search/find/other",false,["orp"],["/search/find/other"],{}), - new MenuItem("","Projects","","/search/find/projects/",false,["project"],["/search/find/projects"],{}), - new MenuItem("","Content Providers","","/search/find/dataproviders",false,["datasource"],["/search/find/dataproviders"],{}), - new MenuItem("","Organizations","","/search/find/organizations/",false,["organization"],["/search/find/organizations"],{}) - ]}, - { - rootItem: new MenuItem("share","Share","","",false,[],["/participate/deposit-publications","/participate/deposit-datasets"],{}), - items: [new MenuItem("","Publications","","/participate/deposit-publications",false,["publication"],["/participate/deposit-publications"],{}), - new MenuItem("","Research Data","","/participate/deposit-datasets",false,["dataset"],["/participate/deposit-datasets"],{})] - }, - { - rootItem: new MenuItem("link","Link","","/participate/claim",false,[],["/participate/claim"],{}), - items: [] - }, - { - rootItem: new MenuItem("datasources","Content Providers","","",false,["datasource"],[],{}), - items: [new MenuItem("","Data Policies","https://beta.openaire.eu/oa-policies-mandates","",false,["datasource"],[],{}), - new MenuItem("","Repositories","","/search/content-providers",false,["datasource"],["/search/content-providers"],{}), - new MenuItem("","Journals","","/search/journals",false,["datasource"],["/search/journals"],{}), - new MenuItem("","Registries","","/search/entity-registries",false,["datasource"],["/search/entity-registries"],{}), - new MenuItem("","Browse all","","/search/find/dataproviders",false,["datasource"],["/search/find/dataproviders"],{})] - } - ]; - ngOnInit() { - - this.propertiesService.loadEnvironment() - .then(es => { - this.propertiesService.setEnvProperties(es); - this.properties = this.propertiesService.envSpecific; - }, error => { - console.log("App couldn't fetch properties"); - console.log(error); - - }); - if (typeof document !== 'undefined') { - try{ - this.isClient = true; - }catch (e) { - } - } - } - - - -} diff --git a/app.module.ts b/app.module.ts deleted file mode 100755 index 23d3ef0f..00000000 --- a/app.module.ts +++ /dev/null @@ -1,83 +0,0 @@ -import {NgModule} from '@angular/core'; -import {SharedModule} from './shared/shared.module'; -import {BrowserModule} from '@angular/platform-browser'; -import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {CommonModule} from '@angular/common'; -import {HttpClientModule} from '@angular/common/http'; -import {AppComponent} from './app.component'; -import {NavigationBarModule} from './sharedComponents/navigationBar.module'; -import {CookieLawModule} from './sharedComponents/cookie-law/cookie-law.module'; -import {BottomModule} from './sharedComponents/bottom.module'; -// import { ErrorModule } from './error/error.module'; -import {ConfigurationService} from './utils/configuration/configuration.service'; -import {MainSearchModule} from './searchPages/find/mainSearch.module'; - -import {ResultLandingModule} from "./landingPages/result/resultLanding.module"; -import {DataProviderModule} from './landingPages/dataProvider/dataProvider.module'; -import {ProjectModule} from './landingPages/project/project.module'; -import {OrganizationModule} from './landingPages/organization/organization.module'; -import {ErrorModule} from './error/error.module'; - -import {SearchResearchResultsModule} from './searchPages/simple/searchResearchResults.module'; -import {SearchDataProvidersModule} from './searchPages/simple/searchDataProviders.module'; -import {SearchProjectsModule} from './searchPages/simple/searchProjects.module'; -import {SearchOrganizationsModule} from './searchPages/simple/searchOrganizations.module'; - -import {AdvancedSearchResearchResultsModule} from './searchPages/advanced/advancedSearchResearchResults.module'; -import {AdvancedSearchDataProvidersModule} from './searchPages/advanced/advancedSearchDataProviders.module'; -import {AdvancedSearchProjectsModule} from './searchPages/advanced/advancedSearchProjects.module'; -import {AdvancedSearchOrganizationsModule} from './searchPages/advanced/advancedSearchOrganizations.module'; - -import {EntityRegistriesModule} from './searchPages/dataProviders/entityRegistries.module'; -import {EntityRegistriesTableModule} from './searchPages/dataProviders/entityRegistriesTable.module'; - -import {JournalsTableModule} from './searchPages/dataProviders/journalsTable.module'; -import {JournalsModule} from './searchPages/dataProviders/journals.module'; - - -import {CompatibleDataProvidersModule} from './searchPages/dataProviders/compatibleDataProviders.module'; -import {CompatibleDataProvidersTableModule} from './searchPages/dataProviders/compatibleDataProvidersTable.module'; - -import {ClaimsAdminModule} from './claims/claimsAdmin/claimsAdmin.module'; -import {MyClaimsModule} from './claims/myClaims/myClaims.module'; -import {ClaimsByTokenModule} from './claims/claimsByToken/claimsByToken.module'; -import {DirectLinkingModule} from './claims/directLinking/directLinking.module'; -import {LinkingGenericModule} from './claims/linking/linkingGeneric.module'; - -import {HtmlProjectReportModule} from './landingPages/htmlProjectReport/htmlProjectReport.module'; -import {AppRoutingModule} from './app-routing.module'; - -@NgModule({ - - imports: [ - SharedModule, - NoopAnimationsModule, - CommonModule, - CookieLawModule, - BottomModule, - HttpClientModule, - NavigationBarModule, - MainSearchModule, - ErrorModule, - SearchResearchResultsModule, SearchDataProvidersModule, SearchProjectsModule, SearchOrganizationsModule, - AdvancedSearchResearchResultsModule, AdvancedSearchDataProvidersModule, AdvancedSearchProjectsModule, AdvancedSearchOrganizationsModule, - ResultLandingModule, DataProviderModule, OrganizationModule, ProjectModule, - EntityRegistriesModule, CompatibleDataProvidersModule, JournalsModule, - JournalsTableModule, EntityRegistriesTableModule, CompatibleDataProvidersTableModule, - ClaimsAdminModule, MyClaimsModule, ClaimsByTokenModule, LinkingGenericModule, DirectLinkingModule, - HtmlProjectReportModule, - BrowserModule.withServerTransition({appId: 'my-app'}), - AppRoutingModule - ], - declarations: [ AppComponent ], - exports: [ AppComponent ], - providers:[ ConfigurationService], - bootstrap: [AppComponent] -}) -export class AppModule {} -/* - -, canActivate: [ IsRouteEnabled], data: { - redirect: '/error' -} -*/ diff --git a/app.server.module.ts b/app.server.module.ts deleted file mode 100644 index 79602ec8..00000000 --- a/app.server.module.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {NgModule} from '@angular/core'; -import {ServerModule} from '@angular/platform-server'; -import {ModuleMapLoaderModule} from '@nguniversal/module-map-ngfactory-loader'; - -import {AppModule} from './app.module'; -import {AppComponent} from './app.component'; - -@NgModule({ - imports: [ - // The AppServerModule should import your AppModule followed - // by the ServerModule from @angular/platform-server. - AppModule, - ServerModule, - ModuleMapLoaderModule, - ], - // Since the bootstrapped component is not inherited from your - // imported AppModule, it needs to be repeated here. - bootstrap: [AppComponent], -}) -export class AppServerModule {} diff --git a/claims/claim-utils/claimContextSearchForm.component.ts b/claims/claim-utils/claimContextSearchForm.component.ts index 7fc318d8..3990df87 100644 --- a/claims/claim-utils/claimContextSearchForm.component.ts +++ b/claims/claim-utils/claimContextSearchForm.component.ts @@ -1,10 +1,11 @@ import {Component, Input} from '@angular/core'; import {Router} from '@angular/router'; import {ContextsService} from './service/contexts.service'; -import {ClaimContext, ClaimEntity} from './claimHelper.class'; +import {ClaimEntity} from './claimHelper.class'; import {Session} from '../../login/utils/helper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {EnvProperties} from '../../utils/properties/env-properties'; +import {Subscriber} from "rxjs"; declare var UIkit: any; @@ -39,11 +40,17 @@ export class ClaimContextSearchFormComponent { @Input() localStoragePrefix: string = ""; keyword = ""; - + subscriptions = []; ngOnInit() { this.getCommunities(); } - + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); + } constructor(private _contextService: ContextsService, private router: Router) { } @@ -114,7 +121,7 @@ export class ClaimContextSearchFormComponent { } else { this.loading = true; - this._contextService.getPublicCommunitiesByState().subscribe( + this.subscriptions.push(this._contextService.getPublicCommunitiesByState().subscribe( data => { this.communities = data; if (this.communities.length > 0) { @@ -143,7 +150,7 @@ export class ClaimContextSearchFormComponent { this.loading = false; this.error = true; } - ); + )); } } @@ -160,7 +167,7 @@ export class ClaimContextSearchFormComponent { this.loading = false; return; } - this._contextService.getCategories(this.selectedCommunityId, this.properties.contextsAPI).subscribe( + this.subscriptions.push(this._contextService.getCategories(this.selectedCommunityId, this.properties.contextsAPI).subscribe( data => { this.categories[this.selectedCommunityId] = data; @@ -176,7 +183,7 @@ export class ClaimContextSearchFormComponent { ClaimContextSearchFormComponent.handleError("Error getting categories for community with id: " + this.selectedCommunityId, err); this.loading = false; } - ); + )); } } } @@ -272,7 +279,7 @@ export class ClaimContextSearchFormComponent { } this.conceptsClass[categoryId] = []; this.conceptsCategoryLoading[categoryId] = true; - this._contextService.getConcepts(categoryId, "", false, this.properties.contextsAPI).subscribe( + this.subscriptions.push(this._contextService.getConcepts(categoryId, "", false, this.properties.contextsAPI).subscribe( data => { // var concepts = data; this.conceptsClass[categoryId] = []; @@ -290,7 +297,7 @@ export class ClaimContextSearchFormComponent { ClaimContextSearchFormComponent.handleError("Error getting concepts for category with id: " + this.selectedCategoryId, err); this.conceptsCategoryLoading[categoryId] = false; } - ); + )); } } @@ -298,7 +305,7 @@ export class ClaimContextSearchFormComponent { browseSubConcepts(categoryId, conceptId) { this.conceptsCategoryLoading[categoryId] = true; - this._contextService.getSubConcepts(conceptId, "", false, this.properties.contextsAPI).subscribe( + this.subscriptions.push(this._contextService.getSubConcepts(conceptId, "", false, this.properties.contextsAPI).subscribe( data => { const concepts = data[0]; this.conceptsClass[categoryId].push(concepts); @@ -309,7 +316,7 @@ export class ClaimContextSearchFormComponent { ClaimContextSearchFormComponent.handleError("Error getting subconcepts for concept with id: " + conceptId, err); this.conceptsCategoryLoading[categoryId] = false; } - ); + )); } diff --git a/claims/claim-utils/claimProjectSearchForm.component.ts b/claims/claim-utils/claimProjectSearchForm.component.ts index e5442576..6ed5616d 100644 --- a/claims/claim-utils/claimProjectSearchForm.component.ts +++ b/claims/claim-utils/claimProjectSearchForm.component.ts @@ -9,6 +9,7 @@ import {Filter, Value} from "../../searchPages/searchUtils/searchHelperClasses.c import {RangeFilter} from "../../utils/rangeFilter/rangeFilterHelperClasses.class"; import {SearchFields} from "../../utils/properties/searchFields"; import {NewSearchPageComponent} from "../../searchPages/searchUtils/newSearchPage.component"; +import {Subscriber} from "rxjs"; declare var UIkit:any; @@ -67,7 +68,12 @@ export class ClaimProjectsSearchFormComponent { this.rangeFilters = RangeFilter.parse(this.rangeFields,"project"); } - + sub; + ngOnDestroy() { + if (this.sub instanceof Subscriber) { + this.sub.unsubscribe(); + } + } search(page,size) { if(this.keyword.length == 0){ @@ -80,7 +86,7 @@ export class ClaimProjectsSearchFormComponent { this.prevFilters = this.filters; //searchProjects (params: string, refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties ):any { - this._projectService.searchProjects(this.createOpenaireQueryParams(),(page==1)? this.refineFieldsQuery:null, page, size, (page==1)?this.refineFields:[], this.properties).subscribe( + this.sub = this._projectService.searchProjects(this.createOpenaireQueryParams(),(page==1)? this.refineFieldsQuery:null, page, size, (page==1)?this.refineFields:[], this.properties).subscribe( data => { if(data != null) { this.openaireResultsPage=page; diff --git a/claims/claim-utils/claimResultSearchForm.component.ts b/claims/claim-utils/claimResultSearchForm.component.ts index e4e7d525..7937e625 100644 --- a/claims/claim-utils/claimResultSearchForm.component.ts +++ b/claims/claim-utils/claimResultSearchForm.component.ts @@ -8,11 +8,10 @@ import {ClaimEntity, ClaimResult} from './claimHelper.class'; import {DOI, StringUtils} from '../../utils/string-utils.class'; import {EnvProperties} from '../../utils/properties/env-properties'; import {Filter, Value} from "../../searchPages/searchUtils/searchHelperClasses.class"; -import {Observable, forkJoin} from "rxjs"; +import {Observable, Subscriber} from "rxjs"; import 'rxjs/add/observable/forkJoin' import {NewSearchPageComponent} from "../../searchPages/searchUtils/newSearchPage.component"; import {RangeFilter} from "../../utils/rangeFilter/rangeFilterHelperClasses.class"; -import {SearchUtilsClass} from "../../searchPages/searchUtils/searchUtils.class"; import {SearchFields} from "../../utils/properties/searchFields"; @Component({ selector: 'claim-result-search-form', @@ -122,7 +121,14 @@ export class ClaimResultSearchFormComponent { this.search(false); } } - + subscriptions = []; + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); + } search(keywordChanged) { //uncomment to disable search with no keyword if (this.keyword.length == 0) { @@ -187,14 +193,14 @@ export class ClaimResultSearchFormComponent { this.crossrefStatus = this.errorCodes.LOADING; // this.crossrefResultsNum = null; if (this.DOIs.length > 0) { - this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs, this.properties, true).subscribe( + this.subscriptions.push(this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs, this.properties, true).subscribe( data => { if (data != null) { this.crossrefResults = data[1]; this.crossrefPage = page; this.crossrefResultsNum = data[0]; if (this.crossrefResultsNum == 0) { - this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( + this.subscriptions.push(this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( data => { if (data != null) { this.crossrefResults = data[1]; @@ -215,7 +221,7 @@ export class ClaimResultSearchFormComponent { ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err); this.crossrefStatus = this.errorCodes.ERROR; } - ); + )); } else { this.crossrefStatus = this.errorCodes.DONE; } @@ -224,7 +230,7 @@ export class ClaimResultSearchFormComponent { err => { ClaimResultSearchFormComponent.handleError("Error getting crossref by DOIs: " + JSON.stringify(this.DOIs), err); - this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( + this.subscriptions.push(this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( data => { this.crossrefResults = data[1]; this.crossrefPage = page; @@ -237,14 +243,14 @@ export class ClaimResultSearchFormComponent { ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err); this.crossrefStatus = this.errorCodes.ERROR; } - ); + )); } - ); + )); } else { - this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( + this.subscriptions.push(this._searchCrossrefService.searchCrossrefResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( data => { if (data != null) { this.crossrefResults = data[1]; @@ -264,7 +270,7 @@ export class ClaimResultSearchFormComponent { ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err); this.crossrefStatus = this.errorCodes.ERROR; } - ); + )); } } @@ -294,14 +300,14 @@ export class ClaimResultSearchFormComponent { this.openaireResultsStatus = this.errorCodes.LOADING; this.openaireResultsPrevFilters = this.openaireResultsfilters; this.openaireResultsNum = 0; - this._searchResearchResultsService.advancedSearchResults('publication', this.createOpenaireQueryParams(), page, size, null, this.properties, this.createOpenaireRefineQueryParams(), (page==1 ?this.openaireRefineFields:[]), (page==1 ?this.openaireRefineFieldsQuery:null)).subscribe( + this.subscriptions.push(this._searchResearchResultsService.advancedSearchResults('publication', this.createOpenaireQueryParams(), page, size, null, this.properties, this.createOpenaireRefineQueryParams(), (page==1 ?this.openaireRefineFields:[]), (page==1 ?this.openaireRefineFieldsQuery:null)).subscribe( data => { this.setOpenaireResults(data, mainResults, page, type); }, err => { this.setOpenaireResultsError(mainResults, term, err); } - ); + )); } public setOpenaireResults(data, mainResults: boolean, page, type) { @@ -379,7 +385,7 @@ export class ClaimResultSearchFormComponent { private getOrcidAuthor(term: string, addId) { this.orcidResultsNum = null; //passing structures in order to fill them in service - this._searchOrcidService.searchOrcidAuthor(StringUtils.URIEncode(term.replace(/\s/g, "")), this.authorIds, + this.subscriptions.push(this._searchOrcidService.searchOrcidAuthor(StringUtils.URIEncode(term.replace(/\s/g, "")), this.authorIds, this.authors, this.properties, addId).subscribe( data => { if (data != null && data == true && addId) { @@ -391,7 +397,7 @@ export class ClaimResultSearchFormComponent { }, err => this.errorHandler(err, term) - ); + )); } private errorHandler(err: any, term: string) { @@ -409,7 +415,7 @@ export class ClaimResultSearchFormComponent { this.selectAuthorId = "0"; this.orcidStatus = this.errorCodes.LOADING; //passing structures in order to fill them in service - this._searchOrcidService.searchOrcidAuthors(StringUtils.URIEncode(term), this.properties).subscribe( + this.subscriptions.push(this._searchOrcidService.searchOrcidAuthors(StringUtils.URIEncode(term), this.properties).subscribe( data => { this.authorIds = data; if (data != null) { @@ -430,7 +436,7 @@ export class ClaimResultSearchFormComponent { //console.log(err.status); ClaimResultSearchFormComponent.handleError("Error getting orcid authors for term: " + term + " and ids: " + JSON.stringify(this.authorIds), err); } - ); + )); } @@ -447,7 +453,7 @@ export class ClaimResultSearchFormComponent { this.authorFamilyName = this.authors[index].authorFamilyName; this.authorId = this.authors[index].id; this.orcidStatus = this.errorCodes.LOADING; - this._searchOrcidService.searchOrcidPublications(this.authors[index].id, this.properties, true).subscribe( + this.subscriptions.push(this._searchOrcidService.searchOrcidPublications(this.authors[index].id, this.properties, true).subscribe( data => { if (data != null) { this.orcidResults = data; @@ -487,7 +493,7 @@ export class ClaimResultSearchFormComponent { ClaimResultSearchFormComponent.handleError("Error getting orcid publications for author id: " + this.authors[index].id, err); this.orcidStatus = this.errorCodes.ERROR; } - ); + )); } @@ -495,7 +501,7 @@ export class ClaimResultSearchFormComponent { private enhanceInfoFromDOI(entity: ClaimEntity) { if (entity.result.DOI != null) { - this._searchCrossrefService.searchCrossrefByDOIs([entity.result.DOI], this.properties, true).subscribe( + this.subscriptions.push(this._searchCrossrefService.searchCrossrefByDOIs([entity.result.DOI], this.properties, true).subscribe( data => { if (data != null && data[0] > 0 && data[1]) { let crossrefResult: ClaimEntity = data[1][0]; @@ -524,7 +530,7 @@ export class ClaimResultSearchFormComponent { err => { ClaimResultSearchFormComponent.handleError("Error getting crossref by DOIs: " + entity['DOI'], err); } - ); + )); } } @@ -683,7 +689,7 @@ export class ClaimResultSearchFormComponent { doiObservables.push(ob); } - Observable.forkJoin(doiObservables).subscribe( + this.subscriptions.push(Observable.forkJoin(doiObservables).subscribe( data => { //if DOI not found or an error occured the result will be null -- remove null values for(let result of data){ @@ -695,7 +701,7 @@ export class ClaimResultSearchFormComponent { this.dataciteResultsNum = this.dataciteResults.length; this.dataciteStatus = this.errorCodes.DONE; if (this.dataciteResultsNum == 0) { - this._searchDataciteService.searchDataciteResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( + this.subscriptions.push(this._searchDataciteService.searchDataciteResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( data => { this.dataciteResults = data[1]; this.datacitePage = page; @@ -712,15 +718,15 @@ export class ClaimResultSearchFormComponent { console.log(err); ClaimResultSearchFormComponent.handleError("Error getting datacite results for term: " + term, err); - }); + })); } } - ); + )); } else { - this._searchDataciteService.searchDataciteResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( + this.subscriptions.push(this._searchDataciteService.searchDataciteResults(StringUtils.URIEncode(term), size, page, this.properties, true).subscribe( data => { this.dataciteResults = data[1]; this.datacitePage = page; @@ -737,7 +743,7 @@ export class ClaimResultSearchFormComponent { //console.log(err); ClaimResultSearchFormComponent.handleError("Error getting datacite results for term: " + term, err); } - ); + )); } } diff --git a/claims/claim-utils/claimResults.component.ts b/claims/claim-utils/claimResults.component.ts index 24b0aa20..17ba2af1 100644 --- a/claims/claim-utils/claimResults.component.ts +++ b/claims/claim-utils/claimResults.component.ts @@ -1,6 +1,5 @@ import {Component, Input} from '@angular/core'; import {ClaimEntity} from './claimHelper.class'; -import {HelperFunctions} from "../../utils/HelperFunctions.class"; declare var UIkit: any; diff --git a/claims/claim-utils/displayClaims/displayClaims.component.ts b/claims/claim-utils/displayClaims/displayClaims.component.ts index 65ae41bb..6ec135dd 100644 --- a/claims/claim-utils/displayClaims/displayClaims.component.ts +++ b/claims/claim-utils/displayClaims/displayClaims.component.ts @@ -1,7 +1,7 @@ import {Component, Input, ViewChild} from '@angular/core'; import {Location} from '@angular/common'; import {ActivatedRoute, Router} from '@angular/router'; -import {Subject} from 'rxjs'; +import {Subject, Subscriber} from 'rxjs'; import {debounceTime, distinctUntilChanged} from 'rxjs/operators'; import {ClaimsService} from '../service/claims.service'; import {ModalLoading} from '../../../utils/modal/loading.component'; @@ -28,11 +28,9 @@ import {properties} from "../../../../../environments/environment"; export class DisplayClaimsComponent { @Input() piwikSiteId = null; @Input() title: string = ""; - piwiksub: any; - properties: EnvProperties; public searchTermStream = new Subject(); - sub: any; + subscriptions: any = []; //string because comes as input from component directive @Input() enableDelete: boolean = false; @Input() showUserEmail: boolean = true; @@ -99,16 +97,16 @@ export class DisplayClaimsComponent { this.updateDescription(description); this.updateUrl(this.url); if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { - this.piwiksub = this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe()); } - this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.pageContents = contents; - }); - this.indexInfoService.getLastIndexDate(this.properties).subscribe(res => { + })); + this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(res => { this.lastIndexDate = res; - }); - this.sub = this.route.queryParams.subscribe(params => { + })); + this.subscriptions.push(this.route.queryParams.subscribe(params => { this.seoService.createLinkForCanonicalURL(this.url, false); if (this.myClaims) { @@ -133,26 +131,26 @@ export class DisplayClaimsComponent { this.setTypes(params['types']); // check the appropriate checkboxes this.setSortby(params['sort']); this.getClaims(); - this.searchTermStream + this.subscriptions.push(this.searchTermStream .pipe(debounceTime(300), distinctUntilChanged()) .subscribe((term: string) => { this.keyword = term; this.page = 1; this.goTo(); - }); + })); - }); + })); } ngOnDestroy() { - this.sub.unsubscribe(); - if (this.piwiksub) { - this.piwiksub.unsubscribe(); - } - //this.searchTermStreamSub.unsubscribe(); + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } getClaims() { @@ -174,7 +172,7 @@ export class DisplayClaimsComponent { } this.pageLoading = true; if (this.fetchBy == "Project") { - this._claimService.getClaimsByProject(this.size, this.page, this.fetchId, this.keyword, this.sortby, this.descending, types, this.properties.claimsAPIURL).subscribe( + this.subscriptions.push(this._claimService.getClaimsByProject(this.size, this.page, this.fetchId, this.keyword, this.sortby, this.descending, types, this.properties.claimsAPIURL).subscribe( data => { this.manageAPIData(data); this.pageLoading = false; @@ -182,9 +180,9 @@ export class DisplayClaimsComponent { err => { this.handleErrors(err, "Error getting claims for project with id: " + this.fetchId); } - ); + )); } else if (this.fetchBy == "User") { - this._claimService.getClaimsByUser(this.size, this.page, this.fetchId, this.keyword, this.sortby, this.descending, types, this.properties.claimsAPIURL).subscribe( + this.subscriptions.push(this._claimService.getClaimsByUser(this.size, this.page, this.fetchId, this.keyword, this.sortby, this.descending, types, this.properties.claimsAPIURL).subscribe( data => { this.manageAPIData(data); this.pageLoading = false; @@ -193,9 +191,9 @@ export class DisplayClaimsComponent { this.handleErrors(err, "Error getting claims for user with id: " + this.fetchId); this.pageLoading = false; } - ); + )); } else if (this.fetchBy == "Result") { - this._claimService.getClaimsByResult(this.size, this.page, this.fetchId, this.keyword, this.sortby, this.descending, types, this.properties.claimsAPIURL).subscribe( + this.subscriptions.push(this._claimService.getClaimsByResult(this.size, this.page, this.fetchId, this.keyword, this.sortby, this.descending, types, this.properties.claimsAPIURL).subscribe( data => { this.manageAPIData(data); this.pageLoading = false; @@ -204,9 +202,9 @@ export class DisplayClaimsComponent { this.handleErrors(err, "Error getting claims for entity with id: " + this.fetchId); this.pageLoading = false; } - ); + )); } else if (this.fetchBy == "Context") { - this._claimService.getClaimsBycontext(this.size, this.page, this.fetchId, this.keyword, this.sortby, this.descending, types, this.properties.claimsAPIURL).subscribe( + this.subscriptions.push(this._claimService.getClaimsBycontext(this.size, this.page, this.fetchId, this.keyword, this.sortby, this.descending, types, this.properties.claimsAPIURL).subscribe( data => { this.manageAPIData(data); this.pageLoading = false; @@ -215,9 +213,9 @@ export class DisplayClaimsComponent { this.handleErrors(err, "Error getting claims for context with id: " + this.fetchId); this.pageLoading = false; } - ); + )); } else { - this._claimService.getClaims(this.size, this.page, this.keyword, this.sortby, this.descending, types, this.properties.claimsAPIURL).subscribe( + this.subscriptions.push(this._claimService.getClaims(this.size, this.page, this.keyword, this.sortby, this.descending, types, this.properties.claimsAPIURL).subscribe( data => { this.manageAPIData(data); this.pageLoading = false; @@ -226,7 +224,7 @@ export class DisplayClaimsComponent { this.handleErrors(err, "Error getting claims"); this.pageLoading = false; } - ); + )); } } } @@ -547,7 +545,7 @@ export class DisplayClaimsComponent { }); } else { //console.warn("Deleting claim with ids:"+ids); - this._claimService.deleteBulk(ids, this.properties.claimsAPIURL).subscribe( + this.subscriptions.push(this._claimService.deleteBulk(ids, this.properties.claimsAPIURL).subscribe( res => { //console.info('Delete response'+res.code ); //console.warn("Deleted ids:"+ res.deletedIds); @@ -588,7 +586,7 @@ export class DisplayClaimsComponent { this.showErrorMessage = true; this.loading.close(); - }); + })); } } diff --git a/claims/claim-utils/entityFormatter/claimEntityFormatter.module.ts b/claims/claim-utils/entityFormatter/claimEntityFormatter.module.ts index 01a1d0ac..620c7f1b 100644 --- a/claims/claim-utils/entityFormatter/claimEntityFormatter.module.ts +++ b/claims/claim-utils/entityFormatter/claimEntityFormatter.module.ts @@ -1,6 +1,5 @@ import { NgModule} from '@angular/core'; import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; import {ProjectTitleFormatter} from './projectTitleFormatter.component'; diff --git a/claims/claim-utils/service/contexts.service.ts b/claims/claim-utils/service/contexts.service.ts index 1e2d0266..bac39660 100644 --- a/claims/claim-utils/service/contexts.service.ts +++ b/claims/claim-utils/service/contexts.service.ts @@ -57,6 +57,9 @@ export class ContextsService { } await this.promise; + if(this.sub){ + this.sub.unsubscribe(); + } if(getAll) { return this.communitiesSubject.getValue(); } else { @@ -102,7 +105,7 @@ export class ContextsService { .pipe(map(res => (parsing)?this.parse(res):res)); } public getSubConcepts(subConceptID :string, keyword: string, parsing:boolean, apiUrl:string):any { - //console.info('ContextsService: request sub concept for concept with id '+subConceptID + ' and keyword '+ keyword); + //console.info('ContextsService: request subscriptions concept for concept with id '+subConceptID + ' and keyword '+ keyword); let url= apiUrl + '/category/concept/' + subConceptID; let key = url+"_parsing="+parsing; diff --git a/claims/claim-utils/startOver.component.ts b/claims/claim-utils/startOver.component.ts index e177391f..a0dca454 100644 --- a/claims/claim-utils/startOver.component.ts +++ b/claims/claim-utils/startOver.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core'; +import {Component, Input, ViewChild} from '@angular/core'; import {AlertModal} from '../../utils/modal/alert'; diff --git a/claims/claimsAdmin/claimsAdmin.component.ts b/claims/claimsAdmin/claimsAdmin.component.ts index a7db85ef..4069af44 100644 --- a/claims/claimsAdmin/claimsAdmin.component.ts +++ b/claims/claimsAdmin/claimsAdmin.component.ts @@ -1,9 +1,10 @@ import {Component, Input} from '@angular/core'; import {Title, Meta} from '@angular/platform-browser'; -import {Session, User} from "../../login/utils/helper.class"; +import {User} from "../../login/utils/helper.class"; import {UserManagementService} from "../../services/user-management.service"; import {LoginErrorCodes} from "../../login/utils/guardHelper.class"; import {Router} from "@angular/router"; +import {Subscriber} from "rxjs"; @Component({ @@ -45,7 +46,7 @@ export class ClaimsAdminComponent { @Input() claimsInfoURL: string; @Input() userInfoURL: string; public user: User = null; - + sub; constructor(private _meta: Meta, private _title: Title, private userManagementService: UserManagementService, private _router: Router) { var titleConnect = "OpenAIRE Connect | Manage links "; @@ -59,9 +60,13 @@ export class ClaimsAdminComponent { } - + ngOnDestroy() { + if (this.sub instanceof Subscriber) { + this.sub.unsubscribe(); + } + } ngOnInit() { - this.userManagementService.getUserInfo().subscribe(user => { + this.sub = this.userManagementService.getUserInfo().subscribe(user => { this.user = user; if (!user) { this._router.navigate(['/user-info'], { diff --git a/claims/claimsByToken/claimsByToken.component.ts b/claims/claimsByToken/claimsByToken.component.ts index c682cb0f..c104bc2f 100644 --- a/claims/claimsByToken/claimsByToken.component.ts +++ b/claims/claimsByToken/claimsByToken.component.ts @@ -1,17 +1,13 @@ -import {Component, ViewChild, ViewChildren, QueryList, Input, ViewEncapsulation} from '@angular/core'; -import {Location} from '@angular/common'; +import {Component, ViewChild, ViewChildren, QueryList, ViewEncapsulation} from '@angular/core'; import {ActivatedRoute, Params, Router} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; import {DataTableDirective} from 'angular-datatables'; -import {Observable, Subject } from 'rxjs'; +import {Subject, Subscriber} from 'rxjs'; import{EnvProperties} from '../../utils/properties/env-properties'; import {ErrorCodes} from '../../utils/properties/errorCodes'; import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; - -import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe'; - import {RouterHelper} from '../../utils/routerHelper.class'; import {ModalSelect} from '../../utils/modal/selectModal.component'; @@ -39,7 +35,7 @@ import {properties} from "../../../../environments/environment"; }) export class ClaimsByTokenComponent { public openaireId: string = ""; - public sub: any; + public subscriptions: any =[]; public project: any; private claims:any = []; public pending_claims: any = []; @@ -96,7 +92,7 @@ export class ClaimsByTokenComponent { this.curated_status = this.errorCodes.LOADING; } ngOnInit() { - this.sub = this.route.queryParams.subscribe(params => { + this.subscriptions.push(this.route.queryParams.subscribe(params => { this.mode = "pending"; this.openaireId = params['openaireId']; this.selectedRight_PendingMode = new Set(); @@ -107,7 +103,7 @@ export class ClaimsByTokenComponent { this.validateJWTandToken(); this.updateTitle("Claims For Project Managers"); } - ); + )); this.dtOptions[0] = { //"paging": false, @@ -161,6 +157,11 @@ export class ClaimsByTokenComponent { // Do not forget to unsubscribe the event this.dtTrigger[0].unsubscribe(); this.dtTrigger[1].unsubscribe(); + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } /* @@ -272,7 +273,7 @@ export class ClaimsByTokenComponent { this.activeCuratedPage.page = 1; this.totalCuratedResults.count = 0; - this.claimsByTokenService.getClaims(this.openaireId, this.properties.claimsAPIURL).subscribe( + this.subscriptions.push(this.claimsByTokenService.getClaims(this.openaireId, this.properties.claimsAPIURL).subscribe( data => { //this.closeLoading(); this.accessStatus = "valid"; @@ -347,7 +348,7 @@ export class ClaimsByTokenComponent { this.accessStatus = "invalid"; //console.log(err); } - ); + )); } else { this.accessStatus = "invalid"; } @@ -463,7 +464,7 @@ export class ClaimsByTokenComponent { } else { let claimCurationInfo: {"id": string, "approved": boolean} = {"id": claim.id, "approved": approved}; - this.claimsByTokenService.updateClaimCuration(claimCurationInfo, this.properties.claimsAPIURL).subscribe( + this.subscriptions.push(this.claimsByTokenService.updateClaimCuration(claimCurationInfo, this.properties.claimsAPIURL).subscribe( data => { this.selectedRight_CuratedMode.delete(claim.id); this.selectedWrong_CuratedMode.delete(claim.id); @@ -476,7 +477,7 @@ export class ClaimsByTokenComponent { this.handleError("Error updating claim curation: "+JSON.stringify(claimCurationInfo), err); this.curated_status = this.errorCodes.NOT_SAVED; } - ); + )); } } } @@ -488,7 +489,7 @@ export class ClaimsByTokenComponent { this.pending_status = this.errorCodes.LOADING; //this.openLoading(); //console.info("Changes Saved!, right-wrong", this.selectedRight_PendingMode, this.selectedWrong_PendingMode); - this.claimsByTokenService.updateClaimsCuration(this.selectedRight_PendingMode, this.selectedWrong_PendingMode, this.properties.claimsAPIURL).subscribe( + this.subscriptions.push(this.claimsByTokenService.updateClaimsCuration(this.selectedRight_PendingMode, this.selectedWrong_PendingMode, this.properties.claimsAPIURL).subscribe( data => { //this.closeLoading(); this.mode = "curated"; @@ -501,7 +502,7 @@ export class ClaimsByTokenComponent { this.handleError("Error updating claims: right: "+JSON.stringify(this.selectedRight_PendingMode)+" and wrong: "+JSON.stringify(this.selectedWrong_PendingMode), err); this.pending_status = this.errorCodes.NOT_SAVED; } - ); + )); } } diff --git a/claims/claimsByToken/claimsByToken.service.ts b/claims/claimsByToken/claimsByToken.service.ts index 8b90b72a..4414065e 100644 --- a/claims/claimsByToken/claimsByToken.service.ts +++ b/claims/claimsByToken/claimsByToken.service.ts @@ -1,6 +1,5 @@ import {Injectable} from '@angular/core'; -import {RequestOptions, Headers} from '@angular/http'; -import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http"; +import {HttpClient, HttpErrorResponse} from "@angular/common/http"; import {throwError} from 'rxjs'; diff --git a/claims/directLinking/directLinking.component.ts b/claims/directLinking/directLinking.component.ts index 21b0da30..8ffbd085 100644 --- a/claims/directLinking/directLinking.component.ts +++ b/claims/directLinking/directLinking.component.ts @@ -1,13 +1,12 @@ import {Component, Input, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; -import {Meta, Title} from '@angular/platform-browser'; - import {EnvProperties} from '../../utils/properties/env-properties'; import {ClaimEntity, ClaimProject, ShowOptions} from '../claim-utils/claimHelper.class'; import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service'; import {SearchResearchResultsService} from '../../services/searchResearchResults.service'; import {LinkingGenericComponent} from "../linking/linkingGeneric.component"; import {ClaimResultSearchFormComponent} from "../claim-utils/claimResultSearchForm.component"; +import {Subscriber} from "rxjs"; @Component({ @@ -31,21 +30,27 @@ export class DirectLinkingComponent { validEntityTypes = ["dataset", "publication", "software", "orp", "project", "context"]; sources: ClaimEntity[] = []; inlineEntity: ClaimEntity = null; - sub: any = null; validInput: boolean = null;//'true; properties: EnvProperties; @Input() communityId: string = null; localStoragePrefix: string = ""; constructor(private _router: Router, private route: ActivatedRoute,private entitySearch:EntitiesSearchService, private _searchResearchResultsService: SearchResearchResultsService) {} - + subscriptions = []; + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); + } ngOnInit() { - this.route.data + this.subscriptions.push(this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; - }); + })); - this.sub = this.route.queryParams.subscribe(params => { + this.subscriptions.push(this.route.queryParams.subscribe(params => { this.id = params['id']; this.type = params['type']; this.showOptions.linkTo = params['linkTo']; @@ -104,7 +109,7 @@ export class DirectLinkingComponent { } - }); + })); } isValidInput(result: ClaimEntity) { @@ -122,7 +127,7 @@ export class DirectLinkingComponent { } getProjectById(id: string) { - this.sub = this.entitySearch.fetchByType(id,"project", this.properties).subscribe( + this.subscriptions.push(this.entitySearch.fetchByType(id,"project", this.properties).subscribe( data => { this.createClaimEntity(data, "project"); }, @@ -130,18 +135,18 @@ export class DirectLinkingComponent { this.validInput = this.isValidInput(null); //console.log("An error occured") this.handleError("Error getting project by id: " + id, err); - }); + })); } getResearchResultById(resultType: string, id: string) { - this.sub = this._searchResearchResultsService.searchById(resultType, id, this.properties).subscribe(data => { + this.subscriptions.push(this._searchResearchResultsService.searchById(resultType, id, this.properties).subscribe(data => { this.createClaimEntity(data, resultType); }, err => { this.validInput = this.isValidInput(null); //console.log("An error occured") this.handleError("Error getting "+this.getEntityName(resultType, false, true)+" by id: " + id, err); - }); + })); } createClaimEntity(data, type: string) { diff --git a/claims/linking/bulkClaim/bulkClaim.component.ts b/claims/linking/bulkClaim/bulkClaim.component.ts index 70be5d98..4bad5180 100644 --- a/claims/linking/bulkClaim/bulkClaim.component.ts +++ b/claims/linking/bulkClaim/bulkClaim.component.ts @@ -6,6 +6,7 @@ import {ModalLoading} from '../../../utils/modal/loading.component'; import {Dates, DOI} from '../../../utils/string-utils.class'; import {EnvProperties} from '../../../utils/properties/env-properties'; import {ClaimEntity} from "../../claim-utils/claimHelper.class"; +import {Subscriber} from "rxjs"; declare var UIkit: any; @@ -123,7 +124,14 @@ export class BulkClaimComponent { ngOnInit() { } - + subscriptions = []; + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); + } upload() { this.enableUpload = false; this.showReport = false; @@ -238,7 +246,7 @@ export class BulkClaimComponent { } fetchResult(id: string, accessMode: string, date: string, row: number) { - this._searchCrossrefService.searchCrossrefByDOIs([id], this.properties, true).subscribe( + this.subscriptions.push(this._searchCrossrefService.searchCrossrefByDOIs([id], this.properties, true).subscribe( data => { const result:ClaimEntity = data[1][0]; @@ -264,11 +272,11 @@ export class BulkClaimComponent { this.notFoundIdsRow.push(row); this.endOfFetching(); } - ); + )); } searchInDatacite(id: string, accessMode: string, date: string, row: number) { - this._searchDataciteService.getDataciteResultByDOI(id, this.properties, true).subscribe( + this.subscriptions.push(this._searchDataciteService.getDataciteResultByDOI(id, this.properties, true).subscribe( result => { if (result) { @@ -293,7 +301,7 @@ export class BulkClaimComponent { this.notFoundIdsRow.push(row); this.endOfFetching(); } - ); + )); } endOfFetching() { diff --git a/claims/linking/bulkClaim/bulkClaim.module.ts b/claims/linking/bulkClaim/bulkClaim.module.ts index 9d064023..c0a6c4c3 100644 --- a/claims/linking/bulkClaim/bulkClaim.module.ts +++ b/claims/linking/bulkClaim/bulkClaim.module.ts @@ -9,7 +9,7 @@ import {HelperModule} from '../../../utils/helper/helper.module'; @NgModule({ imports: [ - SharedModule, LoadingModalModule, SearchCrossrefServiceModule, HelperModule + SharedModule, LoadingModalModule, SearchCrossrefServiceModule,SearchDataciteServiceModule, HelperModule ], declarations: [ BulkClaimComponent diff --git a/claims/linking/insertClaim/insertClaim.component.ts b/claims/linking/insertClaim/insertClaim.component.ts index 0c61ebe1..59e20a98 100644 --- a/claims/linking/insertClaim/insertClaim.component.ts +++ b/claims/linking/insertClaim/insertClaim.component.ts @@ -4,7 +4,6 @@ import {ClaimsService} from '../../claim-utils/service/claims.service'; import {ModalLoading} from '../../../utils/modal/loading.component'; import {AlertModal} from '../../../utils/modal/alert'; import {Md5} from 'ts-md5/dist/md5'; -import {Session, User} from '../../../login/utils/helper.class'; import {LoginErrorCodes} from '../../../login/utils/guardHelper.class'; import {EnvProperties} from '../../../utils/properties/env-properties'; import { @@ -15,6 +14,7 @@ import { Message } from "../../claim-utils/claimHelper.class"; import {UserManagementService} from "../../../services/user-management.service"; +import {Subscriber} from "rxjs"; @Component({ selector: 'claim-insert', @@ -55,12 +55,19 @@ export class ClaimInsertComponent { constructor(private claimService: ClaimsService, private _router: Router, private route: ActivatedRoute, private userManagementService: UserManagementService) { } - - ngOnInit() { - this.route.queryParams.subscribe(params => { - this.params = params; + subscriptions = []; + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } }); } + ngOnInit() { + this.subscriptions.push(this.route.queryParams.subscribe(params => { + this.params = params; + })); + } params = {}; @@ -106,7 +113,7 @@ export class ClaimInsertComponent { this.errorInClaims = []; this.insertedRecords = []; this.errorInRecords = []; - this.userManagementService.getUserInfo().subscribe(user => { + this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { if (!user) { this.saveAndNavigate(); } else { @@ -178,7 +185,7 @@ export class ClaimInsertComponent { // console.log("directclaims"); // console.log(directclaims); if (directclaims.length > 0 && this.properties.environment != "development"){ - this.claimService.insertDirectRecords(directclaims, this.properties.claimsAPIURL).subscribe( + this.subscriptions.push(this.claimService.insertDirectRecords(directclaims, this.properties.claimsAPIURL).subscribe( data => { this.insertedRecords = data.insertedIds; @@ -200,19 +207,19 @@ export class ClaimInsertComponent { ClaimInsertComponent.handleError("Error inserting direct records: " + JSON.stringify(directclaims), err); } - ); + )); } else { this.isertBulkClaims(claims); } } - }); + })); } private isertBulkClaims(claims: ClaimRecord2Insert[]) { console.log("claims"); console.log(claims); this.errors.splice(0, this.errors.length); - this.claimService.insertBulkClaims(claims, this.properties.claimsAPIURL).subscribe( + this.subscriptions.push(this.claimService.insertBulkClaims(claims, this.properties.claimsAPIURL).subscribe( data => { this.insertedClaims = data.insertedIds; this.errorInClaims = data.errorInClaims; @@ -265,7 +272,7 @@ export class ClaimInsertComponent { ClaimInsertComponent.handleError("Error inserting bulk claims: " + JSON.stringify(claims), err); } - ); + )); } createErrorMessagesPerEntity(applyToAll: boolean) { diff --git a/claims/linking/linkingGeneric.component.ts b/claims/linking/linkingGeneric.component.ts index 69f0e904..fc8b5d8f 100644 --- a/claims/linking/linkingGeneric.component.ts +++ b/claims/linking/linkingGeneric.component.ts @@ -9,6 +9,7 @@ import {AlertModal} from "../../utils/modal/alert"; import {HelperFunctions} from "../../utils/HelperFunctions.class"; import {HelperService} from "../../utils/helper/helper.service"; import {PiwikService} from "../../utils/piwik/piwik.service"; +import {Subscriber} from "rxjs"; declare var UIkit:any; @@ -36,7 +37,6 @@ export class LinkingGenericComponent { // show linkToEntities /values: result, project, context @Input() sources:ClaimEntity[] =[]; - sub:any =null; properties:EnvProperties; @Input() localStoragePrefix:string = "linking_"; url=null; @@ -48,6 +48,8 @@ export class LinkingGenericComponent { private _meta: Meta, private _title: Title, private _piwikService:PiwikService, private seoService: SEOService, private helper: HelperService ) { } + subscriptions = []; + ngOnInit() { this.showOptions.show = 'source'; if(this.inlineEntity){ @@ -55,7 +57,7 @@ export class LinkingGenericComponent { this.showOptions.basketShowLinksTo = true; this.showOptions.show = this.showOptions.linkTo; } - this.route.data + this.subscriptions.push(this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.url = this.properties.domain + this.properties.baseLink+this._router.url; @@ -68,14 +70,14 @@ export class LinkingGenericComponent { this.seoService.createLinkForCanonicalURL(this.url, false); if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ - this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe()); } this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.pageContents = contents; }) - }); + })); if( typeof localStorage !== 'undefined') { this.localStoragePrefix +=(this.communityId?this.communityId+"_":""); if(localStorage.getItem(this.localStoragePrefix + "results")){ @@ -89,9 +91,11 @@ export class LinkingGenericComponent { } ngOnDestroy() { - if(this.piwiksub){ - this.piwiksub.unsubscribe(); - } + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } openSelectionModal() { diff --git a/claims/linking/linkingGeneric.module.ts b/claims/linking/linkingGeneric.module.ts index 37be3839..7bffbc00 100644 --- a/claims/linking/linkingGeneric.module.ts +++ b/claims/linking/linkingGeneric.module.ts @@ -5,7 +5,6 @@ import { SharedModule } from '../../shared/shared.module'; import {SelectedProjectsModule} from './selected/selectedProjects.module'; import {SelectedContextsModule} from './selected/selectedContexts.module'; import {SelectedPublicationsModule} from './selected/selectedResults.module'; -import {InsertClaimsModule} from './insertClaim/insertClaim.module'; import {LinkingGenericComponent} from './linkingGeneric.component'; import {StartOverModule} from '../claim-utils/startOver.module'; import {LoginGuard} from'../../login/loginGuard.guard'; diff --git a/claims/linking/selected/ClaimEntityProjectMetadata.component.ts b/claims/linking/selected/ClaimEntityProjectMetadata.component.ts index 57e887ab..70b7060b 100644 --- a/claims/linking/selected/ClaimEntityProjectMetadata.component.ts +++ b/claims/linking/selected/ClaimEntityProjectMetadata.component.ts @@ -1,6 +1,5 @@ import {Component, Input} from '@angular/core'; import {ClaimEntity} from '../../claim-utils/claimHelper.class'; -import {StringUtils} from "../../../utils/string-utils.class"; @Component({ selector: 'claim-project-metadata', diff --git a/claims/linking/selected/ClaimEntityResultMetadata.component.ts b/claims/linking/selected/ClaimEntityResultMetadata.component.ts index 9e5db3d6..2addc8c8 100644 --- a/claims/linking/selected/ClaimEntityResultMetadata.component.ts +++ b/claims/linking/selected/ClaimEntityResultMetadata.component.ts @@ -1,6 +1,5 @@ import {Component, Input} from '@angular/core'; import {ClaimEntity} from '../../claim-utils/claimHelper.class'; -import {StringUtils} from "../../../utils/string-utils.class"; @Component({ selector: 'claim-result-metadata', @@ -51,10 +50,6 @@ export class ClaimEntityResultMetadataComponent { return array.join("; "); } - addStringToNumber(str: string, num: number) { - return (+str) + num; - } - getProjectDurationMessage(result: ClaimEntity) { if(!result.warningMessages){ return null; @@ -67,13 +62,5 @@ export class ClaimEntityResultMetadataComponent { return null; } - // getEmbargoEndDateMessage(result: ClaimEntity) { - // for (var message of result.warningMessages) { - // if (message.type == "embargoEndDate") { - // return "Embargo end date must be later than published date"; - // } - // } - // return null; - // } } diff --git a/claims/linking/selected/ClaimEntityTitle.component.ts b/claims/linking/selected/ClaimEntityTitle.component.ts index f27a9e54..debcc7a3 100644 --- a/claims/linking/selected/ClaimEntityTitle.component.ts +++ b/claims/linking/selected/ClaimEntityTitle.component.ts @@ -63,28 +63,4 @@ export class ClaimEntityTitleComponent { return mystr; } - - addStringToNumber(str: string, num: number) { - return (+str) + num; - } - - getProjectDurationMessage(result: ClaimEntity) { - for (let message of result.warningMessages) { - if (message.type == "projectDuration") { - return "Should be from " + message.projectInfo.startDate + ((message.projectInfo.endDate) ? (" to " + ((5 + +message.projectInfo.endDate))) : ""); - } - } - return null; - } - - getEmbargoEndDateMessage(result: ClaimEntity) { - for (var message of result.warningMessages) { - if (message.type == "embargoEndDate") { - return "Embargo end date must be later than published date"; - } - } - return null; - } - - } diff --git a/claims/linking/selected/selectedContexts.component.ts b/claims/linking/selected/selectedContexts.component.ts index 9ba8a340..64333fe0 100644 --- a/claims/linking/selected/selectedContexts.component.ts +++ b/claims/linking/selected/selectedContexts.component.ts @@ -50,7 +50,6 @@ export class ClaimSelectedContextsComponent { //The following need to be kept in case we have to save the current state @Input() public projects; @Input() public results; - // @Input() public inlineEntity; @Input() componentClass:string = ""; //"" or "col-sm-6" for horizontal display (besides projects) @Input() show='home'; @Input() title='Communities'; @@ -65,16 +64,6 @@ export class ClaimSelectedContextsComponent { todayDate = ''; nextDate = ''; - showType(type){ - if(type != this.show){ - this.show = type; - this.showChange.emit({ - value: this.show - }); - } - } - - removeContext(item:any){ var index:number =this.contexts.indexOf(item); if (index > -1) { @@ -85,8 +74,5 @@ export class ClaimSelectedContextsComponent { } } - contextSelected($event) { - // this.showsearch = false; - } } diff --git a/claims/linking/selected/selectedContexts.module.ts b/claims/linking/selected/selectedContexts.module.ts index 08d3d059..8c9b0900 100644 --- a/claims/linking/selected/selectedContexts.module.ts +++ b/claims/linking/selected/selectedContexts.module.ts @@ -2,12 +2,10 @@ import { NgModule } from '@angular/core'; import { SharedModule } from '../../../shared/shared.module'; import {ClaimSelectedContextsComponent} from './selectedContexts.component'; -// import {ClaimContextSearchFormModule} from '../../claim-utils/claimContextSearchForm.module'; @NgModule({ imports: [ - SharedModule, - // ClaimContextSearchFormModule + SharedModule ], declarations: [ ClaimSelectedContextsComponent diff --git a/claims/linking/selected/selectedProjects.component.ts b/claims/linking/selected/selectedProjects.component.ts index 4a00a306..557aacc3 100644 --- a/claims/linking/selected/selectedProjects.component.ts +++ b/claims/linking/selected/selectedProjects.component.ts @@ -72,19 +72,4 @@ export class ClaimSelectedProjectsComponent { value: this.projects }); } - - showType(type) { - if (type != this.show) { - this.show = type; - this.showChange.emit({ - value: this.show - }); - } - } - - projectSelected($event) { - // this.showsearch = false; - } - - } diff --git a/claims/linking/selected/selectedProjects.module.ts b/claims/linking/selected/selectedProjects.module.ts index e3d96ef7..9b453c00 100644 --- a/claims/linking/selected/selectedProjects.module.ts +++ b/claims/linking/selected/selectedProjects.module.ts @@ -4,12 +4,10 @@ import { RouterModule } from '@angular/router'; import { SharedModule } from '../../../shared/shared.module'; import {ClaimSelectedProjectsComponent} from './selectedProjects.component'; -// import {ClaimProjectsSearchFormModule} from '../../claim-utils/claimProjectSearchForm.module'; @NgModule({ imports: [ SharedModule, RouterModule, - // ClaimProjectsSearchFormModule ], declarations: [ ClaimSelectedProjectsComponent diff --git a/claims/linking/selected/selectedResults.component.ts b/claims/linking/selected/selectedResults.component.ts index 25feb408..b1d7eb07 100644 --- a/claims/linking/selected/selectedResults.component.ts +++ b/claims/linking/selected/selectedResults.component.ts @@ -27,10 +27,4 @@ export class ClaimSelectedResultsComponent { } - sliceString(mystr, size: number): string { - const sliced = String(mystr).substr(0, size); - return sliced + (String(mystr).length > size ? '...' : ''); - } - - } diff --git a/claims/myClaims/myClaims.component.ts b/claims/myClaims/myClaims.component.ts index 1e51daee..ef2fceb2 100644 --- a/claims/myClaims/myClaims.component.ts +++ b/claims/myClaims/myClaims.component.ts @@ -1,9 +1,9 @@ import {Component, Input} from '@angular/core'; -import {Meta, Title} from '@angular/platform-browser'; import {User} from "../../login/utils/helper.class"; import {UserManagementService} from "../../services/user-management.service"; import {LoginErrorCodes} from "../../login/utils/guardHelper.class"; import {Router} from "@angular/router"; +import {Subscriber} from "rxjs"; @Component({ selector: 'my-claims', @@ -42,8 +42,14 @@ export class MyClaimsComponent { constructor(private userManagementService: UserManagementService, private _router: Router) {} + sub; + ngOnDestroy() { + if (this.sub instanceof Subscriber) { + this.sub.unsubscribe(); + } + } ngOnInit() { - this.userManagementService.getUserInfo().subscribe(user => { + this.sub = this.userManagementService.getUserInfo().subscribe(user => { this.user = user; if (!user) { this._router.navigate(['/user-info'], { diff --git a/connect/communityGuard/connectAdminLoginGuard.guard.ts b/connect/communityGuard/connectAdminLoginGuard.guard.ts index 6e24fba1..3ec2ceba 100644 --- a/connect/communityGuard/connectAdminLoginGuard.guard.ts +++ b/connect/communityGuard/connectAdminLoginGuard.guard.ts @@ -1,4 +1,4 @@ -import {map, filter, mergeMap} from 'rxjs/operators'; +import {map, filter, mergeMap, take} from 'rxjs/operators'; import {Injectable} from '@angular/core'; import { Router, @@ -30,7 +30,7 @@ export class ConnectAdminLoginGuard implements CanActivate, CanLoad { check(community: string, path: string): Observable | boolean { let errorCode = LoginErrorCodes.NOT_LOGIN; let email = null; - const authorized = this.userManagementService.getUserInfo(false).pipe(map(user => { + const authorized = this.userManagementService.getUserInfo(false).pipe(take(1),map(user => { if (user) { email = user.email; if (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || Session.isManager('community', community, user)) { @@ -38,7 +38,7 @@ export class ConnectAdminLoginGuard implements CanActivate, CanLoad { } else { errorCode = LoginErrorCodes.NOT_ADMIN; return this.communityService.isCommunityManagerByState(properties, properties['communityAPI'] + community, - email); + email).pipe(take(1)); } } else { return of(false); diff --git a/connect/communityGuard/connectCommunityGuard.guard.ts b/connect/communityGuard/connectCommunityGuard.guard.ts index 5190fa8e..6cb4a638 100644 --- a/connect/communityGuard/connectCommunityGuard.guard.ts +++ b/connect/communityGuard/connectCommunityGuard.guard.ts @@ -1,22 +1,18 @@ - -import {filter, map, mergeMap} from 'rxjs/operators'; -import { Injectable } from '@angular/core'; +import {take, tap} from 'rxjs/operators'; +import {Injectable} from '@angular/core'; import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, - CanLoad, - Route + } 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 ConnectCommunityGuard implements CanActivate { +export class ConnectCommunityGuard implements CanActivate { sub: Subscription = null; constructor(private router: Router, @@ -24,11 +20,10 @@ export class ConnectCommunityGuard implements CanActivate { } check(community: string): Observable | boolean { - return this.communityService.isCommunityTypeByState(properties, properties['communityAPI'] + community).pipe(map(isCommunity => { - if(!isCommunity) { + return this.communityService.isCommunityTypeByState(properties, properties['communityAPI'] + community).pipe(take(1), tap(isCommunity => { + if (!isCommunity) { this.router.navigate(['errorcommunity']); } - return isCommunity; })); } diff --git a/connect/communityGuard/connectRIGuard.guard.ts b/connect/communityGuard/connectRIGuard.guard.ts index 2f7ec458..42c05c78 100644 --- a/connect/communityGuard/connectRIGuard.guard.ts +++ b/connect/communityGuard/connectRIGuard.guard.ts @@ -1,5 +1,4 @@ - -import {filter, mergeMap} from 'rxjs/operators'; +import {tap} from 'rxjs/operators'; import { Injectable } from '@angular/core'; import { Router, @@ -25,13 +24,12 @@ export class ConnectRIGuard implements CanActivate, CanLoad { } check(community: string): Observable | boolean { - const obs = this.communityService.isRITypeByState(properties, properties['communityAPI'] + community); - - this.sub = obs.pipe(filter(enabled => !enabled)) - .subscribe(() => this.router.navigate(['errorcommunity'])); - return obs; + return this.communityService.isRITypeByState(properties, properties['communityAPI'] + community).pipe(tap(authorized => { + if (!authorized) { + this.router.navigate(['errorcommunity']); + } + })); } - canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { return this.check(route.queryParams['communityId']); } diff --git a/connect/communityGuard/connectSubscriber.guard.ts b/connect/communityGuard/connectSubscriber.guard.ts index 54ac06cb..73b1a07c 100644 --- a/connect/communityGuard/connectSubscriber.guard.ts +++ b/connect/communityGuard/connectSubscriber.guard.ts @@ -1,11 +1,10 @@ -import {filter, map, mergeMap} from 'rxjs/operators'; +import {filter, map, mergeMap, take, tap} from 'rxjs/operators'; import {Injectable} from '@angular/core'; import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, Route} from '@angular/router'; import {Observable, of} from 'rxjs'; import {Session} from '../../login/utils/helper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {CommunityService} from '../community/community.service'; -import {EnvironmentSpecificService} from '../../utils/properties/environment-specific.service'; import {ConnectHelper} from '../connectHelper'; import {UserManagementService} from "../../services/user-management.service"; import {SubscribeService} from "../../utils/subscribe/subscribe.service"; @@ -16,14 +15,13 @@ export class ConnectSubscriberGuard implements CanActivate { constructor(private router: Router, private communityService: CommunityService, private subscribeService: SubscribeService, - private userManagementService: UserManagementService, - private propertiesService: EnvironmentSpecificService) { + private userManagementService: UserManagementService) { } check(community: string, path: string): Observable | boolean { let errorCode = LoginErrorCodes.NOT_LOGIN; let email = null; - const subscribed = this.userManagementService.getUserInfo(false).pipe(map(user => { + const subscribed = this.userManagementService.getUserInfo(false).pipe(take(1),map(user => { if (user) { errorCode = LoginErrorCodes.NOT_SUBSCRIBER; email = user.email; @@ -34,7 +32,7 @@ export class ConnectSubscriberGuard implements CanActivate { if (Session.isSubscribedTo('community', community, user)) { return of(true); } - return this.subscribeService.isSubscribedToCommunity(properties, community) + return this.subscribeService.isSubscribedToCommunity(properties, community).pipe(take(1)); } else { return of(false); } diff --git a/deposit/depositFirstPage.component.ts b/deposit/depositFirstPage.component.ts index 46e86a92..9dfcc335 100644 --- a/deposit/depositFirstPage.component.ts +++ b/deposit/depositFirstPage.component.ts @@ -8,6 +8,8 @@ import {RouterHelper} from "../utils/routerHelper.class"; import {SEOService} from "../sharedComponents/SEO/SEO.service"; import {Meta, Title} from "@angular/platform-browser"; import {Breadcrumb} from "../utils/breadcrumbs/breadcrumbs.component"; +import {properties} from "../../../environments/environment"; +import {Subscriber} from "rxjs"; @Component({ selector: 'deposit-first-page', @@ -212,7 +214,6 @@ export class DepositFirstPageComponent { @Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass(); @Input() piwikSiteId = null; - piwiksub:any; @Input() communityId = null; @@ -226,6 +227,7 @@ export class DepositFirstPageComponent { public routerHelper:RouterHelper = new RouterHelper(); @Input() showBreadcrumb:boolean = false; breadcrumbs:Breadcrumb[] = []; + subscriptions = []; constructor (private route: ActivatedRoute, private _piwikService:PiwikService, private helper: HelperService, private _router: Router, @@ -235,9 +237,7 @@ export class DepositFirstPageComponent { ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; + this.properties = properties; this.url = this.properties.domain+this.properties.baseLink + this._router.url; this.seoService.createLinkForCanonicalURL(this.url, false); @@ -260,28 +260,29 @@ export class DepositFirstPageComponent { } if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ - this.piwiksub = this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe()); } this.breadcrumbs.push({name: 'home', route: '/'}, {name: "Deposit", route: null}); - }); } public getPageContents() { - this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.pageContents = contents; - }) + })); } public getDivContents() { - this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.divContents = contents; - }) + })); } ngOnDestroy() { - if(this.piwiksub){ - this.piwiksub.unsubscribe(); - } + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } private updateDescription(description:string) { diff --git a/deposit/searchDataprovidersToDeposit.component.ts b/deposit/searchDataprovidersToDeposit.component.ts index f1b97a7a..bdd71273 100644 --- a/deposit/searchDataprovidersToDeposit.component.ts +++ b/deposit/searchDataprovidersToDeposit.component.ts @@ -126,7 +126,7 @@ export class SearchDataprovidersToDepositComponent { // this.searchPage.keywordFields = this.keywordFields; // var firstLoad =true; // - // this.sub = this.route.queryParams.subscribe(params => { + // this.subscriptions = this.route.queryParams.subscribe(params => { // this.loadPaging = true; // if(params['page'] && this.searchUtils.page != params['page']) { // this.loadPaging = false; diff --git a/deposit/searchDataprovidersToDeposit.module.ts b/deposit/searchDataprovidersToDeposit.module.ts index 3fa3cb3a..c6e8693b 100644 --- a/deposit/searchDataprovidersToDeposit.module.ts +++ b/deposit/searchDataprovidersToDeposit.module.ts @@ -9,8 +9,6 @@ import {SearchResultsModule } from '../searchPages/searchUtils/searchResults.mod import {DataProvidersServiceModule} from '../services/dataProvidersService.module'; import {SearchFormModule} from '../searchPages/searchUtils/searchForm.module'; -// import {SearchPageModule} from '../searchPages/searchUtils/searchPage.module'; -import {FreeGuard} from'../login/freeGuard.guard'; import {IsRouteEnabled} from '../error/isRouteEnabled.guard'; import {SearchDataProvidersModule} from "../searchPages/searchDataProviders.module"; import {BreadcrumbsModule} from "../utils/breadcrumbs/breadcrumbs.module"; @@ -26,7 +24,7 @@ import {BreadcrumbsModule} from "../utils/breadcrumbs/breadcrumbs.module"; declarations: [ SearchDataprovidersToDepositComponent ], - providers:[FreeGuard, IsRouteEnabled], + providers:[ IsRouteEnabled], exports: [ SearchDataprovidersToDepositComponent ] diff --git a/deposit/searchResultsInDeposit.component.ts b/deposit/searchResultsInDeposit.component.ts index 9d7c50a8..74dc7b30 100644 --- a/deposit/searchResultsInDeposit.component.ts +++ b/deposit/searchResultsInDeposit.component.ts @@ -6,6 +6,7 @@ import {EnvProperties} from '../utils/properties/env-properties'; import {ZenodoInformationClass} from "./utils/zenodoInformation.class"; import {ActivatedRoute} from "@angular/router"; import {ResultPreview} from "../utils/result-preview/result-preview"; +import {Subscriber} from "rxjs"; @Component({ selector: 'deposit-result', @@ -26,9 +27,13 @@ export class SearchResultsInDepositComponent { public errorMessage: string = "No results found"; @Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass(); - + sub; constructor (private route: ActivatedRoute) {} - + ngOnDestroy() { + if (this.sub instanceof Subscriber) { + this.sub.unsubscribe(); + } + } ngOnInit() { if(this.type == "publication") { this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications; @@ -53,7 +58,7 @@ export class SearchResultsInDepositComponent { this.urlParam = "datasourceId"; } - this.route.data + this.sub = this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; diff --git a/error/errorPage.component.ts b/error/errorPage.component.ts index df09cd7f..fe312959 100644 --- a/error/errorPage.component.ts +++ b/error/errorPage.component.ts @@ -1,9 +1,8 @@ -import {Component, Inject, Input, Optional} from '@angular/core'; +import {Component, Inject, Optional} from '@angular/core'; import {Location} from '@angular/common'; import {ActivatedRoute} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; import {RESPONSE} from "@nguniversal/express-engine/tokens"; -import {EnvProperties} from "../utils/properties/env-properties"; import {SEOService} from "../sharedComponents/SEO/SEO.service"; import {properties} from "../../../environments/environment"; diff --git a/error/isRouteEnabled.guard.ts b/error/isRouteEnabled.guard.ts index 85e21956..1566b87f 100644 --- a/error/isRouteEnabled.guard.ts +++ b/error/isRouteEnabled.guard.ts @@ -1,32 +1,24 @@ - -import {of as observableOf, Observable, Subject, Subscription} from 'rxjs'; - -import {map, filter, mergeMap, tap} from 'rxjs/operators'; +import {Observable, Subscription} from 'rxjs'; +import {tap, take} from 'rxjs/operators'; import { Injectable } from '@angular/core'; import { Router, CanActivate, - CanLoad, ActivatedRouteSnapshot, RouterStateSnapshot, - Route, Data + Data } from '@angular/router'; import { ConfigurationService } from '../utils/configuration/configuration.service'; -import { EnvironmentSpecificService} from '../utils/properties/environment-specific.service'; import {ConnectHelper} from '../connect/connectHelper'; import {properties} from "../../../environments/environment"; -import {LoginErrorCodes} from "../login/utils/guardHelper.class"; -import {of} from 'rxjs'; -import {Page} from "../utils/entities/adminTool/page"; @Injectable() export class IsRouteEnabled implements CanActivate { sub: Subscription = null; constructor(private router: Router, - private config: ConfigurationService, - private propertiesService: EnvironmentSpecificService) {} + private config: ConfigurationService) {} // check(data: Data, community: string, path: string): Observable | boolean { // const customRedirect = data['redirect']; @@ -72,27 +64,16 @@ export class IsRouteEnabled implements CanActivate { community = properties.adminToolsCommunity; } - const obs = - //this.config.isPageEnabled(properties, community, '/' + path); - this.config.isPageEnabledByState(properties, community, '/'+path); - this.sub = obs - //.pipe(tap((enabled) => console.log("aaa: "+enabled))) - .pipe(filter(enabled => !enabled)) - .subscribe(() => { - this.router.navigate([redirect], {queryParams: {'page': path}}); - }); + return this.config.isPageEnabledByState(properties, community, '/'+path).pipe(take(1),tap((enabled) => { + if(!enabled){ + this.router.navigate([redirect], {queryParams: {'page': path}}); + } + })); - return obs; } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { return this.check(route.data, route.queryParams['communityId'], state.url); } - canDeactivate() { - if(this.sub) { - this.sub.unsubscribe(); - } - return true; - } } diff --git a/landingPages/annotation/annotation.component.ts b/landingPages/annotation/annotation.component.ts index dedfb72f..459393ff 100644 --- a/landingPages/annotation/annotation.component.ts +++ b/landingPages/annotation/annotation.component.ts @@ -159,13 +159,13 @@ export class AnnotationComponent implements OnInit, OnDestroy { if(!this.annotations || this.annotations.length === 0) { this.loading = true; } - this.annotationService.getAllAnnotations(this.properties, this.pid).subscribe(annotations => { + this.subscriptions.push(this.annotationService.getAllAnnotations(this.properties, this.pid).subscribe(annotations => { this.annotations = annotations; this.annotations.forEach(annotation => { annotation.urlSize = 3; }); this.loading = false; - }); + })); } ngOnDestroy(): void { diff --git a/landingPages/annotation/annotation.service.ts b/landingPages/annotation/annotation.service.ts index 5d7819fc..db642fa3 100644 --- a/landingPages/annotation/annotation.service.ts +++ b/landingPages/annotation/annotation.service.ts @@ -3,8 +3,6 @@ import {HttpClient} from "@angular/common/http"; import {Observable} from "rxjs"; import {EnvProperties} from "../../utils/properties/env-properties"; import {map} from "rxjs/operators"; -import {response} from "express"; -import {el} from "@angular/platform-browser/testing/src/browser_util"; export interface Annotation { text: string; diff --git a/landingPages/dataProvider/dataProvider.component.ts b/landingPages/dataProvider/dataProvider.component.ts index 4d658771..d9e11676 100644 --- a/landingPages/dataProvider/dataProvider.component.ts +++ b/landingPages/dataProvider/dataProvider.component.ts @@ -1,4 +1,3 @@ -import {merge as observableMerge} from 'rxjs'; import {Component, Input, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {Meta, Title} from '@angular/platform-browser'; @@ -26,6 +25,7 @@ import {SearchResult} from "../../utils/entities/searchResult"; import {ResultPreview} from "../../utils/result-preview/result-preview"; import {IndexInfoService} from "../../utils/indexInfo.service"; import {properties} from "../../../../environments/environment"; +import {Subscriber} from "rxjs"; @Component({ @@ -43,11 +43,7 @@ export class DataProviderComponent { public warningMessage = ""; public errorMessage = ""; public showLoading: boolean = true; - - // Variable to specify requests with either collectedFrom or hostedBy - public paramsForSearchLink = {}; - public resultParamsForSearchLink = {}; - + // Metrics tab variables public metricsClicked: boolean; public viewsFrameUrl: string; @@ -58,11 +54,6 @@ export class DataProviderComponent { // Statistics tab variables public statsClicked: boolean = false; - public docsTimelineUrl: string; - public docsTypesUrl: string; - public docsFunderUrl: string; - public dataProjectsUrl: string; - public pubsProjectsUrl: string; @ViewChild('statisticsModal') statisticsModal; @ViewChild('relatedDatasourcesModal') relatedDatasourcesModal; @@ -74,10 +65,6 @@ export class DataProviderComponent { public fetchOrps: FetchResearchResults; public fetchProjects: FetchProjects; public fetchDataproviders: FetchDataproviders; - public fetchAggregatorsPublications: FetchResearchResults; - public fetchAggregatorsDatasets: FetchResearchResults; - public fetchAggregatorsSoftware: FetchResearchResults; - public fetchAggregatorsOrps: FetchResearchResults; public fetchAggregatorsResults: FetchResearchResults; public searchNumber: number = 5; @@ -89,7 +76,6 @@ export class DataProviderComponent { public activeTab: string = ""; public showTabs: boolean = false; - public firstTab: string = ""; public _numberOfTabs: number = 0; public tabsAreInitialized: boolean = false; @@ -123,10 +109,7 @@ export class DataProviderComponent { public showFeedback: boolean = false; public feedbackFields: string [] = ['Name', 'Organizations', 'Country', 'Other']; - sub: any; - piwiksub: any; - subInfo: any; - relatedDatasourcesSub: any; + subscriptions = []; properties: EnvProperties = properties; constructor(private _dataproviderService: DataProviderService, @@ -153,16 +136,16 @@ export class DataProviderComponent { ngOnInit() { if (typeof document !== 'undefined') { - this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { + this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { if (lastIndexUpdate) { this.indexUpdateDate = new Date(lastIndexUpdate); } - }); + })); } //this.getDivContents(); this.getPageContents(); this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url); - this.sub = this.route.queryParams.subscribe(data => { + this.subscriptions.push(this.route.queryParams.subscribe(data => { this.updateTitle("Content provider"); this.updateDescription(""); this.datasourceId = data['datasourceId']; @@ -180,7 +163,7 @@ export class DataProviderComponent { } HelperFunctions.scroll(); - }); + })); } public initializeValues() { @@ -205,31 +188,29 @@ export class DataProviderComponent { } private getPageContents() { - this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.pageContents = contents; - }) + })); } private getDivContents() { - this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.divContents = contents; - }) + })); } ngOnDestroy() { - if (this.sub) { - this.sub.unsubscribe(); - } - if (this.piwiksub) { - this.piwiksub.unsubscribe(); - } - if (this.subInfo) { - this.subInfo.unsubscribe(); - } - - if (this.relatedDatasourcesSub) { - this.relatedDatasourcesSub.unsubscribe(); - } + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); + this.fetchDatasets.clearSubscriptions(); + this.fetchPublications.clearSubscriptions(); + this.fetchSoftware.clearSubscriptions(); + this.fetchPublications.clearSubscriptions(); + this.fetchDataproviders.clearSubscriptions(); + this.fetchProjects.clearSubscriptions(); } private getDataProviderInfo(id: string) { @@ -244,7 +225,7 @@ export class DataProviderComponent { this.showLoading = false; this.warningMessage = "No valid datasource id"; } else { - this.subInfo = this._dataproviderService.getDataproviderInfo(this.datasourceId, this.properties).subscribe( + this.subscriptions.push(this._dataproviderService.getDataproviderInfo(this.datasourceId, this.properties).subscribe( data => { this.dataProviderInfo = data; this.seoService.createLinkForCanonicalURL(this.properties.domain +this.properties.baseLink + this._router.url); @@ -260,7 +241,7 @@ export class DataProviderComponent { this.updateTitle(this.dataProviderInfo.title.name); this.updateDescription("Content provider, " + this.dataProviderInfo.title.name); if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { - this.piwiksub = this._piwikService.trackView(this.properties, this.dataProviderInfo.title.name, this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackView(this.properties, this.dataProviderInfo.title.name, this.piwikSiteId).subscribe()); } this.showLoading = false; @@ -284,12 +265,12 @@ export class DataProviderComponent { this.showLoading = false; this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToDataProviders); } - ); + )); } } private getDataProviderAggregationStatus(originalId: string) { - this.subInfo = this._dataproviderService.getDataproviderAggregationStatus(originalId, this.properties).subscribe( + this.subscriptions.push(this._dataproviderService.getDataproviderAggregationStatus(originalId, this.properties).subscribe( data => { this.dataProviderInfo.aggregationStatus = data; }, @@ -300,7 +281,7 @@ export class DataProviderComponent { () => { this.aggregationStatusIsInitialized = true; } - ); + )); } private updateDescription(description: string) { @@ -340,49 +321,13 @@ export class DataProviderComponent { this.metricsClicked = false; this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"dtsrcRepoViews","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; - /*this.viewsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"dtsrcOpenAIRETimeline", "dtsrcName":"'+this.datasourceId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"OpenAIRE","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]},{"query":"dtsrcRepoTimeline", "dtsrcName":"'+this.datasourceId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":[""],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column","column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; - */ - this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"dtsrcRepoDownloads","dtsrcName":"' + this.datasourceId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; - /* - this.downloadsFrameUrl = this.properties.framesAPIURL +'merge.php?com=query&data=[{"query":"dtsrcDownloadsTimeline","dtsrcName":"'+this.datasourceId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"chart","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; - */ - - //if({"name": "Publications", "content": "publicationsTab"} in this.dataProviderInfo.tabs) { - //if(this.dataProviderInfo.tabs.some(function (tab) { - // return tab.name === 'Publications'; - //})) { - // this.relatedDataprovidersResultsType = 'publications'; - - // this.fetchAggregatorsPublications = new FetchResearchResults(this._searchResearchResultsService); - // //} else { - // // this.relatedDataprovidersResultsType = 'datasets'; - // this.fetchAggregatorsDatasets = new FetchResearchResults(this._searchResearchResultsService); - // //} - // this.fetchAggregatorsSoftware = new FetchResearchResults(this._searchResearchResultsService); - // this.fetchAggregatorsOrps = new FetchResearchResults(this._searchResearchResultsService); this.fetchAggregatorsResults = new FetchResearchResults(this._searchResearchResultsService); - //} - // if (this.dataProviderInfo.resultsBy == "collectedFrom") { - // //this.paramsForSearchLink = "?collectedFrom="+this.datasourceId+"&co=and"; - // this.paramsForSearchLink = this.routerHelper.createQueryParams(['f0', 'fv0'], ["collectedfromdatasourceid", this.datasourceId]); - // this.resultParamsForSearchLink = this.routerHelper.createQueryParams(['collectedFrom', 'cl', 'qf'], [this.datasourceId, 'and', 'false']); - // } else if (this.dataProviderInfo.resultsBy == "hostedBy") { - // //this.paramsForSearchLink = "?hostedBy="+this.datasourceId+"&ho=and"; - // this.paramsForSearchLink = this.routerHelper.createQueryParams(['f0', 'fv0'], ["resulthostingdatasourceid", this.datasourceId]); - // this.resultParamsForSearchLink = this.routerHelper.createQueryParams(['hostedBy', 'hs', 'qf'], [this.datasourceId, 'and', 'false']); - // } - + } public getParamsForSearchLink(type: string = "") { - let resultsBy: string = ""; - // if(this.dataProviderInfo.resultsBy == "collectedFrom") { - // resultsBy = "collectedfromdatasourceid" - // } else if (this.dataProviderInfo.resultsBy == "hostedBy") { - // resultsBy = "resulthostingdatasourceid"; - // } - + if (type) { return this.routerHelper.createQueryParams(['f0', 'fv0', 'f1', 'fv1', 'type', 'qf', 'sortBy'], ["collectedfromdatasourceid", this.datasourceId, "resulthostingdatasourceid,or", this.datasourceId, type, "false", 'resultdateofacceptance,descending']); } else { @@ -391,25 +336,14 @@ export class DataProviderComponent { } private count(page: number, size: number) { - //for (let i = 0; i < this.dataProviderInfo.tabs.length; i++) { - //let content: string = this.dataProviderInfo.tabs[i].content; - - //if (content == 'publicationsTab') { + this.countPublications(page, size); - //} else if (content == 'datasetsTab') { this.countDatasets(page, size); - //} else if (content == 'softwareTab') { this.countSoftware(page, size); - //} else if (content == 'orpsTab') { this.countOrps(page, size); - //} else if (content == 'projectsTab') { this.countProjects(page, size); - //} else if (content == 'datasourcesTab') { this.countDatasources(page, size); - //}// else if(content=='relatedDatasourcesTab') { - // this.countRelatedDatasources(page, size); - //} - //} + } public search(content: string, page: number, size: number) { @@ -560,7 +494,7 @@ export class DataProviderComponent { (this.fetchAggregatorsResults.searchUtils.status == this.errorCodes.DONE && this.fetchAggregatorsResults.searchUtils.totalResults > 0) ) ) { - this.relatedDatasourcesSub = this.fetchAggregatorsResults.requestComplete.subscribe( + this.subscriptions.push(this.fetchAggregatorsResults.requestComplete.subscribe( data => { }, err => { @@ -570,7 +504,7 @@ export class DataProviderComponent { this.dataProviderInfo.relatedDatasources = this.fetchAggregatorsResults.results; this.loadingRelatedDatasources = false; } - ); + )); this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties); } else { @@ -582,79 +516,9 @@ export class DataProviderComponent { } private countRelatedDatasources(page: number, size: number) { - // this.fetchAggregatorsPublications.getAggregatorResults("publication", this.datasourceId, page, size, this.properties); - // this.fetchAggregatorsDatasets.getAggregatorResults("dataset", this.datasourceId, page, size, this.properties); - // this.fetchAggregatorsSoftware.getAggregatorResults("software", this.datasourceId, page, size, this.properties); - // this.fetchAggregatorsOrps.getAggregatorResults("other", this.datasourceId, page, size, this.properties); this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties); } - - - // private preprocessRelatedDatasources() { - // if (this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.DONE || - // this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.DONE || - // this.fetchAggregatorsSoftware.searchUtils.status == this.errorCodes.DONE || - // this.fetchAggregatorsOrps.searchUtils.status == this.errorCodes.DONE) { - // this.dataProviderInfo.relatedDatasources = new Map(); - // } - // for (let result of this.fetchAggregatorsPublications.results) { - // if (!this.dataProviderInfo.relatedDatasources.has(result.id)) { - // this.dataProviderInfo.relatedDatasources.set(result.id, { - // "name": result.name, - // "countPublications": result.count, - // "countDatasets": "0", - // "countSoftware": "0", - // "countOrps": "0" - // }); - // } else { - // this.dataProviderInfo.relatedDatasources.get(result.id).countPublications = parseInt(this.dataProviderInfo.relatedDatasources.get(result.id).countPublications + result.count) + ""; - // } - // } - // - // for (let result of this.fetchAggregatorsDatasets.results) { - // if (!this.dataProviderInfo.relatedDatasources.has(result.id)) { - // this.dataProviderInfo.relatedDatasources.set(result.id, { - // "name": result.name, - // "countPublications": "0", - // "countDatasets": result.count, - // "countSoftware": "0", - // "countOrps": "0" - // }); - // } else { - // this.dataProviderInfo.relatedDatasources.get(result.id).countDatasets = parseInt(this.dataProviderInfo.relatedDatasources.get(result.id).countDatasets + result.count) + ""; - // } - // } - // - // for (let result of this.fetchAggregatorsSoftware.results) { - // if (!this.dataProviderInfo.relatedDatasources.has(result.id)) { - // this.dataProviderInfo.relatedDatasources.set(result.id, { - // "name": result.name, - // "countPublications": "0", - // "countDatasets": "0", - // "countSoftware": result.count, - // "countOrps": "0" - // }); - // } else { - // this.dataProviderInfo.relatedDatasources.get(result.id).countSoftware = parseInt(this.dataProviderInfo.relatedDatasources.get(result.id).countSoftware + result.count) + ""; - // } - // } - // - // for (let result of this.fetchAggregatorsOrps.results) { - // if (!this.dataProviderInfo.relatedDatasources.has(result.id)) { - // this.dataProviderInfo.relatedDatasources.set(result.id, { - // "name": result.name, - // "countPublications": "0", - // "countDatasets": "0", - // "countSoftware": "0", - // "countOrps": result.count - // }); - // } else { - // this.dataProviderInfo.relatedDatasources.get(result.id).countOrps = parseInt(this.dataProviderInfo.relatedDatasources.get(result.id).countOrps + result.count) + ""; - // } - // } - // this.loadingRelatedDatasources = false; - // } - + public metricsResults($event) { this.totalViews = $event.totalViews; this.totalDownloads = $event.totalDownloads; @@ -776,74 +640,5 @@ export class DataProviderComponent { || !!this.dataProviderInfo.oaiPmhURL || !!this.dataProviderInfo.openDoarId || !!this.dataProviderInfo.r3DataId ); } - - // public numberOfTabs(): number { - // if(this.tabsAreInitialized) { - // return this._numberOfTabs; - // } - // - // // if(!this.dataProviderInfo || !this.aggregationStatusIsInitialized - // // || this.fetchProjects.searchUtils.status == this.errorCodes.LOADING - // // || this.fetchDataproviders.searchUtils.status == this.errorCodes.LOADING - // // || this.fetchPublications.searchUtils.status == this.errorCodes.LOADING - // // || this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING - // // || this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING - // // || this.fetchOrps.searchUtils.status == this.errorCodes.LOADING) { - // // return 0; - // // } - // - // if(this.dataProviderInfo - // && this.fetchProjects.searchUtils.status != this.errorCodes.LOADING - // && this.fetchDataproviders.searchUtils.status != this.errorCodes.LOADING - // && this.fetchPublications.searchUtils.status != this.errorCodes.LOADING - // && this.fetchDatasets.searchUtils.status != this.errorCodes.LOADING - // && this.fetchSoftware.searchUtils.status != this.errorCodes.LOADING - // && this.fetchOrps.searchUtils.status != this.errorCodes.LOADING) { - // this.tabsAreInitialized = true; - // } - // - // this._numberOfTabs = 0; - // //if (this.hasPrimaryInfo || this.hasSecondaryInfo) { - // this.firstTab = "summary"; - // this._numberOfTabs++; - // //} - // if(this.fetchProjects.searchUtils.totalResults > 0) { - // /*if( this._numberOfTabs == 0) { - // this.firstTab = "projects"; - // this.searchProjects(1, this.searchNumber); - // }*/ - // this._numberOfTabs++; - // } - // if(this.fetchDataproviders.searchUtils.totalResults > 0) { - // /*if( this._numberOfTabs == 0) { - // this.firstTab = "datasources"; - // this.searchDatasources(1, this.searchNumber); - // }*/ - // this._numberOfTabs++; - // } - // if(this.fetchPublications.searchUtils.totalResults > 0 || this.fetchDatasets.searchUtils.totalResults > 0 - // || this.fetchSoftware.searchUtils.totalResults > 0 || this.fetchOrps.searchUtils.totalResults > 0) { - // /*if( this._numberOfTabs == 0) { - // this.firstTab = "relatedDatasources"; - // this.searchRelatedDatasources(1, this.searchNumber); - // }*/ - // this._numberOfTabs += 2; - // - // if(this.fetchPublications.searchUtils.totalResults > 0) { - // this._numberOfTabs++; - // } - // if(this.fetchDatasets.searchUtils.totalResults > 0) { - // this._numberOfTabs++; - // } - // if(this.fetchSoftware.searchUtils.totalResults > 0) { - // this._numberOfTabs++; - // } - // if(this.fetchOrps.searchUtils.totalResults > 0) { - // this._numberOfTabs++; - // } - // } - // //this.activeTab = this.firstTab; - // //this.tabsAreInitialized = true; - // return this._numberOfTabs; - // } + } diff --git a/landingPages/dataProvider/dataProvider.module.ts b/landingPages/dataProvider/dataProvider.module.ts index a31a9ba0..bbf5e882 100644 --- a/landingPages/dataProvider/dataProvider.module.ts +++ b/landingPages/dataProvider/dataProvider.module.ts @@ -5,7 +5,6 @@ import { RouterModule } from '@angular/router'; import {IFrameModule} from '../../utils/iframe.module'; import {ErrorMessagesModule} from '../../utils/errorMessages.module'; -// import { ResultLandingModule } from '../resultLanding.module'; import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; import {MetricsModule} from '../landing-utils/metrics/metrics.module'; import {LandingModule} from '../landing-utils/landing.module'; @@ -27,8 +26,6 @@ import {DataProvidersServiceModule} from '../../services/dataProvidersService.mo import {ProjectsServiceModule} from '../../services/projectsService.module'; import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module'; -import {FreeGuard} from'../../login/freeGuard.guard'; -import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module'; import {ShowPublisherModule} from "../landing-utils/showPublisher.module"; @@ -54,7 +51,7 @@ import {SearchTabModule} from "../../utils/tabs/contents/search-tab.module"; RelatedDatasourcesTabComponent, DataProviderComponent, SoftwareTabComponent, OrpsTabComponent ], providers:[ - DataProviderService, FreeGuard, IsRouteEnabled], + DataProviderService], exports: [ DataProviderComponent ] diff --git a/landingPages/dataProvider/dataProvider.service.ts b/landingPages/dataProvider/dataProvider.service.ts index 5926afeb..85b91614 100644 --- a/landingPages/dataProvider/dataProvider.service.ts +++ b/landingPages/dataProvider/dataProvider.service.ts @@ -1,11 +1,7 @@ import {Injectable} from '@angular/core'; -import {Http, Response,Headers, RequestOptions} from '@angular/http'; import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http"; -import {Observable, throwError} from 'rxjs'; +import {throwError} from 'rxjs'; import {DataProviderInfo} from '../../utils/entities/dataProviderInfo'; - - - import{EnvProperties} from '../../utils/properties/env-properties'; import {map} from "rxjs/operators"; diff --git a/landingPages/dataProvider/orpsTab.component.ts b/landingPages/dataProvider/orpsTab.component.ts index ce84dbbc..cd429174 100644 --- a/landingPages/dataProvider/orpsTab.component.ts +++ b/landingPages/dataProvider/orpsTab.component.ts @@ -36,6 +36,4 @@ export class OrpsTabComponent { ngOnInit() { this.linkToSearchOrps = this.properties.searchLinkToAdvancedOrps; } - - ngOnDestroy() {} } diff --git a/landingPages/dataProvider/softwareTab.component.ts b/landingPages/dataProvider/softwareTab.component.ts index faa8b0d7..a04f26a1 100644 --- a/landingPages/dataProvider/softwareTab.component.ts +++ b/landingPages/dataProvider/softwareTab.component.ts @@ -37,5 +37,4 @@ export class SoftwareTabComponent { this.linkToSearchSoftware = this.properties.searchLinkToAdvancedSoftware; } - ngOnDestroy() {} } diff --git a/landingPages/dataProvider/statisticsTab.component.ts b/landingPages/dataProvider/statisticsTab.component.ts index 93b2f2ae..e8512a26 100644 --- a/landingPages/dataProvider/statisticsTab.component.ts +++ b/landingPages/dataProvider/statisticsTab.component.ts @@ -4,6 +4,7 @@ import {FetchResearchResults} from '../../utils/fetchEntitiesClasses/fetchResear import {ErrorCodes} from '../../utils/properties/errorCodes'; import {EnvProperties} from '../../utils/properties/env-properties'; import {StringUtils} from "../../utils/string-utils.class"; +import {Subscriber} from "rxjs"; @Component({ selector: 'statisticsTab', @@ -67,10 +68,11 @@ export class StatisticsTabComponent { private pubsProjectsUrl:string; public errorCodes:ErrorCodes = new ErrorCodes(); properties:EnvProperties; + sub; constructor (private route: ActivatedRoute) {} ngOnInit() { - this.route.data + this.sub = this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; @@ -95,5 +97,8 @@ export class StatisticsTabComponent { }); } - ngOnDestroy() {} -} + ngOnDestroy() { + if (this.sub instanceof Subscriber) { + this.sub.unsubscribe(); + } + }} diff --git a/landingPages/feedback/feedback.component.ts b/landingPages/feedback/feedback.component.ts index eaee02dc..85216ba3 100644 --- a/landingPages/feedback/feedback.component.ts +++ b/landingPages/feedback/feedback.component.ts @@ -19,6 +19,7 @@ import {ProjectInfo} from "../../utils/entities/projectInfo"; import {DataProviderInfo} from "../../utils/entities/dataProviderInfo"; import {EmailService} from "../../utils/email/email.service"; import {Composer} from "../../utils/email/composer"; +import {Subscriber} from "rxjs"; @Component({ selector: 'feedback', @@ -44,11 +45,17 @@ export class FeedbackComponent implements OnInit, OnChanges { public form: FormGroup; public url: string = null; public recipients: string[] = []; - + subscriptions =[]; constructor(private fb: FormBuilder, private emailService: EmailService) { } - + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); + } ngOnInit(): void { if(typeof window !== "undefined") { this.url = window.location.href; @@ -117,17 +124,17 @@ export class FeedbackComponent implements OnInit, OnChanges { public sendReport() { this.sending = true; - this.emailService.contact(this.properties, + this.subscriptions.push(this.emailService.contact(this.properties, Composer.composeEmailForFeedback(this.form.value, this.recipients), this.form.get('recaptcha').value).subscribe(sent => { this.error = !sent; if(sent) { if(this.form.get('email').value !== '') { - this.emailService.contact(this.properties, + this.subscriptions.push(this.emailService.contact(this.properties, Composer.composeEmailForUserAfterFeedback([this.form.get('email').value])).subscribe(sent => { if(sent) { //console.log('An email has been sent to user ' + this.form.get('email').value); } - }) + })); } this.init(); this.sent = true; @@ -137,6 +144,6 @@ export class FeedbackComponent implements OnInit, OnChanges { console.log(error); this.error = true; this.sending = false; - }); + })); } -} \ No newline at end of file +} diff --git a/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts b/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts deleted file mode 100644 index 75a108fb..00000000 --- a/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts +++ /dev/null @@ -1,15 +0,0 @@ -// import { NgModule } from '@angular/core'; -// import { RouterModule } from '@angular/router'; -// -// import { HtmlProjectReportComponent } from './htmlProjectReport.component'; -// import {FreeGuard} from'../../login/freeGuard.guard'; -// import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; -// -// @NgModule({ -// imports: [ -// RouterModule.forChild([ -// { path: '', component: HtmlProjectReportComponent , canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder]} -// ]) -// ] -// }) -// export class HtmlProjectReportRoutingModule { } diff --git a/landingPages/htmlProjectReport/htmlProjectReport.component.ts b/landingPages/htmlProjectReport/htmlProjectReport.component.ts index 8832715c..c2e3f3e4 100644 --- a/landingPages/htmlProjectReport/htmlProjectReport.component.ts +++ b/landingPages/htmlProjectReport/htmlProjectReport.component.ts @@ -9,6 +9,7 @@ import {ProjectService} from '../project/project.service'; import {PiwikService} from '../../utils/piwik/piwik.service'; import {SEOService} from '../../sharedComponents/SEO/SEO.service'; import {HelperService} from "../../utils/helper/helper.service"; +import {Subscriber} from "rxjs"; declare var UIkit: any; @@ -62,10 +63,7 @@ export class HtmlProjectReportComponent { public header2: string = ""; public htmlResult: string = ""; - public sub: any; - piwiksub: any; - public subHTML: any; - public subHTMLInfo: any; + subscriptions = []; public warningMessage: string = ""; public errorMessage: string = ""; @@ -86,7 +84,7 @@ export class HtmlProjectReportComponent { } ngOnInit() { - this.route.data + this.subscriptions.push(this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; //this.getDivContents(); @@ -94,8 +92,8 @@ export class HtmlProjectReportComponent { this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url); this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this._router.url); - }); - this.sub = this.route.queryParams.subscribe(params => { + })); + this.subscriptions.push(this.route.queryParams.subscribe(params => { this.projectId = params['projectId']; if (params['size'] == parseInt(params['size'], 10)) { @@ -136,40 +134,35 @@ export class HtmlProjectReportComponent { this.warningMessage = "No valid project id"; } } - }); + })); } private getPageContents() { if(this.communityId) { - this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.pageContents = contents; - }); + })); } } private getDivContents() { if(this.communityId) { - this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.divContents = contents; - }); + })); } } ngOnDestroy() { - this.sub.unsubscribe(); - if (this.piwiksub) { - this.piwiksub.unsubscribe(); - } - if (this.subHTML) { - this.subHTML.unsubscribe(); - } - if (this.subHTMLInfo) { - this.subHTMLInfo.unsubscribe(); - } + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } private createHeaders() { - this.subHTMLInfo = this._projectService.getHTMLInfo(this.projectId, this.properties).subscribe( + this.subscriptions.push(this._projectService.getHTMLInfo(this.projectId, this.properties).subscribe( data => { this.createHeader1(data); if (data.acronym) { @@ -178,7 +171,7 @@ export class HtmlProjectReportComponent { this.updateTitle(data.title + " " + this.resultsType + " report"); } if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { - this.piwiksub = this._piwikService.trackView(this.properties, ((data.acronym) ? data.acronym : data.title) + " " + this.resultsType + " report", this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackView(this.properties, ((data.acronym) ? data.acronym : data.title) + " " + this.resultsType + " report", this.piwikSiteId).subscribe()); } }, err => { @@ -186,7 +179,7 @@ export class HtmlProjectReportComponent { //console.log(err); this.createClipboard(); } - ); + )); if (this.resultsType == "publication") { this.header2 += this.totalResults.toLocaleString('en-US') + " publications"; @@ -207,7 +200,7 @@ export class HtmlProjectReportComponent { intro += ''; if (typeof window !== 'undefined') { - this.subHTML = this.htmlService.getHTML(this.projectId, this.resultsType, this.properties.csvAPIURL).subscribe( + this.subscriptions.push(this.htmlService.getHTML(this.projectId, this.resultsType, this.properties.csvAPIURL).subscribe( data => { //let body: string = intro+'

'+this.header1+'

'+this.header2+'

'+data+''; let body: string = intro + '

' + this.header1 + '

' + this.header2 + '

'; @@ -238,7 +231,7 @@ export class HtmlProjectReportComponent { this.errorMessage = 'Service not available'; this.showLoading = false; } - ); + )); } } diff --git a/landingPages/htmlProjectReport/htmlProjectReport.module.ts b/landingPages/htmlProjectReport/htmlProjectReport.module.ts index a31e42e4..f80a1974 100644 --- a/landingPages/htmlProjectReport/htmlProjectReport.module.ts +++ b/landingPages/htmlProjectReport/htmlProjectReport.module.ts @@ -7,8 +7,6 @@ import { ProjectServiceModule} from '../project/projectService.module'; import {HtmlProjectReportService} from './htmlProjectReport.service'; import {HtmlProjectReportComponent} from './htmlProjectReport.component'; -// import { HtmlProjectReportRoutingModule } from './htmlProjectReport-routing.module'; -import {FreeGuard} from'../../login/freeGuard.guard'; import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module'; import {HelperModule} from "../../utils/helper/helper.module"; @@ -23,7 +21,7 @@ import {RouterModule} from '@angular/router'; HtmlProjectReportComponent ], providers:[ - HtmlProjectReportService, FreeGuard + HtmlProjectReportService ], exports: [ HtmlProjectReportComponent diff --git a/landingPages/landing-utils/addThis.component.ts b/landingPages/landing-utils/addThis.component.ts index 0397107d..3f349672 100644 --- a/landingPages/landing-utils/addThis.component.ts +++ b/landingPages/landing-utils/addThis.component.ts @@ -21,12 +21,16 @@ declare var addthis: addthis; ` }) export class AddThisComponent implements OnInit { - + sub; constructor(private route: ActivatedRoute, @Inject(DOCUMENT) private document, private rendererFactory: RendererFactory2) {} - + ngOnDestroy() { + if(this.sub) { + this.sub.unsubscribe(); + } + } ngOnInit() { - this.route.queryParams.subscribe(data => { + this.sub = this.route.queryParams.subscribe(data => { try { if (!this.document.getElementById('addThisScript') && typeof document !== 'undefined') { // console.log(" create script AddThis"); diff --git a/landingPages/landing-utils/citeThis/citation.class.ts b/landingPages/landing-utils/citeThis/citation.class.ts index d5be677d..3c6c51de 100644 --- a/landingPages/landing-utils/citeThis/citation.class.ts +++ b/landingPages/landing-utils/citeThis/citation.class.ts @@ -15,7 +15,7 @@ export class Citation{ apa:string =' `'; // is short version harvard:string = ' '; - locale:string =' This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License 2012-07-04T23:31:02+00:00 radio broadcast television broadcast podcast instant message email volume volumes accessed and & and others anonymous anon. at available at by circa c. cited edition editions ed. et al. forthcoming from ibid. in in press internet interview letter no date n.d. online presented at the reference references ref. refs. retrieved scale version AD BC th st nd rd th th th first second third fourth fifth sixth seventh eighth ninth tenth book books chapter chapters column columns figure figures folio folios number numbers line lines note notes opus opera page pages paragraph paragraph part parts section sections sub verbo sub verbis verse verses volume volumes bk. chap. col. fig. f. no. l. n. op. p. pp. para. pt. sec. s.v. s.vv. v. vv. vol. vols. ¶¶ § §§ director directors editor editors editor editors illustrator illustrators translator translators editor & translator editors & translators dir. dirs. ed. eds. ed. eds. ill. ills. tran. trans. ed. & tran. eds. & trans. directed by edited by edited by illustrated by interview by to by translated by edited & translated by by dir. ed. ed. illus. trans. ed. & trans. January February March April May June July August September October November December Jan. Feb. Mar. Apr. May Jun. Jul. Aug. Sep. Oct. Nov. Dec. Spring Summer Autumn Winter '; + locale:string =' This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License 2012-07-04T23:31:02+00:00 radio broadcast television broadcast podcast instant message email volume volumes accessed and & and others anonymous anon. at available at by circa c. cited edition editions ed. et al. forthcoming from ibid. in in press internet interview letter no date n.d. online presented at the reference references ref. refs. retrieved scale version AD BC th st nd rd th th th first second third fourth fifth sixth seventh eighth ninth tenth book books chapter chapters column columns figure figures folio folios number numbers line lines note notes opus opera page pages paragraph paragraph part parts section sections subscriptions verbo subscriptions verbis verse verses volume volumes bk. chap. col. fig. f. no. l. n. op. p. pp. para. pt. sec. s.v. s.vv. v. vv. vol. vols. ¶¶ § §§ director directors editor editors editor editors illustrator illustrators translator translators editor & translator editors & translators dir. dirs. ed. eds. ed. eds. ill. ills. tran. trans. ed. & tran. eds. & trans. directed by edited by edited by illustrated by interview by to by translated by edited & translated by by dir. ed. ed. illus. trans. ed. & trans. January February March April May June July August September October November December Jan. Feb. Mar. Apr. May Jun. Jul. Aug. Sep. Oct. Nov. Dec. Spring Summer Autumn Winter '; frontiers:string = ''; ama:string = ''; } diff --git a/landingPages/landing-utils/citeThis/citeThis.component.ts b/landingPages/landing-utils/citeThis/citeThis.component.ts index 8d29796e..20069a86 100644 --- a/landingPages/landing-utils/citeThis/citeThis.component.ts +++ b/landingPages/landing-utils/citeThis/citeThis.component.ts @@ -1,6 +1,5 @@ import { Component, - ElementRef, Inject, Input, OnDestroy, @@ -8,7 +7,6 @@ import { RendererFactory2, ViewEncapsulation } from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; import {Citation, CitationData} from './citation.class'; import {ResultLandingInfo} from "../../../utils/entities/resultLandingInfo"; import {DOCUMENT} from "@angular/common"; @@ -55,6 +53,7 @@ export class CiteThisComponent implements OnInit, OnDestroy { public citeproc; public data; public clipboard; + timeout; constructor( @Inject(DOCUMENT) private document, private rendererFactory: RendererFactory2){ @@ -78,7 +77,7 @@ export class CiteThisComponent implements OnInit, OnDestroy { renderer.setAttribute(script, "type", "text/javascript"); renderer.appendChild(head, script); } - setTimeout(() => { + this.timeout = setTimeout(() => { this.parseData(); this.selectedStyle = this.citation.templates[0]; this.updateCitation(); @@ -92,6 +91,7 @@ export class CiteThisComponent implements OnInit, OnDestroy { ngOnDestroy() { delete this.clipboard; + clearTimeout(this.timeout); } private createClipboard() { diff --git a/landingPages/landing-utils/projects-in-modal.component.ts b/landingPages/landing-utils/projects-in-modal.component.ts index 68372f7b..03a4ac76 100644 --- a/landingPages/landing-utils/projects-in-modal.component.ts +++ b/landingPages/landing-utils/projects-in-modal.component.ts @@ -8,8 +8,6 @@ import {ErrorCodes} from '../../utils/properties/errorCodes'; import {StringUtils} from '../../utils/string-utils.class'; import {RouterHelper} from '../../utils/routerHelper.class'; import {EnvProperties} from '../../utils/properties/env-properties'; -import {ResultPreview} from "../../utils/result-preview/result-preview"; -import {SearchResult} from "../../utils/entities/searchResult"; import {AlertModal} from "../../utils/modal/alert"; @Component({ diff --git a/landingPages/landing-utils/resultLandingUtils.module.ts b/landingPages/landing-utils/resultLandingUtils.module.ts index 12a76e93..036a76a8 100644 --- a/landingPages/landing-utils/resultLandingUtils.module.ts +++ b/landingPages/landing-utils/resultLandingUtils.module.ts @@ -4,8 +4,6 @@ import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; import {PagingModule} from '../../utils/paging.module'; - -//import {ShowAuthorsComponent} from './showAuthors.component'; import {ShowIdentifiersComponent} from './showIdentifiers.component'; import {ShowSubjectsComponent} from './showSubjects.component'; import {FundedByComponent} from './fundedBy.component'; diff --git a/landingPages/landing-utils/showTitle.component.ts b/landingPages/landing-utils/showTitle.component.ts index b6130c96..2d068045 100644 --- a/landingPages/landing-utils/showTitle.component.ts +++ b/landingPages/landing-utils/showTitle.component.ts @@ -44,18 +44,6 @@ export class ShowTitleComponent { @Input() iconClass:string; @Input() classNames: string = ""; - sub: any; + constructor () {} - constructor (private route: ActivatedRoute) {} - - ngOnInit() { - this.sub = this.route.queryParams.subscribe( - params => { - } - ); - } - - ngOnDestroy() { - this.sub.unsubscribe(); - } } diff --git a/landingPages/landing-utils/tabTable.component.ts b/landingPages/landing-utils/tabTable.component.ts index ebce491a..0ca42f49 100644 --- a/landingPages/landing-utils/tabTable.component.ts +++ b/landingPages/landing-utils/tabTable.component.ts @@ -1,6 +1,5 @@ import {Component, Input} from '@angular/core'; import {RouterHelper} from '../../utils/routerHelper.class'; -//import {PagingModule} from '../utils/paging.module'; import{EnvProperties} from '../../utils/properties/env-properties'; @Component({ diff --git a/landingPages/organization/deletedByInference/deletedByInference.component.ts b/landingPages/organization/deletedByInference/deletedByInference.component.ts index cab2a84a..fd5f1b73 100644 --- a/landingPages/organization/deletedByInference/deletedByInference.component.ts +++ b/landingPages/organization/deletedByInference/deletedByInference.component.ts @@ -1,4 +1,4 @@ -import {Component, ViewChild} from '@angular/core'; +import {Component} from '@angular/core'; import {ElementRef, Input} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; @@ -8,9 +8,9 @@ import {RouterHelper} from '../../../utils/routerHelper.class'; import {ErrorCodes} from '../../../utils/properties/errorCodes'; import {OrganizationsDeletedByInferenceService} from './deletedByInference.service'; -import {ResultLandingInfo} from "../../../utils/entities/resultLandingInfo"; import {ResultPreview} from "../../../utils/result-preview/result-preview"; import {AlertModal} from "../../../utils/modal/alert"; +import {Subscriber} from "rxjs"; @Component({ selector: 'organizationsDeletedByInference', @@ -48,36 +48,40 @@ export class OrganizationsDeletedByInferenceComponent { public routerHelper:RouterHelper = new RouterHelper(); public errorCodes:ErrorCodes = new ErrorCodes(); - sub: any; + subscriptions = []; properties:EnvProperties; constructor ( private element: ElementRef, private _deletedByInferenceService: OrganizationsDeletedByInferenceService, - private route: ActivatedRoute, - private _router: Router) { + private route: ActivatedRoute) { } ngOnInit() { - this.route.data + this.subscriptions.push(this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; - }); - this.sub = this.route.queryParams.subscribe(data => { + })); + this.subscriptions.push(this.route.queryParams.subscribe(data => { this.errorCodes = new ErrorCodes(); this.status = this.errorCodes.LOADING; this.getDeletedByInference(); - }); + })); } - ngOnDestroy() {} - + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); + } getDeletedByInference() { this.results = []; this.status = this.errorCodes.LOADING; - this._deletedByInferenceService.getDeletedByInferenceResults(this.id, String(this.ids.length), this.properties).subscribe( + this.subscriptions.push(this._deletedByInferenceService.getDeletedByInferenceResults(this.id, String(this.ids.length), this.properties).subscribe( data => { this.results = data; this.status = this.errorCodes.DONE; @@ -91,7 +95,7 @@ export class OrganizationsDeletedByInferenceComponent { this.status = this.errorCodes.NOT_AVAILABLE; } } - ); + )); } public getResultPreview(result: OrganizationInfo): ResultPreview { diff --git a/landingPages/organization/organization-routing.module.ts b/landingPages/organization/organization-routing.module.ts deleted file mode 100644 index 52d44be3..00000000 --- a/landingPages/organization/organization-routing.module.ts +++ /dev/null @@ -1,18 +0,0 @@ -// import { NgModule } from '@angular/core'; -// import { RouterModule } from '@angular/router'; -// -// import { OrganizationComponent } from './organization.component'; -// import {FreeGuard} from'../../login/freeGuard.guard'; -// import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard'; -// import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; -// -// @NgModule({ -// imports: [ -// RouterModule.forChild([ -// { path: '', component: OrganizationComponent, canActivate: [FreeGuard, IsRouteEnabled], data: { -// redirect: '/error' -// },canDeactivate: [PreviousRouteRecorder] } -// ]) -// ] -// }) -// export class OrganizationRoutingModule { } diff --git a/landingPages/organization/organization.component.ts b/landingPages/organization/organization.component.ts index 6032ef13..f9714445 100644 --- a/landingPages/organization/organization.component.ts +++ b/landingPages/organization/organization.component.ts @@ -22,6 +22,7 @@ import {Location} from "@angular/common"; import {FetchResearchResults} from "../../utils/fetchEntitiesClasses/fetchResearchResults.class"; import {FetchDataproviders} from "../../utils/fetchEntitiesClasses/fetchDataproviders.class"; import {IndexInfoService} from "../../utils/indexInfo.service"; +import {Subscriber} from "rxjs"; @Component({ selector: 'organization', @@ -62,11 +63,7 @@ export class OrganizationComponent { // Active tab variable for responsiveness public activeTab: string = ""; - - public firstTab: string = ""; - public _numberOfTabs: number = 0; - public tabsAreInitialized: boolean = false; - + @ViewChild('downloadReportModal') downloadReportModal; @ViewChild('downloadFunderReportModal') downloadFunderReportModal; @@ -93,14 +90,7 @@ export class OrganizationComponent { public funder: any = ""; private funderId: string; private funderCount: number; - sub: any; - infoSub: any; - piwiksub: any; - downloadFileSub: any; - downloadFilePiwikSub: any; - countProjectsSub: any; - countPublSub: any; - downloadProjectPublSub: any; + subscriptions = []; properties: EnvProperties; public indexUpdateDate: Date; public showFeedback: boolean = false; @@ -110,8 +100,7 @@ export class OrganizationComponent { @ViewChild('projectsModal') projectsModal; public deleteByInferenceOpened: boolean = false; - //private ngUnsubscribe: Subject = new Subject(); - + constructor(private element: ElementRef, private _organizationService: OrganizationService, private _piwikService: PiwikService, @@ -136,21 +125,21 @@ export class OrganizationComponent { } ngOnInit() { - this.route.data + this.subscriptions.push(this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; if (typeof document !== 'undefined') { - this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { + this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { if (lastIndexUpdate) { this.indexUpdateDate = new Date(lastIndexUpdate); } - }); + })); } //this.getDivContents(); this.getPageContents(); this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url); - }); - this.sub = this.route.queryParams.subscribe(params => { + })); + this.subscriptions.push(this.route.queryParams.subscribe(params => { this.organizationInfo = null; this.updateTitle("Organization"); this.updateDescription(""); @@ -174,7 +163,7 @@ export class OrganizationComponent { this.csvParamsTail = '" and relorganizationid exact "' + this.organizationId + '" ))'; - }); + })); this.downloadURLAPI = this.properties.csvAPIURL; //this.csvAffiliatedPublications = this.downloadURLAPI + "?format=csv&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relorganizationid exact \"" + this.organizationId + "\"))"; @@ -184,53 +173,34 @@ export class OrganizationComponent { private getPageContents() { if(this.communityId) { - this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.pageContents = contents; - }); + })); } } private getDivContents() { if(this.communityId) { - this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.divContents = contents; - }); + })); } } - - + ngOnDestroy() { - if (this.sub) { - this.sub.unsubscribe(); - } - if (this.piwiksub) { - this.piwiksub.unsubscribe(); - } - if (this.infoSub) { - this.infoSub.unsubscribe(); - } - if (this.downloadFileSub) { - this.downloadFileSub.unsubscribe(); - } - if (this.downloadFilePiwikSub) { - this.downloadFilePiwikSub.unsubscribe(); - } - if (this.countProjectsSub) { - this.countProjectsSub.unsubscribe(); - } - if (this.countPublSub) { - this.countPublSub.unsubscribe(); - } - if (this.downloadProjectPublSub) { - this.downloadProjectPublSub.unsubscribe(); - } - - /* - this.ngUnsubscribe.next(); - this.ngUnsubscribe.complete(); - */ + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); + this.fetchDatasets.clearSubscriptions(); + this.fetchPublications.clearSubscriptions(); + this.fetchSoftware.clearSubscriptions(); + this.fetchPublications.clearSubscriptions(); + this.fetchDataproviders.clearSubscriptions(); + this.fetchProjects.clearSubscriptions(); } - + private getTotalResearchResults() { this.fetchPublications.getNumForEntity('publication', 'organization', this.organizationId, this.properties); this.fetchDatasets.getNumForEntity('dataset', 'organization', this.organizationId, this.properties); @@ -319,8 +289,8 @@ export class OrganizationComponent { this.showLoading = true; this.organizationInfo = null; - - this.infoSub = this._organizationService.getOrganizationInfo(this.organizationId, this.properties).subscribe( + + this.subscriptions.push(this._organizationService.getOrganizationInfo(this.organizationId, this.properties).subscribe( data => { if (data == null) { this.showLoading = false; @@ -340,7 +310,7 @@ export class OrganizationComponent { ((this.organizationInfo.title.name && this.organizationInfo.title.name != this.organizationInfo.name) ? (', ') : '') + (this.organizationInfo.name?this.organizationInfo.name:'')); if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { - this.piwiksub = this._piwikService.trackView(this.properties, this.organizationInfo.title.name, this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackView(this.properties, this.organizationInfo.title.name, this.piwikSiteId).subscribe()); } var refineFields: string [] = ["funder"]; @@ -368,14 +338,14 @@ export class OrganizationComponent { this.errorMessage = 'No organization found'; this.showLoading = false; } - ); + )); } public downloadFile(url: string, filename: string) { this.openLoading(); this.setMessageLoading("Downloading CSV file"); - - this.downloadFileSub = this._reportsService.downloadCSVFile(url).subscribe( + + this.subscriptions.push(this._reportsService.downloadCSVFile(url).subscribe( data => { this.closeLoading(); @@ -391,7 +361,7 @@ export class OrganizationComponent { //window.open(window.URL.createObjectURL(data)); if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { - this.downloadFilePiwikSub = this._piwikService.trackDownload(this.properties, url, this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackDownload(this.properties, url, this.piwikSiteId).subscribe()); } }, err => { @@ -402,7 +372,7 @@ export class OrganizationComponent { this.confirmOpenCsvError(); }/*, () => console.log('Completed file download.')*/ - ); + )); } private downloadFileByFunder() { @@ -418,12 +388,12 @@ export class OrganizationComponent { let title_index: number = 0; let filename: string = 'funder-project-' + this.funderContentType + '-report'; - - this.countProjectsSub = this._searchProjectsService.getProjectsForOrganizations(this.organizationId, ' and (funder exact "' + this.encodeURI(this.funderId) + '" ) ', 1, this.funderCount, [], this.properties).subscribe( + + this.subscriptions.push(this._searchProjectsService.getProjectsForOrganizations(this.organizationId, ' and (funder exact "' + this.encodeURI(this.funderId) + '" ) ', 1, this.funderCount, [], this.properties).subscribe( data => { projects = data[1]; for (let index = 0; index < projects.length; index++) { - this.countPublSub = this._searchResearchResultsService.numOfEntityResults(this.funderContentType, projects[index].id, "project", this.properties).subscribe( + this.subscriptions.push(this._searchResearchResultsService.numOfEntityResults(this.funderContentType, projects[index].id, "project", this.properties).subscribe( data => { //if(data == 0 && title) { // if no publications for this project if (data == 0 && (counter > 1 || title)) { // if no publications for this project @@ -464,8 +434,8 @@ export class OrganizationComponent { url = this.downloadURLAPI + '?format=csv-special-notitle&' + this.getTypeParam(this.funderContentType) + '&fq=((relprojectid exact "' + projects[index].id + '"))'; } title = true; - - this.downloadProjectPublSub = this._reportsService.getCSVResponse(url).subscribe( + + this.subscriptions.push(this._reportsService.getCSVResponse(url).subscribe( data => { counter--; response[index] = data; @@ -502,12 +472,12 @@ export class OrganizationComponent { this.confirmOpenCsvError(); }/*, () => console.log('Completed file download.')*/ - ); + ) ); } }, err => { this.handleError("Error getting number of publications for project with id: " + projects[index].id, err); - }); + })); } }, err => { @@ -516,7 +486,7 @@ export class OrganizationComponent { this.closeLoading(); this.confirmOpenCsvError(); } - ); + )); } private updateDescription(description: string) { diff --git a/landingPages/organization/organization.module.ts b/landingPages/organization/organization.module.ts index 61e4da37..8d1f1225 100644 --- a/landingPages/organization/organization.module.ts +++ b/landingPages/organization/organization.module.ts @@ -17,8 +17,7 @@ import {SearchResearchResultsServiceModule} from '../../services/searchResearchR import {ProjectsServiceModule} from '../../services/projectsService.module'; import {ProjectsInModalModule} from '../landing-utils/projects-in-modal.module'; -import {FreeGuard} from '../../login/freeGuard.guard'; -import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; + import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; import {SEOServiceModule} from '../../sharedComponents/SEO/SEOService.module'; import {HelperModule} from "../../utils/helper/helper.module"; @@ -51,9 +50,7 @@ import {SearchTabModule} from "../../utils/tabs/contents/search-tab.module"; declarations: [ OrganizationComponent, ], - providers: [ - FreeGuard, IsRouteEnabled - ], + providers: [], exports: [ OrganizationComponent ] diff --git a/landingPages/project/project.component.ts b/landingPages/project/project.component.ts index 3d2809ba..8623e90f 100644 --- a/landingPages/project/project.component.ts +++ b/landingPages/project/project.component.ts @@ -22,10 +22,10 @@ import {HelperService} from "../../utils/helper/helper.service"; import {Location} from "@angular/common"; import {HtmlProjectReportService} from "../htmlProjectReport/htmlProjectReport.service"; import {StringUtils} from "../../utils/string-utils.class"; -import {ResultLandingInfo} from "../../utils/entities/resultLandingInfo"; import {ResultPreview} from "../../utils/result-preview/result-preview"; import {SearchResult} from "../../utils/entities/searchResult"; import {IndexInfoService} from "../../utils/indexInfo.service"; +import {Subscriber} from "rxjs"; @Component({ selector: 'project', @@ -75,12 +75,7 @@ export class ProjectComponent { // Active tab variable for responsiveness public activeTab: string = ""; - public firstTab: string = ""; - public _numberOfTabs: number = 0; - public tabsAreInitialized: boolean = false; - @ViewChild('statisticsModal') statisticsModal; - @ViewChild('linkProjectModal') linkProjectModal; @ViewChild('shareResultsModal') shareResultsModal; @ViewChild('downloadReportModal') downloadReportModal; @@ -125,15 +120,9 @@ export class ProjectComponent { public thresholdOrganizations: number = 20; public showNumOrganizations: number = 20; - sub: any; - piwiksub: any; - infoSub: any; - downloadFilePiwikSub: any; - downloadHtmlFilePiwikSub: any; + subscriptions = []; properties: EnvProperties; - public subHTML: any; - constructor(private route: ActivatedRoute, private _router: Router, private _location: Location, @@ -149,22 +138,22 @@ export class ProjectComponent { private indexInfoService: IndexInfoService) {} ngOnInit() { - this.route.data + this.subscriptions.push(this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; if (typeof document !== 'undefined') { - this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { + this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { if (lastIndexUpdate) { this.indexUpdateDate = new Date(lastIndexUpdate); } - }); + })); } //this.getDivContents(); this.getPageContents(); this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url); - }); - this.sub = this.route.queryParams.subscribe(params => { + })); + this.subscriptions.push(this.route.queryParams.subscribe(params => { this.metricsClicked = false; this.statsClicked = false; this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService); @@ -200,7 +189,7 @@ export class ProjectComponent { this.createClipboard(); HelperFunctions.scroll(); - }); + })); } public getFileNameType(type: string) { @@ -227,17 +216,17 @@ export class ProjectComponent { private getPageContents() { if(this.communityId) { - this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.pageContents = contents; - }); + })); } } private getDivContents() { if(this.communityId) { - this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.divContents = contents; - }); + })); } } @@ -267,21 +256,15 @@ export class ProjectComponent { } ngOnDestroy() { - if (this.sub) { - this.sub.unsubscribe(); - } - if (this.piwiksub) { - this.piwiksub.unsubscribe(); - } - if (this.infoSub) { - this.infoSub.unsubscribe(); - } - if (this.downloadFilePiwikSub) { - this.downloadFilePiwikSub.unsubscribe(); - } - if(this.downloadHtmlFilePiwikSub) { - this.downloadHtmlFilePiwikSub.unsubscribe(); - } + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); + this.fetchDatasets.clearSubscriptions(); + this.fetchPublications.clearSubscriptions(); + this.fetchSoftware.clearSubscriptions(); + this.fetchPublications.clearSubscriptions(); } private createClipboard() { @@ -344,7 +327,7 @@ export class ProjectComponent { this.projectInfo = null; - this.infoSub = this._projectService.getProjectInfo(id, this.properties).subscribe( + this.subscriptions.push(this._projectService.getProjectInfo(id, this.properties).subscribe( data => { this.projectInfo = data; @@ -360,7 +343,7 @@ export class ProjectComponent { this.errorMessage = 'No project found'; this.showLoading = false; } - ); + )); } private getProjectInfoByGrantId(grantId: string, funder: string) { @@ -370,7 +353,7 @@ export class ProjectComponent { this.projectInfo = null; - this._projectService.getProjectInfoByGrantId(grantId, funder, this.properties).subscribe( + this.subscriptions.push(this._projectService.getProjectInfoByGrantId(grantId, funder, this.properties).subscribe( data => { this.projectInfo = data; @@ -389,7 +372,7 @@ export class ProjectComponent { this.errorMessage = 'No project found'; this.showLoading = false; } - ); + )); } actionsAfterGettingProjectInfo() { @@ -401,7 +384,7 @@ export class ProjectComponent { this.updateTitle(this.projectName); this.updateDescription(this.projectInfo.description?this.projectInfo.description: ("project" + (this.projectInfo.title?"," + this.projectInfo.title:"") + (this.projectInfo.funding && this.projectInfo.funding.funderName?", funder: " + this.projectInfo.funding.funderName:"") + (this.projectInfo.acronym?"," + this.projectInfo.acronym:""))); if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { - this.piwiksub = this._piwikService.trackView(this.properties, this.projectName, this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackView(this.properties, this.projectName, this.piwikSiteId).subscribe()); } this.project = { @@ -441,7 +424,7 @@ export class ProjectComponent { this.openLoading(); this.setMessageLoading("Downloading CSV file"); - this._reportsService.downloadCSVFile(url).subscribe( + this.subscriptions.push(this._reportsService.downloadCSVFile(url).subscribe( data => { this.closeLoading(); @@ -449,7 +432,7 @@ export class ProjectComponent { this.download(url, filename+".csv"); if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { - this.downloadFilePiwikSub = this._piwikService.trackDownload(this.properties, url).subscribe(); + this.subscriptions.push(this._piwikService.trackDownload(this.properties, url).subscribe()); } }, error => { @@ -460,7 +443,7 @@ export class ProjectComponent { this.confirmOpenFileDownloadError("CSV"); }/*, () => console.log('Completed file download.')*/ - ); + )); } public metricsResults($event) { @@ -541,7 +524,7 @@ export class ProjectComponent { intro += ''; if (typeof window !== 'undefined') { - this.subHTML = this.htmlService.getHTML(this.projectId, type, this.properties.csvAPIURL).subscribe( + this.subscriptions.push(this.htmlService.getHTML(this.projectId, type, this.properties.csvAPIURL).subscribe( data => { //console.info(data); this.htmlResultDownload = intro + '
' + this.header1 + '

' + this.header2 + '

'; @@ -555,7 +538,7 @@ export class ProjectComponent { this.download(url, filename+".html"); if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { - this.downloadHtmlFilePiwikSub = this._piwikService.trackDownload(this.properties, url).subscribe(); + this.subscriptions.push(this._piwikService.trackDownload(this.properties, url).subscribe()); } }, err => { @@ -564,7 +547,7 @@ export class ProjectComponent { this.closeLoading(); this.confirmOpenFileDownloadError("HTML"); } - ); + )); } else { this.closeLoading(); this.confirmOpenFileDownloadError("HTML"); @@ -657,20 +640,6 @@ export class ProjectComponent { a.remove(); // remove the element } - // copyToClipboard(element: HTMLElement) { - // if (typeof document !== 'undefined') { - // if (window.getSelection) { - // const selection = window.getSelection(); - // const range = document.createRange(); - // range.selectNodeContents(element); - // selection.removeAllRanges(); - // selection.addRange(range); - // document.execCommand('copy'); - // } else { - // console.warn("Could not select text in node: Unsupported browser."); - // } - // } - // } public onSelectActiveTab(activeTabId) { if(this.activeTab != activeTabId) { // tab really changed diff --git a/landingPages/project/project.module.ts b/landingPages/project/project.module.ts index d3b62fa3..c347af56 100644 --- a/landingPages/project/project.module.ts +++ b/landingPages/project/project.module.ts @@ -21,8 +21,6 @@ import {ErrorMessagesModule} from '../../utils/errorMessages.module'; import {HelperModule} from "../../utils/helper/helper.module"; import {IFrameModule} from '../../utils/iframe.module'; -import {FreeGuard} from '../../login/freeGuard.guard'; -import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; import {SEOServiceModule} from '../../sharedComponents/SEO/SEOService.module'; import {FeedbackModule} from "../feedback/feedback.module"; @@ -44,7 +42,7 @@ import {SearchTabModule} from "../../utils/tabs/contents/search-tab.module"; ProjectComponent ], providers:[ - FreeGuard, IsRouteEnabled, HtmlProjectReportService + HtmlProjectReportService ], exports: [ ProjectComponent diff --git a/landingPages/project/project.service.ts b/landingPages/project/project.service.ts index de5064de..ae4c65d6 100644 --- a/landingPages/project/project.service.ts +++ b/landingPages/project/project.service.ts @@ -1,7 +1,6 @@ import {Injectable} from '@angular/core'; -import {Http, Response} from '@angular/http'; import {HttpClient, HttpErrorResponse} from "@angular/common/http"; -import {Observable, throwError} from 'rxjs'; +import {throwError} from 'rxjs'; import {ProjectInfo} from '../../utils/entities/projectInfo'; diff --git a/landingPages/result/deletedByInference/deletedByInference.component.ts b/landingPages/result/deletedByInference/deletedByInference.component.ts index f09dfb41..581292db 100644 --- a/landingPages/result/deletedByInference/deletedByInference.component.ts +++ b/landingPages/result/deletedByInference/deletedByInference.component.ts @@ -1,4 +1,4 @@ -import {Component, ViewChild} from '@angular/core'; +import {Component} from '@angular/core'; import {ElementRef, Input} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; @@ -8,9 +8,9 @@ import {RouterHelper} from '../../../utils/routerHelper.class'; import {ErrorCodes} from '../../../utils/properties/errorCodes'; import {DeletedByInferenceService} from './deletedByInference.service'; -import {SearchResult} from "../../../utils/entities/searchResult"; import {ResultPreview} from "../../../utils/result-preview/result-preview"; import {AlertModal} from "../../../utils/modal/alert"; +import {Subscriber} from "rxjs"; @Component({ selector: 'deletedByInference', @@ -49,7 +49,7 @@ export class DeletedByInferenceComponent { public routerHelper: RouterHelper = new RouterHelper(); public errorCodes: ErrorCodes = new ErrorCodes(); - sub: any; + subscriptions = []; properties: EnvProperties; constructor(private element: ElementRef, @@ -59,26 +59,31 @@ export class DeletedByInferenceComponent { } ngOnInit() { - this.route.data + this.subscriptions.push(this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; - }); - this.sub = this.route.queryParams.subscribe(data => { + })); + this.subscriptions.push(this.route.queryParams.subscribe(data => { this.errorCodes = new ErrorCodes(); this.status = this.errorCodes.LOADING; this.getDeletedByInference(); - }); + })); } - + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } getDeletedByInference() { this.results = []; this.status = this.errorCodes.LOADING; - this._deletedByInferenceService.getDeletedByInferenceResults(this.id, String(this.ids.length), this.properties).subscribe( + this.subscriptions.push(this._deletedByInferenceService.getDeletedByInferenceResults(this.id, String(this.ids.length), this.properties).subscribe( data => { this.results = data; this.status = this.errorCodes.DONE; @@ -92,7 +97,7 @@ export class DeletedByInferenceComponent { this.status = this.errorCodes.NOT_AVAILABLE; } } - ); + )); } public getResultPreview(result: ResultLandingInfo): ResultPreview { diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index f847b76d..e603d01d 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -19,6 +19,7 @@ import {FormBuilder} from "@angular/forms"; import {StringUtils} from "../../utils/string-utils.class"; import {properties} from "../../../../environments/environment"; import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabularies.service"; +import {Subscriber} from "rxjs"; @Component({ @@ -37,7 +38,6 @@ export class ResultLandingComponent { public deleteByInferenceOpened: boolean = false; public resultLandingInfo: ResultLandingInfo; - public relatedResults: RelationResult[]; public supplementaryResults: RelationResult[]; public relation: string = 'trust'; public id: string; @@ -78,8 +78,7 @@ export class ResultLandingComponent { // Map counting variables public bioentitiesNum: number = 0; public relatedResultsNum: number = 0; - public supplementaryResultsNum: number = 0; - + // Message variables public warningMessage = ""; public errorMessage = ""; @@ -89,9 +88,7 @@ export class ResultLandingComponent { public routerHelper: RouterHelper = new RouterHelper(); public activeTab: string = null; private doi: string; - sub: any; - piwiksub: any; - infoSub: any; + subscriptions = []; properties: EnvProperties = properties; public indexUpdateDate: Date; public pageContents = null; @@ -121,16 +118,16 @@ export class ResultLandingComponent { ngOnInit() { if (typeof document !== 'undefined') { - this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { + this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { if (lastIndexUpdate) { this.indexUpdateDate = new Date(lastIndexUpdate); } - }); + })); } //this.getDivContents(); this.getPageContents(); this.updateUrl(this.properties.domain +this.properties.baseLink + this._router.url); - this.sub = this.route.queryParams.subscribe(data => { + this.subscriptions.push(this.route.queryParams.subscribe(data => { this.resultLandingInfo = null; if (data['articleId']) { this.type = "publication"; @@ -189,35 +186,32 @@ export class ResultLandingComponent { this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; this.scroll(); - }); + })); } private getPageContents() { if (this.communityId) { - this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.pageContents = contents; - }); + })); } } private getDivContents() { if (this.communityId) { - this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.divContents = contents; - }); + })); } } - + ngOnDestroy() { - if (this.sub) { - this.sub.unsubscribe(); - } - if (this.piwiksub) { - this.piwiksub.unsubscribe(); - } - if (this.infoSub) { - this.infoSub.unsubscribe(); - } + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); + this._vocabulariesService.clearSubscriptions(); } public getTypeName(): string { @@ -244,14 +238,14 @@ export class ResultLandingComponent { } private getOpenCitations() { - this._resultLaningService.getOpenCitations(this.id, this.properties).subscribe( + this.subscriptions.push(this._resultLaningService.getOpenCitations(this.id, this.properties).subscribe( data => { this.resultLandingInfo.openCitations = data[1]; }, err => { this.handleError("Error getting open citation for " + this.type + " with id: " + this.id, err); } - ); + )); } private getProvenanceVocabularyAndResultLandingInfo() { @@ -262,14 +256,14 @@ export class ResultLandingComponent { this.resultLandingInfo = null; if (typeof document !== 'undefined') { - this._vocabulariesService.getProvenanceActionVocabulary(this.properties).subscribe( + this.subscriptions.push(this._vocabulariesService.getProvenanceActionVocabulary(this.properties).subscribe( provenanceActionVocabulary => { this.getResultLandingInfo(provenanceActionVocabulary); }, err => { this.getResultLandingInfo(null); this.handleError("Error getting provenance action vocabulary for " + this.type + " with id: " + this.id, err); } - ); + )); } else { this.getResultLandingInfo(null); } @@ -315,7 +309,7 @@ export class ResultLandingComponent { // } private getResultLandingInfo(provenanceActionVocabulary: any) { - this.infoSub = this._resultLaningService.getResultLandingInfo(this.id, this.type, provenanceActionVocabulary, this.properties).subscribe( + this.subscriptions.push(this._resultLaningService.getResultLandingInfo(this.id, this.type, provenanceActionVocabulary, this.properties).subscribe( data => { this.resultLandingInfo = data; if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType @@ -331,7 +325,7 @@ export class ResultLandingComponent { this.updateDescription((this.resultLandingInfo.description ? (this.resultLandingInfo.description) : ("," + this.resultLandingInfo.title))); } if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { - this.piwiksub = this._piwikService.trackView(this.properties, this.resultLandingInfo.title/*.name*/, this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackView(this.properties, this.resultLandingInfo.title/*.name*/, this.piwikSiteId).subscribe()); } let bioentitiesNum = 0; @@ -344,11 +338,11 @@ export class ResultLandingComponent { if (typeof document !== 'undefined') { if (this.resultLandingInfo.identifiers != undefined && this.resultLandingInfo.identifiers.has('doi')) { this.doi = this.resultLandingInfo.identifiers.get('doi')[0]; - this.metricsService.hasAltMetrics(this.properties.altMetricsAPIURL, this.doi).subscribe(hasAltMetrics => { + this.subscriptions.push(this.metricsService.hasAltMetrics(this.properties.altMetricsAPIURL, this.doi).subscribe(hasAltMetrics => { this.hasAltMetrics = hasAltMetrics; }, error => { this.hasAltMetrics = false; - }); + })); } } this.showLoading = false; @@ -371,7 +365,7 @@ export class ResultLandingComponent { this.showLoading = false; this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink + this.linkToSearchPage); } - ); + )); } public metricsResults($event) { diff --git a/landingPages/result/resultLanding.module.ts b/landingPages/result/resultLanding.module.ts index 2b646693..9faca221 100644 --- a/landingPages/result/resultLanding.module.ts +++ b/landingPages/result/resultLanding.module.ts @@ -11,8 +11,6 @@ import {IFrameModule} from '../../utils/iframe.module'; import {AltMetricsModule} from '../../utils/altmetrics.module'; import {PagingModule} from '../../utils/paging.module'; -import {FreeGuard} from '../../login/freeGuard.guard'; -import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; import {ResultLandingService} from './resultLanding.service'; import {ResultLandingComponent} from './resultLanding.component'; import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; @@ -42,7 +40,7 @@ import {LoadingModule} from "../../utils/loading/loading.module"; ResultLandingComponent ], providers: [ - ResultLandingService, FreeGuard, IsRouteEnabled + ResultLandingService ], exports: [ ResultLandingComponent diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index d543fcb2..73b92de9 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -4,7 +4,7 @@ import {throwError} from 'rxjs'; import {ResultLandingInfo} from '../../utils/entities/resultLandingInfo'; import {EnvProperties} from '../../utils/properties/env-properties'; import {ParsingFunctions} from '../landing-utils/parsingFunctions.class'; -import {map, tap} from "rxjs/operators"; +import {map} from "rxjs/operators"; import {HostedByCollectedFrom, Organization} from "../../utils/result-preview/result-preview"; import {Dates} from "../../utils/string-utils.class"; diff --git a/login/adminLoginGuard.guard.ts b/login/adminLoginGuard.guard.ts index b80aba1b..689f137c 100644 --- a/login/adminLoginGuard.guard.ts +++ b/login/adminLoginGuard.guard.ts @@ -4,7 +4,7 @@ import {Observable} from 'rxjs'; import {Session} from './utils/helper.class'; import {LoginErrorCodes} from './utils/guardHelper.class'; import {UserManagementService} from "../services/user-management.service"; -import {filter, map} from "rxjs/operators"; +import {map, tap} from "rxjs/operators"; @Injectable() export class AdminLoginGuard implements CanActivate { @@ -15,21 +15,22 @@ export class AdminLoginGuard implements CanActivate { check(path: string): Observable { let errorCode = LoginErrorCodes.NOT_LOGIN; - const obs = this.userManagementService.getUserInfo(false).pipe(map(user => { + return this.userManagementService.getUserInfo(false).pipe(map(user => { if (user) { errorCode = LoginErrorCodes.NOT_ADMIN; } return Session.isPortalAdministrator(user); + }),tap(isAdmin => { + if(!isAdmin) { + this.router.navigate(['/user-info'], { + queryParams: { + 'errorCode': errorCode, + 'redirectUrl': path + } + }); + } })); - obs.pipe(filter(isAdmin => !isAdmin)).subscribe(() => { - this.router.navigate(['/user-info'], { - queryParams: { - 'errorCode': errorCode, - 'redirectUrl': path - } - }); - }); - return obs; + } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { diff --git a/login/claimsCuratorGuard.guard.ts b/login/claimsCuratorGuard.guard.ts index 39a1f1fe..e226fec7 100644 --- a/login/claimsCuratorGuard.guard.ts +++ b/login/claimsCuratorGuard.guard.ts @@ -3,7 +3,7 @@ import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from ' import {Observable} from 'rxjs'; import {Session} from './utils/helper.class'; import {LoginErrorCodes} from './utils/guardHelper.class'; -import {filter, map} from "rxjs/operators"; +import {map, tap} from "rxjs/operators"; import {UserManagementService} from "../services/user-management.service"; @Injectable() @@ -15,21 +15,21 @@ export class ClaimsCuratorGuard implements CanActivate { check(path: string): Observable | boolean { let errorCode = LoginErrorCodes.NOT_LOGIN; - const obs = this.userManagementService.getUserInfo(false).pipe(map(user => { + return this.userManagementService.getUserInfo(false).pipe(map(user => { if (user) { errorCode = LoginErrorCodes.NOT_ADMIN; } return Session.isClaimsCurator(user) || Session.isPortalAdministrator(user); + }),tap(isAdmin => { + if(!isAdmin) { + this.router.navigate(['/user-info'], { + queryParams: { + 'errorCode': errorCode, + 'redirectUrl': path + } + }); + } })); - obs.pipe(filter(isAdmin => !isAdmin)).subscribe(() => { - this.router.navigate(['/user-info'], { - queryParams: { - 'errorCode': errorCode, - 'redirectUrl': path - } - }); - }); - return obs; } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { diff --git a/login/freeGuard.guard.ts b/login/freeGuard.guard.ts index d90dc0ad..7708ecdb 100644 --- a/login/freeGuard.guard.ts +++ b/login/freeGuard.guard.ts @@ -4,8 +4,6 @@ import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, - Route, - CanLoad } from '@angular/router'; import {Observable} from 'rxjs'; import {LoginErrorCodes} from './utils/guardHelper.class'; diff --git a/login/loginGuard.guard.ts b/login/loginGuard.guard.ts index 6e13fdfb..4c7c1e84 100644 --- a/login/loginGuard.guard.ts +++ b/login/loginGuard.guard.ts @@ -3,7 +3,7 @@ import {ActivatedRouteSnapshot, CanActivate, CanLoad, Route, Router, RouterState import {Observable} from 'rxjs/Observable'; import {Session} from './utils/helper.class'; import {LoginErrorCodes} from './utils/guardHelper.class'; -import {filter, map} from "rxjs/operators"; +import {map, tap} from "rxjs/operators"; import {UserManagementService} from "../services/user-management.service"; @Injectable() @@ -15,13 +15,18 @@ export class LoginGuard implements CanActivate, CanLoad { check(path: string): Observable | boolean { if (Session.isLoggedIn()) { - const obs = this.userManagementService.getUserInfo(false).pipe(map(user => { + return this.userManagementService.getUserInfo(false).pipe(map(user => { return user !== null; + }),tap(isLoggedIn => { + if(!isLoggedIn) { + this.router.navigate(['/user-info'], { + queryParams: { + 'errorCode': LoginErrorCodes.NOT_LOGIN, + 'redirectUrl': path + } + }); + } })); - obs.pipe(filter(isLoggedIn => !isLoggedIn)).subscribe(() => { - this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN,'redirectUrl': path}}); - }); - return obs; } else { this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, 'redirectUrl':path}}); return false; diff --git a/login/user.component.ts b/login/user.component.ts index c7a7eed0..6f73773d 100644 --- a/login/user.component.ts +++ b/login/user.component.ts @@ -8,6 +8,7 @@ import {RouterHelper} from '../utils/routerHelper.class'; import {EnvProperties} from '../utils/properties/env-properties'; import {UserManagementService} from "../services/user-management.service"; import {properties} from "../../../environments/environment"; +import {Subscriber} from "rxjs"; import {StringUtils} from "../utils/string-utils.class"; @Component({ @@ -21,8 +22,7 @@ export class UserComponent { public server: boolean = true; public errorMessage: string = ""; public password: string = ""; - private sub: any; - private sublogin: any; + private subscriptions = []; public errorCode: string = ""; public redirectUrl: string = ""; public routerHelper: RouterHelper = new RouterHelper(); @@ -41,38 +41,37 @@ export class UserComponent { } ngOnInit() { - this.route.data + this.subscriptions.push(this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.loginUrl = this.properties.loginUrl; - }); + })); if (typeof document !== 'undefined') { this.server = false; - this.userManagementsService.getUserInfo().subscribe(user => { + this.subscriptions.push(this.userManagementsService.getUserInfo().subscribe(user => { this.user = user; this.loggedIn = !!this.user; this.errorMessage = ""; - this.sub = this.route.queryParams.subscribe(params => { + this.subscriptions.push(this.route.queryParams.subscribe(params => { this.errorCode = params["errorCode"]; this.redirectUrl = params["redirectUrl"]; this.errorMessage = ""; if (this.loggedIn && this.errorCode == '1') { this.redirect(); } - }); - }); + })); + })); } } ngOnDestroy() { - if(this.sub) { - this.sub.unsubscribe(); - } - if (this.sublogin) { - this.sublogin.unsubscribe(); - } + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } redirect() { diff --git a/login/user.module.ts b/login/user.module.ts index 1f94750a..851e5cc0 100644 --- a/login/user.module.ts +++ b/login/user.module.ts @@ -8,15 +8,13 @@ import {UserRoutingModule} from './user-routing.module'; import {UserComponent} from './user.component'; import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard'; -import {FreeGuard} from './freeGuard.guard'; -import {LoginGuard} from './loginGuard.guard'; @NgModule({ imports: [ CommonModule, FormsModule, UserRoutingModule, RouterModule ], providers: [ - PreviousRouteRecorder, FreeGuard, LoginGuard + PreviousRouteRecorder ], declarations: [ UserComponent diff --git a/login/userMini.component.ts b/login/userMini.component.ts index 4149ca4a..ecc3b649 100644 --- a/login/userMini.component.ts +++ b/login/userMini.component.ts @@ -1,11 +1,10 @@ -import {Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; +import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; import {ActivatedRoute, NavigationStart, Router} from '@angular/router'; -import {Location} from '@angular/common'; import {User, Session} from './utils/helper.class'; import {RouterHelper} from '../utils/routerHelper.class'; import {StringUtils} from '../utils/string-utils.class'; -import {EnvProperties} from '../utils/properties/env-properties'; import {properties} from "../../../environments/environment"; +import {Subscriber} from "rxjs"; // declare var logoutClicked; @Component({ @@ -180,23 +179,23 @@ export class UserMiniComponent implements OnInit, OnChanges { @Input() redirectUrl: string; @Input() dark: boolean = false; search: string = ''; - sub: any; + subscriptions = []; constructor(private router: Router, private route: ActivatedRoute) { - this.router.events.forEach(event => { + this.subscriptions.push(this.router.events.forEach(event => { if (event instanceof NavigationStart) { this.initialize(event.url); } - }); + })); } ngOnInit() { if (typeof document !== 'undefined') { this.server = false; } - this.sub = this.route.queryParams.subscribe(params => { + this.subscriptions.push(this.route.queryParams.subscribe(params => { this.initialize(); - }); + })); } ngOnChanges(changes: SimpleChanges): void { @@ -204,11 +203,13 @@ export class UserMiniComponent implements OnInit, OnChanges { this.initialize(); } } - + ngOnDestroy() { - if (this.sub) { - this.sub.unsubscribe(); - } + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } initialize(url: string = null) { diff --git a/reload/reload-routing.module.ts b/reload/reload-routing.module.ts index f304da05..32d1c68c 100644 --- a/reload/reload-routing.module.ts +++ b/reload/reload-routing.module.ts @@ -2,13 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{ReloadComponent} from './reload.component'; -import {FreeGuard} from'../login/freeGuard.guard'; import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: ReloadComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } + { path: '', component: ReloadComponent, canDeactivate: [PreviousRouteRecorder] } ]) ] diff --git a/reload/reload.module.ts b/reload/reload.module.ts index 2b7e8469..e12ae190 100644 --- a/reload/reload.module.ts +++ b/reload/reload.module.ts @@ -7,7 +7,6 @@ import{ReloadRoutingModule } from './reload-routing.module'; import{ReloadComponent} from './reload.component'; - import {FreeGuard} from'../login/freeGuard.guard'; import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard'; @NgModule({ @@ -20,7 +19,7 @@ import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard' ReloadComponent ], providers:[ - FreeGuard, PreviousRouteRecorder + PreviousRouteRecorder ], exports: [ ReloadComponent diff --git a/role-verification/role-verification.component.ts b/role-verification/role-verification.component.ts index 2f3f2db3..13f8c03d 100644 --- a/role-verification/role-verification.component.ts +++ b/role-verification/role-verification.component.ts @@ -172,33 +172,33 @@ export class RoleVerificationComponent implements OnInit, OnDestroy { public verifyManager() { this.loading = true; - this.userRegistryService.verify(this.verification.id, this.code.value).subscribe(() => { + this.subs.push(this.userRegistryService.verify(this.verification.id, this.code.value).subscribe(() => { this.loading = false; this.managerModal.cancel(); this.error = null; - this.userManagementService.getUserInfo(false).subscribe(user => { + this.subs.push(this.userManagementService.getUserInfo(false).subscribe(user => { this.user = user; this.router.navigate(['/admin/' + this.verification.entity]); - }); + })); }, error => { this.loading = false; this.error = 'The verification code is invalid'; - }); + })); } public verifyMember() { this.loading = true; - this.userRegistryService.verify(this.verification.id, this.code.value, "member").subscribe(() => { + this.subs.push(this.userRegistryService.verify(this.verification.id, this.code.value, "member").subscribe(() => { this.loading = false; this.error = null; - this.userManagementService.getUserInfo(false).subscribe(user => { + this.subs.push(this.userManagementService.getUserInfo(false).subscribe(user => { this.user = user; this.memberModal.cancel(); - }); + })); }, error => { this.loading = false; this.error = 'The verification code is invalid'; - }); + })); } public reset() { diff --git a/searchPages/advanced/advancedSearchDataProviders.component.ts b/searchPages/advanced/advancedSearchDataProviders.component.ts deleted file mode 100644 index d9f576c8..00000000 --- a/searchPages/advanced/advancedSearchDataProviders.component.ts +++ /dev/null @@ -1,176 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; -import {AdvancedField} from '../searchUtils/searchHelperClasses.class'; -import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; -import {SearchFields} from '../../utils/properties/searchFields'; -import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class'; - -import {EnvProperties} from '../../utils/properties/env-properties'; - - -@Component({ - selector: 'advanced-search-dataprovider', - template: ` - - - - ` - }) - -export class AdvancedSearchDataProvidersComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; -@Input() piwikSiteId = null; -@Input() customFilter:SearchCustomFilter= null; - public results =[]; - public filters =[]; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public searchFields:SearchFields = new SearchFields(); - - public fieldIds: string[] = this.searchFields.DATASOURCE_ADVANCED_FIELDS; - public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; - public selectedFields:AdvancedField[] = []; - - @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; - public resourcesQuery = "(oaftype exact datasource)"; - public csvParams: string; - public disableForms: boolean = false; - public loadPaging: boolean = true; - public oldTotalResults: number = 0; - public pagingLimit: number = 0; - public isPiwikEnabled; - properties:EnvProperties; - - constructor (private route: ActivatedRoute, private _searchDataProvidersService: SearchDataprovidersService ) { - this.results =[]; - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - - //console.info("Con -base url:"+this.searchUtils.baseUrl ); - - } - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties= data.envSpecific; - this.searchUtils.baseUrl = data.envSpecific.searchLinkToAdvancedDataProviders; - this.pagingLimit = data.envSpecific.pagingLimit; - this.isPiwikEnabled = data.envSpecific.enablePiwikTrack; - - }); - - - this.sub = this.route.queryParams.subscribe(params => { - this.loadPaging = true; - if(params['page'] && this.searchUtils.page != params['page']) { - this.loadPaging = false; - this.oldTotalResults = this.searchUtils.totalResults; - } - - let page = (params['page']=== undefined)?0:+params['page']; - this.searchUtils.page = ( page < 1 ) ? 1 : page; - - this.searchUtils.size = (params['size']=== undefined)?10:+params['size']; - if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { - this.searchUtils.size = 10; - } - - this.searchPage.fieldIds = this.fieldIds; - this.selectedFields =[]; - this.searchPage.selectedFields = this.selectedFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - this.searchPage.customFilter = this.customFilter; - this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); - }); - } - ngOnDestroy() { - this.sub.unsubscribe(); - } - sub: any; - public getResults(parameters:string, page: number, size: number){ - if(page > this.pagingLimit ) { - size=0; - } - if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) { - if(parameters!= null && parameters != '' ) { - this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))"; - }else{ - this.csvParams ="&fq="+this.resourcesQuery; - } - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; - - //console.info("Advanced Search for Content Providers: Execute search query "+parameters); - this._searchDataProvidersService.advancedSearchDataproviders(parameters, page, size, this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - this.searchPage.updateBaseUrlWithParameters(); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } - }, - err => { - //console.log(err); - this.handleError("Error getting content providers", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = errorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - //this.searchPage.closeLoading(); - this.disableForms = false; - } - ); - } - } - - private handleError(message: string, error) { - console.error("Content Providers advanced Search Page: "+message, error); - } -} diff --git a/searchPages/advanced/advancedSearchDataProviders.module.ts b/searchPages/advanced/advancedSearchDataProviders.module.ts deleted file mode 100644 index 333e386b..00000000 --- a/searchPages/advanced/advancedSearchDataProviders.module.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import{AdvancedSearchDataProvidersComponent} from './advancedSearchDataProviders.component'; - - -import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; - import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; - import {FreeGuard} from'../../login/freeGuard.guard'; - import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - DataProvidersServiceModule, - AdvancedSearchPageModule - - ], - declarations: [ - AdvancedSearchDataProvidersComponent - ], - providers:[FreeGuard, IsRouteEnabled], - exports: [ - AdvancedSearchDataProvidersComponent - ] -}) -export class AdvancedSearchDataProvidersModule { } diff --git a/searchPages/advanced/advancedSearchOrganizations.component.ts b/searchPages/advanced/advancedSearchOrganizations.component.ts deleted file mode 100644 index 6cdd4425..00000000 --- a/searchPages/advanced/advancedSearchOrganizations.component.ts +++ /dev/null @@ -1,181 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; -import {AdvancedField} from '../searchUtils/searchHelperClasses.class'; -import {SearchOrganizationsService} from '../../services/searchOrganizations.service'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; -import {SearchFields} from '../../utils/properties/searchFields'; -import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class'; -import {EnvProperties} from '../../utils/properties/env-properties'; - - -@Component({ - selector: 'advanced-search-organizations', - template: ` - - - - ` - }) - -export class AdvancedSearchOrganizationsComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; - properties:EnvProperties; -@Input() piwikSiteId = null; - public results =[]; - public filters =[]; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public searchFields:SearchFields = new SearchFields(); - - public fieldIds: string[] = this.searchFields.ORGANIZATION_ADVANCED_FIELDS; - public fieldIdsMap = this.searchFields.ORGANIZATION_FIELDS; - public selectedFields:AdvancedField[] = []; - public csvParams: string; - public disableForms: boolean = false; - public loadPaging: boolean = true; - public oldTotalResults: number = 0; - public pagingLimit: number = 0; - public isPiwikEnabled; - - @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; - @Input() customFilter:SearchCustomFilter= null; - -public resourcesQuery = "(oaftype exact organization)"; - constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) { - this.results =[]; - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - - - - } - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties= data.envSpecific; - this.searchUtils.baseUrl = data.envSpecific.searchLinkToAdvancedOrganizations; - this.pagingLimit = data.envSpecific.pagingLimit; - this.isPiwikEnabled = data.envSpecific.enablePiwikTrack; - - }); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - - this.sub = this.route.queryParams.subscribe(params => { - this.loadPaging = true; - if(params['page'] && this.searchUtils.page != params['page']) { - this.loadPaging = false; - this.oldTotalResults = this.searchUtils.totalResults; - } - - let page = (params['page']=== undefined)?1:+params['page']; - this.searchUtils.page = ( page <= 0 ) ? 1 : page; - - this.searchUtils.size = (params['size']=== undefined)?10:+params['size']; - if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { - this.searchUtils.size = 10; - } - - this.searchPage.fieldIds = this.fieldIds; - this.selectedFields =[]; - this.searchPage.selectedFields = this.selectedFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - this.searchPage.customFilter = this.customFilter; - this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); - - }); - } - ngOnDestroy() { - this.sub.unsubscribe(); - } - sub: any; - public getResults(parameters:string, page: number, size: number){ - if(page > this.pagingLimit) { - size=0; - } - if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) { - if(parameters!= null && parameters != '' ) { - this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))"; - }else{ - this.csvParams ="&fq="+this.resourcesQuery; - } - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; - - //console.info("Advanced Search for Organizations: Execute search query "+parameters); - this._searchOrganizationsService.advancedSearchOrganizations(parameters, page, size, this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - this.searchPage.updateBaseUrlWithParameters(); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } - }, - err => { - //console.log(err); - this.handleError("Error getting organizations", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = errorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - - //this.searchPage.closeLoading(); - this.disableForms = false; - } - ); - } - } - private setFilters(){ - //TODO set filters from - } - - private handleError(message: string, error) { - console.error("Organizations advanced Search Page: "+message, error); - } -} diff --git a/searchPages/advanced/advancedSearchOrganizations.module.ts b/searchPages/advanced/advancedSearchOrganizations.module.ts deleted file mode 100644 index 2ce5a6fa..00000000 --- a/searchPages/advanced/advancedSearchOrganizations.module.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import{AdvancedSearchOrganizationsComponent} from './advancedSearchOrganizations.component'; - - -import {OrganizationsServiceModule} from '../../services/organizationsService.module'; - import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; - import {FreeGuard} from'../../login/freeGuard.guard'; - import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - OrganizationsServiceModule, - AdvancedSearchPageModule - - ], - declarations: [ - AdvancedSearchOrganizationsComponent - ], - providers:[FreeGuard, IsRouteEnabled], - exports: [ - AdvancedSearchOrganizationsComponent - ] -}) -export class AdvancedSearchOrganizationsModule { } diff --git a/searchPages/advanced/advancedSearchProjects.component.ts b/searchPages/advanced/advancedSearchProjects.component.ts deleted file mode 100644 index ee4b2c7c..00000000 --- a/searchPages/advanced/advancedSearchProjects.component.ts +++ /dev/null @@ -1,180 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; -import {AdvancedField} from '../searchUtils/searchHelperClasses.class'; -import {SearchProjectsService} from '../../services/searchProjects.service'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; -import {SearchFields} from '../../utils/properties/searchFields'; -import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class'; -import {EnvProperties} from '../../utils/properties/env-properties'; - -@Component({ - selector: 'advanced-search-projects', - template: ` - - - - ` - }) - -export class AdvancedSearchProjectsComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; -@Input() piwikSiteId = null; -@Input() customFilter:SearchCustomFilter= null; - public results =[]; - public filters =[]; - - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public searchFields:SearchFields = new SearchFields(); - - public fieldIds: string[] = this.searchFields.PROJECT_ADVANCED_FIELDS; - public fieldIdsMap = this.searchFields.PROJECT_FIELDS; - public selectedFields:AdvancedField[] = []; - properties:EnvProperties; - - @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; - public resourcesQuery = "(oaftype exact project)"; - public csvParams: string; - public disableForms: boolean = false; - public loadPaging: boolean = true; - public oldTotalResults: number = 0; - public pagingLimit: number = 0; - public isPiwikEnabled; - - constructor (private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService ) { - - this.results =[]; - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - - - - - } - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties= data.envSpecific; - this.searchUtils.baseUrl = data.envSpecific.searchLinkToAdvancedProjects; - this.pagingLimit = data.envSpecific.pagingLimit; - this.isPiwikEnabled = data.envSpecific.enablePiwikTrack; - - }); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - this.sub = this.route.queryParams.subscribe(params => { - this.loadPaging = true; - if(params['page'] && this.searchUtils.page != params['page']) { - this.loadPaging = false; - this.oldTotalResults = this.searchUtils.totalResults; - } - - let page = (params['page']=== undefined)?1:+params['page']; - this.searchUtils.page = ( page <= 0 ) ? 1 : page; - - this.searchUtils.size = (params['size']=== undefined)?10:+params['size']; - if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { - this.searchUtils.size = 10; - } - - this.searchPage.fieldIds = this.fieldIds; - this.selectedFields =[]; - this.searchPage.selectedFields = this.selectedFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - this.searchPage.customFilter = this.customFilter; - this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); - - }); - } - ngOnDestroy() { - this.sub.unsubscribe(); - } - sub: any; - public getResults(parameters:string, page: number, size: number){ - if(page > this.pagingLimit) { - size=0; - } - if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) { - if(parameters!= null && parameters != '' ) { - this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))"; - }else{ - this.csvParams ="&fq="+this.resourcesQuery; - } - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; - - //console.info("Advanced Search for Publications: Execute search query "+parameters); - this._searchProjectsService.advancedSearchProjects(parameters, page, size, this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - this.searchPage.updateBaseUrlWithParameters(); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } - }, - err => { - //console.log(err); - this.handleError("Error getting projects", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = errorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - - //this.searchPage.closeLoading(); - this.disableForms = false; - - } - ); - } - } - - private handleError(message: string, error) { - console.error("Projects advanced Search Page: "+message, error); - } -} diff --git a/searchPages/advanced/advancedSearchProjects.module.ts b/searchPages/advanced/advancedSearchProjects.module.ts deleted file mode 100644 index 1239745e..00000000 --- a/searchPages/advanced/advancedSearchProjects.module.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import{AdvancedSearchProjectsComponent} from './advancedSearchProjects.component'; - - -import {ProjectsServiceModule} from '../../services/projectsService.module'; - import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; - import {FreeGuard} from'../../login/freeGuard.guard'; - import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - ProjectsServiceModule, - AdvancedSearchPageModule - - ], - declarations: [ - AdvancedSearchProjectsComponent - ], - providers:[FreeGuard, IsRouteEnabled], - exports: [ - AdvancedSearchProjectsComponent - ] -}) -export class AdvancedSearchProjectsModule { } diff --git a/searchPages/advanced/advancedSearchResearchResults.component.ts b/searchPages/advanced/advancedSearchResearchResults.component.ts deleted file mode 100644 index 3623429e..00000000 --- a/searchPages/advanced/advancedSearchResearchResults.component.ts +++ /dev/null @@ -1,213 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; -import {AdvancedField} from '../searchUtils/searchHelperClasses.class'; -import {SearchResearchResultsService} from '../../services/searchResearchResults.service'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; -import {SearchFields} from '../../utils/properties/searchFields'; -import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class'; -import {EnvProperties} from '../../utils/properties/env-properties'; - - -@Component({ - selector: 'advanced-search-research-results', - template: ` - - - ` -}) - -export class AdvancedSearchResearchResultsComponent { - @Input() resultType: string = "publication"; - - public simpleSearchLink: string = ""; - - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; - @Input() piwikSiteId = null; - @Input() hasPrefix: boolean = true; - public results =[]; - public filters =[]; - - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public searchFields:SearchFields = new SearchFields(); - - public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS; - public fieldIdsMap= this.searchFields.RESULT_FIELDS; - public selectedFields:AdvancedField[] = []; - public resourcesQuery = "((oaftype exact result) and (resulttypeid exact "+this.resultType+"))"; - public csvParams: string; - public disableForms: boolean = false; - public loadPaging: boolean = true; - public oldTotalResults: number = 0; - @Input() openaireLink: string ; - @Input() customFilter:SearchCustomFilter= null; - public pagingLimit: number = 0; - public isPiwikEnabled; - public sort: boolean = true; - properties:EnvProperties; - - @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; - - - constructor (private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService ) { - this.results =[]; - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - } - ngOnInit() { - this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { - this.properties= data.envSpecific; - this.pagingLimit = data.envSpecific.pagingLimit; - this.isPiwikEnabled = data.envSpecific.enablePiwikTrack; - - if(this.resultType == "publication") { - this.simpleSearchLink = this.properties.searchLinkToPublications; - this.searchUtils.baseUrl = this.properties.searchLinkToAdvancedPublications; - } else if(this.resultType == "dataset") { - this.simpleSearchLink = this.properties.searchLinkToDatasets; - this.searchUtils.baseUrl = this.properties.searchLinkToAdvancedDatasets; - } else if(this.resultType == "software") { - this.simpleSearchLink = this.properties.searchLinkToSoftware; - this.searchUtils.baseUrl = this.properties.searchLinkToAdvancedSoftware; - } else if(this.resultType == "other") { - this.simpleSearchLink = this.properties.searchLinkToOrps; - this.searchUtils.baseUrl = this.properties.searchLinkToAdvancedOrps; - } - }); - - this.searchUtils.status = this.errorCodes.LOADING; - this.sub = this.route.queryParams.subscribe(params => { - this.loadPaging = true; - if(params['page'] && this.searchUtils.page != params['page']) { - this.loadPaging = false; - this.oldTotalResults = this.searchUtils.totalResults; - } - - let page = (params['page']=== undefined)?1:+params['page']; - this.searchUtils.page = ( page <= 0 ) ? 1 : page; - - this.searchUtils.size = (params['size']=== undefined)?10:+params['size']; - if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { - this.searchUtils.size = 10; - } - this.searchUtils.sortBy = (params['sortBy'])?params['sortBy']:''; - if(this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") { - this.searchUtils.sortBy = ""; - } - - this.searchPage.fieldIds = this.fieldIds; - this.selectedFields =[]; - this.searchPage.selectedFields = this.selectedFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - this.searchPage.customFilter = this.customFilter; - this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy); - }); - } - - ngOnDestroy() { - this.sub.unsubscribe(); - } - - sub: any; - public getResults(parameters:string, page: number, size: number, sortBy: string){ - if(page > this.pagingLimit) { - size=0; - } - if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) { - if(parameters!= null && parameters != '' ) { - this.csvParams ="&fq=("+this.resourcesQuery +" and (" + parameters + "))"; - }else{ - this.csvParams ="&fq="+this.resourcesQuery; - } - - this.searchUtils.status = this.errorCodes.LOADING; - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; - - this._searchResearchResultsService.advancedSearch(this.resultType, parameters, page, size, sortBy, this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - this.searchPage.updateBaseUrlWithParameters(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - this.disableForms = false; - - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } - }, - err => { - this.handleError("Error getting "+this.getEntityName(this.resultType, true, true), err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.NOT_AVAILABLE; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - - //this.searchPage.closeLoading(); - this.disableForms = false; - - } - ); - } - } - - - - private handleError(message: string, error) { - console.error(this.getEntityName(this.resultType, true, true)+" advanced Search Page: "+message, error); - } - - public getEntityName (entityType:string, plural:boolean, full:boolean): string { - if(entityType == "publication") { - return "publication" + (plural ? "s" : ""); - } else if(entityType == "dataset") { - return (full ? "research data" : ("dataset" + (plural ? "s" : ""))); - } else if(entityType == "software") { - return "software"; - } else if(entityType == "other") { - return (full ? ("other research product" + (plural ? "s" : "")) : "other"); - } - } -} diff --git a/searchPages/advanced/advancedSearchResearchResults.module.ts b/searchPages/advanced/advancedSearchResearchResults.module.ts deleted file mode 100644 index f42452eb..00000000 --- a/searchPages/advanced/advancedSearchResearchResults.module.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import {AdvancedSearchResearchResultsComponent} from './advancedSearchResearchResults.component'; - -import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module'; -import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; -import {FreeGuard} from'../../login/freeGuard.guard'; -import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - SearchResearchResultsServiceModule, - AdvancedSearchPageModule - - ], - declarations: [ - AdvancedSearchResearchResultsComponent - ], - providers:[FreeGuard, IsRouteEnabled], - exports: [ - AdvancedSearchResearchResultsComponent - ] -}) -export class AdvancedSearchResearchResultsModule { } diff --git a/searchPages/dataProviders/compatibleDataProviders.component.ts b/searchPages/dataProviders/compatibleDataProviders.component.ts deleted file mode 100644 index b7b0eff5..00000000 --- a/searchPages/dataProviders/compatibleDataProviders.component.ts +++ /dev/null @@ -1,206 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import {Location} from '@angular/common'; -import { ActivatedRoute} from '@angular/router'; -import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; -import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; -import {SearchResult} from '../../utils/entities/searchResult'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; -import {SearchPageComponent } from '../searchUtils/searchPage.component'; -import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; -import{EnvProperties} from '../../utils/properties/env-properties'; - -@Component({ - selector: 'search-content-providers', - template: ` - - - - - ` - -}) -export class SearchCompatibleDataprovidersComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; - public results =[]; - public filters =[]; - public baseUrl:string; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public sub: any; public subResults: any; - public _location:Location; - public searchFields:SearchFields = new SearchFields(); - public refineFields: string[] = this.searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; - public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; - public _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[{field:"compatibility",opName:"cm",opValue:"not", values:["UNKNOWN","hostedBy","notCompatible"]},{field:"type",opName:"tp",opValue:"not",values: ["other"]}]; - // ["entityregistry","entityregistry::projects","entityregistry::repositories"]}]; - public _prefixQuery: string = ""; - - public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], - "export":[] - }; - public resourcesQuery = '((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))'; - public csvParams: string; - public disableForms: boolean = false; - public mapUrl: string; -properties:EnvProperties; - @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; - - constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - for(var i = 0; i < this._prefixQueryFields.length; i++ ){ - for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ - this._prefixQuery+="&" + this._prefixQueryFields[i].field + "=" - + this._prefixQueryFields[i].values[j] + "&" + - this._prefixQueryFields[i].opName + "=" + this._prefixQueryFields[i].opValue; - } - } - this._prefixQuery+="&"; - } - - public ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.baseUrl = data.envSpecific.searchLinkToCompatibleDataProviders - // this.mapUrl = this.properties.statisticsFrameAPIURL+"markers-test.html"; - - }); - this.searchPage.refineFields = this.refineFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - this.sub = this.route.queryParams.subscribe(params => { - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - this.filters = this.createFilters(); - var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params); - var csvParameters = this.searchPage.getQueryParametersFromUrl(params); - - //console.info("|"+queryParameters+"|"); - this._getResults(queryParameters, csvParameters, false, this.searchUtils.page, this.searchUtils.size); - }); - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } } - private _getResults(parameters:string, csv_parameters:string, refine:boolean, page: number, size: number){ - if(csv_parameters.indexOf("fq=") != -1) { - this.csvParams = csv_parameters+" and "+this.resourcesQuery; - } else { - this.csvParams = csv_parameters+"&fq="+this.resourcesQuery; - } - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; - - this.subResults = this._searchDataprovidersService.searchCompatibleDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, [],this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - //console.info("search Content Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); - this.results = data[1]; - this.searchPage.checkSelectedFilters(this.filters); - this.searchPage.updateBaseUrlWithParameters(this.filters); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - }, - err => { - //console.log(err); - this.handleError("Error getting compatible content providers", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - - //this.searchPage.closeLoading(); - this.disableForms = false; - - } - ); - } - private setFilters(){ - //TODO set filters from - } - - - private createFilters():Filter[] { - var filter_names=["Type","Compatibility Level"]; - var filter_ids=["datasourcetypeuiid","datasourcecompatibilityname"]; - var searchFields = new SearchFields(); - var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; - var value_names=[ - /*[ - "Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", - "Institutional Repositories Aggregators", - "Thematic Repositories Aggregators", "Other Repositories Aggregators", - "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"], - */ - [ - "Institutional Repository", "Thematic Repository", "Publication Repository", - "Institutional Repository Aggregator", - "Thematic Repository Aggregator", "Publication Repository Aggregator", - "Data Repository", "Data Repository Aggregator", "CRIS System", "Publication Catalogue", - "Software Repository", "Software Repository Aggregator"], - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", "OpenAIRE CRIS v1.1", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - - var value_original_ids=[ - ["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::institutional","aggregator::pubsrepository::thematic","aggregator::pubsrepository::unknown", - "datarepository::unknown", "aggregator::datarepository", "crissystem", "pubscatalogue::unknown", "softwarerepository", "aggregator::softwarerepository"], - //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"] - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", "OpenAIRE CRIS v1.1", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - var filters: Filter[] =[]; - for(var i =0 ; i < filter_names.length;i++){ - var values:Value[] = []; - for(var j =0 ; j < value_names[i].length;j++){ - var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} - values.push(value); - } - var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, filterType: "checkbox" }; - filters.push(filter); - } - return filters; - } - - private handleError(message: string, error) { - console.error("Compatible Content Providers (Repositories) Search Page: "+message, error); - } -} diff --git a/searchPages/dataProviders/compatibleDataProviders.module.ts b/searchPages/dataProviders/compatibleDataProviders.module.ts deleted file mode 100644 index 62d0c525..00000000 --- a/searchPages/dataProviders/compatibleDataProviders.module.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import{SearchCompatibleDataprovidersComponent} from './compatibleDataProviders.component'; - -import {SearchResultsModule } from '../searchUtils/searchResults.module'; - -import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; -import {SearchFormModule} from '../searchUtils/searchForm.module'; -import {SearchPageModule} from '../searchUtils/searchPage.module'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - DataProvidersServiceModule, - SearchFormModule, SearchResultsModule, SearchPageModule - - ], - declarations: [ - SearchCompatibleDataprovidersComponent - ], - exports: [ - SearchCompatibleDataprovidersComponent - ] -}) -export class CompatibleDataProvidersModule { } diff --git a/searchPages/dataProviders/compatibleDataProvidersTable.component.ts b/searchPages/dataProviders/compatibleDataProvidersTable.component.ts deleted file mode 100644 index f958ac9a..00000000 --- a/searchPages/dataProviders/compatibleDataProvidersTable.component.ts +++ /dev/null @@ -1,262 +0,0 @@ -import {Component, ViewChild} from '@angular/core'; -import {Location} from '@angular/common'; -import { ActivatedRoute} from '@angular/router'; -import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; -import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {SearchFields} from '../../utils/properties/searchFields'; -import {SearchPageTableViewComponent } from '../searchUtils/searchPageTableView.component'; -import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; -import{EnvProperties} from '../../utils/properties/env-properties'; - - -@Component({ - selector: 'search-content-providers-table', - template: ` - - - - ` - -}) -export class SearchCompatibleDataprovidersTableComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; - public results =[]; - public filters =[]; - public columnNames = ["Name", "Type", "Country", "Institution", "Compatibility"]; - public baseUrl:string; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public sub: any; public subResults: any; - public _location:Location; - public searchFields:SearchFields = new SearchFields(); - public refineFields: string[] = this.searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; - public mapUrl: string; - - /*public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], - "export":[] - }; - public CSVDownloaded = false; - public csvParams: string; - public resourcesQuery = "&query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))";*/ - - public disableForms: boolean = false; - public enableSearchView: boolean = true; -properties:EnvProperties; - @ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ; - - constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - } - - public ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.baseUrl = data.envSpecific.searchLinkToEntityRegistriesDataProvidersTable; - // this.mapUrl = this.properties.statisticsFrameAPIURL+"markers-test.html"; - }); - this.refineFields.push("datasourcecountryname"); - this.searchPage.refineFields = this.refineFields; - this.sub = this.route.queryParams.subscribe(params => { - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - //this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - //this.filters = this.createFilters(); - //this.searchPage.getParametersFromUrl(params); - this._getResults(params); - }); - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } } - private _getResults(params){ - //this.csvParams = this.resourcesQuery+"&type=datasources"; - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - this.disableForms = true; - this.enableSearchView = false; - this.results = []; - this.searchUtils.totalResults = 0; - - let size: number = 0; - this.subResults = this._searchDataprovidersService.searchCompatibleDataprovidersTable(this.properties).subscribe( - data => { - size = data; - if(size > 0) { - this.subResults = this._searchDataprovidersService.searchCompatibleDataproviders("", null, 1, size, [],this.properties).subscribe( - data => { - this.filters = this.createFilters(data[1], params); - - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - - this.searchPage.checkSelectedFilters(this.filters); - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } else { - this.searchPage.triggerInitialLoad(); - this.searchPage.transform(this.results, this.searchUtils); - this.disableForms = false; - } - this.enableSearchView = true; - }, - err => { - //console.log(err); - this.handleError("Error getting compatible content providers", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - this.enableSearchView = true; - } - ); - } else { - this.searchPage.checkSelectedFilters(this.filters); - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.NONE; - this.enableSearchView = true; - } - }, - err => { - //console.log(err); - this.handleError("Error getting compatible content providers (size=0)", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - this.enableSearchView = true; - } - ); - - } - private setFilters(){ - //TODO set filters from - } - - private createFilters(data, params):Filter[] { - let length = Array.isArray(data) ? data.length : 1; - - var filter_names=["Type","Compatibility","Country"]; - var filter_ids=["datasourcetypeuiid","datasourcecompatibilityname","datasourcecountryname"]; - var searchFields = new SearchFields(); - var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; - filter_original_ids.push("datasourcecountryname"); - var filter_valueIsExact = [true, true, false]; - - //this.refineFields = ["relfunder"]; - //this.searchPage.refineFields = this.refineFields; - this.searchPage.getParametersFromUrl(params); - - var value_names=[ - /*[ - "Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", - "Institutional Repositories Aggregators", - "Thematic Repositories Aggregators", "Other Repositories Aggregators", - "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"], - */ - [ - "Institutional Repository", "Thematic Repository", "Publication Repository", - "Institutional Repository Aggregator", - "Thematic Repository Aggregator", "Publication Repository Aggregator", - "Data Repository", "Data Repository Aggregator", "CRIS Systems", "Publication Catalogue", - "Software Repository", "Software Repository Aggregator"], - - - - - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - - var value_original_ids=[ - ["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::institutional","aggregator::pubsrepository::thematic","aggregator::pubsrepository::unknown", - "datarepository::unknown", "aggregator::datarepository", "cris", "pubscatalogue::unknown", "softwarerepository", "aggregator::softwarerepository"], - //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"] - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - - var countries = new Set(); - var value_name = []; - var value_original_id = []; - let i, j; - - for(i=0; i - - - ` - -}) -export class SearchEntityRegistriesComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; - public results =[]; - public filters =[]; - public baseUrl:string; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public sub: any; public subResults: any; - public _location:Location; - public searchFields:SearchFields = new SearchFields(); - public refineFields: string[] = this.searchFields.ENTITY_REGISTRIES_FIELDS; - public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; - public _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[ - {field:"type",opName:"tp",opValue:"and",values: ["other"]}]; - // ["entityregistry","entityregistry::projects","entityregistry::repositories"]}]; - public _prefixQuery: string = ""; - - public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], - "export":[] - }; - public disableForms: boolean = false; - - @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; - public resourcesQuery = "((oaftype exact datasource) and(datasourcetypeuiid = other))"; - public csvParams: string; - public mapUrl: string; -properties:EnvProperties; - constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - - for(var i = 0; i < this._prefixQueryFields.length; i++ ){ - for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ - this._prefixQuery+="&" + this._prefixQueryFields[i].field + "=" - + this._prefixQueryFields[i].values[j] + "&" + - this._prefixQueryFields[i].opName + "=" + this._prefixQueryFields[i].opValue; - } - } - this._prefixQuery+="&"; - } - - public ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.baseUrl = data.envSpecific.searchLinkToEntityRegistriesDataProviders; - // this.mapUrl = this.properties.statisticsFrameAPIURL+"markers-test.html?show=registries"; - - }); - this.searchPage.refineFields = this.refineFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - this.sub = this.route.queryParams.subscribe(params => { - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - this.filters = this.createFilters(); - - var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params); - var csvParameters = this.searchPage.getQueryParametersFromUrl(params); - - this._getResults(queryParameters, csvParameters, false, this.searchUtils.page, this.searchUtils.size); - }); - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } } - private _getResults(parameters:string, csv_parameters:string, refine:boolean, page: number, size: number){ - if(csv_parameters.indexOf("fq=") != -1) { - this.csvParams = csv_parameters+" and "+this.resourcesQuery; - } else { - this.csvParams = csv_parameters+"&fq="+this.resourcesQuery; - } - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; - - this.subResults = this._searchDataprovidersService.searchEntityRegistries(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, [],this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - this.searchPage.checkSelectedFilters(this.filters); - this.searchPage.updateBaseUrlWithParameters(this.filters); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - }, - err => { - //console.log(err); - this.handleError("Error getting entity registries", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - - //this.searchPage.closeLoading(); - this.disableForms = false; - - } - ); - } - private setFilters(){ - //TODO set filters from - } - - private createFilters():Filter[] { - var filter_names=["Type","Compatibility Level"]; - var filter_ids=["datasourcetypename","datasourcecompatibilityname"]; - var searchFields = new SearchFields(); - var filter_original_ids = searchFields.ENTITY_REGISTRIES_FIELDS; - var value_names=[ - ["Funder","Registry of repositories","Scholarly Comm. Infrastructure","Registry","Information Space","Web Source"], - - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - - var value_original_ids=[ - ["Funder database","Registry of repositories","Scholarly Comm. Infrastructure","Registry","Information Space","Web Source"], - //["entityregistry::projects","entityregistry::repositories","scholarcomminfra","entityregistry","infospace","websource"], - //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"] - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - - var filters: Filter[] =[]; - for(var i =0 ; i < filter_names.length;i++){ - var values:Value[] = []; - for(var j =0 ; j < value_names[i].length;j++){ - var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} - values.push(value); - } - var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, filterType: "checkbox" }; - filters.push(filter); - } - return filters; - } - - private handleError(message: string, error) { - console.error("Entity Registries Search Page: "+message, error); - } -} diff --git a/searchPages/dataProviders/entityRegistries.module.ts b/searchPages/dataProviders/entityRegistries.module.ts deleted file mode 100644 index 4b5dcf6e..00000000 --- a/searchPages/dataProviders/entityRegistries.module.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import{SearchEntityRegistriesComponent} from './entityRegistries.component'; -import {SearchResultsModule } from '../searchUtils/searchResults.module'; -import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; -import {SearchFormModule} from '../searchUtils/searchForm.module'; -import {SearchPageModule} from '../searchUtils/searchPage.module'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - DataProvidersServiceModule, - SearchFormModule, SearchResultsModule, SearchPageModule - - ], - declarations: [ - SearchEntityRegistriesComponent - ], - exports: [ - SearchEntityRegistriesComponent - ] -}) -export class EntityRegistriesModule { } diff --git a/searchPages/dataProviders/entityRegistriesTable.component.ts b/searchPages/dataProviders/entityRegistriesTable.component.ts deleted file mode 100644 index b97d552e..00000000 --- a/searchPages/dataProviders/entityRegistriesTable.component.ts +++ /dev/null @@ -1,267 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import { ActivatedRoute} from '@angular/router'; -import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; -import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; -import {SearchResult} from '../../utils/entities/searchResult'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; -import {SearchPageTableViewComponent } from '../searchUtils/searchPageTableView.component'; -import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; -import{EnvProperties} from '../../utils/properties/env-properties'; - -@Component({ - selector: 'search-entity-registries-table', - template: ` - - - - - ` - -}) -export class SearchEntityRegistriesTableComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; - public results =[]; - public filters =[]; - public columnNames = ["Name", "Type", "Country", "Institution", "Compatibility"]; - public baseUrl:string; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public sub: any; public subResults: any; - public _location:Location; - public searchFields:SearchFields = new SearchFields(); - public refineFields: string[] = this.searchFields.ENTITY_REGISTRIES_FIELDS; - public disableForms: boolean = false; - public enableSearchView: boolean = true; - public mapUrl: string; -properties:EnvProperties; - @ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ; - - constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - } - - public ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.baseUrl = data.envSpecific.searchLinkToEntityRegistriesDataProviders; - // this.mapUrl = this.properties.statisticsFrameAPIURL+"markers-test.html?show=registries"; - }); - this.refineFields.push("datasourcecountryname"); - this.searchPage.refineFields = this.refineFields; - this.sub = this.route.queryParams.subscribe(params => { - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - //this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - //this.filters = this.createFilters(); - - //this.searchPage.getParametersFromUrl(params); - this._getResults(params, false, this.searchUtils.page); - }); - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } } - private _getResults(params,refine:boolean, page: number){ - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - this.disableForms = true; - this.enableSearchView = false; - this.results = []; - this.searchUtils.totalResults = 0; - - let size: number = 0; - this.subResults = this._searchDataprovidersService.searchEntityRegistriesTable(this.properties).subscribe( - data => { - size = data; - if(size > 0) { - this.subResults = this._searchDataprovidersService.searchEntityRegistries("",null, page, size, [],this.properties).subscribe( - data => { - this.filters = this.createFilters(data[1], params); - - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - this.searchPage.checkSelectedFilters(this.filters); - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } else { - this.searchPage.triggerInitialLoad(); - this.searchPage.transform(this.results, this.searchUtils); - this.disableForms = false; - } - this.enableSearchView = true; - }, - err => { - //console.log(err); - this.handleError("Error getting entity registries", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - this.enableSearchView = true; - } - ); - } else { - this.searchPage.checkSelectedFilters(this.filters); - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.NONE; - this.enableSearchView = true; - } - }, - err => { - //console.log(err); - this.handleError("Error getting entity registries (size=0)", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - this.enableSearchView = true; - } - ); -/* - this.subResults = this._searchDataprovidersService.searchEntityRegistries(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - console.info("search Entity Registries: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); - this.results = data[1]; - this.searchPage.checkSelectedFilters(this.filters); - this.searchPage.updateBaseUrlWithParameters(this.filters); - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - }, - err => { - console.log(err); - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = errorCodes.ERROR; - //this.searchPage.closeLoading(); - this.disableForms = false; - - } - ); -*/ - } - private setFilters(){ - //TODO set filters from - } - - - private createFilters(data, params):Filter[] { - let length = Array.isArray(data) ? data.length : 1; - - var filter_names=["Type","Compatibility","Country"]; - var filter_ids=["datasourcetypename","datasourcecompatibilityname","datasourcecountryname"]; - var searchFields = new SearchFields(); - var filter_original_ids = searchFields.ENTITY_REGISTRIES_FIELDS; - filter_original_ids.push("datasourcecountryname"); - var filter_valueIsExact = [true, true, false]; - - this.searchPage.getParametersFromUrl(params); - - var value_names=[ - ["Funder database","Registry of repositories","Scholarly Comm. Infrastructure","Registry","Information Space","Web Source"], - - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - - var value_original_ids=[ - ["Funder database","Registry of repositories","Scholarly Comm. Infrastructure","Registry","Information Space","Web Source"], - //["entityregistry::projects","entityregistry::repositories","scholarcomminfra","entityregistry","infospace","websource"], - //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"] - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - - var countries = new Set(); - var value_name = []; - var value_original_id = []; - let i, j; - - for(i=0; i - - - ` - -}) -export class SearchJournalsComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; - public results =[]; - public filters =[]; - public baseUrl:string; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public sub: any; public subResults: any; - public _location:Location; - public searchFields:SearchFields = new SearchFields(); - public refineFields: string[] = this.searchFields.JOURNAL_FIELDS; - public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; - public _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[{field:"compatibility",opName:"cm",opValue:"not", values:["UNKNOWN","hostedBy","notCompatible"]},{field:"type",opName:"tp",opValue:"not",values: ["other"]}]; - // ["entityregistry","entityregistry::projects","entityregistry::repositories"]}]; - public _prefixQuery: string = ""; - - public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], - "export":[] - }; - public resourcesQuery = '((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))'; - //"&query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"; - public csvParams: string; - public disableForms: boolean = false; - public mapUrl: string; -properties:EnvProperties; - @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; - - constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - for(var i = 0; i < this._prefixQueryFields.length; i++ ){ - for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ - this._prefixQuery+="&" + this._prefixQueryFields[i].field + "=" - + this._prefixQueryFields[i].values[j] + "&" + - this._prefixQueryFields[i].opName + "=" + this._prefixQueryFields[i].opValue; - } - } - this._prefixQuery+="&"; - } - - public ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.baseUrl = data.envSpecific.searchLinkToJournals; - // this.mapUrl = this.properties.statisticsFrameAPIURL+"markers-test.html?show=journals"; - - }); - this.searchPage.refineFields = this.refineFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - this.sub = this.route.queryParams.subscribe(params => { - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - this.filters = this.createFilters(); - var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params); - //console.info("|"+queryParameters+"|"); - var csvParameters = this.searchPage.getQueryParametersFromUrl(params); - - this._getResults(queryParameters, csvParameters, false, this.searchUtils.page, this.searchUtils.size); - }); - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } } - private _getResults(parameters:string, csv_parameters:string, refine:boolean, page: number, size: number){ - if(csv_parameters.indexOf("fq=") != -1) { - this.csvParams = csv_parameters+" and "+this.resourcesQuery; - } else { - this.csvParams = csv_parameters+"&fq="+this.resourcesQuery; - } - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; - - this.subResults = this._searchDataprovidersService.searchJournals(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, [],this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - this.searchPage.checkSelectedFilters(this.filters); - this.searchPage.updateBaseUrlWithParameters(this.filters); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - }, - err => { - //console.log(err); - this.handleError("Error getting journals", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - - //this.searchPage.closeLoading(); - this.disableForms = false; - - } - ); - } - private setFilters(){ - //TODO set filters from - } - - private createFilters():Filter[] { - var filter_names=["Type","Compatibility Level"]; - var filter_ids=["datasourcetypeuiid","datasourcecompatibilityname"]; - var searchFields = new SearchFields(); - var filter_original_ids = searchFields.JOURNAL_FIELDS; - var value_names=[ - /*[ - "Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", - "Institutional Repositories Aggregators", - "Thematic Repositories Aggregators", "Other Repositories Aggregators", - "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"], - */ - ["Journal", "Journal Aggregator\/Publisher"], - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - - var value_original_ids=[ - ["pubsrepository::journal", "aggregator::pubsrepository::journals"], - //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"] - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - var filters: Filter[] =[]; - for(var i =0 ; i < filter_names.length;i++){ - var values:Value[] = []; - for(var j =0 ; j < value_names[i].length;j++){ - var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} - values.push(value); - } - var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, filterType: "checkbox" }; - filters.push(filter); - } - return filters; - } - - private handleError(message: string, error) { - console.error("Journals Search Page: "+message, error); - } -} diff --git a/searchPages/dataProviders/journals.module.ts b/searchPages/dataProviders/journals.module.ts deleted file mode 100644 index 296987e5..00000000 --- a/searchPages/dataProviders/journals.module.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import{SearchJournalsComponent} from './journals.component'; - -import {SearchResultsModule } from '../searchUtils/searchResults.module'; - -import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; -import {SearchFormModule} from '../searchUtils/searchForm.module'; -import {SearchPageModule} from '../searchUtils/searchPage.module'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - DataProvidersServiceModule, - SearchFormModule, SearchResultsModule, SearchPageModule - - ], - declarations: [ - SearchJournalsComponent - ], - exports: [ - SearchJournalsComponent - ] -}) -export class JournalsModule { } diff --git a/searchPages/dataProviders/journalsTable.component.ts b/searchPages/dataProviders/journalsTable.component.ts deleted file mode 100644 index 1776bdb2..00000000 --- a/searchPages/dataProviders/journalsTable.component.ts +++ /dev/null @@ -1,222 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import { ActivatedRoute} from '@angular/router'; - -import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; - -import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; -import {SearchResult} from '../../utils/entities/searchResult'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; -import {SearchPageTableViewComponent } from '../searchUtils/searchPageTableView.component'; -import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; -import{EnvProperties} from '../../utils/properties/env-properties'; - -@Component({ - selector: 'search-journals-table', - template: ` - - - - ` - -}) -export class SearchJournalsTableComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; - public results =[]; - public filters =[]; - public columnNames = ["Name", "Type", "Country", "Institution", "Compatibility"]; - public baseUrl:string; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public sub: any; public subResults: any; - public _location:Location; - public searchFields:SearchFields = new SearchFields(); - public refineFields: string[] = this.searchFields.JOURNAL_FIELDS; - public mapUrl: string; -properties:EnvProperties; - /*public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], - "export":[] - }; - public CSVDownloaded = false; - public csvParams: string; - public resourcesQuery = "&query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))";*/ - - public disableForms: boolean = false; - public enableSearchView: boolean = true; - - @ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ; - - constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - } - - public ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.baseUrl = data.envSpecific.searchLinkToJournalsTable; - // this.mapUrl = this.properties.statisticsFrameAPIURL+"markers-test.html?show=journals"; - }); - this.searchPage.refineFields = this.refineFields; - this.sub = this.route.queryParams.subscribe(params => { - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - //this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - this.filters = this.createFilters(); - this.searchPage.getParametersFromUrl(params); - this._getResults(); - }); - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } - } - private _getResults(){ - //this.csvParams = this.resourcesQuery+"&type=datasources"; - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - this.disableForms = true; - this.enableSearchView = false; - this.results = []; - this.searchUtils.totalResults = 0; - - let size: number = 0; - this.subResults = this._searchDataprovidersService.searchJournalsTable(this.properties).subscribe( - data => { - size = data; - if(size > 0) { - this.subResults = this._searchDataprovidersService.searchJournals("", null, 1, size, [],this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - - this.searchPage.checkSelectedFilters(this.filters); - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } else { - this.searchPage.triggerInitialLoad(); - this.searchPage.transform(this.results, this.searchUtils); - this.disableForms = false; - } - this.enableSearchView = true; - }, - err => { - //console.log(err); - this.handleError("Error getting journals", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - - this.enableSearchView = true; - } - ); - } else { - this.searchPage.checkSelectedFilters(this.filters); - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.NONE; - this.enableSearchView = true; - } - }, - err => { - //console.log(err); - this.handleError("Error getting journals (size=0)", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - this.enableSearchView = true; - } - ); - - } - private setFilters(){ - //TODO set filters from - } - - private createFilters():Filter[] { - var filter_names=["Type","Compatibility Level"]; - var filter_ids=["datasourcetypeuiid","datasourcecompatibilityname"]; - var searchFields = new SearchFields(); - var filter_original_ids = searchFields.JOURNAL_FIELDS; - var value_names=[ - /*[ - "Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", - "Institutional Repositories Aggregators", - "Thematic Repositories Aggregators", "Other Repositories Aggregators", - "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"], - */ - ["Journal", "Journal Aggregator\/Publisher"], - - - - - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - - var value_original_ids=[ - ["pubsrepository::journal", "aggregator::pubsrepository::journals"], - //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"] - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)", - "collected from a compatible aggregator", "proprietary", "under validation"]]; - var filters: Filter[] =[]; - for(var i =0 ; i < filter_names.length;i++){ - var values:Value[] = []; - for(var j =0 ; j < value_names[i].length;j++){ - var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} - values.push(value); - } - var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, filterType: "checkbox" }; - filters.push(filter); - } - return filters; - } - - private handleError(message: string, error) { - console.error("Journals Search Page - Table view: "+message, error); - } -} diff --git a/searchPages/dataProviders/journalsTable.module.ts b/searchPages/dataProviders/journalsTable.module.ts deleted file mode 100644 index 2a50de8a..00000000 --- a/searchPages/dataProviders/journalsTable.module.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import{SearchJournalsTableComponent} from './journalsTable.component'; - -import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; -import {SearchFormModule} from '../searchUtils/searchForm.module'; -import {SearchPageTableViewModule} from '../searchUtils/searchPageTableView.module'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - DataProvidersServiceModule, - SearchFormModule, SearchPageTableViewModule - - ], - declarations: [ - SearchJournalsTableComponent - ], - exports: [ - SearchJournalsTableComponent - ] -}) -export class JournalsTableModule { } diff --git a/searchPages/find/mainSearch.module.ts b/searchPages/find/mainSearch.module.ts deleted file mode 100644 index a34fb18a..00000000 --- a/searchPages/find/mainSearch.module.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; - -import {SearchComponent} from './search.component'; - -import {SearchResultsModule } from '../searchUtils/searchResults.module'; - -import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; -import {ProjectsServiceModule} from '../../services/projectsService.module'; -import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module'; -import {OrganizationsServiceModule} from '../../services/organizationsService.module'; -import {BrowseEntitiesModule} from '../searchUtils/browseEntities.module'; -import {SearchFormModule} from '../searchUtils/searchForm.module'; -import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; - -import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; -import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, RouterModule, - DataProvidersServiceModule, ProjectsServiceModule, - SearchResearchResultsServiceModule, OrganizationsServiceModule, - BrowseEntitiesModule, SearchFormModule, SearchResultsModule, PiwikServiceModule, Schema2jsonldModule, SEOServiceModule - - ], - declarations: [ - SearchComponent - ], - providers:[ - //FreeGuard, PreviousRouteRecorder - ], - exports: [ - SearchComponent - ] -}) -export class MainSearchModule { } diff --git a/searchPages/find/search.component.html b/searchPages/find/search.component.html deleted file mode 100644 index c560905f..00000000 --- a/searchPages/find/search.component.html +++ /dev/null @@ -1,297 +0,0 @@ -
-
-
-
-
- - -
- - - -
-
-
-
-
- - - -
-
-
-
- -
-
- - - - - -
- -
-
-
-
diff --git a/searchPages/find/search.component.ts b/searchPages/find/search.component.ts deleted file mode 100644 index eb79733a..00000000 --- a/searchPages/find/search.component.ts +++ /dev/null @@ -1,469 +0,0 @@ -import {Component, Input} from '@angular/core'; -import {ChangeDetectionStrategy} from '@angular/core'; -import {ViewEncapsulation} from '@angular/core'; -import {ActivatedRoute, Router} from '@angular/router'; -import {Location} from '@angular/common'; -import {Title, Meta} from '@angular/platform-browser'; - -import {FetchResearchResults} from '../../utils/fetchEntitiesClasses/fetchResearchResults.class'; -import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.class'; -import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class'; -import {FetchOrganizations} from '../../utils/fetchEntitiesClasses/fetchOrganizations.class'; - -import {SearchResearchResultsService} from '../../services/searchResearchResults.service'; -import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; -import {SearchProjectsService} from '../../services/searchProjects.service'; -import {SearchOrganizationsService} from '../../services/searchOrganizations.service'; - -import {SearchFields} from '../../utils/properties/searchFields'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {RouterHelper} from '../../utils/routerHelper.class'; -import {RefineFieldResultsService} from '../../services/refineFieldResults.service'; -import {PiwikService} from '../../utils/piwik/piwik.service'; -import {ConfigurationService} from '../../utils/configuration/configuration.service'; -import {EnvProperties} from '../../utils/properties/env-properties'; -import {SEOService} from '../../sharedComponents/SEO/SEO.service'; -import {StringUtils} from '../../utils/string-utils.class'; -import {SearchCustomFilter} from "../searchUtils/searchUtils.class"; -import {Observable, Subscription} from "rxjs"; - -@Component({ - changeDetection: ChangeDetectionStrategy.Default, - encapsulation: ViewEncapsulation.Emulated, - selector: 'search-find', - templateUrl: 'search.component.html' -}) -export class SearchComponent { - subs: Subscription[] = []; - - public reloadPublications: boolean; - public reloadDatasets: boolean; - public reloadSoftware: boolean; - public reloadOrps: boolean; - public reloadProjects: boolean; - public reloadDataproviders: boolean; - public reloadOrganizations: boolean; - - - public pageTitle = "Search in OpenAIRE" - public keyword: string = ""; - public publications: string[]; - public datasets: string[]; - public software: string[]; - public orps: string[]; - public projectsTab: string[]; - public dataproviders: string[]; - public organizations: string[]; - - public activeTab = "publications"; - public linkToSearchPublications = ""; - public linkToSearchProjects = ""; - public linkToSearchDataproviders = ""; - public linkToSearchDatasets = ""; - public linkToSearchSoftware = ""; - public linkToSearchOrps = ""; - public linkToSearchOrganizations = ""; - - public fetchPublications: FetchResearchResults; - public fetchDataproviders: FetchDataproviders; - public fetchProjects: FetchProjects; - public fetchDatasets: FetchResearchResults; - public fetchSoftware: FetchResearchResults; - public fetchOrps: FetchResearchResults; - public fetchOrganizations: FetchOrganizations; - - public searchFields: SearchFields = new SearchFields(); - public errorCodes: ErrorCodes = new ErrorCodes(); - public routerHelper: RouterHelper = new RouterHelper(); - - public publicationsSize: any = null; - public datasetsSize: any = null; - public softwareSize: any = null; - public oprsSize: any = null; - public fundersSize: any = null; - public projectsSize: any = null; - public datasourcesSize: any = null; - showPublications: boolean = false; - showDatasets: boolean = false; - showSoftware: boolean = false; - showOrps: boolean = false; - showProjects: boolean = false; - showDataProviders: boolean = false; - showOrganizations: boolean = false; - properties: EnvProperties; - advancedSearchLink: string = this.properties.searchLinkToAdvancedResults; - @Input() logoURL; - @Input() name; - @Input() customFilter: SearchCustomFilter = null; - @Input() piwikSiteId = null; - @Input() formPlaceholderText = "Search for research outcomes, projects, content providers & organizations in OpenAIRE"; - - constructor(private route: ActivatedRoute, - private _router: Router, - private _searchResearchResultsService: SearchResearchResultsService, - private _searchDataprovidersService: SearchDataprovidersService, - private _searchProjectsService: SearchProjectsService, - private _searchOrganizationsService: SearchOrganizationsService, - private _refineFieldResultsService: RefineFieldResultsService, - private location: Location, - private _meta: Meta, - private _title: Title, - private _piwikService: PiwikService, - private config: ConfigurationService, - private seoService: SEOService) { - this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService); - this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); - this.fetchProjects = new FetchProjects(this._searchProjectsService); - this.fetchDatasets = new FetchResearchResults(this._searchResearchResultsService); - this.fetchSoftware = new FetchResearchResults(this._searchResearchResultsService); - this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService); - this.fetchOrganizations = new FetchOrganizations(this._searchOrganizationsService); - - } - - public ngOnInit() { - this.subs.push(this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - - var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects "; - var title = "OpenAIRE | Search publications, research data, projects... | OpenAIRE"; - this.properties = data.envSpecific; - var url = this.properties.domain + this.properties.baseLink + this._router.url; - this._title.setTitle(title); - this._meta.updateTag({content: description}, "name='description'"); - this._meta.updateTag({content: description}, "property='og:description'"); - this._meta.updateTag({content: title}, "property='og:title'"); - this._meta.updateTag({content: url}, "property='og:url'"); - this.seoService.createLinkForCanonicalURL(this.properties.domain +this.properties.baseLink + this._router.url, false); - if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { - this.subs.push(this._piwikService.trackView(this.properties, "OpenAIRE |Search publications, research data, projects...", this.piwikSiteId).subscribe()); - - } - - - if ((this.customFilter && this.customFilter.queryFieldName == "communityId") || this.properties.adminToolsCommunity) { - //this.subs.push(this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => { - this.subs.push(this.config.communityInformationState.subscribe(data => { - if(data) { - var showEntity = {}; - for (var i = 0; i < data['entities'].length; i++) { - - showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"]; - } - this.showPublications = showEntity["publication"]; - this.showDatasets = showEntity["dataset"]; - this.showProjects = showEntity["project"]; - this.showOrganizations = showEntity["organization"]; - this.showDataProviders = showEntity["datasource"]; - this.showSoftware = showEntity["software"]; - this.showOrps = showEntity["orp"]; - if (this.customFilter && this.customFilter.queryFieldName == "communityId") { - this.showProjects = false; - this.showOrganizations = false; - this.showDataProviders = false; - } - this.loadAll(); - } - })); - } else { - if ((this.customFilter && this.customFilter.queryFieldName == "country")) { - this.showPublications =true; - this.showDatasets = true; - this.showDataProviders = true; - this.showSoftware = true; - this.showOrps = true; - this.showProjects = true; - this.showOrganizations = true; - this.showDataProviders = true; - } - } - this.loadAll(); - })); - } - - loadAll() { - this.subs.push(this.route.queryParams.subscribe(params => { - - this.reloadTabs(); - this.keyword = (params['keyword']) ? params['keyword'] : ""; - if (this.keyword != null && this.keyword.length > 0) { - //if showPublications == false will setValues another entity as the first - if (this.showPublications) { - this.activeTab = "publications"; - this.searchPublications(); - } else if (this.showDatasets) { - this.activeTab = "research data"; - this.searchDatasets(); - } else if (this.showSoftware) { - this.activeTab = "software"; - this.searchSoftware(); - } else if (this.showOrps) { - this.activeTab = "other research products"; - this.searchOrps(); - } else if (this.showProjects) { - this.activeTab = "projects"; - this.searchProjects(); - } else if (this.showDataProviders) { - this.activeTab = "content providers"; - this.searchDataProviders(); - } else if (this.showOrganizations) { - this.activeTab = "organizations"; - this.searchOrganizations(); - } - this.count(); - } - })); - } - - - public ngOnDestroy() { - for (let sub of this.subs) { - sub.unsubscribe(); - } - } - - public searchPublications() { - this.activeTab = "publications"; - this.advancedSearchLink = this.properties.searchLinkToAdvancedPublications;//"/search/advanced/publications"; - if (this.reloadPublications && - this.fetchPublications.searchUtils.status != this.errorCodes.NONE /*&& - this.fetchPublications.searchUtils.status != this.errorCodes.ERROR*/ - && (this.keyword != null && this.keyword.length > 0)) { - this.reloadPublications = false; - this.fetchPublications.getResultsByKeyword("publication", this.keyword, 1, 10, this.properties, this.customFilter); - this.linkToSearchPublications = this.properties.searchLinkToPublications;// + "?keyword=" + this.keyword; - } - } - - public searchDatasets() { - this.activeTab = "research data"; - this.advancedSearchLink = this.properties.searchLinkToAdvancedDatasets;//"/search/advanced/datasets"; - if (this.reloadDatasets && - this.fetchDatasets.searchUtils.status != this.errorCodes.NONE /*&& - this.fetchDatasets.searchUtils.status != this.errorCodes.ERROR*/ - && (this.keyword != null && this.keyword.length > 0)) { - this.reloadDatasets = false; - this.fetchDatasets.getResultsByKeyword("dataset", this.keyword, 1, 10, this.properties, this.customFilter); - this.linkToSearchDatasets = this.properties.searchLinkToDatasets;// + "?keyword=" + this.keyword; - } - } - - public searchSoftware() { - - this.activeTab = "software"; - this.advancedSearchLink = this.properties.searchLinkToAdvancedSoftware;//"/search/advanced/software"; - if (this.reloadSoftware - && this.fetchSoftware.searchUtils.status != this.errorCodes.NONE/* && - ( this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING || - this.fetchSoftware.searchUtils.status == this.errorCodes.DONE )*/ - && (this.keyword != null && this.keyword.length > 0)) { - this.reloadSoftware = false; - this.fetchSoftware.getResultsByKeyword("software", this.keyword, 1, 10, this.properties, this.customFilter); - this.linkToSearchSoftware = this.properties.searchLinkToSoftware;// + "?keyword=" + this.keyword; - } - } - - public searchOrps() { - this.activeTab = "other research products"; - this.advancedSearchLink = this.properties.searchLinkToAdvancedOrps;//"/search/advanced/other"; - if (this.reloadOrps && - this.fetchOrps.searchUtils.status != this.errorCodes.NONE /*&& - this.fetchOrps.searchUtils.status != this.errorCodes.ERROR*/ - && (this.keyword != null && this.keyword.length > 0)) { - this.reloadOrps = false; - this.fetchOrps.getResultsByKeyword("other", this.keyword, 1, 10, this.properties, this.customFilter); - this.linkToSearchOrps = this.properties.searchLinkToOrps; - } - } - - public searchProjects() { - this.activeTab = "projects"; - this.advancedSearchLink = this.properties.searchLinkToAdvancedProjects;//"/search/advanced/projects"; - if (this.reloadProjects && - this.fetchProjects.searchUtils.status != this.errorCodes.NONE /*&& - this.fetchProjects.searchUtils.status != this.errorCodes.ERROR*/ - && (this.keyword != null && this.keyword.length > 0)) { - this.reloadProjects = false; - this.fetchProjects.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter); - this.linkToSearchProjects = this.properties.searchLinkToProjects;// + "?keyword=" + this.keyword; - } - } - - public searchDataProviders() { - this.activeTab = "content providers"; - this.advancedSearchLink = this.properties.searchLinkToAdvancedDataProviders;//"/search/advanced/dataproviders"; - if (this.reloadDataproviders && - this.fetchDataproviders.searchUtils.status != this.errorCodes.NONE /*&& - this.fetchDataproviders.searchUtils.status != this.errorCodes.ERROR*/ - && (this.keyword != null && this.keyword.length > 0)) { - this.reloadDataproviders = false; - this.fetchDataproviders.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter); - this.linkToSearchDataproviders = this.properties.searchLinkToDataProviders;// + "?keyword=" + this.keyword; - } - } - - public searchOrganizations() { - this.activeTab = "organizations"; - this.advancedSearchLink = this.properties.searchLinkToAdvancedOrganizations;//"/search/advanced/organizations"; - if (this.reloadOrganizations && - this.fetchOrganizations.searchUtils.status != this.errorCodes.NONE /*&& - this.fetchOrganizations.searchUtils.status != this.errorCodes.ERROR*/ - && (this.keyword != null && this.keyword.length > 0)) { - this.reloadOrganizations = false; - this.fetchOrganizations.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter); - this.linkToSearchOrganizations = this.properties.searchLinkToOrganizations;// + "?keyword=" + this.keyword; - } - } - - - public keywordChanged($event) { - - this.keyword = $event.value; - //console.info("Search Find: search with keyword \"" + this.keyword + "\"" ); - this.location.go(location.pathname, "?keyword=" + this.keyword); - this.reloadTabs(); - if (this.activeTab == "publications") { - this.searchPublications(); - } - if (this.activeTab == "projects") { - this.searchProjects(); - } - if (this.activeTab == "content providers") { - this.searchDataProviders(); - } - if (this.activeTab == "research data") { - this.searchDatasets(); - } - if (this.activeTab == "software") { - this.searchSoftware(); - } - if (this.activeTab == "other research products") { - this.searchOrps(); - } - if (this.activeTab == "organizations") { - this.searchOrganizations(); - } - - this.count(); - } - - private count() { - var refineParams = null; - if (this.customFilter) { - refineParams = (refineParams ? (refineParams + '&') : '') + "&fq=" + StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId))); - } - if (this.activeTab != "publications" && this.showPublications) { - this.fetchPublications.searchUtils.status = this.errorCodes.LOADING; - this.fetchPublications.results = []; - - this.subs.push(this.numOfSearchResults("publication", this.fetchPublications, refineParams)); - } - if (this.activeTab != "research data" && this.showDatasets) { - this.fetchDatasets.searchUtils.status = this.errorCodes.LOADING; - this.fetchDatasets.results = []; - this.subs.push(this.numOfSearchResults("dataset", this.fetchDatasets, refineParams)); - } - if (this.activeTab != "software" && this.showSoftware) { - this.fetchSoftware.searchUtils.status = this.errorCodes.LOADING; - this.fetchSoftware.results = []; - this.subs.push(this.numOfSearchResults("software", this.fetchSoftware, refineParams)); - } - if (this.activeTab != "other research products" && this.showOrps) { - this.fetchOrps.searchUtils.status = this.errorCodes.LOADING; - this.fetchOrps.results = []; - this.subs.push(this.numOfSearchResults("other", this.fetchOrps, refineParams)); - } - if (this.activeTab != "projects" && this.showProjects) { - this.fetchProjects.searchUtils.status = this.errorCodes.LOADING; - this.fetchProjects.results = []; - this.subs.push(this._searchProjectsService.numOfSearchProjects(this.keyword, this.properties, refineParams).subscribe( - data => { - this.fetchProjects.searchUtils.totalResults = data; - this.fetchProjects.searchUtils.status = this.errorCodes.DONE; - if (this.fetchProjects.searchUtils.totalResults == 0) { - this.fetchProjects.searchUtils.status = this.errorCodes.NONE; - } - }, - err => { - //console.log(err); - this.handleError("Error getting number of Projects", err); - this.fetchProjects.searchUtils.status = this.errorCodes.ERROR; - } - )); - } - if (this.activeTab != "content providers" && this.showDataProviders) { - this.fetchDataproviders.results = []; - this.fetchDataproviders.getNumForSearch(this.keyword, this.properties, refineParams); - } - if (this.activeTab != "organizations" && this.showOrganizations) { - this.fetchOrganizations.searchUtils.status = this.errorCodes.LOADING; - this.fetchOrganizations.results = []; - this.subs.push(this._searchOrganizationsService.numOfSearchOrganizations(this.keyword, this.properties, refineParams).subscribe( - data => { - this.fetchOrganizations.searchUtils.totalResults = data; - this.fetchOrganizations.searchUtils.status = this.errorCodes.DONE; - if (this.fetchOrganizations.searchUtils.totalResults == 0) { - this.fetchOrganizations.searchUtils.status = this.errorCodes.NONE; - } - }, - err => { - //console.log(err); - this.handleError("Error getting number of Organizations", err); - this.fetchOrganizations.searchUtils.status = this.errorCodes.ERROR; - - } - )); - } - - - } - - private numOfSearchResults(resultType: string, fetchClass: FetchResearchResults, refineParams) { - return this._searchResearchResultsService.numOfSearchResults(resultType, this.keyword, this.properties, refineParams).subscribe( - data => { - fetchClass.searchUtils.totalResults = data; - fetchClass.searchUtils.status = this.errorCodes.DONE; - if (fetchClass.searchUtils.totalResults == 0) { - fetchClass.searchUtils.status = this.errorCodes.NONE; - } - }, - err => { - this.handleError("Error getting number of "+this.getEntityName(resultType, true, true), err); - fetchClass.searchUtils.status = this.errorCodes.ERROR; - } - ); - } - - private reloadTabs() { - this.reloadPublications = true; - this.reloadDatasets = true; - this.reloadSoftware = true; - this.reloadOrps = true; - this.reloadProjects = true; - this.reloadDataproviders = true; - this.reloadOrganizations = true; - this.fetchOrganizations.searchUtils.status = null; - this.fetchDataproviders.searchUtils.status = null; - this.fetchProjects.searchUtils.status = null; - this.fetchPublications.searchUtils.status = null; - this.fetchDatasets.searchUtils.status = null; - this.fetchSoftware.searchUtils.status = null; - this.fetchOrps.searchUtils.status = null; - } - - private handleError(message: string, error) { - console.error("General Search Page: " + message, error); - } - - private getEntityName (entityType:string, plural:boolean, full:boolean): string { - if(entityType == "publication") { - return "publication" + (plural ? "s" : ""); - } else if(entityType == "dataset") { - return (full ? "research data" : ("dataset" + (plural ? "s" : ""))); - } else if(entityType == "software") { - return "software"; - } else if(entityType == "other") { - return (full ? ("other research product" + (plural ? "s" : "")) : "other"); - } - } -} diff --git a/searchPages/find/searchAll.component.ts b/searchPages/find/searchAll.component.ts index 1d2572f9..e558884c 100644 --- a/searchPages/find/searchAll.component.ts +++ b/searchPages/find/searchAll.component.ts @@ -25,7 +25,7 @@ import {EnvProperties} from '../../utils/properties/env-properties'; import {SEOService} from '../../sharedComponents/SEO/SEO.service'; import {StringUtils} from '../../utils/string-utils.class'; import {SearchCustomFilter} from "../searchUtils/searchUtils.class"; -import {Observable, Subscription} from "rxjs"; +import {Subscription} from "rxjs"; import {AdvancedField, Filter} from "../searchUtils/searchHelperClasses.class"; import {SearchResearchResultsComponent} from "../searchResearchResults.component"; import {SearchProjectsComponent} from "../searchProjects.component"; @@ -252,6 +252,13 @@ export class SearchAllComponent { for (let sub of this.subs) { sub.unsubscribe(); } + this.fetchDatasets.clearSubscriptions(); + this.fetchPublications.clearSubscriptions(); + this.fetchSoftware.clearSubscriptions(); + this.fetchPublications.clearSubscriptions(); + this.fetchOrganizations.clearSubscriptions(); + this.fetchDataproviders.clearSubscriptions(); + this.fetchProjects.clearSubscriptions(); } public searchResults() { diff --git a/searchPages/find/searchAll.module.ts b/searchPages/find/searchAll.module.ts index 76a583aa..e895fc4f 100644 --- a/searchPages/find/searchAll.module.ts +++ b/searchPages/find/searchAll.module.ts @@ -21,6 +21,7 @@ import {SearchResearchResultsModule} from "../searchResearchResults.module"; import {SearchProjectsModule} from "../searchProjects.module"; import {SearchOrganizationsModule} from "../searchOrganizations.module"; import {SearchDataProvidersModule} from "../searchDataProviders.module"; +import {PreviousRouteRecorder} from "../../utils/piwik/previousRouteRecorder.guard"; @NgModule({ imports: [ @@ -33,7 +34,7 @@ import {SearchDataProvidersModule} from "../searchDataProviders.module"; SearchAllComponent ], providers:[ - //FreeGuard, PreviousRouteRecorder + PreviousRouteRecorder ], exports: [ SearchAllComponent diff --git a/searchPages/searchDataProviders.component.ts b/searchPages/searchDataProviders.component.ts index 02fa4f9b..f65bc6fd 100644 --- a/searchPages/searchDataProviders.component.ts +++ b/searchPages/searchDataProviders.component.ts @@ -103,17 +103,13 @@ export class SearchDataProvidersComponent { if(this.showSwitchSearchLink == null){ this.showSwitchSearchLink = (this.type == "all"); } - // this.route.data - // .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties= properties; - if (!this.simpleSearchLink) { - this.simpleSearchLink = this.properties.searchLinkToDataProviders; - } this.advancedSearchLink = this.properties.searchLinkToAdvancedDataProviders; - this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink; - this.pagingLimit = properties.pagingLimit; - this.isPiwikEnabled = properties.enablePiwikTrack; - - // }); + this.properties= properties; + if (!this.simpleSearchLink) { + this.simpleSearchLink = this.properties.searchLinkToDataProviders; + } this.advancedSearchLink = this.properties.searchLinkToAdvancedDataProviders; + this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink; + this.pagingLimit = properties.pagingLimit; + this.isPiwikEnabled = properties.enablePiwikTrack; let firstLoad = true; this.filters = DatasourcesHelperClass.createFilters(this.type); diff --git a/searchPages/searchDataProviders.module.ts b/searchPages/searchDataProviders.module.ts index f129fffa..25fb6452 100644 --- a/searchPages/searchDataProviders.module.ts +++ b/searchPages/searchDataProviders.module.ts @@ -1,8 +1,6 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {FormsModule} from '@angular/forms'; -import {FreeGuard} from '../login/freeGuard.guard'; -import {IsRouteEnabled} from '../error/isRouteEnabled.guard'; import {NewSearchPageModule} from "./searchUtils/newSearchPage.module"; import {DataProvidersServiceModule} from "../services/dataProvidersService.module"; import {SearchDataProvidersComponent} from "./searchDataProviders.component"; @@ -17,7 +15,7 @@ import {SearchDataProvidersComponent} from "./searchDataProviders.component"; declarations: [ SearchDataProvidersComponent ], - providers: [FreeGuard, IsRouteEnabled], + providers: [], exports: [ SearchDataProvidersComponent ] diff --git a/searchPages/searchOrganizations.component.ts b/searchPages/searchOrganizations.component.ts index 58c6b464..388e4c14 100644 --- a/searchPages/searchOrganizations.component.ts +++ b/searchPages/searchOrganizations.component.ts @@ -91,19 +91,16 @@ export class SearchOrganizationsComponent { } ngOnInit() { - // this.route.data - // .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties= properties; - if (!this.simpleSearchLink) { - this.simpleSearchLink = this.properties.searchLinkToOrganizations; - } - this.advancedSearchLink = this.properties.searchLinkToAdvancedOrganizations; - this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink; - this.pagingLimit = properties.pagingLimit; - this.isPiwikEnabled = properties.enablePiwikTrack; - // }); - //var errorCodes:ErrorCodes = new ErrorCodes(); + this.properties= properties; + if (!this.simpleSearchLink) { + this.simpleSearchLink = this.properties.searchLinkToOrganizations; + } + this.advancedSearchLink = this.properties.searchLinkToAdvancedOrganizations; + this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink; + this.pagingLimit = properties.pagingLimit; + this.isPiwikEnabled = properties.enablePiwikTrack; + this.searchUtils.status = this.errorCodes.LOADING; var firstLoad = true; diff --git a/searchPages/searchOrganizations.module.ts b/searchPages/searchOrganizations.module.ts index 3cec0145..664c3ab7 100644 --- a/searchPages/searchOrganizations.module.ts +++ b/searchPages/searchOrganizations.module.ts @@ -1,7 +1,6 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {FormsModule} from '@angular/forms'; -import {FreeGuard} from '../login/freeGuard.guard'; import {IsRouteEnabled} from '../error/isRouteEnabled.guard'; import {NewSearchPageModule} from "./searchUtils/newSearchPage.module"; import {OrganizationsServiceModule} from "../services/organizationsService.module"; @@ -17,7 +16,7 @@ import {SearchOrganizationsComponent} from "./searchOrganizations.component"; declarations: [ SearchOrganizationsComponent ], - providers: [FreeGuard, IsRouteEnabled], + providers: [], exports: [ SearchOrganizationsComponent ] diff --git a/searchPages/searchProjects.component.ts b/searchPages/searchProjects.component.ts index 92fb4888..1003a805 100644 --- a/searchPages/searchProjects.component.ts +++ b/searchPages/searchProjects.component.ts @@ -93,19 +93,16 @@ export class SearchProjectsComponent { } ngOnInit() { - // this.route.data - // .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties= properties; - if (!this.simpleSearchLink) { - this.simpleSearchLink = this.properties.searchLinkToProjects; - } - this.advancedSearchLink = this.properties.searchLinkToAdvancedProjects; - this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink; - this.pagingLimit = properties.pagingLimit; - this.isPiwikEnabled = properties.enablePiwikTrack; - // }); - //var errorCodes:ErrorCodes = new ErrorCodes(); + this.properties= properties; + if (!this.simpleSearchLink) { + this.simpleSearchLink = this.properties.searchLinkToProjects; + } + this.advancedSearchLink = this.properties.searchLinkToAdvancedProjects; + this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink; + this.pagingLimit = properties.pagingLimit; + this.isPiwikEnabled = properties.enablePiwikTrack; + this.searchUtils.status = this.errorCodes.LOADING; var firstLoad = true; diff --git a/searchPages/searchProjects.module.ts b/searchPages/searchProjects.module.ts index 8e791ec0..817e208e 100644 --- a/searchPages/searchProjects.module.ts +++ b/searchPages/searchProjects.module.ts @@ -1,8 +1,6 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {FormsModule} from '@angular/forms'; -import {FreeGuard} from '../login/freeGuard.guard'; -import {IsRouteEnabled} from '../error/isRouteEnabled.guard'; import {NewSearchPageModule} from "./searchUtils/newSearchPage.module"; import {SearchProjectsComponent} from "./searchProjects.component"; import {ProjectsServiceModule} from "../services/projectsService.module"; @@ -17,7 +15,7 @@ import {ProjectsServiceModule} from "../services/projectsService.module"; declarations: [ SearchProjectsComponent ], - providers: [FreeGuard, IsRouteEnabled], + providers: [], exports: [ SearchProjectsComponent ] diff --git a/searchPages/searchResearchResults.module.ts b/searchPages/searchResearchResults.module.ts index 89c59fe7..a0cbfd43 100644 --- a/searchPages/searchResearchResults.module.ts +++ b/searchPages/searchResearchResults.module.ts @@ -3,7 +3,6 @@ import {CommonModule} from '@angular/common'; import {FormsModule} from '@angular/forms'; import {SearchResearchResultsServiceModule} from '../services/searchResearchResultsService.module'; -import {FreeGuard} from '../login/freeGuard.guard'; import {IsRouteEnabled} from '../error/isRouteEnabled.guard'; import {SearchResearchResultsComponent} from "./searchResearchResults.component"; import {NewSearchPageModule} from "./searchUtils/newSearchPage.module"; @@ -18,7 +17,7 @@ import {NewSearchPageModule} from "./searchUtils/newSearchPage.module"; declarations: [ SearchResearchResultsComponent ], - providers:[FreeGuard, IsRouteEnabled], + providers:[], exports: [ SearchResearchResultsComponent ] diff --git a/searchPages/searchUtils/advancedSearchForm.component.ts b/searchPages/searchUtils/advancedSearchForm.component.ts index b466c9e7..b8cbd44e 100644 --- a/searchPages/searchUtils/advancedSearchForm.component.ts +++ b/searchPages/searchUtils/advancedSearchForm.component.ts @@ -5,8 +5,8 @@ import {AdvancedField, Filter} from '../searchUtils/searchHelperClasses.class'; import {SearchFields} from '../../utils/properties/searchFields'; import {Dates} from '../../utils/string-utils.class'; import {EnvProperties} from '../../utils/properties/env-properties'; -import {ConfigurationService} from "../../utils/configuration/configuration.service"; import {SearchCustomFilter} from "./searchUtils.class"; +import {Subscriber} from "rxjs"; @Component({ selector: 'advanced-search-form', @@ -41,13 +41,18 @@ export class AdvancedSearchFormComponent { selectedEntityAdvancedUrl; @Input() entitiesSelection:boolean; @Input() showSwitchSearchLink:boolean = true; + sub; constructor (private route: ActivatedRoute, private router: Router) { } - + ngOnDestroy() { + if (this.sub instanceof Subscriber) { + this.sub.unsubscribe(); + } + } ngOnInit() { this.selectedEntity = this.entityType; - this.route.data + this.sub = this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; diff --git a/searchPages/searchUtils/advancedSearchPage.component.html b/searchPages/searchUtils/advancedSearchPage.component.html deleted file mode 100644 index ca673ca5..00000000 --- a/searchPages/searchUtils/advancedSearchPage.component.html +++ /dev/null @@ -1,87 +0,0 @@ -
-
-
-
-
- - -
- - -
-
-
-
-
- - - - -
-
-
-
-
- - -
-
- -
-
- - -
- -
- - - -
- - -
- -
-

For more results please try a new, more specific query

-
- -
-
- - -
- -
- - - Last index information - -
-
- -
- -
- - -
-
-
-
-
diff --git a/searchPages/searchUtils/advancedSearchPage.component.ts b/searchPages/searchUtils/advancedSearchPage.component.ts deleted file mode 100644 index 2945fba1..00000000 --- a/searchPages/searchUtils/advancedSearchPage.component.ts +++ /dev/null @@ -1,349 +0,0 @@ -import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; -import {Location} from '@angular/common'; -import {ActivatedRoute, Router} from '@angular/router'; -import {Meta, Title} from '@angular/platform-browser'; - -import {AdvancedField} from '../searchUtils/searchHelperClasses.class'; -import {SearchCustomFilter, SearchUtilsClass} from './searchUtils.class'; -import {ModalLoading} from '../../utils/modal/loading.component'; -import {Dates, StringUtils} from '../../utils/string-utils.class'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {RouterHelper} from '../../utils/routerHelper.class'; - -import {PiwikService} from '../../utils/piwik/piwik.service'; -import {EnvProperties} from '../../utils/properties/env-properties'; -import {SEOService} from '../../sharedComponents/SEO/SEO.service'; -import {HelperService} from "../../utils/helper/helper.service"; - -@Component({ - selector: 'advanced-search-page', - templateUrl: 'advancedSearchPage.component.html' -}) -export class AdvancedSearchPageComponent { - @Input() piwikSiteId = null; - @Input() hasPrefix: boolean = true; - @Input() pageTitle = ""; - @Input() results = []; - @Input() type; - @Input() entityType; - @Input() searchUtils: SearchUtilsClass = new SearchUtilsClass(); - @Input() fieldIds: string[]; - @Input() fieldIdsMap;//:{ [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ; - @Input() selectedFields: AdvancedField[]; - @Input() simpleSearchUrl: string; - @ViewChild(ModalLoading) loading: ModalLoading; - @Input() csvParams: string; - @Input() csvPath: string; - @Input() simpleSearchLink: string = ""; - @Input() disableForms: boolean = false; - @Input() loadPaging: boolean = true; - @Input() oldTotalResults: number = 0; - @Input() openaireLink: string; - @Input() customFilter: SearchCustomFilter = null; - @Input() sort: boolean = false; - @Input() searchFormClass: string = "searchForm"; - piwiksub: any; - public parameterNames: string[] = []; - public parameterValues: string[] = []; - - public baseURLWithParameters: string = ''; - - public csvLimit: number = 0; - public pagingLimit: number = 0; - public resultsPerPage: number = 0; - isPiwikEnabled = false; - properties: EnvProperties; - public pageContents = null; - public divContents = null; - public routerHelper: RouterHelper = new RouterHelper(); - public errorCodes: ErrorCodes = new ErrorCodes(); - - url = null; - - constructor(private route: ActivatedRoute, - private location: Location, - private _meta: Meta, - private _title: Title, - private _piwikService: PiwikService, - private router: Router, - private seoService: SEOService, - private helper: HelperService) { - } - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - //this.getDivContents(); - this.getPageContents(); - this.pagingLimit = data.envSpecific.pagingLimit; - this.resultsPerPage = data.envSpecific.resultsPerPage; - this.csvLimit = data.envSpecific.csvLimit; - this.isPiwikEnabled = data.envSpecific.enablePiwikTrack; - if (typeof window !== 'undefined') { - this.updateUrl(this.properties.domain + this.properties.baseLink + location.pathname); - this.url = this.properties.domain + this.properties.baseLink + location.pathname - } - if (typeof document !== 'undefined' && this.isPiwikEnabled) { - this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); - } - }); - - var description = "Openaire, search, repositories, open access, type, content provider, funder, project, " + this.pageTitle; - - this.updateTitle(this.pageTitle); - this.updateDescription(description); - - this.searchUtils.baseUrl = "/" + this.searchUtils.baseUrl; - - this.updateBaseUrlWithParameters(); - this.seoService.createLinkForCanonicalURL(this.properties.domain +this.properties.baseLink + this.router.url, false); - - - } - - private getPageContents() { - this.helper.getPageHelpContents(this.properties, (this.customFilter)?this.customFilter.valueId:null, this.router.url).subscribe(contents => { - - this.pageContents = contents; - }) - } - - private getDivContents() { - this.helper.getDivHelpContents(this.properties, (this.customFilter)?this.customFilter.valueId:null, this.router.url).subscribe(contents => { - this.divContents = contents; - }) - } - - ngOnDestroy() { - if (this.piwiksub) { - this.piwiksub.unsubscribe(); - } - } - - updateDescription(description: string) { - this._meta.updateTag({content: description}, "name='description'"); - this._meta.updateTag({content: description}, "property='og:description'"); - } - - updateTitle(title: string) { - var _prefix = ""; - if(this.hasPrefix) { - _prefix = "OpenAIRE | "; - } - var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title); - this._title.setTitle(_title); - this._meta.updateTag({content: _title}, "property='og:title'"); - } - - updateUrl(url: string) { - this._meta.updateTag({content: url}, "property='og:url'"); - } - - public getSelectedFiltersFromUrl(params) { - for (var i = 0; i < this.fieldIds.length; i++) { - - var fieldId = this.fieldIds[i]; - var fieldparam = (this.fieldIdsMap[fieldId]) ? this.fieldIdsMap[fieldId].param : ""; - if (!this.fieldIdsMap[fieldId]) { - - console.error("Field: " + fieldId + " not found in fieldIds map"); - } - - var operatorId = this.getOperatorParameter(fieldparam); - if (params[fieldparam] != undefined && params[operatorId] != undefined) { - var values: string [] = StringUtils.URIDecode(params[fieldparam]).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1); - var operators: string [] = (StringUtils.URIDecode(params[operatorId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1); - if (values.length == operators.length) { - for (var j = 0; j < values.length; j++) { - if (this.fieldIdsMap[fieldId].type == "date") { - var value: string = StringUtils.unquote(values[j]); - var validDates: boolean = true; - var dateField: AdvancedField = new AdvancedField(fieldId, fieldparam, this.fieldIdsMap[fieldId].name, this.fieldIdsMap[fieldId].type, value, operators[j]); - if (value.indexOf("range") != -1) { - dateField.dateValue.type = "range"; - if (value.length < 26) { - validDates = false; - } else { - if (!Dates.isValidDate(value.substring(5, 15)) || !Dates.isValidDate(value.substring(16, 26))) { - validDates = false; - } else { - dateField.dateValue.from = Dates.getDateFromString(value.substring(5, 15)); - dateField.dateValue.to = Dates.getDateFromString(value.substring(16, 26)); - } - } - // "rangeYYYY-MM-DD:YYYY-MM-DD" - } else { - dateField.dateValue.setDatesByType(value); - } - if (validDates) { - this.selectedFields.push(dateField); - } - - } else { - this.selectedFields.push(new AdvancedField(fieldId, fieldparam, this.fieldIdsMap[fieldId].name, this.fieldIdsMap[fieldId].type, StringUtils.unquote(values[j]), operators[j])); - } - } - } - } - } - if (this.selectedFields.length == 0) { - this.selectedFields.push(new AdvancedField(this.fieldIds[0], fieldparam, this.fieldIdsMap[this.fieldIds[0]].name, this.fieldIdsMap[this.fieldIds[0]].type, "", "and")); - } - } - - /** - * Create Page URL parameters based on the selected fields of the advanced form - * @param includePage - */ - private createUrlParameters(includePage: boolean) { - var params = ""; - this.parameterNames.splice(0, this.parameterNames.length); - this.parameterValues.splice(0, this.parameterValues.length); - var fields: { [key: string]: { values: string[], operators: string[] } } = {}; - for (var i = 0; i < this.selectedFields.length; i++) { - if (this.fieldIdsMap[this.selectedFields[i].id] != undefined && (this.selectedFields[i].value.length > 0 || this.selectedFields[i].type == "date")) { - if (!fields[this.selectedFields[i].id]) { - fields[this.selectedFields[i].id] = {values: [], operators: []}; - fields[this.selectedFields[i].id].values = []; - fields[this.selectedFields[i].id].operators = []; - } - if (this.selectedFields[i].type == "date") { - if (this.selectedFields[i].dateValue.type == "range") { - fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode("range" + Dates.getDateToString(this.selectedFields[i].dateValue.from) + ":" + Dates.getDateToString(this.selectedFields[i].dateValue.to)))); - } else { - fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode(this.selectedFields[i].dateValue.type))); - } - } else { - fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode(this.selectedFields[i].value))); - } - fields[this.selectedFields[i].id].operators.push(this.selectedFields[i].operatorId); - - } - } - for (var i = 0; i < this.fieldIds.length; i++) { - if (fields[this.fieldIds[i]]) { - - params += "&" + this.fieldIdsMap[this.fieldIds[i]].param + "=" + fields[this.fieldIds[i]].values.join() + - "&" + this.fieldIdsMap[this.fieldIds[i]].operator + "=" + fields[this.fieldIds[i]].operators.join() - this.parameterNames.push(this.fieldIdsMap[this.fieldIds[i]].param); - this.parameterValues.push(fields[this.fieldIds[i]].values.join()); - this.parameterNames.push(this.fieldIdsMap[this.fieldIds[i]].operator); - this.parameterValues.push(fields[this.fieldIds[i]].operators.join()); - } - } - if (includePage && this.searchUtils.page != 1) { - params += "&page=" + this.searchUtils.page; - } - - if (this.searchUtils.size != 10) { - params += ((params.length == 0) ? '' : '&') + 'size=' + this.searchUtils.size; - this.parameterNames.push("size"); - this.parameterValues.push("" + this.searchUtils.size); - } - - if (this.sort && this.searchUtils.sortBy) { - params += ((params.length == 0) ? '' : '&') + 'sortBy=' + this.searchUtils.sortBy; - this.parameterNames.push("sortBy"); - this.parameterValues.push(this.searchUtils.sortBy); - } - - return '?' + params; - } - - /** - * Create Search API query based on the selected fields of the advanced form - */ - public createQueryParameters() { - var params = ""; - var countParams = 0; - for (var i = 0; i < this.selectedFields.length; i++) { - if (this.fieldIdsMap[this.selectedFields[i].id] != undefined && (this.selectedFields[i].value != "" || this.selectedFields[i].type == "date")) { - //console.log("createQueryParameters::"+this.selectedFields[i].type); - if (this.selectedFields[i].type == "date") { - if (this.selectedFields[i].dateValue.type != "any") { - params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + this.selectedFields[i].id + this.fieldIdsMap[this.selectedFields[i].id].equalityOperator + '"' + StringUtils.URIEncode(Dates.getDateToString(this.selectedFields[i].dateValue.from)) + " " - + StringUtils.URIEncode(Dates.getDateToString(this.selectedFields[i].dateValue.to)) + '"' + " "; - } - } else { - if (this.selectedFields[i].id == "q") { - var op = ""; - // if() - params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + '"' + StringUtils.URIEncode(this.selectedFields[i].value) + '"' + " "; - } else if (countParams == 0 && this.selectedFields[i].operatorId == "not") { - params += " " + this.selectedFields[i].id + " <> " + '"' + StringUtils.URIEncode(this.selectedFields[i].value) + '"' + " "; - } else { - params += (countParams == 0 ? "" : this.selectedFields[i].operatorId + " ") + this.selectedFields[i].id + this.fieldIdsMap[this.selectedFields[i].id].equalityOperator + '"' + encodeURIComponent(this.selectedFields[i].value) + '"' + " "; - - } - } - countParams++; - } - } - - if (this.customFilter) { - params += (countParams == 0 ? "" : " and ") + this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId)); - } - return params; - - } - - goTo(page: number = 1) { - this.searchUtils.page = page; - this.createUrlParameters(true); - this.router.navigate([this.searchUtils.baseUrl], {queryParams: this.routerHelper.createQueryParams(this.parameterNames, this.parameterValues)}); - /* Code For Piwik*/ - if (typeof localStorage !== 'undefined') { - //console.log("In PreviousRouteRecorder : "+this.router.url ); - localStorage.setItem('previousRoute', this.properties.domain + this.properties.baseLink + this.router.url); - } - if (this.isPiwikEnabled && (typeof document !== 'undefined')) { - this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); - } - /* End Piwik Code */ - } - - queryChanged($event) { - - this.goTo(1); - } - - pageChanged($event) { - this.searchUtils.page = +$event.value; - this.goTo(this.searchUtils.page); - } - - sizeChanged($event) { - this.searchUtils.size = $event.value; - this.goTo(1); - } - - sortByChanged($event) { - this.searchUtils.sortBy = $event.value; - this.goTo(1); - } - - /* - * Update the url with proper parameters. This is used as base url in Paging Component - */ - public updateBaseUrlWithParameters() { - this.baseURLWithParameters = this.searchUtils.baseUrl + this.createUrlParameters(false); - } - - getOperatorParameter(parameter: string): string { - for (let id of this.fieldIds) { - if (this.fieldIdsMap[id]["param"] == parameter) { - return this.fieldIdsMap[id]["operator"]; - } - } - } - - // for loading - public openLoading() { - this.loading.open(); - } - - public closeLoading() { - this.loading.close(); - } -} diff --git a/searchPages/searchUtils/advancedSearchPage.module.ts b/searchPages/searchUtils/advancedSearchPage.module.ts deleted file mode 100644 index 27adf68f..00000000 --- a/searchPages/searchUtils/advancedSearchPage.module.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; - -import{AdvancedSearchPageComponent} from './advancedSearchPage.component'; -import{SearchResultsModule} from './searchResults.module'; -import{LoadingModalModule} from '../../utils/modal/loadingModal.module'; -import {ReportsServiceModule} from '../../services/reportsService.module'; -import {SearchDownloadModule} from './searchDownload.module'; -import{SearchPagingModule} from './searchPaging.module'; -import {SearchResultsPerPageModule} from './searchResultsPerPage.module'; -import {SearchSortingModule} from './searchSorting.module'; - -import {AdvancedSearchFormModule} from '../searchUtils/advancedSearchForm.module'; -import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; -import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; -import {HelperModule} from '../../utils/helper/helper.module'; -import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; -import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, RouterModule, SearchResultsModule, LoadingModalModule, ReportsServiceModule, SearchPagingModule, AdvancedSearchFormModule, SearchDownloadModule, PiwikServiceModule, HelperModule, - Schema2jsonldModule, SEOServiceModule, SearchResultsPerPageModule, SearchSortingModule - ], - declarations: [ - AdvancedSearchPageComponent, -], - - providers:[ - PreviousRouteRecorder - ], - exports: [ - AdvancedSearchPageComponent, - ] -}) -export class AdvancedSearchPageModule { } diff --git a/searchPages/searchUtils/browseEntities.component.ts b/searchPages/searchUtils/browseEntities.component.ts index c27d05d5..d1c15a02 100644 --- a/searchPages/searchUtils/browseEntities.component.ts +++ b/searchPages/searchUtils/browseEntities.component.ts @@ -1,15 +1,9 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import { ActivatedRoute} from '@angular/router'; -import {Location} from '@angular/common'; - -import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; - +import {Component, Input, } from '@angular/core'; import {RefineFieldResultsService} from '../../services/refineFieldResults.service'; import {ErrorCodes} from '../../utils/properties/errorCodes'; import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; -import {SearchPageComponent } from '../searchUtils/searchPage.component'; -import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchCustomFilter} from '../searchUtils/searchUtils.class'; import{EnvProperties} from '../../utils/properties/env-properties'; import {StringUtils} from '../../utils/string-utils.class'; @@ -17,11 +11,7 @@ import {StringUtils} from '../../utils/string-utils.class'; selector: 'browse-entities', template: `
- +
diff --git a/searchPages/searchUtils/browseStatistic.component.ts b/searchPages/searchUtils/browseStatistic.component.ts index 26e63767..cdb47d22 100644 --- a/searchPages/searchUtils/browseStatistic.component.ts +++ b/searchPages/searchUtils/browseStatistic.component.ts @@ -1,16 +1,5 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import { ActivatedRoute} from '@angular/router'; -import {Location} from '@angular/common'; - -import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; - -import {RefineFieldResultsService} from '../../services/refineFieldResults.service'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; -import {SearchPageComponent } from '../searchUtils/searchPage.component'; -import {SearchUtilsClass} from '../searchUtils/searchUtils.class'; +import {Component, Input, } from '@angular/core'; import {RouterHelper} from '../../utils/routerHelper.class'; -import{EnvProperties} from '../../utils/properties/env-properties'; @Component({ selector: 'browse-statistic', diff --git a/searchPages/searchUtils/entitiesSelection.component.ts b/searchPages/searchUtils/entitiesSelection.component.ts index 1f2ef9b1..8544623f 100644 --- a/searchPages/searchUtils/entitiesSelection.component.ts +++ b/searchPages/searchUtils/entitiesSelection.component.ts @@ -4,9 +4,7 @@ import {EnvProperties} from "../../utils/properties/env-properties"; import {SearchCustomFilter} from "./searchUtils.class"; import {ConfigurationService} from "../../utils/configuration/configuration.service"; import {Router} from "@angular/router"; -import {LoginErrorCodes} from "../../login/utils/guardHelper.class"; import {MatSelect} from "@angular/material"; -import {properties} from "../../../../environments/environment"; import {Subscription} from "rxjs"; @Component({ diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts index a785624a..c3e840a7 100644 --- a/searchPages/searchUtils/newSearchPage.component.ts +++ b/searchPages/searchUtils/newSearchPage.component.ts @@ -22,6 +22,7 @@ import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component"; import {HelperFunctions} from "../../utils/HelperFunctions.class"; import {properties} from "../../../../environments/environment"; import {AlertModal} from "../../utils/modal/alert"; +import {Subscriber} from "rxjs"; declare var UIkit: any; @@ -89,7 +90,7 @@ export class NewSearchPageComponent { @Input() lastIndex: boolean = true; public dashboard: boolean = properties.isDashboard; - piwiksub: any; + subscriptions = []; public parameterNames: string[] = []; public parameterValues: string[] = []; @@ -145,7 +146,7 @@ export class NewSearchPageComponent { this.updateUrl(this.properties.domain + this.properties.baseLink + this.router.url); this.url = this.properties.domain + this.properties.baseLink + this.router.url; if (typeof document !== 'undefined' && this.isPiwikEnabled && !this.includeOnlyResultsAndFilter) { - this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe()); } this.route.queryParams.subscribe(params => { if (params['page'] && params['page'] != 1) { @@ -183,24 +184,26 @@ export class NewSearchPageComponent { private getPageContents() { if((this.customFilter && this.customFilter.queryFieldName == "communityId") && this.properties.adminToolsCommunity !== "monitor") { - this.helper.getPageHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getPageHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => { this.pageContents = contents; - }); + })); } } private getDivContents() { if((this.customFilter && this.customFilter.queryFieldName == "communityId") && this.properties.adminToolsCommunity !== "monitor") { - this.helper.getDivHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getDivHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => { this.divContents = contents; - }); + })); } } ngOnDestroy() { - if (this.piwiksub) { - this.piwiksub.unsubscribe(); - } + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } updateDescription() { @@ -301,7 +304,7 @@ export class NewSearchPageComponent { localStorage.setItem('previousRoute', this.router.url); } if (this.isPiwikEnabled && (typeof document !== 'undefined')) { - this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe()); } /* End Piwik Code */ } diff --git a/searchPages/searchUtils/newSearchPage.module.ts b/searchPages/searchUtils/newSearchPage.module.ts index 1860b057..3d5c6b4d 100644 --- a/searchPages/searchUtils/newSearchPage.module.ts +++ b/searchPages/searchUtils/newSearchPage.module.ts @@ -19,7 +19,6 @@ import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.gua import {HelperModule} from '../../utils/helper/helper.module'; import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; import {SEOServiceModule} from '../../sharedComponents/SEO/SEOService.module'; -import {SearchDataproviderMapModule} from './searchDataproviderMap.module'; import {PortalSearchResultModule} from "./portal-search-result.module"; import {SearchResultsModule} from "./searchResults.module"; import {SearchResultsInDepositModule} from "../../deposit/searchResultsInDeposit.module"; @@ -32,7 +31,7 @@ import {ClickModule} from "../../utils/click/click.module"; @NgModule({ imports: [ CommonModule, FormsModule, RouterModule, SearchFormModule, SearchResultsModule, PortalSearchResultModule, - LoadingModalModule, ReportsServiceModule, SearchDataproviderMapModule, + LoadingModalModule, ReportsServiceModule, SearchPagingModule, SearchResultsPerPageModule, SearchSortingModule, SearchDownloadModule, ModalModule, SearchFilterModule, RangeFilterModule, PiwikServiceModule, HelperModule, Schema2jsonldModule, SEOServiceModule, SearchResultsModule, diff --git a/searchPages/searchUtils/no-load-paging.component.ts b/searchPages/searchUtils/no-load-paging.component.ts index 932dacd6..be8d3ac4 100644 --- a/searchPages/searchUtils/no-load-paging.component.ts +++ b/searchPages/searchUtils/no-load-paging.component.ts @@ -1,6 +1,4 @@ import {Component, Input, Output, EventEmitter} from '@angular/core'; -import {Observable} from 'rxjs'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; @Component({ selector: 'no-load-paging', diff --git a/searchPages/searchUtils/portal-search-result.component.ts b/searchPages/searchUtils/portal-search-result.component.ts index b3876156..49cdb7f1 100644 --- a/searchPages/searchUtils/portal-search-result.component.ts +++ b/searchPages/searchUtils/portal-search-result.component.ts @@ -6,6 +6,7 @@ import {CommunityInfo, prodReadyCommunities} from "../../connect/community/commu import {Router} from "@angular/router"; import {LocalStorageService} from "../../services/localStorage.service"; import {Stakeholder, StakeholderInfo, Visibility} from "../../monitor/entities/stakeholder"; +import {Subscriber} from "rxjs"; @Component({ selector: 'portal-search-result', @@ -34,14 +35,18 @@ export class PortalSearchResultComponent implements OnInit, OnChanges{ public errorMessage: string = "No results found"; public selected: CommunityInfo & Stakeholder; public directLink: boolean = true; - + sub; constructor(private router: Router, private localStorageService: LocalStorageService) { } - + ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + } ngOnInit() { - this.localStorageService.get().subscribe(value => { + this.sub = this.localStorageService.get().subscribe(value => { this.directLink = value; }); } diff --git a/searchPages/searchUtils/portal-search-result.module.ts b/searchPages/searchUtils/portal-search-result.module.ts index 42771e9c..56ce3858 100644 --- a/searchPages/searchUtils/portal-search-result.module.ts +++ b/searchPages/searchUtils/portal-search-result.module.ts @@ -7,8 +7,8 @@ import {PortalSearchResultComponent} from "./portal-search-result.component"; import {AlertModalModule} from "../../utils/modal/alertModal.module"; import {ManageModule} from "../../utils/manage/manage.module"; import {IconsModule} from "../../utils/icons/icons.module"; -import {IconsService} from "../../utils/icons/icons.service"; -import {group, lock} from "../../utils/icons/icons"; +// import {IconsService} from "../../utils/icons/icons.service"; +// import {group, lock} from "../../utils/icons/icons"; @NgModule({ imports: [ diff --git a/searchPages/searchUtils/quick-selections.component.ts b/searchPages/searchUtils/quick-selections.component.ts index 74cfa495..1cb36d71 100644 --- a/searchPages/searchUtils/quick-selections.component.ts +++ b/searchPages/searchUtils/quick-selections.component.ts @@ -86,10 +86,10 @@ export class QuickSelectionsComponent { } ngOnInit() { - this.route.queryParams.subscribe(params => { + this.subs.push(this.route.queryParams.subscribe(params => { this.queryParams = Object.assign({}, params); this.initializeFilters(); - }); + })); if(this.properties && !this.initialized) { if(this.properties.adminToolsCommunity !== "monitor") { diff --git a/searchPages/searchUtils/searchDataproviderMap.component.ts b/searchPages/searchUtils/searchDataproviderMap.component.ts deleted file mode 100644 index 5bf3d2e5..00000000 --- a/searchPages/searchUtils/searchDataproviderMap.component.ts +++ /dev/null @@ -1,55 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; -import {AlertModal} from '../../utils/modal/alert'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; - -@Component({ - selector: 'search-dataprovider-map', - template: ` - - - - - - - - - - - - - - - - ` -}) - -export class SearchDataproviderMapComponent { - @Input() searchUtils; - @Input() oldTotalResults:number = 0; - @Input() loadPaging: boolean = true; - @Input() totalResults:number = 0; - @Input() mapUrl: string; - @Input() mapTooltipType: string =""; - @ViewChild('AlertModalMap') alertModalMap: AlertModal; - - public errorCodes:ErrorCodes = new ErrorCodes(); - - constructor (private route: ActivatedRoute) {} - - ngOnInit() {} - - ngOnDestroy() {} - - openMapModal() { - this.alertModalMap.cancelButton = true; - this.alertModalMap.okButton = false; - this.alertModalMap.alertTitle = "Map of Content Providers"; - this.alertModalMap.message = ""; - this.alertModalMap.cancelButtonText = "Close"; - this.alertModalMap.open(); - } -} diff --git a/searchPages/searchUtils/searchDataproviderMap.module.ts b/searchPages/searchUtils/searchDataproviderMap.module.ts deleted file mode 100644 index beae6636..00000000 --- a/searchPages/searchUtils/searchDataproviderMap.module.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import {SearchDataproviderMapComponent} from './searchDataproviderMap.component'; -import {AlertModalModule} from '../../utils/modal/alertModal.module'; -import {IFrameModule} from '../../utils/iframe.module'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, AlertModalModule, IFrameModule - ], - declarations: [ - SearchDataproviderMapComponent -], - - providers:[ - ], - exports: [ - SearchDataproviderMapComponent - - ] -}) -export class SearchDataproviderMapModule { } diff --git a/searchPages/searchUtils/searchDownload.component.ts b/searchPages/searchUtils/searchDownload.component.ts index b9e7d328..cdeee342 100644 --- a/searchPages/searchUtils/searchDownload.component.ts +++ b/searchPages/searchUtils/searchDownload.component.ts @@ -8,6 +8,7 @@ import {EnvProperties} from '../../utils/properties/env-properties'; import {ErrorCodes} from '../../utils/properties/errorCodes'; import 'rxjs'; +import {Subscriber} from "rxjs"; @Component({ selector: 'search-download', @@ -38,10 +39,7 @@ export class SearchDownloadComponent { @Input() type: string; @ViewChild(AlertModal) alertApplyAll: AlertModal; downloadURLAPI: string; - - sub: any; - downloadFilePiwikSub: any; - + public csvLimit: number = 0; @ViewChild(ModalLoading) loading: ModalLoading; @@ -50,27 +48,26 @@ export class SearchDownloadComponent { public isPiwikEnabled; public properties: EnvProperties; public errorCodes: ErrorCodes = new ErrorCodes(); - + subscriptions = []; constructor(private route: ActivatedRoute, private _reportsService: ReportsService, private _piwikService: PiwikService) { } ngOnInit() { - this.route.data + this.subscriptions.push(this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.csvLimit = data.envSpecific.csvLimit; this.downloadURLAPI = data.envSpecific.csvAPIURL; this.isPiwikEnabled = data.envSpecific.enablePiwikTrack; - }); + })); } - + ngOnDestroy() { - if (this.sub) { - this.sub.unsubscribe(); - } - if (this.downloadFilePiwikSub) { - this.downloadFilePiwikSub.unsubscribe(); - } + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } denialOfDownload() { @@ -91,8 +88,8 @@ export class SearchDownloadComponent { //console.log("Downloading file: "+ url); this.openLoading(); this.setMessageLoading("Downloading CSV file"); - - this._reportsService.downloadCSVFile(url).subscribe( + + this.subscriptions.push(this._reportsService.downloadCSVFile(url).subscribe( data => { this.closeLoading(); //window.open(window.URL.createObjectURL(data),filename+".csv"); @@ -113,7 +110,7 @@ export class SearchDownloadComponent { //window.location.href = window.URL.createObjectURL(data); if (this.isPiwikEnabled && (typeof document !== 'undefined')) { - this.downloadFilePiwikSub = this._piwikService.trackDownload(this.properties, url).subscribe(); + this.subscriptions.push(this._piwikService.trackDownload(this.properties, url).subscribe()); } }, error => { @@ -128,7 +125,7 @@ export class SearchDownloadComponent { console.log('Completed file download.'); //setTimeout(function(){ newWindow.close(); }, 500); }*/ - ); + )); } diff --git a/searchPages/searchUtils/searchFilter.component.ts b/searchPages/searchUtils/searchFilter.component.ts index e9c18a14..c83654d6 100644 --- a/searchPages/searchUtils/searchFilter.component.ts +++ b/searchPages/searchUtils/searchFilter.component.ts @@ -3,14 +3,12 @@ import { Input, Output, EventEmitter, - ViewChild, - ElementRef, OnInit, OnChanges, SimpleChanges } from '@angular/core'; import { Filter, Value} from './searchHelperClasses.class'; -import {ActivatedRoute, NavigationStart, Router} from "@angular/router"; +import {ActivatedRoute, Router} from "@angular/router"; import {properties} from "../../../../environments/environment"; import 'rxjs/add/operator/filter'; @Component({ @@ -38,13 +36,18 @@ export class SearchFilterComponent implements OnInit, OnChanges{ queryParams = {}; @Input() actionRoute:boolean = false; @Input() quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string }; + sub; public isOpen:boolean=false; constructor (private _router: Router, private route: ActivatedRoute) { } - + ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + } ngOnInit() { - this.route.queryParams.subscribe(params => { + this.sub = this.route.queryParams.subscribe(params => { this.queryParams = Object.assign({}, params); }); this.filter.values = this.filter.values.filter(value => !value.name.toLowerCase().includes('unknown') && !value.name.toLowerCase().includes('not available')); diff --git a/searchPages/searchUtils/searchFilterModal.component.ts b/searchPages/searchUtils/searchFilterModal.component.ts index 4381e76e..bfd430ff 100644 --- a/searchPages/searchUtils/searchFilterModal.component.ts +++ b/searchPages/searchUtils/searchFilterModal.component.ts @@ -1,7 +1,4 @@ import {Component, ViewEncapsulation, ComponentRef, ElementRef, Input, EventEmitter, Output} from '@angular/core'; -// import { DynamicComponentLoader} from '@angular/core'; - -import {Open} from '../../utils/modal/open.component'; import { Filter} from './searchHelperClasses.class'; @Component({ diff --git a/searchPages/searchUtils/searchPage.component.html b/searchPages/searchUtils/searchPage.component.html deleted file mode 100644 index f4ff0705..00000000 --- a/searchPages/searchUtils/searchPage.component.html +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
-
-
- -
- -
-
-
-
- - - -
-
- -
-
-
-
-
- -
-
- - - -
-
- -
- - - - - - - - - - - - - -
-
- Filters - - Clear All - -
- - Keywords: - - - - -
- {{filter.title}}: - - - , - - -
- - -
- - - -
-
- No filters available -
-
Filter By:
- -
-
- -
-
- -
-
- - - - - - - - - - - - - - -
-
- Filters - - Clear All - -
- -
- - Keywords: - - - - -
- {{filter.title}}: - - -
-
- - -
-
- No filters available -
- -
- -
- - -
-
- - - - -
- - -
-
- - - - - - -
- -
-

For more results please try a new, more specific query

-
- -
-
- - - - - -
- -
- - Last index information - -
-
- - -
-
-
-
-
diff --git a/searchPages/searchUtils/searchPage.component.ts b/searchPages/searchUtils/searchPage.component.ts deleted file mode 100644 index 86df5545..00000000 --- a/searchPages/searchUtils/searchPage.component.ts +++ /dev/null @@ -1,682 +0,0 @@ -import {Component, Input} from '@angular/core'; -import {ViewChild, Output} from '@angular/core'; -import { Location} from '@angular/common'; -import {Router, ActivatedRoute} from '@angular/router'; -import {Title, Meta} from '@angular/platform-browser'; - -import {Filter, Value} from './searchHelperClasses.class'; -import {SearchFields} from '../../utils/properties/searchFields'; -import {SearchCustomFilter, SearchUtilsClass} from './searchUtils.class'; -import {DOI, StringUtils} from '../../utils/string-utils.class'; -import {RouterHelper} from '../../utils/routerHelper.class'; -import {ModalLoading} from '../../utils/modal/loading.component'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {PiwikService} from '../../utils/piwik/piwik.service'; -import {EnvProperties} from '../../utils/properties/env-properties'; -import { SEOService } from '../../sharedComponents/SEO/SEO.service'; -import {HelperFunctions} from "../../utils/HelperFunctions.class"; -import {ZenodoInformationClass} from "../../deposit/utils/zenodoInformation.class"; -import {HelperService} from "../../utils/helper/helper.service"; -import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component"; - -@Component({ - selector: 'search-page', - templateUrl: 'searchPage.component.html' - -}) -export class SearchPageComponent { - @Input() piwikSiteId = null; - @Input() pageTitle = ""; - @Input() formPlaceholderText = "Type Keywords..."; - @Input() results = []; - @Input() filters = []; - @Input() type:string = ""; - @Input() entityType: string = ""; - @Input() usedBy: string = "search"; - @Input() showMoreFilterValuesInline: boolean = false; - @Input() filterValuesNum: number = 5; - @Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass(); - @Input() searchUtils:SearchUtilsClass = new SearchUtilsClass(); - @Input() baseUrl:string = ''; - @Input() showResultCount:boolean = true; - @Input() showRefine:boolean = true; - @Input() refineFields = []; - @Input() csvParams: string; - @Input() csvPath: string; - @Input() advancedSearchLink: string = ""; - @Input() advancedSearchParameters; - @Input() tableViewLink: string; - @Input() disableForms: boolean = false; - @Input() loadPaging: boolean = true; - @Input() oldTotalResults: number = 0; - @Input() tableView: boolean = false; - @Input() searchFormClass: string = "searchForm"; - @Input() openaireLink: string; - @Input() customFilter:SearchCustomFilter= null; - @Input() sort: boolean = false; - @Input() mapUrl: string = ""; - @Input() mapTooltipType: string ="content providers"; - @Input() newQueryButton: boolean = true; - @Input() lastIndex: boolean = true; - @Input() hasPrefix: boolean = true; - @Input() showType = false; - //@Input() sortBy: string = ""; - @ViewChild (ModalLoading) loading : ModalLoading ; - public fieldIdsMap;//: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }}; - @Input() keywordFields = []; - @Input() public breadcrumbs: Breadcrumb[]; - private searchFieldsHelper:SearchFields = new SearchFields(); - private queryParameters: Map = new Map(); - private baseURLWithParameters:string = ''; - private sub: any; piwiksub: any; - // public countFilters= 0; - public parameterNames:string[] =[]; - public parameterValues:string[] =[]; - public showUnknownFilters:boolean = false; // when a filter exists in query but has no results, so no filters returned from the query - //@ViewChild (SearchFilterModalComponent) searchFilterModal : SearchFilterModalComponent ; - // public currentFilter: Filter; - public csvLimit: number = 0; - public pagingLimit: number = 0; - public resultsPerPage: number = 10; - public isPiwikEnabled; - public pageContents = null; - public divContents = null; - properties:EnvProperties; - public routerHelper:RouterHelper = new RouterHelper(); - public errorCodes:ErrorCodes = new ErrorCodes(); - - constructor (private route: ActivatedRoute, - private location: Location, - private _meta: Meta, - private _title: Title, - private _piwikService:PiwikService, - private router: Router, - private seoService: SEOService, - private helper: HelperService) { - } - - ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - //this.getDivContents(); - this.getPageContents(); - this.pagingLimit = data.envSpecific.pagingLimit; - HelperFunctions.scroll(); - this.csvLimit = data.envSpecific.csvLimit; - this.isPiwikEnabled = data.envSpecific.enablePiwikTrack; - if(typeof window !== 'undefined') { - this.updateUrl(this.properties.domain + this.properties.baseLink+location.pathname); - } - if(typeof document !== 'undefined' && this.isPiwikEnabled){ - this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); - } - }); - - // this.updateBaseUrlWithParameters(this.filters); - this.updateTitle(this.pageTitle); - var description = "Openaire, search, repositories, open access, type, content provider, funder, project, " + this.type + "," +this.pageTitle; - this.updateDescription(description); - this.seoService.createLinkForCanonicalURL(this.properties.domain+this.properties.baseLink + this.router.url,false); - } - - private getPageContents() { - this.helper.getPageHelpContents(this.properties, (this.customFilter)?this.customFilter.valueId:null, this.router.url).subscribe(contents => { - - this.pageContents = contents; - }) - } - - private getDivContents() { - this.helper.getDivHelpContents(this.properties, (this.customFilter)?this.customFilter.valueId:null, this.router.url).subscribe(contents => { - this.divContents = contents; - }) - } - - ngOnDestroy() { - if(this.piwiksub){ - this.piwiksub.unsubscribe(); - } - } - - - updateDescription(description:string) { - this._meta.updateTag({content:description},"name='description'"); - this._meta.updateTag({content:description},"property='og:description'"); - } - - updateTitle(title:string) { - let _title: string; - if(this.hasPrefix && !this.customFilter) { - let _prefix ="OpenAIRE | "; - _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title); - } else { - _title = ((title.length > 50) ? title.substring(0, 50) : title); - } - this._title.setTitle(_title); - this._meta.updateTag({content:_title},"property='og:title'"); - } - - updateUrl(url:string) { - this._meta.updateTag({content:url},"property='og:url'"); - } - - public getQueryParamsFromUrl(params) { - this.queryParameters = new Map(); - for(let i=0; i< this.refineFields.length ; i++) { - let filterId = this.refineFields[i]; - if (params[filterId] != undefined) { - this.queryParameters.set(filterId, StringUtils.URIDecode(params[filterId])); - } - } - return this.queryParameters; - } - - /** - * Create Search API query based on the page URL parameters - * @param params page URL parameters - */ - public getQueryParametersFromUrl(params){ // called by ngOnInit function of search find pages - // var parameters = ""; - var allFqs = ""; - - this.queryParameters = new Map(); - for(var i=0; i< this.refineFields.length ; i++){ - var filterId = this.refineFields[i]; - - if(params[filterId] != undefined) { - this.queryParameters.set(filterId, StringUtils.URIDecode(params[filterId])); - let values = (StringUtils.URIDecode(this.queryParameters.get(filterId))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); - var countvalues = 0; - var fq = ""; - let filterOp: string = this.searchFieldsHelper.getFieldOperator(filterId); - console.info(filterId, filterOp); - for(let value of values) { - countvalues++; - var paramId = this.fieldIdsMap[filterId].param; - // parameters+='&' + paramId+ '='+ value;//+"&" + this.fieldIdsMap[paramId].operator + "="+((countvalues == 1)?"and":"or"); - fq+=(fq.length > 0 ? " " + filterOp + " ":"" ) + filterId +" exact " +(value); - } - if(countvalues > 0){ - fq="&fq="+StringUtils.URIEncode(fq); - } - allFqs += fq; - } - } - if(this.customFilter){ - allFqs+= "&fq="+StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId ))); - } - var keyword = params['keyword']; - var doiQuery = ""; - var keywordQuery = ""; - if((keyword && keyword.length > 0)){ - if((this.type == 'publications' ||this.type == 'research data' || this.type == 'software' || this.type == 'other research products')){ - var DOIs:string[] = DOI.getDOIsFromString(keyword); - var doisParams = ""; - - for(var i =0 ;i < DOIs.length; i++){ - doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; - } - if(doisParams.length > 0){ - doiQuery += "&"+doisParams; - }else { - keywordQuery += "&q="+StringUtils.URIEncode(keyword); - } - }else{ - if(this.usedBy == "deposit") { - if(this.keywordFields.length > 0) { - keywordQuery = "&fq="; - } - - for(let i=0; i< this.keywordFields.length ; i++) { - if(i > 0) { - keywordQuery += " or "; - } - let field = this.keywordFields[i]; - //keywordQuery += field.name+field.equalityOperator+StringUtils.URIEncode(keyword); - keywordQuery += field.name+field.equalityOperator+StringUtils.quote(StringUtils.URIEncode(keyword)); - } - } else { - keywordQuery += "&q=" + StringUtils.URIEncode(keyword); - } - - } - } - return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; - } - public getIndexQueryParametersFromUrl(params){ // called by ngOnInit function of search pages that request 'resources' - // var parameters = ""; - var allFqs = ""; - - for(var i=0; i< this.refineFields.length ; i++){ - var filterId = this.refineFields[i]; - var fq = ""; - if(params[filterId] != undefined) { - this.queryParameters.set(filterId,decodeURIComponent(params[filterId])); - let values = (decodeURIComponent(this.queryParameters.get(filterId))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); - var countvalues = 0; - let filterOp: string = this.searchFieldsHelper.getFieldOperator(filterId); - console.info(filterId, filterOp); - for(let value of values) { - countvalues++; - // parameters+= ((countvalues == 1)?" and (":" or ")+ filterId+ '='+ value; - fq+=(fq.length > 0 ? " " + filterOp + " ":"" ) + filterId + " exact " + value;//StringUtils.quote(value); - } - // parameters+= " ) "; - if(countvalues > 0){ - fq="&fq="+StringUtils.URIEncode(fq); - } - allFqs += fq; - } - - } - var keyword = params['keyword']; - var doiQuery = ""; - var keywordQuery = ""; - if((keyword && keyword.length > 0)){ - if((this.type == 'publications' ||this.type == 'research data' || this.type == 'software' || this.type == 'other research products')){ - var DOIs:string[] = DOI.getDOIsFromString(keyword); - var doisParams = ""; - - for(var i =0 ;i < DOIs.length; i++){ - doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; - } - if(doisParams.length > 0){ - doiQuery += "&"+doisParams; - } - }else{ - keywordQuery += "and ("+StringUtils.quote(StringUtils.URIEncode(keyword)) +")"; - - } - } - return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; - -} - /* - * Mark as check the new filters that are selected, when you get them from search - */ - public checkSelectedFilters(filters:Filter[]){ - this.filters = filters; - for(var i=0; i< filters.length ; i++){ - var filter:Filter = filters[i]; - filter.countSelectedValues = 0; - if(this.queryParameters.get(filter.filterId) != undefined) { - let values = (decodeURIComponent(this.queryParameters.get(filter.filterId))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); - for(let filterValue of filter.values) { - if(values.indexOf(StringUtils.quote(filterValue.id)) > -1) { - filterValue.selected = true; - filter.countSelectedValues++; - }else{ - filterValue.selected = false; - - } - } - }else{ - for(let filterValue of filter.values) { - filterValue.selected = false; - } - } - } - this.filterFilterValues(this.filters); - return filters; - } - /* - * For Funder filters - if funder selected - */ - public filterFilterValues(filters:Filter[]){ - var funders = []; - var funder_prefix = []; - for(var i=0; i< filters.length ; i++){ - - var filter:Filter = filters[i]; - // console.log(filter.filterId); - if(filter.filterId.indexOf("funder")!=-1 && this.queryParameters.get(filter.filterId) != undefined) { - let funders = (decodeURIComponent(this.queryParameters.get(filter.filterId))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); - for(let funder of funders) { - funder_prefix.push(StringUtils.unquote(funder).split("____")[0]); - } - // console.log(funder_prefix ); - }else if(filter.filterId.indexOf("funding")!=-1){ - // console.log(" funding: "+filter.filterId ); - var filteredValues = [] - for(let filterValue of filter.values) { - var value_prefix = filterValue.id.split("____")[0]; - // console.log("Value prefix: "+value_prefix ); - if(funder_prefix.indexOf(value_prefix)!=-1){ - // console.log("here" + value_prefix); - filteredValues.push(filterValue); - } - - } - if(filteredValues.length > 0){ - filter.values = filteredValues; - } - } - - } - - return filters; - } - /* - * Update the url with proper parameters. This is used as base url in Paging Component - */ - public updateBaseUrlWithParameters(filters:Filter[]){ - this.baseURLWithParameters = this.baseUrl + this.createUrlParameters(filters,false); - - } - - /** - * Get The filters and create page URL parameters - * @param filters - * @param includePage - */ - private createUrlParameters(filters:Filter[], includePage:boolean){ - var allLimits="";//location.search.slice(1); - this.queryParameters = new Map(); - this.parameterNames.splice(0,this.parameterNames.length); - this.parameterValues.splice(0,this.parameterValues.length); - - for (let filter of filters){ - var filterLimits=""; - if(filter.countSelectedValues > 0 ){ - for (let value of filter.values){ - if(value.selected == true){ - filterLimits+=((filterLimits.length == 0)?'':',') +'"'+ (value.id)+'"'; - } - } - this.queryParameters.set(filter.filterId,filterLimits); - if(filterLimits.length > 0){ - this.parameterNames.push(filter.filterId); - this.parameterValues.push(filterLimits); - } - allLimits+=(allLimits.length==0?"?":"&")+((filterLimits.length == 0 )?'':filter.filterId + '='+ filterLimits) ; - } - } - if(this.searchUtils.keyword.length > 0 ){ - allLimits+=(allLimits.length==0?"?":"&")+'keyword=' + this.searchUtils.keyword; - this.parameterNames.push("keyword"); - this.parameterValues.push(this.searchUtils.keyword); - //this.parameterValues.push(StringUtils.quote(this.searchUtils.keyword)); - } - if(this.searchUtils.page != 1 && includePage){ - allLimits+=((allLimits.length == 0)?'?':'&') + 'page=' + this.searchUtils.page; - } - if(this.searchUtils.size != this.resultsPerPage) { - allLimits+=((allLimits.length == 0)?'?':'&') + 'size=' + this.searchUtils.size; - this.parameterNames.push("size"); - this.parameterValues.push(""+this.searchUtils.size); - } - if(this.sort && this.searchUtils.sortBy) { - allLimits+=((allLimits.length == 0)?'?':'&') + 'sortBy=' + this.searchUtils.sortBy; - this.parameterNames.push("sortBy"); - this.parameterValues.push(this.searchUtils.sortBy); - } /*else { - let index: number = this.parameterNames.findIndex(function(element) { - return element == "sortBy"; - }); - console.info("index of sortby: "+index); - if(index >= 0) { - console.info("------remove sortBy------"); - this.parameterNames.splice(index, 1); - this.parameterValues.splice(index, 1); - } - }*/ - - return allLimits; - } - /* - * - */ - private createSearchQueryParameters(filters:Filter[]){ // called by goTo, result emited to and used by search find pages - var allFqs = ""; - for (let filter of filters){ - if(filter.countSelectedValues > 0 ){ - var fq = ""; - var count_selected=0; - for (let value of filter.values){ - if(value.selected == true){ - count_selected++; - fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + StringUtils.quote((value.id)); - } - } - - fq="&fq="+StringUtils.URIEncode(fq); - allFqs += fq; - } - } - - var doiQuery = ""; - var keywordQuery = ""; - if((this.searchUtils.keyword && this.searchUtils.keyword.length > 0)){ - if((this.type == 'publications' ||this.type == 'research data' || this.type == 'software' || this.type == 'other research products')){ - var DOIs:string[] = DOI.getDOIsFromString(this.searchUtils.keyword); - var doisParams = ""; - - for(var i =0 ;i < DOIs.length; i++){ - doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; - } - if(doisParams.length > 0){ - doiQuery += "&"+doisParams; - }else{ - keywordQuery += "&q="+StringUtils.URIEncode(this.searchUtils.keyword); - } - }else{ - if(this.usedBy == "deposit") { - if(this.keywordFields.length > 0) { - keywordQuery = "&fq="; - } - - for(let i=0; i< this.keywordFields.length ; i++) { - if(i > 0) { - keywordQuery += " or "; - } - let field = this.keywordFields[i]; - //keywordQuery += field.name+field.equalityOperator+StringUtils.URIEncode(this.searchUtils.keyword); - keywordQuery += field.name+field.equalityOperator+StringUtils.quote(StringUtils.URIEncode(this.searchUtils.keyword)); - } - } else { - keywordQuery += "&q=" + StringUtils.URIEncode(this.searchUtils.keyword); - } - } - } - return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; - - } - private createIndexQueryParameters(filters:Filter[]){ // called by goTo, result emited to and used by search pages that request 'resources' - var allFqs = ""; - for (let filter of filters){ - if(filter.countSelectedValues > 0){ - var count_selected=0; - var fq = ""; - for (let value of filter.values){ - if(value.selected == true){ - count_selected++; - fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + (StringUtils.quote(value.id)); - } - } - if(count_selected > 0){ - fq="&fq="+StringUtils.URIEncode(fq); - allFqs += fq; - } - } - } - var doiQuery = ""; - var keywordQuery = ""; - if((this.searchUtils.keyword && this.searchUtils.keyword.length > 0)){ - if((this.type == 'publications' ||this.type == 'research data' || this.type == 'software' || this.type == 'other research products')){ - var DOIs:string[] = DOI.getDOIsFromString(this.searchUtils.keyword); - var doisParams = ""; - for(var i =0 ;i < DOIs.length; i++){ - doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; - } - if(doisParams.length > 0){ - doiQuery += "&"+doisParams; - } - }else{ - keywordQuery += " and ("+StringUtils.quote(StringUtils.URIEncode(this.searchUtils.keyword)) +")" - - } - } - return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; - - } - public countFilters():number{ - var filters=0; - this.showUnknownFilters = false; - for (let filter of this.filters){ - if(filter.countSelectedValues > 0){ - filters+=filter.countSelectedValues; - } - } - if(this.searchUtils.keyword.length > 0 ){ - filters++; - } - var errorCodes:ErrorCodes = new ErrorCodes(); - if(this.queryParameters.keys() && this.searchUtils.totalResults == 0 && this.searchUtils.status !=errorCodes.LOADING ){ - if(this.newQueryButton) { - this.showUnknownFilters = true; - } - } - return filters; - } - private clearKeywords(){ - if(this.searchUtils.keyword.length > 0 ){ - this.searchUtils.keyword =''; - } - this.goTo(1); - } - private clearFilters(){ - for (var i =0 ; i < this.filters.length; i++){ - for (var j=0; j < this.filters[i].countSelectedValues; j++){ - if(this.filters[i].values[j].selected){ - this.filters[i].values[j].selected = false; - } - this.filters[i].countSelectedValues = 0; - } - } - this.clearKeywords(); - - } - private removeFilter(value:Value,filter:Filter){ - filter.countSelectedValues--; - if(value.selected == true){ - value.selected = false; - } - this.goTo(1); - - } - goTo(page:number = 1){ - this.searchUtils.page = page; - this.createUrlParameters(this.filters,true); - this.router.navigate( [this.baseUrl], { queryParams: this.routerHelper.createQueryParams(this.parameterNames, this.parameterValues) } ); - -/* Code For Piwik*/ - if (typeof localStorage !== 'undefined') { - localStorage.setItem('previousRoute', this.router.url); - } - if(this.isPiwikEnabled && (typeof document !== 'undefined')){ - this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); - } - HelperFunctions.scroll(); - } - filterChanged($event){ - this.goTo(1); - } - keywordChanged($event) { - this.searchUtils.keyword = $event.value; - this.goTo(1); - } - - sizeChanged($event) { - this.searchUtils.size = $event.value; - this.goTo(1); - } - - sortByChanged($event) { - this.searchUtils.sortBy = $event.value; - this.goTo(1); - } - - /* - * Get A sub-array of this.refineFields array, which contains the ids of the selected filters - */ - public getSelectedFilters():string[] { - var selected:string[] = []; - for(var i=0; i < this.filters.length; i++){ - var filter:Filter = this.filters[i]; - if(filter.countSelectedValues > 0){ - selected.push(filter.filterId); - } - } - return selected; - } - /* - * Get A sub-array of this.refineFields array, which contains the ids of the selected parameters - */ - private getSelectedParameters():string[] { - var selected:string[] = []; - var params:string[] = Object.keys(this.queryParameters); - - for(var i=0; i < this.refineFields.length; i++){ - if(this.queryParameters.get(this.refineFields[i])!= undefined ){ - selected.push(this.refineFields[i]); - } - } - return selected; - } - /* - * Get A sub-array of this.refineFields array, which hides hidden fields (e.g Funding level 0,1,2,..), and contains those that depend on another fields (e.g Funding level 0 if Funder is selected ) - */ - public getFields():string[] { - var selected_filters:string[] = this.getSelectedFilters(); - if(selected_filters.length == 0){ - selected_filters = this.getSelectedParameters(); - } - var fields:string[] = []; - for(var i =0 ; i < this.refineFields.length;i++){ - var dependentTo = this.searchFieldsHelper.DEPENDENT_FIELDS[this.refineFields[i]]; - - //if filter is not marked as hidden OR it is hidden but it is dependent to a field that it IS selected - if(this.searchFieldsHelper.HIDDEN_FIELDS.indexOf(this.refineFields[i]) == -1 || (selected_filters.indexOf(dependentTo) != -1) || (selected_filters.indexOf(this.refineFields[i]) != -1) ){ - fields.push(this.refineFields[i]); - } - } - return fields; - } - /* - * Get a query string of all fields, that want to get from search (e.g. &fields=funderid&fields=projectstartyear&...)) - */ - public getRefineFieldsQuery():string{ - - var fields:string[] = this.getFields(); - var fieldsStr = "" - for(var i =0 ; i < fields.length ;i++){ - fieldsStr+="&fields="+fields[i]; - } - return "&refine=true"+fieldsStr; - } - - // for loading - public openLoading(){ - if(this.loading){ - this.loading.open(); - } - } - public closeLoading(){ - if(this.loading){ - this.loading.close(); - } - } - getSelectedValues(filter):any{ - var selected = []; - if(filter.countSelectedValues >0){ - for (var i=0; i < filter.values.length; i++){ - if(filter.values[i].selected){ - selected.push(filter.values[i]); - } - } - } - return selected; - - } -} diff --git a/searchPages/searchUtils/searchPage.module.ts b/searchPages/searchUtils/searchPage.module.ts deleted file mode 100644 index e748021e..00000000 --- a/searchPages/searchUtils/searchPage.module.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; - -import{SearchPageComponent} from './searchPage.component'; -import{SearchFormModule} from './searchForm.module'; -import {SearchFilterModule} from './searchFilter.module'; -import{LoadingModalModule} from '../../utils/modal/loadingModal.module'; -import {ReportsServiceModule} from '../../services/reportsService.module'; -import{SearchPagingModule} from './searchPaging.module'; -import {SearchResultsPerPageModule} from './searchResultsPerPage.module'; -import {SearchSortingModule} from './searchSorting.module'; -import {SearchDownloadModule} from './searchDownload.module'; -import {ModalModule} from '../../utils/modal/modal.module'; -import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; -import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; -import {HelperModule} from '../../utils/helper/helper.module'; -import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; -import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module'; -import { SearchDataproviderMapModule } from './searchDataproviderMap.module'; -import {PortalSearchResultModule} from "./portal-search-result.module"; -import {SearchResultsModule} from "./searchResults.module"; -import {SearchResultsInDepositModule} from "../../deposit/searchResultsInDeposit.module"; -import {BreadcrumbsModule} from "../../utils/breadcrumbs/breadcrumbs.module"; - -@NgModule({ - imports: [ - CommonModule, FormsModule, RouterModule, SearchFormModule, SearchResultsModule, PortalSearchResultModule, - LoadingModalModule, ReportsServiceModule, SearchDataproviderMapModule, - SearchPagingModule, SearchResultsPerPageModule, SearchSortingModule, SearchDownloadModule, ModalModule, SearchFilterModule, PiwikServiceModule, HelperModule, Schema2jsonldModule, SEOServiceModule, SearchResultsModule, - SearchResultsInDepositModule, BreadcrumbsModule - ], - declarations: [ - SearchPageComponent -], - - providers:[ - PreviousRouteRecorder - ], - exports: [ - SearchPageComponent - ] -}) -export class SearchPageModule { } diff --git a/searchPages/searchUtils/searchPageTableView.component.ts b/searchPages/searchUtils/searchPageTableView.component.ts index 651b0793..faea5cb6 100644 --- a/searchPages/searchUtils/searchPageTableView.component.ts +++ b/searchPages/searchUtils/searchPageTableView.component.ts @@ -5,7 +5,7 @@ import {OnInit, AfterViewInit} from '@angular/core'; import {Location} from '@angular/common'; import {ActivatedRoute, Router} from '@angular/router'; import {Title, Meta} from '@angular/platform-browser'; -import {Subject} from 'rxjs'; +import {Subject, Subscriber} from 'rxjs'; import {DataTableDirective } from 'angular-datatables'; import {EnvProperties} from '../../utils/properties/env-properties'; import {Filter, Value} from './searchHelperClasses.class'; @@ -68,7 +68,7 @@ export class SearchPageTableViewComponent implements OnInit, AfterViewInit { @ViewChild (SearchFilterModalComponent) searchFilterModal : SearchFilterModalComponent ; public currentFilter: Filter; public errorCodes:ErrorCodes = new ErrorCodes(); - piwiksub: any; + subscriptions = []; dtOptions: DataTables.Settings = {}; showTable = false; filteringAdded = false; @ViewChild(DataTableDirective) datatableElement: DataTableDirective; @@ -92,7 +92,7 @@ export class SearchPageTableViewComponent implements OnInit, AfterViewInit { private helper: HelperService) { } ngOnInit() { - this.route.data + this.subscriptions.push(this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.getPageContents(); @@ -102,9 +102,9 @@ export class SearchPageTableViewComponent implements OnInit, AfterViewInit { this.url =this.properties.domain+this.properties.baseLink+location.pathname; } if(typeof document !== 'undefined' && this.isPiwikEnabled){ - this.piwiksub = this._piwikService.trackView(data.envSpecific, this.pageTitle, this.piwikSiteId).subscribe(); + this.subscriptions.push(this._piwikService.trackView(data.envSpecific, this.pageTitle, this.piwikSiteId).subscribe()); } - }); + })); this.dtOptions = { "paging": true, "searching": false, @@ -120,9 +120,12 @@ export class SearchPageTableViewComponent implements OnInit, AfterViewInit { } ngOnDestroy() { - if(this.piwiksub){ - this.piwiksub.unsubscribe(); + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); } + }); + try{ $.fn['dataTable'].ext.search.pop(); }catch(e){ @@ -577,9 +580,9 @@ Transform initial - not filtered results to get the filtered number return filters; } private getPageContents() { - this.helper.getPageHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : null, this.router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getPageHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : null, this.router.url).subscribe(contents => { this.pageContents = contents; - }) + })); } } diff --git a/searchPages/searchUtils/searchPageTableView.module.ts b/searchPages/searchUtils/searchPageTableView.module.ts index 56369f47..ee12e619 100644 --- a/searchPages/searchUtils/searchPageTableView.module.ts +++ b/searchPages/searchUtils/searchPageTableView.module.ts @@ -23,7 +23,6 @@ import {HelperModule} from '../../utils/helper/helper.module'; import {ErrorMessagesModule} from '../../utils/errorMessages.module'; import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module'; -import { SearchDataproviderMapModule } from './searchDataproviderMap.module'; import {AdvancedSearchFormModule} from "./advancedSearchForm.module"; import {EntitiesSelectionModule} from "./entitiesSelection.module"; import {BreadcrumbsModule} from "../../utils/breadcrumbs/breadcrumbs.module"; @@ -34,7 +33,7 @@ import {BreadcrumbsModule} from "../../utils/breadcrumbs/breadcrumbs.module"; CommonModule, FormsModule, RouterModule, SearchFormModule, SearchResultsModule, LoadingModalModule, ReportsServiceModule, SearchPagingModule, SearchDownloadModule, ModalModule, PagingModule, DataTablesModule, SearchFilterModule, PiwikServiceModule, HelperModule, ErrorMessagesModule, - Schema2jsonldModule, SEOServiceModule, SearchResultsPerPageModule, SearchDataproviderMapModule, AdvancedSearchFormModule, EntitiesSelectionModule, BreadcrumbsModule + Schema2jsonldModule, SEOServiceModule, SearchResultsPerPageModule, AdvancedSearchFormModule, EntitiesSelectionModule, BreadcrumbsModule ], declarations: [ SearchPageTableViewComponent diff --git a/searchPages/searchUtils/searchPaging.component.ts b/searchPages/searchUtils/searchPaging.component.ts index 26947afb..289930a7 100644 --- a/searchPages/searchUtils/searchPaging.component.ts +++ b/searchPages/searchUtils/searchPaging.component.ts @@ -1,5 +1,4 @@ -import {Component, Input, Output, EventEmitter} from '@angular/core'; -import {Observable} from 'rxjs'; +import {Component, Input} from '@angular/core'; import {ErrorCodes} from '../../utils/properties/errorCodes'; @Component({ diff --git a/searchPages/searchUtils/searchResult.component.ts b/searchPages/searchUtils/searchResult.component.ts index ad24d244..3ced8a86 100644 --- a/searchPages/searchUtils/searchResult.component.ts +++ b/searchPages/searchUtils/searchResult.component.ts @@ -24,7 +24,12 @@ export class SearchResultComponent implements OnInit, OnChanges { } ngOnInit() {} - + sub; + ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + } initialize(){ this.previewResults = []; for(let result of this.results){ @@ -36,7 +41,7 @@ export class SearchResultComponent implements OnInit, OnChanges { // console.log(dois); if(dois.length > 0 && this.showImpactFactors && this.properties.environment != "production" && (this.properties.impactFactorsAPIURL && this.properties.impactFactorsAPIURL.length > 0) ) { let url = this.properties.impactFactorsAPIURL + dois; - this.http.get((this.properties.useCache?(this.properties.cacheUrl+(encodeURIComponent(url))):url)).subscribe((data_received:any[]) => { + this.sub = this.http.get((this.properties.useCache?(this.properties.cacheUrl+(encodeURIComponent(url))):url)).subscribe((data_received:any[]) => { let impact =[]; data_received.forEach(function (result) { if(result.doi && result.doi.length > 0 && result.pop_class!=null && result.inf_class!=null) diff --git a/searchPages/searchUtils/tabResult.module.ts b/searchPages/searchUtils/tabResult.module.ts index e0231542..32321609 100644 --- a/searchPages/searchUtils/tabResult.module.ts +++ b/searchPages/searchUtils/tabResult.module.ts @@ -2,7 +2,6 @@ import { NgModule} from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; -import {SearchResult} from '../../utils/entities/searchResult'; import {TabResultComponent} from './tabResult.component'; import {RouterModule} from '@angular/router'; import {ShowAuthorsModule} from "../../utils/authors/showAuthors.module"; diff --git a/searchPages/simple/searchDataProviders.module.ts b/searchPages/simple/searchDataProviders.module.ts deleted file mode 100644 index 27db9dde..00000000 --- a/searchPages/simple/searchDataProviders.module.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import{SearchDataprovidersComponent} from './searchDataproviders.component'; - -import {SearchResultsModule } from '../searchUtils/searchResults.module'; - -import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; -import {SearchFormModule} from '../searchUtils/searchForm.module'; -//import {SearchFilterModalModule} from '../searchUtils/searchFilterModal.module'; -import {SearchPageModule} from '../searchUtils/searchPage.module'; -import {FreeGuard} from'../../login/freeGuard.guard'; -import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - - DataProvidersServiceModule, - SearchFormModule, SearchResultsModule, SearchPageModule - - ], - declarations: [ - SearchDataprovidersComponent - ], - providers:[FreeGuard, IsRouteEnabled], - exports: [ - SearchDataprovidersComponent - ] -}) -export class SearchDataProvidersModule { } diff --git a/searchPages/simple/searchDataproviders.component.ts b/searchPages/simple/searchDataproviders.component.ts deleted file mode 100644 index a26d3dee..00000000 --- a/searchPages/simple/searchDataproviders.component.ts +++ /dev/null @@ -1,392 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import { ActivatedRoute} from '@angular/router'; -import {Location} from '@angular/common'; -import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; -import { ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {SearchFields} from '../../utils/properties/searchFields'; -import {SearchPageComponent } from '../searchUtils/searchPage.component'; -import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class'; -import{EnvProperties} from '../../utils/properties/env-properties'; - -@Component({ - selector: 'search-dataproviders', - template: ` - - - - - ` -}) -export class SearchDataprovidersComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; -@Input() piwikSiteId = null; -@Input() customFilter:SearchCustomFilter= null; - public results =[]; - public filters =[]; - public totalResults:number = 0 ; - public baseUrl:string; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public sub: any; public subResults: any; - public _location:Location; - public searchFields:SearchFields = new SearchFields(); - public refineFields: string[] = this.searchFields.DATASOURCE_REFINE_FIELDS; - public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; - public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], - "export":[] - }; - public csvParams: string; - - public disableForms: boolean = false; - public loadPaging: boolean = true; - public oldTotalResults: number = 0; - pagingLimit = 0; - public mapUrl: string; - -properties: EnvProperties; - @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; - - constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - this.searchUtils.page =1; - } - - public ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.baseUrl = data.envSpecific.searchLinkToDataProviders; - this.pagingLimit = data.envSpecific.pagingLimit; - this.mapUrl = this.properties.statisticsFrameAPIURL+"markers-test.html?show=all"; - }); - this.searchPage.refineFields = this.refineFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - var firstLoad =true; - - this.sub = this.route.queryParams.subscribe(params => { - this.loadPaging = true; - if(params['page'] && this.searchUtils.page != params['page']) { - this.loadPaging = false; - this.oldTotalResults = this.searchUtils.totalResults; - } - - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - var refine = true; - if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ - refine = false; - - } - firstLoad = false; - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - this.searchUtils.size = (params['size']=== undefined)?10:+params['size']; - if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { - this.searchUtils.size = 10; - } - this.searchPage.customFilter = this.customFilter; - var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); - }); - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } - } - - public getNumForEntity(entity: string, id:string) { - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - - if(id != "" && entity != "") { - - this._searchDataprovidersService.numOfEntityDataproviders(id, entity,this.properties).subscribe( - data => { - this.searchUtils.totalResults = data; - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - }, - err => { - //console.log(err); - this.handleError("Error getting content providers for "+entity+" with id: "+id, err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - } - ); - } - } - - public getNumForSearch(keyword: string) { - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.LOADING; - - this._searchDataprovidersService.numOfDataproviders(keyword,this.properties).subscribe( - data => { - this.searchUtils.totalResults = data; - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - }, - err => { - //console.log(err); - this.handleError("Error getting number of content providers for keyword: "+keyword, err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - } - ); - } - -public getResultsForDeposit(id:string, type:string, page: number, size: number){ - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.status = errorCodes.LOADING; - if(id != "") { - - this._searchDataprovidersService.searchDataprovidersForDeposit(id,type, page, size,this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - }, - err => { - //console.log(err); - this.handleError("Error getting content providers in share "+type+" for organization with id: "+id, err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - } - ); - } -} - public getResultsForEntity(entity:string, id:string, page: number, size: number){ - var parameters = ""; - - if(entity == "organization") { - parameters = "organizations/"+id; - } - - if(parameters != "") { - - this._searchDataprovidersService.searchDataprovidersForEntity(parameters, page, size,this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - }, - err => { - //console.log(err); - this.handleError("Error getting content providers for "+entity+" with id: "+id, err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - } - ); - } - } - - public getResultsForDataproviders(id:string, page: number, size: number){ - - this._searchDataprovidersService.getDataProvidersforEntityRegistry(id, page, size,this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - }, - err => { - //console.log(err); - this.handleError("Error getting content providers for entity registry with id: "+id, err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - } - ); - } - - public getResults(keyword:string,refine:boolean, page: number, size: number){ - var parameters = ""; - if(keyword.length > 0){ - parameters = "q="+ keyword; - } - this._getResults(parameters,refine,page, size); - } - private _getResults(parameters:string,refine:boolean, page: number, size: number){ - if(page > this.pagingLimit) { - size=0; - } - if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) { - this.csvParams = parameters; - - this.searchUtils.status = this.errorCodes.LOADING; - - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; - - this.subResults = this._searchDataprovidersService.searchDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields(),this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - if(refine){ - this.filters = data[2]; - } - this.searchPage.checkSelectedFilters(this.filters); - // this.filters = this.searchPage.checkSelectedFilters(data[2]); - this.searchPage.updateBaseUrlWithParameters(this.filters); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } - }, - err => { - //console.log(err); - this.handleError("Error getting content providers", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - - //this.searchPage.closeLoading(); - this.disableForms = false; - } - ); - } - } - - private setFilters(){ - //TODO set filters from - } - - - private handleError(message: string, error) { - console.error("Content Providers simple Search Page: "+message, error); - } -} diff --git a/searchPages/simple/searchOrganizations.component.ts b/searchPages/simple/searchOrganizations.component.ts deleted file mode 100644 index 64e0def7..00000000 --- a/searchPages/simple/searchOrganizations.component.ts +++ /dev/null @@ -1,193 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import { ActivatedRoute} from '@angular/router'; -import {Location} from '@angular/common'; -import {SearchOrganizationsService} from '../../services/searchOrganizations.service'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {SearchFields} from '../../utils/properties/searchFields'; -import {SearchPageComponent } from '../searchUtils/searchPage.component'; -import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class'; -import{EnvProperties} from '../../utils/properties/env-properties'; - -@Component({ - selector: 'search-organizations', - template: ` - - - - - ` - -}) -export class SearchOrganizationsComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; -@Input() piwikSiteId = null; - public results =[]; - public filters =[]; - public baseUrl:string; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public sub: any; - public subResults: any; - public searchFields:SearchFields = new SearchFields(); - public refineFields: string[] = this.searchFields.ORGANIZATION_REFINE_FIELDS; - public fieldIdsMap = this.searchFields.ORGANIZATION_FIELDS; - public _location:Location; - public csvParams: string; - public disableForms: boolean = false; - public loadPaging: boolean = true; - public oldTotalResults: number = 0; - pagingLimit = 0; -properties: EnvProperties; - @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; - @Input() customFilter:SearchCustomFilter= null; - - constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) { - - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - this.searchUtils.page =1; - - } - - public ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.baseUrl = data.envSpecific.searchLinkToOrganizations; - this.pagingLimit = data.envSpecific.pagingLimit; - - }); - this.searchPage.refineFields = this.refineFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - var firstLoad = true; - this.sub = this.route.queryParams.subscribe(params => { - this.loadPaging = true; - if(params['page'] && this.searchUtils.page != params['page']) { - this.loadPaging = false; - this.oldTotalResults = this.searchUtils.totalResults; - } - - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - var refine = true; - if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ - refine = false; - - } - firstLoad = false; - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - this.searchUtils.size = (params['size']=== undefined)?10:+params['size']; - if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { - this.searchUtils.size = 10; - } - - this.searchPage.customFilter = this.customFilter; - var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); - }); - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } - } - - - public getResults(keyword:string,refine:boolean, page: number, size: number){ - var parameters = ""; - if(keyword.length > 0){ - parameters = "q=" + keyword; - } - this._getResults(parameters,refine,page,this.searchUtils.size); - } - private _getResults(parameters:string,refine:boolean, page: number, size: number){ - if(page > this.pagingLimit) { - size=0; - } - if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) { - this.csvParams = parameters; - - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; - - this.subResults = this._searchOrganizationsService.searchOrganizations(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields(), this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - //console.info("search Organizations: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); - this.results = data[1]; - if(refine){ - this.filters = data[2]; - } - this.searchPage.checkSelectedFilters(this.filters); - this.searchPage.updateBaseUrlWithParameters(this.filters); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } - }, - err => { - //console.log(err); - this.handleError("Error getting organizations", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - - //this.searchPage.closeLoading(); - this.disableForms = false; - } - ); - } - } - - - - private handleError(message: string, error) { - console.error("Organizations simple Search Page: "+message, error); - } -} diff --git a/searchPages/simple/searchOrganizations.module.ts b/searchPages/simple/searchOrganizations.module.ts deleted file mode 100644 index cd5bf990..00000000 --- a/searchPages/simple/searchOrganizations.module.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import{SearchOrganizationsComponent} from './searchOrganizations.component'; - -import {SearchResultsModule } from '../searchUtils/searchResults.module'; - -import {OrganizationsServiceModule} from '../../services/organizationsService.module'; -import {SearchFormModule} from '../searchUtils/searchForm.module'; -import {SearchPageModule} from '../searchUtils/searchPage.module'; -import {FreeGuard} from'../../login/freeGuard.guard'; -import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - - OrganizationsServiceModule, - SearchFormModule, SearchResultsModule, SearchPageModule - - ], - declarations: [ - SearchOrganizationsComponent - ], - providers:[FreeGuard, IsRouteEnabled], - exports: [ - SearchOrganizationsComponent - ] -}) -export class SearchOrganizationsModule { } diff --git a/searchPages/simple/searchProjects.component.ts b/searchPages/simple/searchProjects.component.ts deleted file mode 100644 index 6cc929d6..00000000 --- a/searchPages/simple/searchProjects.component.ts +++ /dev/null @@ -1,240 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import { ActivatedRoute} from '@angular/router'; -import {Location} from '@angular/common'; -import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; -import {SearchProjectsService} from '../../services/searchProjects.service'; -import {SearchResult} from '../../utils/entities/searchResult'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {SearchFields, FieldDetails} from '../../utils/properties/searchFields'; -import {SearchPageComponent } from '../searchUtils/searchPage.component'; -import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class'; -import{EnvProperties} from '../../utils/properties/env-properties'; - -@Component({ - selector: 'search-projects', - template: ` - - - - ` - -}) -export class SearchProjectsComponent { - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; -@Input() piwikSiteId = null; -@Input() customFilter:SearchCustomFilter= null; - public results =[]; - public filters: Filter[] =[]; - public baseUrl:string; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public sub: any; - public subResults: any; - public searchFields:SearchFields = new SearchFields(); - public refineFields: string[] = this.searchFields.PROJECT_REFINE_FIELDS; - public fieldIdsMap = this.searchFields.PROJECT_FIELDS; - public _location:Location; - public csvParams: string; - public disableForms: boolean = false; - public loadPaging: boolean = true; - public oldTotalResults: number = 0; - pagingLimit = 0; -properties: EnvProperties; - - @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; - - constructor (private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService) { - - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - this.searchUtils.page =1; - - } - - public ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.baseUrl = data.envSpecific.searchLinkToProjects; - this.pagingLimit = data.envSpecific.pagingLimit; - - }); - this.searchPage.refineFields = this.refineFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - //get refine field filters from url parameters - var firstLoad = true; - this.sub = this.route.queryParams.subscribe(params => { - this.loadPaging = true; - if(params['page'] && this.searchUtils.page != params['page']) { - this.loadPaging = false; - this.oldTotalResults = this.searchUtils.totalResults; - } - - //get keyword from url parameters - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - var refine = true; - if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ - refine = false; - - } - firstLoad = false; - //get page from url parameters - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - this.searchUtils.size = (params['size']=== undefined)?10:+params['size']; - if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { - this.searchUtils.size = 10; - } - this.searchPage.customFilter = this.customFilter; - var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); - }); - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } - } - - public getResults(keyword:string,refine:boolean, page: number, size: number){ - var parameters = ""; - if(keyword.length > 0){ - parameters = "q="+keyword; - } - this._getResults(parameters,refine,page,this.searchUtils.size); - } - private _getResults(parameters:string,refine:boolean, page: number, size: number){ - if(page > this.pagingLimit) { - size=0; - } - if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) { - this.csvParams = parameters; - - this.searchUtils.status = this.errorCodes.LOADING; - //this.searchPage.openLoading(); - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; - - this.subResults = this._searchProjectsService.searchProjects(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields(), this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - //console.info("search Projects: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); - this.results = data[1]; - if(refine){ - this.filters = data[2]; - } - this.searchPage.checkSelectedFilters(this.filters); - // this.filters = this.searchPage.checkSelectedFilters(data[2]); - this.searchPage.updateBaseUrlWithParameters(this.filters); - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } - }, - err => { - //console.log(err); - this.handleError("Error getting projects", err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - - //this.searchPage.closeLoading(); - this.disableForms = false; - } - ); - } - } - - public getResultsForDataproviders(id:string, page: number, size: number){ - - this._searchProjectsService.getProjectsforDataProvider(id, page, size, this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - //console.info("search Projects for Dataproviders: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]"); - this.results = data[1]; - - //var errorCodes:ErrorCodes = new ErrorCodes(); - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - }, - err => { - //console.log(err); - this.handleError("Error getting projects for content provider with id: "+id, err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - } - ); - } - - - // public queryChanged($event) { - // this.loadPaging = true; - // - // this.urlParams = undefined; - // var parameters = $event.value; - // //this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); - // } - - private handleError(message: string, error) { - console.error("Projects simple Search Page: "+message, error); - } -} diff --git a/searchPages/simple/searchProjects.module.ts b/searchPages/simple/searchProjects.module.ts deleted file mode 100644 index c8e1b094..00000000 --- a/searchPages/simple/searchProjects.module.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import{SearchProjectsComponent} from './searchProjects.component'; - -import {SearchResultsModule } from '../searchUtils/searchResults.module'; - -import {ProjectsServiceModule} from '../../services/projectsService.module'; -import {SearchFormModule} from '../searchUtils/searchForm.module'; -//import {SearchFilterModalModule} from '../searchUtils/searchFilterModal.module'; -import {SearchPageModule} from '../searchUtils/searchPage.module'; -import {FreeGuard} from'../../login/freeGuard.guard'; -import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - - ProjectsServiceModule, - SearchFormModule, SearchResultsModule, SearchPageModule - - ], - declarations: [ - SearchProjectsComponent - ], - providers:[FreeGuard, IsRouteEnabled], - exports: [ - SearchProjectsComponent - ] -}) -export class SearchProjectsModule { } diff --git a/searchPages/simple/searchResearchResults.component.ts b/searchPages/simple/searchResearchResults.component.ts deleted file mode 100644 index 1de742f3..00000000 --- a/searchPages/simple/searchResearchResults.component.ts +++ /dev/null @@ -1,252 +0,0 @@ -import {Component, Input, ViewChild} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; -import {Location} from '@angular/common'; - -import {SearchResearchResultsService} from '../../services/searchResearchResults.service'; -import {ErrorCodes} from '../../utils/properties/errorCodes'; -import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; -import {SearchFields} from '../../utils/properties/searchFields'; -import {SearchPageComponent} from '../searchUtils/searchPage.component'; -import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class'; -import {DOI} from '../../utils/string-utils.class'; -import {EnvProperties} from '../../utils/properties/env-properties'; - -@Component({ - selector: 'search-research-results', - template: ` - - - - ` - -}) -export class SearchResearchResultsComponent { - @Input() resultType: string = "publication"; - - public advancedSearchLink: string = ""; - private errorCodes: ErrorCodes; - private errorMessages: ErrorMessagesComponent; - @Input() piwikSiteId = null; - @Input() hasPrefix: boolean = true; - public results =[]; - public filters =[]; - public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public baseUrl:string = ""; - public sub: any; - public subResults: any; - public searchFields:SearchFields = new SearchFields(); - public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS; - public fieldIdsMap=this.searchFields.RESULT_FIELDS; - @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; - public _location:Location; - - public CSV: any = { - "columnNames": [ - "Title", "Authors", "Publication Year", "DOI", - "Funder", "Project Name (GA Number)", "Access" - ], - "export":[] - }; - public CSVDownloaded = false; - public csvParams: string; - public disableForms: boolean = false; - public loadPaging: boolean = true; - public oldTotalResults: number = 0; - @Input() openaireLink: string; - @Input() customFilter:SearchCustomFilter= null; - @Input() advancedSearchParameters ; - pagingLimit = 0; - public sort: boolean = true; - properties: EnvProperties; - constructor (private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService ) { - this.errorCodes = new ErrorCodes(); - this.errorMessages = new ErrorMessagesComponent(); - this.searchUtils.status = this.errorCodes.LOADING; - this.searchUtils.page =1; - - } - - public ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - this.pagingLimit = data.envSpecific.pagingLimit; - - if(this.resultType == "publication") { - this.advancedSearchLink = this.properties.searchLinkToAdvancedPublications; - this.baseUrl = this.properties.searchLinkToPublications; - } else if(this.resultType == "dataset") { - this.advancedSearchLink = this.properties.searchLinkToAdvancedDatasets; - this.baseUrl = this.properties.searchLinkToDatasets; - } else if(this.resultType == "software") { - this.advancedSearchLink = this.properties.searchLinkToAdvancedSoftware; - this.baseUrl = this.properties.searchLinkToSoftware; - } else if(this.resultType == "other") { - this.advancedSearchLink = this.properties.searchLinkToAdvancedOrps; - this.baseUrl = this.properties.searchLinkToOrps; - } - }); - this.searchPage.refineFields = this.refineFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - this.searchPage.type = this.getEntityName(this.resultType, true, true); - var firstLoad =true; - this.sub = this.route.queryParams.subscribe(params => { - this.loadPaging = true; - if(params['page'] && this.searchUtils.page != params['page']) { - this.loadPaging = false; - this.oldTotalResults = this.searchUtils.totalResults; - } - - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - var refine = true; - if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ - refine = false; - - } - firstLoad = false; - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - this.searchUtils.size = (params['size']=== undefined)?10:+params['size']; - if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { - this.searchUtils.size = 10; - } - this.searchUtils.sortBy = (params['sortBy'])?params['sortBy']:''; - if(this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") { - this.searchUtils.sortBy = ""; - } - - this.searchPage.customFilter = this.customFilter; - var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy); - }); - } - - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } - } - - public getResults(keyword:string,refine:boolean, page: number, size: number, sortBy: string){ - var parameters = ""; - if(keyword.length > 0){ - var DOIs:string[] = DOI.getDOIsFromString(keyword); - var doisParams = ""; - - for(var i =0 ;i < DOIs.length; i++){ - doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; - } - if(doisParams.length > 0){ - parameters += "&"+doisParams; - }else{ - parameters = "q=" + keyword; - } - } - this._getResults(parameters,refine,page,size,sortBy); - } - - private _getResults(parameters:string,refine:boolean, page: number, size: number, sortBy: string){ - if(page > this.pagingLimit) { - size=0; - } - if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) { - this.csvParams = parameters; - - this.searchUtils.status = this.errorCodes.LOADING; - this.disableForms = true; - this.results = []; - this.searchUtils.totalResults = 0; - - this.subResults = this._searchResearchResultsService.search(this.resultType, parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, sortBy, this.searchPage.getFields(), this.properties).subscribe( - data => { - this.searchUtils.totalResults = data[0]; - this.results = data[1]; - if(refine){ - this.filters = data[2]; - } - this.searchPage.checkSelectedFilters(this.filters); - this.searchPage.updateBaseUrlWithParameters(this.filters); - - this.searchUtils.status = this.errorCodes.DONE; - if(this.searchUtils.totalResults == 0 ){ - this.searchUtils.status = this.errorCodes.NONE; - } - //this.searchPage.closeLoading(); - this.disableForms = false; - - if(this.searchUtils.status == this.errorCodes.DONE) { - // Page out of limit!!! - let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); - if(!(Number.isInteger(totalPages))) { - totalPages = (parseInt(totalPages, 10) + 1); - } - if(totalPages < page) { - this.searchUtils.totalResults = 0; - this.searchUtils.status = this.errorCodes.OUT_OF_BOUND; - } - } - }, - err => { - //console.log(err); - this.handleError("Error getting "+this.getEntityName(this.resultType, true, true), err); - this.searchUtils.status = this.errorMessages.getErrorCode(err.status); - - //TODO check erros (service not available, bad request) - // if( ){ - // this.searchUtils.status = ErrorCodes.ERROR; - // } - //var errorCodes:ErrorCodes = new ErrorCodes(); - //this.searchUtils.status = errorCodes.ERROR; - /*if(err.status == '404') { - this.searchUtils.status = this.errorCodes.NOT_FOUND; - } else if(err.status == '500') { - this.searchUtils.status = this.errorCodes.ERROR; - } else { - this.searchUtils.status = this.errorCodes.NOT_AVAILABLE; - }*/ - - //this.searchPage.closeLoading(); - this.disableForms = false; - - } - ); - } - } - - // public queryChanged($event) { - // // this.loadPaging = true; - // } - - private handleError(message: string, error) { - console.error(this.getEntityName(this.resultType, true, true)+" simple Search Page (SearchResearchResultsComponent): "+message, error); - } - - public getEntityName (entityType:string, plural:boolean, full:boolean): string { - if(entityType == "publication") { - return "publication" + (plural ? "s" : ""); - } else if(entityType == "dataset") { - return (full ? "research data" : ("dataset" + (plural ? "s" : ""))); - } else if(entityType == "software") { - return "software"; - } else if(entityType == "other") { - return (full ? ("other research product" + (plural ? "s" : "")) : "other"); - } - } -} diff --git a/searchPages/simple/searchResearchResults.module.ts b/searchPages/simple/searchResearchResults.module.ts deleted file mode 100644 index 2a96f3f7..00000000 --- a/searchPages/simple/searchResearchResults.module.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; - -import {SearchResearchResultsComponent} from './searchResearchResults.component'; -import {SearchResultsModule } from '../searchUtils/searchResults.module'; -import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.module'; -import {SearchFormModule} from '../searchUtils/searchForm.module'; -import {SearchPageModule} from '../searchUtils/searchPage.module'; -import {FreeGuard} from'../../login/freeGuard.guard'; -import {IsRouteEnabled} from '../../error/isRouteEnabled.guard'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, - SearchResearchResultsServiceModule, - SearchFormModule, SearchResultsModule, SearchPageModule - - ], - declarations: [ - SearchResearchResultsComponent - ], - providers:[FreeGuard, IsRouteEnabled], - exports: [ - SearchResearchResultsComponent - ] -}) -export class SearchResearchResultsModule { } diff --git a/services/help-content.service.ts b/services/help-content.service.ts index 177ab218..c3697f91 100644 --- a/services/help-content.service.ts +++ b/services/help-content.service.ts @@ -2,7 +2,7 @@ * Created by stefania on 7/13/17. */ import { Injectable } from '@angular/core'; -import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http"; +import {HttpClient, HttpErrorResponse} from "@angular/common/http"; import { Observable } from 'rxjs'; import { Page } from "../utils/entities/adminTool/page"; import { PageHelpContent } from "../utils/entities/adminTool/page-help-content"; diff --git a/services/layout.service.ts b/services/layout.service.ts index 6083532a..04961d40 100644 --- a/services/layout.service.ts +++ b/services/layout.service.ts @@ -4,7 +4,6 @@ import {Observable, throwError} from 'rxjs'; import {CustomOptions} from './servicesUtils/customOptions.class'; import {CustomizationOptions} from '../connect/community/CustomizationOptions'; import {EnvProperties} from "../utils/properties/env-properties"; -import {properties} from "../../../environments/environment"; @Injectable() export class LayoutService { diff --git a/services/metrics.service.ts b/services/metrics.service.ts index 32353e4b..de27cfad 100644 --- a/services/metrics.service.ts +++ b/services/metrics.service.ts @@ -1,11 +1,10 @@ import {Injectable} from '@angular/core'; -import {Http, Response} from '@angular/http'; import {HttpClient} from "@angular/common/http"; import {Observable} from 'rxjs'; import {Metrics} from '../utils/entities/metrics'; import{EnvProperties} from '../utils/properties/env-properties'; -import {catchError, map} from "rxjs/operators"; +import {map} from "rxjs/operators"; @Injectable() export class MetricsService { diff --git a/services/organization.service.ts b/services/organization.service.ts index 991551b8..69f74898 100644 --- a/services/organization.service.ts +++ b/services/organization.service.ts @@ -1,7 +1,6 @@ import {Injectable} from '@angular/core'; -import {Http, Response} from '@angular/http'; import {HttpClient, HttpErrorResponse} from "@angular/common/http"; -import {Observable, throwError} from 'rxjs'; +import {throwError} from 'rxjs'; import {OrganizationInfo} from '../utils/entities/organizationInfo'; diff --git a/services/refineFieldResults.service.ts b/services/refineFieldResults.service.ts index 59fb2fa6..eca09c9d 100644 --- a/services/refineFieldResults.service.ts +++ b/services/refineFieldResults.service.ts @@ -1,7 +1,6 @@ import {Injectable} from '@angular/core'; -import {Http, Response} from '@angular/http'; import {HttpClient, HttpErrorResponse} from "@angular/common/http"; -import {Observable, throwError} from 'rxjs'; +import {throwError} from 'rxjs'; import {AutoCompleteValue} from '../searchPages/searchUtils/searchHelperClasses.class'; diff --git a/services/reports.service.ts b/services/reports.service.ts index fa9b1f04..56abf310 100644 --- a/services/reports.service.ts +++ b/services/reports.service.ts @@ -1,7 +1,6 @@ import {Injectable} from '@angular/core'; -import {Http, Response, Headers} from '@angular/http'; import {HttpClient, HttpErrorResponse} from "@angular/common/http"; -import {Observable, throwError} from 'rxjs'; +import {throwError} from 'rxjs'; diff --git a/services/searchDataproviders.service.ts b/services/searchDataproviders.service.ts index 4c870768..17cc08c6 100644 --- a/services/searchDataproviders.service.ts +++ b/services/searchDataproviders.service.ts @@ -1,7 +1,5 @@ import {Injectable} from '@angular/core'; -import {Http, Response} from '@angular/http'; import {HttpClient} from "@angular/common/http"; -import {Observable} from 'rxjs'; import {SearchResult} from '../utils/entities/searchResult'; import {RefineResultsUtils} from './servicesUtils/refineResults.class'; diff --git a/services/searchOrganizations.service.ts b/services/searchOrganizations.service.ts index 8e8141c5..af8aee90 100644 --- a/services/searchOrganizations.service.ts +++ b/services/searchOrganizations.service.ts @@ -1,7 +1,5 @@ import {Injectable} from '@angular/core'; -import {Http, Response} from '@angular/http'; import {HttpClient} from "@angular/common/http"; -import {Observable} from 'rxjs'; diff --git a/services/searchProjects.service.ts b/services/searchProjects.service.ts index a63b002c..181269c0 100644 --- a/services/searchProjects.service.ts +++ b/services/searchProjects.service.ts @@ -1,7 +1,5 @@ import {Injectable} from '@angular/core'; -import {Http, Response} from '@angular/http'; import {HttpClient} from "@angular/common/http"; -import {Observable} from 'rxjs'; diff --git a/services/searchResearchResults.service.ts b/services/searchResearchResults.service.ts index f6aca66c..2044ca8b 100644 --- a/services/searchResearchResults.service.ts +++ b/services/searchResearchResults.service.ts @@ -1,4 +1,4 @@ -import {Injectable} from '@angular/core'; +import {Injectable, OnDestroy} from '@angular/core'; import {HttpClient} from "@angular/common/http"; import {SearchResult} from '../utils/entities/searchResult'; import {RefineResultsUtils} from './servicesUtils/refineResults.class'; @@ -13,7 +13,9 @@ export class SearchResearchResultsService { private sizeOfDescription: number = 270; public parsingFunctions: ParsingFunctions = new ParsingFunctions(); - constructor(private http: HttpClient ) {} + constructor(private http: HttpClient ) { + } + search (resultType:string, params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[] , properties:EnvProperties):any { let link = properties.searchAPIURLLAst+this.getEntityName(resultType,true); diff --git a/services/user-management.service.ts b/services/user-management.service.ts index fd932ed0..601066db 100644 --- a/services/user-management.service.ts +++ b/services/user-management.service.ts @@ -9,24 +9,34 @@ import {properties} from "../../../environments/environment"; @Injectable({ providedIn: 'root' }) -export class UserManagementService { +export class UserManagementService{ private getUserInfoSubject: BehaviorSubject = new BehaviorSubject(null); private readonly promise: Promise; - + sub; + routeSub; constructor(private http: HttpClient, private router: Router) { this.promise = new Promise((resolve => { this.updateUserInfo(resolve); })); - this.router.events.subscribe(event => { + this.routeSub = this.router.events.subscribe(event => { if (event instanceof NavigationEnd) { const token = COOKIE.getCookie('AccessToken'); if (!token && this.getUserInfoSubject.getValue() !== null) { this.getUserInfoSubject.next(null); } } - }) + }); + } + + clearSubscriptions() { + if(this.routeSub){ + this.routeSub.unsubscribe(); + } + if(this.sub){ + this.sub.unsubscribe(); + } } public getUserInfo(subject: boolean = true): Observable { @@ -45,7 +55,7 @@ export class UserManagementService { resolve(); } } else { - this.http.get(properties.userInfoUrl + token).pipe(map(userInfo => { + this.sub = this.http.get(properties.userInfoUrl + token).pipe(map(userInfo => { return this.parseUserInfo(userInfo); })).pipe(timeout(3000), catchError(() => { return of(null); @@ -60,12 +70,15 @@ export class UserManagementService { private async getUserInfoAsync(): Promise { await this.promise; + if(this.sub){ + this.sub.unsubscribe(); + } return this.getUserInfoSubject.getValue(); } private parseUserInfo(info: any) { const user: User = new User(); - user.id = (info.sub && info.sub.indexOf('@')) ? info.sub.substring(0, info.sub.indexOf('@')) : info.sub; + user.id = (info.subscriptions && info.subscriptions.indexOf('@')) ? info.subscriptions.substring(0, info.subscriptions.indexOf('@')) : info.subscriptions; user.firstname = (info.given_name) ? info.given_name : ""; user.lastname = (info.family_name) ? info.family_name : ""; user.email = info.email.toLowerCase(); // TODO remove, is a quick fix diff --git a/sharedComponents/SEO/SEOService.module.ts b/sharedComponents/SEO/SEOService.module.ts index 3684ac74..b4570800 100644 --- a/sharedComponents/SEO/SEOService.module.ts +++ b/sharedComponents/SEO/SEOService.module.ts @@ -1,10 +1,8 @@ import { NgModule} from '@angular/core'; -// import { CommonModule } from '@angular/common'; -// import { FormsModule } from '@angular/forms'; + import {SEOService} from './SEO.service'; @NgModule({ imports: [ - // CommonModule, FormsModule ], providers:[SEOService] }) diff --git a/sharedComponents/feedback/feedback.module.ts b/sharedComponents/feedback/feedback.module.ts index b9b35306..11db9b4c 100644 --- a/sharedComponents/feedback/feedback.module.ts +++ b/sharedComponents/feedback/feedback.module.ts @@ -1,9 +1,6 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; - -import { RouterModule } from "@angular/router"; - import {FeedbackComponent} from './feedback.component'; diff --git a/sharedComponents/metaService.module.ts b/sharedComponents/metaService.module.ts deleted file mode 100644 index da566459..00000000 --- a/sharedComponents/metaService.module.ts +++ /dev/null @@ -1,15 +0,0 @@ -// import { NgModule} from '@angular/core'; -// import { CommonModule } from '@angular/common'; -// import { FormsModule } from '@angular/forms'; -// import { RouterModule } from '@angular/router'; -// import {Meta} from './metaService'; -// -// -// @NgModule({ -// imports: [ -// CommonModule -// -// ], -// providers:[ Meta] -// }) -// export class MetaModule {} diff --git a/sharedComponents/metaService.ts b/sharedComponents/metaService.ts deleted file mode 100644 index 1d64a83c..00000000 --- a/sharedComponents/metaService.ts +++ /dev/null @@ -1,220 +0,0 @@ -// /** -// * @license -// * Copyright Google Inc. All Rights Reserved. -// * -// * Use of this source code is governed by an MIT-style license that can be -// * found in the LICENSE file at https://angular.io/license -// */ -// -// import {Injectable, Inject} from '@angular/core'; -// // es6-modules are used here -// import { ɵgetDOM as getDOM} from '@angular/platform-browser'; -// import {DOCUMENT} from '@angular/platform-browser'; -// /** -// * Represent meta element. -// * -// * ### Example -// * -// * ```ts -// * { name: 'application-name', content: 'Name of my application' }, -// * { name: 'description', content: 'A description of the page', id: 'desc' } -// * // ... -// * // Twitter -// * { name: 'twitter:title', content: 'Content Title' } -// * // ... -// * // Google+ -// * { itemprop: 'name', content: 'Content Title' }, -// * { itemprop: 'description', content: 'Content Title' } -// * // ... -// * // Facebook / Open Graph -// * { property: 'fb:app_id', content: '123456789' }, -// * { property: 'og:title', content: 'Content Title' } -// * ``` -// * -// * @experimental -// */ -// export interface MetaDefinition { -// charset?: string; -// content?: string; -// httpEquiv?: string; -// id?: string; -// itemprop?: string; -// name?: string; -// property?: string; -// scheme?: string; -// url?: string; -// [prop: string]: string; -// } -// -// /** -// * A service that can be used to get and add meta tags. -// * -// * @experimental -// */ -// @Injectable() -// export class Meta { -// private _dom: any = getDOM(); -// constructor( @Inject(DOCUMENT) private _document: any) { } -// /** -// * Sets the title of the page -// */ -// setTitle(title: string) { -// this._document.title = title -// } -// /** -// * Adds a new meta tag to the dom. -// * -// * ### Example -// * -// * ```ts -// * const name: MetaDefinition = {name: 'application-name', content: 'Name of my application'}; -// * const desc: MetaDefinition = {name: 'description', content: 'A description of the page'}; -// * const tags: HTMLMetaElement[] = this.meta.addTags([name, desc]); -// * ``` -// * -// * @param tags -// * @returns {HTMLMetaElement[]} -// */ -// addTags(...tags: Array): HTMLMetaElement[] { -// const presentTags = this._flattenArray(tags); -// if (presentTags.length === 0) return []; -// return presentTags.map((tag: MetaDefinition) => this._addInternal(tag)); -// } -// -// /** -// * Gets the meta tag by the given selector. Returns element or null -// * if there's no such meta element. -// * -// * ### Example -// * -// * ```ts -// * const meta: HTMLMetaElement = this.meta.getTag('name=description'); -// * const twitterMeta: HTMLMetaElement = this.meta.getTag('name="twitter:title"'); -// * const fbMeta: HTMLMetaElement = this.meta.getTag('property="fb:app_id"'); -// * ``` -// * -// * @param selector -// * @returns {HTMLMetaElement} -// */ -// // getTag(selector: string): HTMLMetaElement { -// // if (!selector) return null; -// // return this._dom.query(`meta[${selector}]`); -// // } -// getTag(attrSelector: string): HTMLMetaElement|null { -// if (!attrSelector) return null; -// return this._dom.querySelector(this._document, `meta[${attrSelector}]`); -// } -// -// /** -// * Updates the meta tag with the given selector. -// * -// * * ### Example -// * -// * ```ts -// * const meta: HTMLMetaElement = this.meta.updateTag('name=description', {name: 'description', -// * content: 'New description'}); -// * console.log(meta.content); // 'New description' -// * ``` -// * -// * @param selector -// * @param tag updated tag definition -// * @returns {HTMLMetaElement} -// */ -// updateTag(selector: string, tag: MetaDefinition): HTMLMetaElement { -// const meta: HTMLMetaElement = this.getTag(selector); -// if (!meta) { -// // create element if it doesn't exist -// return this._addInternal(tag); -// } -// return this._prepareMetaElement(tag, meta); -// } -// -// updateMeta(name, content) { -// const head = this._document.head; -// let childNodesAsList = this._dom.childNodesAsList(head); -// let metaEl = childNodesAsList.find(el => el['attribs'] ? el['attribs'].name == name : false); -// if (metaEl) metaEl['attribs'].content = content; -// } -// updateProperty(property, content) { -// const head = this._document.head; -// let childNodesAsList = this._dom.childNodesAsList(head); -// let metaEl = childNodesAsList.find(el => el['attribs'] ? el['attribs'].property == property : false); -// if (metaEl) metaEl['attribs'].content = content; -// } -// -// /** -// * Removes meta tag with the given selector from the dom. -// * -// * ### Example -// * -// * ```ts -// * this.meta.removeTagBySelector('name=description'); -// * ``` -// * -// * @param selector -// */ -// removeTagBySelector(selector: string): void { -// const meta: HTMLMetaElement = this.getTag(selector); -// this.removeTagElement(meta); -// } -// -// /** -// * Removes given meta element from the dom. -// * -// * ### Example -// * ```ts -// * const elem: HTMLMetaElement = this.meta.getTag('name=description'); -// * this.meta.removeTagElement(elem); -// * ``` -// * -// * @param meta meta element -// */ -// removeTagElement(meta: HTMLMetaElement): void { -// if (meta) { -// this._removeMetaElement(meta); -// } -// } -// -// private _addInternal(tag: MetaDefinition): HTMLMetaElement { -// const meta: HTMLMetaElement = this._createMetaElement(); -// this._prepareMetaElement(tag, meta); -// this._appendMetaElement(meta); -// return meta; -// } -// -// private _createMetaElement(): HTMLMetaElement { -// return this._dom.createElement('meta') as HTMLMetaElement; -// } -// -// private _prepareMetaElement(tag: MetaDefinition, el: HTMLMetaElement): HTMLMetaElement { -// Object.keys(tag).forEach((prop: string) => this._dom.setAttribute(el, prop, tag[prop])); -// return el; -// } -// -// // private _appendMetaElement(meta: HTMLMetaElement): void { -// // const head = this._dom.getElementsByTagName(this._dom.defaultDoc(), 'head')[0]; -// // this._dom.appendChild(head, meta); -// // } -// private _appendMetaElement(meta: HTMLMetaElement): void { -// const head = this._document.head; -// this._dom.appendChild(head, meta); -// } -// private _removeMetaElement(meta: HTMLMetaElement): void { -// const head = this._dom.parentElement(meta); -// this._dom.removeChild(head, meta); -// } -// -// private _flattenArray(input: any[], out: any[] = []): any[] { -// if (input) { -// for (let i = 0; i < input.length; i++) { -// const item: any = input[i]; -// if (Array.isArray(item)) { -// this._flattenArray(item, out); -// } else if (item) { -// out.push(item); -// } -// } -// } -// return out; -// } -// } diff --git a/sharedComponents/navigationBar.component.ts b/sharedComponents/navigationBar.component.ts index ba7f19c0..89adc6b5 100644 --- a/sharedComponents/navigationBar.component.ts +++ b/sharedComponents/navigationBar.component.ts @@ -68,7 +68,7 @@ export class NavigationBarComponent implements OnInit, OnDestroy{ ngOnInit() { this.activeRouteEnabled = false; - //this.sub = this.route.queryParams.subscribe(params => { + //this.subscriptions = this.route.queryParams.subscribe(params => { //console.log("params: ",params); this.initialize(); //}); diff --git a/sharedComponents/searchBar/searchBar.component.ts b/sharedComponents/searchBar/searchBar.component.ts index 70af00eb..210b73de 100644 --- a/sharedComponents/searchBar/searchBar.component.ts +++ b/sharedComponents/searchBar/searchBar.component.ts @@ -1,7 +1,8 @@ import {Component, Input} from '@angular/core'; -import {ActivatedRoute, NavigationEnd, NavigationStart, Router} from '@angular/router'; +import {ActivatedRoute, NavigationEnd, Router} from '@angular/router'; import {EnvProperties} from "../../utils/properties/env-properties"; import {SearchCustomFilter} from "../../searchPages/searchUtils/searchUtils.class"; +import {Subscriber} from "rxjs"; @Component({ selector: 'search-bar', @@ -22,16 +23,23 @@ export class SearchBarComponent { @Input() onlyresults:boolean=false; parameters = {}; advancedSearchLink = null; + subscriptions = []; constructor(private router: Router, private route: ActivatedRoute ) { - this.router.events.subscribe((e) => { + this.subscriptions.push(this.router.events.subscribe((e) => { if(e instanceof NavigationEnd){ // console.log(e) this.initialize(); } + })); + } + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } }); } - ngOnInit() { // this.activeRouteEnabled = false; @@ -39,7 +47,7 @@ export class SearchBarComponent { this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, ""); } this.entityType = "all"; - this.route.queryParams.subscribe(params => { + this.subscriptions.push(this.route.queryParams.subscribe(params => { this.parameters = Object.assign({}, params); if(params["fv0"] && params["f0"] && params["f0"] == "q"){ this.keyword =params["fv0"]; @@ -60,7 +68,7 @@ export class SearchBarComponent { } } } - }); + })); this.initialize() } initialize(){ diff --git a/sharedComponents/sidebar/sideBar.component.ts b/sharedComponents/sidebar/sideBar.component.ts index 2d7bc28e..e22daf85 100644 --- a/sharedComponents/sidebar/sideBar.component.ts +++ b/sharedComponents/sidebar/sideBar.component.ts @@ -1,7 +1,7 @@ import {Component, Input, OnInit} from '@angular/core'; -import {RootMenuItem, SideMenuItem} from '../menu'; +import {SideMenuItem} from '../menu'; import {ActivatedRoute, Router} from '@angular/router'; -import {Observable} from 'rxjs/Observable'; +import {Subscriber} from "rxjs"; @Component({ selector: 'sidebar', @@ -11,13 +11,17 @@ export class SideBarComponent implements OnInit { @Input() communityId: string = ''; @Input() menuItems: SideMenuItem[] = []; currentParams: any = {}; - + sub; constructor(private router: Router, private route: ActivatedRoute) { } - + ngOnDestroy() { + if (this.sub instanceof Subscriber) { + this.sub.unsubscribe(); + } + } ngOnInit(): void { - this.route.queryParams.subscribe(params => { + this.sub = this.route.queryParams.subscribe(params => { this.currentParams = params; }); } diff --git a/test/test-routing.module.ts b/test/test-routing.module.ts deleted file mode 100644 index 07f034d4..00000000 --- a/test/test-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule } from '@angular/router'; - -import { TestComponent } from './test.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', component: TestComponent}, - - ]) - ] -}) -export class TestRoutingModule { } diff --git a/test/test.component.ts b/test/test.component.ts deleted file mode 100644 index ef3ca11d..00000000 --- a/test/test.component.ts +++ /dev/null @@ -1,60 +0,0 @@ -import {Component, ElementRef} from '@angular/core'; -import { Subject , Observable} from 'rxjs'; - -import {SearchFields, FieldDetails} from '../utils/properties/searchFields'; - -@Component({ - selector: 'test', - template: ` - - - -` - -}) -export class TestComponent { - - constructor() { - - } - - - ngOnInit() { - - } - - - test(){ - var sf:SearchFields = new SearchFields(); - console.info("~~~RESULT"); - - this.checktables(sf.RESULT_REFINE_FIELDS,sf.RESULT_FIELDS,sf.RESULT_FIELDS); - this.checktables(sf.RESULT_ADVANCED_FIELDS,sf.RESULT_FIELDS,sf.RESULT_FIELDS); - console.info("~~~PR"); - - this.checktables(sf.PROJECT_REFINE_FIELDS,sf.PROJECT_FIELDS,sf.PROJECT_FIELDS); - this.checktables(sf.PROJECT_ADVANCED_FIELDS,sf.PROJECT_FIELDS,sf.PROJECT_FIELDS); - console.info("~~~DATAPR"); - - this.checktables(sf.DATASOURCE_REFINE_FIELDS,sf.DATASOURCE_FIELDS,sf.DATASOURCE_FIELDS); - this.checktables(sf.DATASOURCE_ADVANCED_FIELDS,sf.DATASOURCE_FIELDS,sf.DATASOURCE_FIELDS); - - console.info("~~~ORG"); - this.checktables(sf.ORGANIZATION_REFINE_FIELDS,sf.ORGANIZATION_FIELDS,sf.ORGANIZATION_FIELDS); - this.checktables(sf.ORGANIZATION_ADVANCED_FIELDS,sf.ORGANIZATION_FIELDS,sf.ORGANIZATION_FIELDS); - console.info("~~~PERSON"); - - } - checktables(fields,fieldsDetails,fieldsParam){ - for(var i =0; i < fields.length; i++){ - if(!fieldsDetails[fields[i]]){ - console.info("!!!!"+fields[i]+ "field has to details"); - } - } - - } - - - - -} diff --git a/test/test.module.ts b/test/test.module.ts deleted file mode 100644 index 8277654b..00000000 --- a/test/test.module.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { NgModule } from '@angular/core'; - -import { SharedModule } from '../shared/shared.module'; -import { TestComponent } from './test.component'; -import { TestRoutingModule } from './test-routing.module'; - - - -@NgModule({ - imports: [ - SharedModule, - TestRoutingModule, - - ], - declarations: [ - TestComponent - ] -}) -export class TestModule { } diff --git a/utils/configuration/configuration.service.ts b/utils/configuration/configuration.service.ts index d9e21b8f..60c98984 100644 --- a/utils/configuration/configuration.service.ts +++ b/utils/configuration/configuration.service.ts @@ -1,18 +1,13 @@ -import {Injectable} from '@angular/core'; -import {Http, Response, Headers} from '@angular/http'; +import {Injectable, OnDestroy} from '@angular/core'; import {HttpClient} from "@angular/common/http"; import {BehaviorSubject, from, Observable, Subscription} from 'rxjs'; - - -// import 'rxjs/add/operator/do'; -// import 'rxjs/add/operator/share'; -import {map, mapTo} from 'rxjs/operators'; +import {map} from 'rxjs/operators'; import {EnvProperties} from "../properties/env-properties"; import {Portal} from "../entities/adminTool/portal"; import {Page} from "../entities/adminTool/page"; @Injectable({ providedIn: 'root' }) -export class ConfigurationService { +export class ConfigurationService{ private communityInformation: BehaviorSubject = new BehaviorSubject(null); private sub: Subscription = null; private source: Observable = null; @@ -21,6 +16,10 @@ export class ConfigurationService { constructor(private http: HttpClient ) {} ngOnDestroy() { + this.clearSubscriptions(); + } + + clearSubscriptions() { if(this.sub) { this.sub.unsubscribe(); } @@ -100,6 +99,9 @@ export class ConfigurationService { } await this.promise; + if(this.sub){ + this.sub.unsubscribe(); + } return this.filtering(page_route); } diff --git a/utils/configuration/configurationService.module.ts b/utils/configuration/configurationService.module.ts index 050255e5..2d30982a 100644 --- a/utils/configuration/configurationService.module.ts +++ b/utils/configuration/configurationService.module.ts @@ -1,8 +1,6 @@ import { NgModule} from '@angular/core'; import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; import { SharedModule } from '../../shared/shared.module'; -import { RouterModule } from '@angular/router'; import { ConfigurationService } from './configuration.service'; diff --git a/utils/email/email.service.ts b/utils/email/email.service.ts index ea4ab62e..bac4c7c4 100644 --- a/utils/email/email.service.ts +++ b/utils/email/email.service.ts @@ -1,5 +1,4 @@ import {Injectable} from '@angular/core'; -import {Http, Response, Headers, RequestOptions} from '@angular/http'; import {HttpClient} from "@angular/common/http"; import {Email} from './email'; import {CustomOptions} from '../../services/servicesUtils/customOptions.class'; diff --git a/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts b/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts index 4a2a3ba9..97503726 100644 --- a/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts +++ b/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts @@ -1,8 +1,7 @@ import {switchMap, distinctUntilChanged, debounceTime} from 'rxjs/operators'; -import {Component, ElementRef, Input, Output, EventEmitter, OnChanges, SimpleChange} from '@angular/core'; +import {Component, ElementRef, Input, Output, EventEmitter, SimpleChange} from '@angular/core'; import {Observable, Subject} from 'rxjs'; -import {Value} from '../../searchPages/searchUtils/searchHelperClasses.class'; import {EntitiesSearchService} from './entitySearch.service'; import{EnvProperties} from '../properties/env-properties'; import {StringUtils} from "../string-utils.class"; @@ -142,7 +141,7 @@ export class EntitiesAutocompleteComponent { } ngOnDestroy(){ - if(this.sub && this.sub != undefined){ + if(this.sub){ this.sub.unsubscribe(); } } diff --git a/utils/entitiesAutoComplete/entitySearch.service.ts b/utils/entitiesAutoComplete/entitySearch.service.ts index 66b923b5..f52c8609 100644 --- a/utils/entitiesAutoComplete/entitySearch.service.ts +++ b/utils/entitiesAutoComplete/entitySearch.service.ts @@ -1,14 +1,11 @@ import {Injectable} from '@angular/core'; -import {Http, Response} from '@angular/http'; import {HttpClient, HttpErrorResponse} from "@angular/common/http"; -import {Observable, throwError} from 'rxjs'; -import {AutoCompleteValue} from '../../searchPages/searchUtils/searchHelperClasses.class'; +import {throwError} from 'rxjs'; import{EnvProperties} from '../properties/env-properties'; -import {StringUtils} from '../string-utils.class'; import {catchError, map} from "rxjs/operators"; @Injectable() export class EntitiesSearchService { diff --git a/utils/fetchEntitiesClasses/fetchDataproviders.class.ts b/utils/fetchEntitiesClasses/fetchDataproviders.class.ts index ec28c638..9b400af1 100644 --- a/utils/fetchEntitiesClasses/fetchDataproviders.class.ts +++ b/utils/fetchEntitiesClasses/fetchDataproviders.class.ts @@ -4,6 +4,7 @@ import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchCustomFilter, SearchUtilsClass} from '../../searchPages/searchUtils/searchUtils.class'; import {EnvProperties} from '../../utils/properties/env-properties'; import {StringUtils} from '../../utils/string-utils.class'; +import {Subscriber} from "rxjs"; export class FetchDataproviders { private errorCodes: ErrorCodes; @@ -11,8 +12,7 @@ export class FetchDataproviders { public results = []; public searchUtils: SearchUtilsClass = new SearchUtilsClass(); - public sub: any; - public subResults: any; + subscriptions = []; public CSV: any = { "columnNames": ["Title", "Type", "Coutries", "Compatibility"], "export": [] @@ -27,15 +27,15 @@ export class FetchDataproviders { this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; } - - - public ngOnDestroy() { - if (this.sub) { - this.sub.unsubscribe(); - } - if (this.subResults) { - this.subResults.unsubscribe(); - } + + + public clearSubscriptions() { + + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } public getResultsByKeyword(keyword: string, page: number, size: number, properties: EnvProperties, customFilter: SearchCustomFilter = null) { @@ -51,7 +51,7 @@ export class FetchDataproviders { if (customFilter) { refineParams = (refineParams ? (refineParams + '&') : '') + "&fq=" + StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId))); } - this.subResults = this._searchDataprovidersService.searchDataproviders(parameters, refineParams, page, size, [], properties).subscribe( + this.subscriptions.push(this._searchDataprovidersService.searchDataproviders(parameters, refineParams, page, size, [], properties).subscribe( data => { this.searchUtils.totalResults = data[0]; //console.info("search Content Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); @@ -82,7 +82,7 @@ export class FetchDataproviders { this.handleError("Error getting content providers for keyword: " + keyword, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } public getResultsForHome(size: number, properties: EnvProperties) { @@ -90,8 +90,8 @@ export class FetchDataproviders { var parameters = "&sortBy=resultdateofacceptance,descending";//"orderby=date"; this.searchUtils.status = this.errorCodes.LOADING; - - this.subResults = this._searchDataprovidersService.searchDataproviders(parameters, null, page, size, [], properties).subscribe( + + this.subscriptions.push(this._searchDataprovidersService.searchDataproviders(parameters, null, page, size, [], properties).subscribe( data => { this.searchUtils.totalResults = data[0]; //console.info("search Content Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); @@ -115,7 +115,7 @@ export class FetchDataproviders { this.handleError("Error getting content providers with parameters: " + parameters + " for Home", err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } public getNumForEntity(entity: string, id: string, properties: EnvProperties) { @@ -123,8 +123,8 @@ export class FetchDataproviders { this.searchUtils.status = this.errorCodes.LOADING; if (id != "" && entity != "") { - - this._searchDataprovidersService.numOfEntityDataproviders(id, entity, properties).subscribe( + + this.subscriptions.push(this._searchDataprovidersService.numOfEntityDataproviders(id, entity, properties).subscribe( data => { this.searchUtils.totalResults = data; @@ -152,15 +152,15 @@ export class FetchDataproviders { this.handleError("Error getting content providers for " + entity + " with id: " + id, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } } public getNumForSearch(keyword: string, properties: EnvProperties, refineParams: string = null) { //var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = this.errorCodes.LOADING; - - this._searchDataprovidersService.numOfSearchDataproviders(keyword, properties, refineParams).subscribe( + + this.subscriptions.push(this._searchDataprovidersService.numOfSearchDataproviders(keyword, properties, refineParams).subscribe( data => { this.searchUtils.totalResults = data; this.searchUtils.status = this.errorCodes.DONE; @@ -187,7 +187,7 @@ export class FetchDataproviders { this.handleError("Error getting number of content providers for keyword: " + keyword, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } public getResultsForDeposit(id: string, type: string, page: number, size: number, properties: EnvProperties) { @@ -198,8 +198,8 @@ export class FetchDataproviders { this.loadPaging = false; if (id != "") { - - this._searchDataprovidersService.searchDataprovidersForDeposit(id, type, page, size, properties).subscribe( + + this.subscriptions.push(this._searchDataprovidersService.searchDataprovidersForDeposit(id, type, page, size, properties).subscribe( data => { this.searchUtils.totalResults = data[0]; //console.info("search Dataproviders forDeposit: [id:"+id+", type:"+type+" ] [total results:"+this.searchUtils.totalResults+"]"); @@ -246,7 +246,7 @@ export class FetchDataproviders { this.loadPaging = true; this.oldTotalResults = 0; } - ); + )); } } @@ -257,8 +257,8 @@ export class FetchDataproviders { this.results = []; this.searchUtils.totalResults = 0; this.loadPaging = false; - - this._searchDataprovidersService.searchDataProvidersBySubjects(subject, type, page, size, properties).subscribe( + + this.subscriptions.push(this._searchDataprovidersService.searchDataProvidersBySubjects(subject, type, page, size, properties).subscribe( data => { this.searchUtils.totalResults = data[0]; //console.info("search Dataproviders forDeposit: [subject:"+subject+", type:"+type+" ] [total results:"+this.searchUtils.totalResults+"]"); @@ -304,7 +304,7 @@ export class FetchDataproviders { this.loadPaging = true; this.oldTotalResults = 0; } - ); + )); } @@ -319,8 +319,8 @@ export class FetchDataproviders { } if (parameters != "") { - - this._searchDataprovidersService.searchDataprovidersForEntity(parameters, page, size, properties).subscribe( + + this.subscriptions.push(this._searchDataprovidersService.searchDataprovidersForEntity(parameters, page, size, properties).subscribe( data => { this.searchUtils.totalResults = data[0]; //console.info("search Dataproviders for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); @@ -350,15 +350,15 @@ export class FetchDataproviders { this.handleError("Error getting content providers for " + entity + " with id: " + id, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } } public getResultsForDataproviders(id: string, page: number, size: number, properties: EnvProperties) { //var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = this.errorCodes.LOADING; - - this._searchDataprovidersService.getDataProvidersforEntityRegistry(id, page, size, properties).subscribe( + + this.subscriptions.push(this._searchDataprovidersService.getDataProvidersforEntityRegistry(id, page, size, properties).subscribe( data => { this.searchUtils.totalResults = data[0]; //console.info("search Dataproviders for Entity Registry: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]"); @@ -388,7 +388,7 @@ export class FetchDataproviders { this.handleError("Error getting content providers for entity registry with id: " + id, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } private handleError(message: string, error) { diff --git a/utils/fetchEntitiesClasses/fetchOrganizations.class.ts b/utils/fetchEntitiesClasses/fetchOrganizations.class.ts index d0303b79..21e4253d 100644 --- a/utils/fetchEntitiesClasses/fetchOrganizations.class.ts +++ b/utils/fetchEntitiesClasses/fetchOrganizations.class.ts @@ -11,8 +11,7 @@ export class FetchOrganizations { public results =[]; public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public sub: any; - public subResults: any; + public subResults: any; @@ -25,10 +24,8 @@ export class FetchOrganizations { } - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } + public clearSubscriptions() { + if(this.subResults){ this.subResults.unsubscribe(); } diff --git a/utils/fetchEntitiesClasses/fetchProjects.class.ts b/utils/fetchEntitiesClasses/fetchProjects.class.ts index 346c2ace..6b228463 100644 --- a/utils/fetchEntitiesClasses/fetchProjects.class.ts +++ b/utils/fetchEntitiesClasses/fetchProjects.class.ts @@ -5,6 +5,7 @@ import {SearchCustomFilter, SearchUtilsClass} from '../../searchPages/searchUtil import {EnvProperties} from '../../utils/properties/env-properties'; import {StringUtils} from '../../utils/string-utils.class'; import {SearchResult} from "../entities/searchResult"; +import {Subscriber} from "rxjs"; export class FetchProjects { private errorCodes: ErrorCodes; @@ -14,9 +15,8 @@ export class FetchProjects { public filters; // for getResultsForOrganizations public funders: any = []; // for getResultsForOrganizations // this is filled with the initial query - before filtering - - public sub: any; - public subResults: any; + + subscriptions = []; public searchUtils: SearchUtilsClass = new SearchUtilsClass(); @@ -26,16 +26,15 @@ export class FetchProjects { this.searchUtils.status = this.errorCodes.LOADING; } - - public ngOnDestroy() { - if (this.sub) { - this.sub.unsubscribe(); - } - if (this.subResults) { - this.subResults.unsubscribe(); - } + + public clearSubscriptions() { + + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } - public getResultsByKeyword(keyword: string, page: number, size: number, properties: EnvProperties, customFilter: SearchCustomFilter = null) { var parameters = ""; if (keyword.length > 0) { @@ -48,7 +47,7 @@ export class FetchProjects { if (customFilter) { refineParams = (refineParams ? (refineParams + '&') : '') + "&fq=" + StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId))); } - this.subResults = this._searchProjectsService.searchProjects(parameters, refineParams, page, size, [], properties).subscribe( + this.subscriptions.push(this._searchProjectsService.searchProjects(parameters, refineParams, page, size, [], properties).subscribe( data => { this.searchUtils.totalResults = data[0]; //console.info("search Projects: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); @@ -78,14 +77,14 @@ export class FetchProjects { this.handleError("Error getting projects for keyword: " + keyword, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } public getResultsForDataproviders(id: string, page: number, size: number, properties: EnvProperties) { //var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = this.errorCodes.LOADING; - - this._searchProjectsService.getProjectsforDataProvider(id, page, size, properties).subscribe( + + this.subscriptions.push(this._searchProjectsService.getProjectsforDataProvider(id, page, size, properties).subscribe( data => { this.searchUtils.totalResults = data[0]; //console.info("search Projects for Dataproviders: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]"); @@ -115,7 +114,7 @@ export class FetchProjects { this.handleError("Error getting projects for content provider with id: " + id, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } public getNumForEntity(entity: string, id: string, properties: EnvProperties) { @@ -123,8 +122,8 @@ export class FetchProjects { this.searchUtils.status = this.errorCodes.LOADING; if (id != "" && entity != "") { - - this._searchProjectsService.numOfEntityProjects(id, entity, properties).subscribe( + + this.subscriptions.push(this._searchProjectsService.numOfEntityProjects(id, entity, properties).subscribe( data => { this.searchUtils.totalResults = data; @@ -153,14 +152,14 @@ export class FetchProjects { this.handleError("Error getting number of projects for " + entity + " with id: " + id, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } } public getResultsForOrganizations(organizationId: string, filterquery: string, page: number, size: number, refineFields: string[], properties: EnvProperties) { //var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = this.errorCodes.LOADING; - this._searchProjectsService.getProjectsForOrganizations(organizationId, filterquery, page, size, refineFields, properties).subscribe( + this.subscriptions.push(this._searchProjectsService.getProjectsForOrganizations(organizationId, filterquery, page, size, refineFields, properties).subscribe( data => { this.searchUtils.totalResults = data[0]; // the results can be filtered so this number can be no total results //console.info("search Projects for Organization: [Id:"+organizationId+" ] [total results:"+this.searchUtils.totalResults+"]"); @@ -203,7 +202,7 @@ export class FetchProjects { this.handleError("Error getting projects for organization with id: " + organizationId, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } private handleError(message: string, error) { diff --git a/utils/fetchEntitiesClasses/fetchResearchResults.class.ts b/utils/fetchEntitiesClasses/fetchResearchResults.class.ts index 7917e159..fde1baff 100644 --- a/utils/fetchEntitiesClasses/fetchResearchResults.class.ts +++ b/utils/fetchEntitiesClasses/fetchResearchResults.class.ts @@ -4,7 +4,7 @@ import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {SearchFields} from '../../utils/properties/searchFields'; import {SearchCustomFilter, SearchUtilsClass} from '../../searchPages/searchUtils/searchUtils.class'; import {DOI, StringUtils} from '../../utils/string-utils.class'; -import {Subject} from 'rxjs'; +import {Subject, Subscriber} from 'rxjs'; import {EnvProperties} from '../../utils/properties/env-properties'; export class FetchResearchResults { @@ -16,8 +16,7 @@ export class FetchResearchResults { public requestComplete: Subject; public searchUtils:SearchUtilsClass = new SearchUtilsClass(); - public sub: any; - public subResults: any; + subscriptions = []; public searchFields:SearchFields = new SearchFields(); public CSV: any = { @@ -38,19 +37,18 @@ export class FetchResearchResults { this.requestComplete = new Subject(); } - public ngOnDestroy() { - if(this.sub){ - this.sub.unsubscribe(); - } - if(this.subResults){ - this.subResults.unsubscribe(); - } + public clearSubscriptions() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); } public getResultsForCommunity(resultType:string, communityId: string, page: number, size: number, properties:EnvProperties) { this.searchUtils.status = this.errorCodes.LOADING; - this.subResults = this._searchResearchResultsService.search(resultType, "", "&fq=communityid=" + communityId, page, size, "resultdateofacceptance,descending", [], properties).subscribe( + this.subscriptions.push(this._searchResearchResultsService.search(resultType, "", "&fq=communityid=" + communityId, page, size, "resultdateofacceptance,descending", [], properties).subscribe( data => { this.searchUtils.totalResults = data[0]; this.results = data[1]; @@ -64,13 +62,13 @@ export class FetchResearchResults { this.handleError("Error getting "+this.getEntityName(resultType,true)+" for community: "+communityId, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } public getNumForCommunity(resultType:string, communityId: string, properties:EnvProperties) { this.searchUtils.status = this.errorCodes.LOADING; - this.subResults = this._searchResearchResultsService.countTotalResults(resultType, properties, "&fq=communityid=" + communityId).subscribe( + this.subscriptions.push(this._searchResearchResultsService.countTotalResults(resultType, properties, "&fq=communityid=" + communityId).subscribe( data => { this.searchUtils.totalResults = data; @@ -83,7 +81,7 @@ export class FetchResearchResults { this.handleError("Error getting number of "+this.getEntityName(resultType,true)+" for community: "+communityId, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } public getResultsByKeyword(resultType:string, keyword:string, page: number, size: number, properties:EnvProperties, customFilter:SearchCustomFilter=null){ @@ -107,7 +105,7 @@ export class FetchResearchResults { if(customFilter){ refineParams = (refineParams?(refineParams+'&'):'')+"&fq="+StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId ))); } - this.subResults = this._searchResearchResultsService.search(this.getEntityName(resultType,false), parameters,refineParams, page, size, "", [], properties).subscribe( + this.subscriptions.push(this._searchResearchResultsService.search(this.getEntityName(resultType,false), parameters,refineParams, page, size, "", [], properties).subscribe( data => { this.searchUtils.totalResults = data[0]; this.results = data[1]; @@ -135,14 +133,14 @@ export class FetchResearchResults { this.handleError("Error getting "+this.getEntityName(resultType,true)+" for keyword: "+keyword + (doisParams ? "(DOI)" : ""), err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } public getNumForEntity(resultType: string, entity:string, id:string, properties:EnvProperties){ this.searchUtils.status = this.errorCodes.LOADING; if(id != "" && entity != "") { - this._searchResearchResultsService.numOfEntityResults(this.getEntityName(resultType,false), id, entity, properties).subscribe( + this.subscriptions.push(this._searchResearchResultsService.numOfEntityResults(this.getEntityName(resultType,false), id, entity, properties).subscribe( data => { this.searchUtils.totalResults = data; @@ -169,7 +167,7 @@ export class FetchResearchResults { this.handleError("Error getting "+this.getEntityName(resultType,true)+" for "+entity+" with id: "+id, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } } @@ -186,7 +184,7 @@ export class FetchResearchResults { } if(parameters != "") { - this._searchResearchResultsService.searchResultForEntity(this.getEntityName(resultType,false), parameters, page, size, properties).subscribe( + this.subscriptions.push(this._searchResearchResultsService.searchResultForEntity(this.getEntityName(resultType,false), parameters, page, size, properties).subscribe( data => { this.searchUtils.totalResults = data[0]; this.results = data[1]; @@ -215,7 +213,7 @@ export class FetchResearchResults { this.handleError("Error getting "+this.getEntityName(resultType,true)+" for "+entity+" with id: "+id, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } } @@ -233,7 +231,7 @@ export class FetchResearchResults { if(parameters != "") { - this._searchResearchResultsService.searchForDataproviders(this.getEntityName(resultType,false), parameters, page, size, properties).subscribe( + this.subscriptions.push(this._searchResearchResultsService.searchForDataproviders(this.getEntityName(resultType,false), parameters, page, size, properties).subscribe( data => { this.searchUtils.totalResults = data[0]; this.results = data[1]; @@ -261,7 +259,7 @@ export class FetchResearchResults { this.handleError("Error getting "+this.getEntityName(resultType,true)+" for content provider ("+resultsFrom+") with id: "+id, err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); } - ); + )); } } @@ -269,7 +267,7 @@ export class FetchResearchResults { this.searchUtils.status = this.errorCodes.LOADING; // this.getEntityName(resultType,false) - this.subResults = this._searchResearchResultsService.searchAggregators(resultType, id, '&fq=(collectedfromdatasourceid exact "'+id+'" or resulthostingdatasourceid exact "'+id+'")',"&refine=true&fields=resulthostingdatasource&type="+resultType , page, size, properties).subscribe( + this.subscriptions.push(this._searchResearchResultsService.searchAggregators(resultType, id, '&fq=(collectedfromdatasourceid exact "'+id+'" or resulthostingdatasourceid exact "'+id+'")',"&refine=true&fields=resulthostingdatasource&type="+resultType , page, size, properties).subscribe( data => { this.results = data; this.searchUtils.totalResults = this.results.length; @@ -301,7 +299,7 @@ export class FetchResearchResults { this.requestComplete.complete(); } - ); + )); } private handleError(message: string, error) { diff --git a/utils/staticAutoComplete/ISVocabularies.service.ts b/utils/staticAutoComplete/ISVocabularies.service.ts index d4f6d6e5..f5c33c89 100644 --- a/utils/staticAutoComplete/ISVocabularies.service.ts +++ b/utils/staticAutoComplete/ISVocabularies.service.ts @@ -1,6 +1,6 @@ import {Injectable} from '@angular/core'; import {HttpClient, HttpErrorResponse} from "@angular/common/http"; -import {Observable, throwError, of, BehaviorSubject, from} from 'rxjs'; +import {Observable, throwError, of, BehaviorSubject, from, Subscriber} from 'rxjs'; import {AutoCompleteValue} from '../../searchPages/searchUtils/searchHelperClasses.class'; import 'rxjs/add/observable/zip'; @@ -11,9 +11,21 @@ import {catchError, map} from "rxjs/operators"; export class ISVocabulariesService { private vocabularies: Map> = new Map>(); private provenanceActionVocabulary: BehaviorSubject<{}> = new BehaviorSubject(null); + private subscriptions = []; constructor(private http: HttpClient) {} - + + ngOnDestroy() { + this.clearSubscriptions(); + } + + clearSubscriptions() { + this.subscriptions.forEach(subscription => { + if (subscription instanceof Subscriber) { + subscription.unsubscribe(); + } + }); + } getVocabularyByType(field: string, entity: string, properties: EnvProperties): Observable { //console.log("getVocabulary field: "+ field + " for entity: "+ entity); var file = ""; @@ -78,7 +90,7 @@ export class ISVocabulariesService { await new Promise(resolve => { this.vocabularies.set(vocabularyName, new BehaviorSubject(null)); - this.getVocabularyFromService(vocabularyName, properties).subscribe( + this.subscriptions.push(this.getVocabularyFromService(vocabularyName, properties).subscribe( vocabularyRes => { this.vocabularies.get(vocabularyName).next(vocabularyRes); resolve(); @@ -86,8 +98,9 @@ export class ISVocabulariesService { this.vocabularies.get(vocabularyName).next(null); resolve(); } - ); + )); }); + this.clearSubscriptions(); } return this.vocabularies.get(vocabularyName).getValue(); @@ -127,7 +140,7 @@ export class ISVocabulariesService { async getProvenanceActionVocabularyFromServiceAsync (vocabularyName: string, properties: EnvProperties): Promise<{}> { if(!this.provenanceActionVocabulary || !this.provenanceActionVocabulary.getValue()) { await new Promise(resolve => { - this.getProvenanceActionVocabularyFromService(vocabularyName, properties).subscribe( + this.subscriptions.push(this.getProvenanceActionVocabularyFromService(vocabularyName, properties).subscribe( vocabularyRes => { this.provenanceActionVocabulary.next(vocabularyRes); resolve(); @@ -136,8 +149,9 @@ export class ISVocabulariesService { this.provenanceActionVocabulary.next(null); resolve(); } - ); + )); }); + this.clearSubscriptions(); } return this.provenanceActionVocabulary.getValue(); } diff --git a/utils/staticAutoComplete/staticAutoComplete.component.ts b/utils/staticAutoComplete/staticAutoComplete.component.ts index c1e18331..49fb2153 100644 --- a/utils/staticAutoComplete/staticAutoComplete.component.ts +++ b/utils/staticAutoComplete/staticAutoComplete.component.ts @@ -1,5 +1,4 @@ import {Component, ElementRef, Input, Output, EventEmitter, OnChanges, SimpleChange} from '@angular/core'; -import {Value} from '../../searchPages/searchUtils/searchHelperClasses.class'; import {ISVocabulariesService} from './ISVocabularies.service'; import {RefineFieldResultsService} from '../../services/refineFieldResults.service'; import{EnvProperties} from '../../utils/properties/env-properties'; @@ -81,6 +80,7 @@ export class StaticAutoCompleteComponent implements OnChanges{ if(this.sub){ this.sub.unsubscribe(); } + this._vocabulariesService.clearSubscriptions(); } ngOnChanges(changes: {[propKey: string]: SimpleChange}) {