[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
This commit is contained in:
argiro.kokogiannaki 2020-11-11 14:43:13 +00:00
parent 72cd3c9c43
commit 1d5c753ff6
178 changed files with 833 additions and 7753 deletions

View File

@ -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 { }

View File

@ -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: `
<navbar *ngIf= "properties" portal="explore" [properties]=properties [onlyTop]=false [userMenu]=true [communityId]="properties.adminToolsCommunity" [userMenuItems]=userMenuItems [menuItems]=menuItems ></navbar>
<h1>Openaire Lib Component</h1>
<!--div id="tm-main" class=" uk-section uk-margin-large-top tm-middle custom-main-content" >
<div uk-grid uk-grid>
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first "-->
<div class="custom-main-content" >
<main>
<router-outlet></router-outlet>
</main>
</div>
<!--/div>
</div>
</div-->
<!--feedback *ngIf= "isClient"></feedback-->
<cookie-law *ngIf= "isClient" position="bottom">
OpenAIRE uses cookies in order to function properly.<br>
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. <a href="http://ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right" ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline></svg>
</span></a>
</cookie-law>
<bottom *ngIf= "isClient && properties" [assetsPath]=assetsPath [properties]=properties></bottom>
`
})
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) {
}
}
}
}

View File

@ -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'
}
*/

View File

@ -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 {}

View File

@ -1,10 +1,11 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {ContextsService} from './service/contexts.service'; 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 {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {Subscriber} from "rxjs";
declare var UIkit: any; declare var UIkit: any;
@ -39,11 +40,17 @@ export class ClaimContextSearchFormComponent {
@Input() localStoragePrefix: string = ""; @Input() localStoragePrefix: string = "";
keyword = ""; keyword = "";
subscriptions = [];
ngOnInit() { ngOnInit() {
this.getCommunities(); this.getCommunities();
} }
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
constructor(private _contextService: ContextsService, private router: Router) { constructor(private _contextService: ContextsService, private router: Router) {
} }
@ -114,7 +121,7 @@ export class ClaimContextSearchFormComponent {
} else { } else {
this.loading = true; this.loading = true;
this._contextService.getPublicCommunitiesByState().subscribe( this.subscriptions.push(this._contextService.getPublicCommunitiesByState().subscribe(
data => { data => {
this.communities = data; this.communities = data;
if (this.communities.length > 0) { if (this.communities.length > 0) {
@ -143,7 +150,7 @@ export class ClaimContextSearchFormComponent {
this.loading = false; this.loading = false;
this.error = true; this.error = true;
} }
); ));
} }
} }
@ -160,7 +167,7 @@ export class ClaimContextSearchFormComponent {
this.loading = false; this.loading = false;
return; return;
} }
this._contextService.getCategories(this.selectedCommunityId, this.properties.contextsAPI).subscribe( this.subscriptions.push(this._contextService.getCategories(this.selectedCommunityId, this.properties.contextsAPI).subscribe(
data => { data => {
this.categories[this.selectedCommunityId] = 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); ClaimContextSearchFormComponent.handleError("Error getting categories for community with id: " + this.selectedCommunityId, err);
this.loading = false; this.loading = false;
} }
); ));
} }
} }
} }
@ -272,7 +279,7 @@ export class ClaimContextSearchFormComponent {
} }
this.conceptsClass[categoryId] = []; this.conceptsClass[categoryId] = [];
this.conceptsCategoryLoading[categoryId] = true; 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 => { data => {
// var concepts = data; // var concepts = data;
this.conceptsClass[categoryId] = []; this.conceptsClass[categoryId] = [];
@ -290,7 +297,7 @@ export class ClaimContextSearchFormComponent {
ClaimContextSearchFormComponent.handleError("Error getting concepts for category with id: " + this.selectedCategoryId, err); ClaimContextSearchFormComponent.handleError("Error getting concepts for category with id: " + this.selectedCategoryId, err);
this.conceptsCategoryLoading[categoryId] = false; this.conceptsCategoryLoading[categoryId] = false;
} }
); ));
} }
} }
@ -298,7 +305,7 @@ export class ClaimContextSearchFormComponent {
browseSubConcepts(categoryId, conceptId) { browseSubConcepts(categoryId, conceptId) {
this.conceptsCategoryLoading[categoryId] = true; 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 => { data => {
const concepts = data[0]; const concepts = data[0];
this.conceptsClass[categoryId].push(concepts); this.conceptsClass[categoryId].push(concepts);
@ -309,7 +316,7 @@ export class ClaimContextSearchFormComponent {
ClaimContextSearchFormComponent.handleError("Error getting subconcepts for concept with id: " + conceptId, err); ClaimContextSearchFormComponent.handleError("Error getting subconcepts for concept with id: " + conceptId, err);
this.conceptsCategoryLoading[categoryId] = false; this.conceptsCategoryLoading[categoryId] = false;
} }
); ));
} }

View File

@ -9,6 +9,7 @@ import {Filter, Value} from "../../searchPages/searchUtils/searchHelperClasses.c
import {RangeFilter} from "../../utils/rangeFilter/rangeFilterHelperClasses.class"; import {RangeFilter} from "../../utils/rangeFilter/rangeFilterHelperClasses.class";
import {SearchFields} from "../../utils/properties/searchFields"; import {SearchFields} from "../../utils/properties/searchFields";
import {NewSearchPageComponent} from "../../searchPages/searchUtils/newSearchPage.component"; import {NewSearchPageComponent} from "../../searchPages/searchUtils/newSearchPage.component";
import {Subscriber} from "rxjs";
declare var UIkit:any; declare var UIkit:any;
@ -67,7 +68,12 @@ export class ClaimProjectsSearchFormComponent {
this.rangeFilters = RangeFilter.parse(this.rangeFields,"project"); this.rangeFilters = RangeFilter.parse(this.rangeFields,"project");
} }
sub;
ngOnDestroy() {
if (this.sub instanceof Subscriber) {
this.sub.unsubscribe();
}
}
search(page,size) { search(page,size) {
if(this.keyword.length == 0){ if(this.keyword.length == 0){
@ -80,7 +86,7 @@ export class ClaimProjectsSearchFormComponent {
this.prevFilters = this.filters; this.prevFilters = this.filters;
//searchProjects (params: string, refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties ):any { //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 => { data => {
if(data != null) { if(data != null) {
this.openaireResultsPage=page; this.openaireResultsPage=page;

View File

@ -8,11 +8,10 @@ import {ClaimEntity, ClaimResult} from './claimHelper.class';
import {DOI, StringUtils} from '../../utils/string-utils.class'; import {DOI, StringUtils} from '../../utils/string-utils.class';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {Filter, Value} from "../../searchPages/searchUtils/searchHelperClasses.class"; import {Filter, Value} from "../../searchPages/searchUtils/searchHelperClasses.class";
import {Observable, forkJoin} from "rxjs"; import {Observable, Subscriber} from "rxjs";
import 'rxjs/add/observable/forkJoin' import 'rxjs/add/observable/forkJoin'
import {NewSearchPageComponent} from "../../searchPages/searchUtils/newSearchPage.component"; import {NewSearchPageComponent} from "../../searchPages/searchUtils/newSearchPage.component";
import {RangeFilter} from "../../utils/rangeFilter/rangeFilterHelperClasses.class"; import {RangeFilter} from "../../utils/rangeFilter/rangeFilterHelperClasses.class";
import {SearchUtilsClass} from "../../searchPages/searchUtils/searchUtils.class";
import {SearchFields} from "../../utils/properties/searchFields"; import {SearchFields} from "../../utils/properties/searchFields";
@Component({ @Component({
selector: 'claim-result-search-form', selector: 'claim-result-search-form',
@ -122,7 +121,14 @@ export class ClaimResultSearchFormComponent {
this.search(false); this.search(false);
} }
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
search(keywordChanged) { search(keywordChanged) {
//uncomment to disable search with no keyword //uncomment to disable search with no keyword
if (this.keyword.length == 0) { if (this.keyword.length == 0) {
@ -187,14 +193,14 @@ export class ClaimResultSearchFormComponent {
this.crossrefStatus = this.errorCodes.LOADING; this.crossrefStatus = this.errorCodes.LOADING;
// this.crossrefResultsNum = null; // this.crossrefResultsNum = null;
if (this.DOIs.length > 0) { 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 => { data => {
if (data != null) { if (data != null) {
this.crossrefResults = data[1]; this.crossrefResults = data[1];
this.crossrefPage = page; this.crossrefPage = page;
this.crossrefResultsNum = data[0]; this.crossrefResultsNum = data[0];
if (this.crossrefResultsNum == 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 => { data => {
if (data != null) { if (data != null) {
this.crossrefResults = data[1]; this.crossrefResults = data[1];
@ -215,7 +221,7 @@ export class ClaimResultSearchFormComponent {
ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err); ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err);
this.crossrefStatus = this.errorCodes.ERROR; this.crossrefStatus = this.errorCodes.ERROR;
} }
); ));
} else { } else {
this.crossrefStatus = this.errorCodes.DONE; this.crossrefStatus = this.errorCodes.DONE;
} }
@ -224,7 +230,7 @@ export class ClaimResultSearchFormComponent {
err => { err => {
ClaimResultSearchFormComponent.handleError("Error getting crossref by DOIs: " + JSON.stringify(this.DOIs), 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 => { data => {
this.crossrefResults = data[1]; this.crossrefResults = data[1];
this.crossrefPage = page; this.crossrefPage = page;
@ -237,14 +243,14 @@ export class ClaimResultSearchFormComponent {
ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err); ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err);
this.crossrefStatus = this.errorCodes.ERROR; this.crossrefStatus = this.errorCodes.ERROR;
} }
); ));
} }
); ));
} else { } 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 => { data => {
if (data != null) { if (data != null) {
this.crossrefResults = data[1]; this.crossrefResults = data[1];
@ -264,7 +270,7 @@ export class ClaimResultSearchFormComponent {
ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err); ClaimResultSearchFormComponent.handleError("Error getting crossref results for term: " + term, err);
this.crossrefStatus = this.errorCodes.ERROR; this.crossrefStatus = this.errorCodes.ERROR;
} }
); ));
} }
} }
@ -294,14 +300,14 @@ export class ClaimResultSearchFormComponent {
this.openaireResultsStatus = this.errorCodes.LOADING; this.openaireResultsStatus = this.errorCodes.LOADING;
this.openaireResultsPrevFilters = this.openaireResultsfilters; this.openaireResultsPrevFilters = this.openaireResultsfilters;
this.openaireResultsNum = 0; 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 => { data => {
this.setOpenaireResults(data, mainResults, page, type); this.setOpenaireResults(data, mainResults, page, type);
}, },
err => { err => {
this.setOpenaireResultsError(mainResults, term, err); this.setOpenaireResultsError(mainResults, term, err);
} }
); ));
} }
public setOpenaireResults(data, mainResults: boolean, page, type) { public setOpenaireResults(data, mainResults: boolean, page, type) {
@ -379,7 +385,7 @@ export class ClaimResultSearchFormComponent {
private getOrcidAuthor(term: string, addId) { private getOrcidAuthor(term: string, addId) {
this.orcidResultsNum = null; this.orcidResultsNum = null;
//passing structures in order to fill them in service //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( this.authors, this.properties, addId).subscribe(
data => { data => {
if (data != null && data == true && addId) { if (data != null && data == true && addId) {
@ -391,7 +397,7 @@ export class ClaimResultSearchFormComponent {
}, },
err => this.errorHandler(err, term) err => this.errorHandler(err, term)
); ));
} }
private errorHandler(err: any, term: string) { private errorHandler(err: any, term: string) {
@ -409,7 +415,7 @@ export class ClaimResultSearchFormComponent {
this.selectAuthorId = "0"; this.selectAuthorId = "0";
this.orcidStatus = this.errorCodes.LOADING; this.orcidStatus = this.errorCodes.LOADING;
//passing structures in order to fill them in service //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 => { data => {
this.authorIds = data; this.authorIds = data;
if (data != null) { if (data != null) {
@ -430,7 +436,7 @@ export class ClaimResultSearchFormComponent {
//console.log(err.status); //console.log(err.status);
ClaimResultSearchFormComponent.handleError("Error getting orcid authors for term: " + term + " and ids: " + JSON.stringify(this.authorIds), err); 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.authorFamilyName = this.authors[index].authorFamilyName;
this.authorId = this.authors[index].id; this.authorId = this.authors[index].id;
this.orcidStatus = this.errorCodes.LOADING; 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 => { data => {
if (data != null) { if (data != null) {
this.orcidResults = data; this.orcidResults = data;
@ -487,7 +493,7 @@ export class ClaimResultSearchFormComponent {
ClaimResultSearchFormComponent.handleError("Error getting orcid publications for author id: " + this.authors[index].id, err); ClaimResultSearchFormComponent.handleError("Error getting orcid publications for author id: " + this.authors[index].id, err);
this.orcidStatus = this.errorCodes.ERROR; this.orcidStatus = this.errorCodes.ERROR;
} }
); ));
} }
@ -495,7 +501,7 @@ export class ClaimResultSearchFormComponent {
private enhanceInfoFromDOI(entity: ClaimEntity) { private enhanceInfoFromDOI(entity: ClaimEntity) {
if (entity.result.DOI != null) { 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 => { data => {
if (data != null && data[0] > 0 && data[1]) { if (data != null && data[0] > 0 && data[1]) {
let crossrefResult: ClaimEntity = data[1][0]; let crossrefResult: ClaimEntity = data[1][0];
@ -524,7 +530,7 @@ export class ClaimResultSearchFormComponent {
err => { err => {
ClaimResultSearchFormComponent.handleError("Error getting crossref by DOIs: " + entity['DOI'], err); ClaimResultSearchFormComponent.handleError("Error getting crossref by DOIs: " + entity['DOI'], err);
} }
); ));
} }
} }
@ -683,7 +689,7 @@ export class ClaimResultSearchFormComponent {
doiObservables.push(ob); doiObservables.push(ob);
} }
Observable.forkJoin(doiObservables).subscribe( this.subscriptions.push(Observable.forkJoin(doiObservables).subscribe(
data => { data => {
//if DOI not found or an error occured the result will be null -- remove null values //if DOI not found or an error occured the result will be null -- remove null values
for(let result of data){ for(let result of data){
@ -695,7 +701,7 @@ export class ClaimResultSearchFormComponent {
this.dataciteResultsNum = this.dataciteResults.length; this.dataciteResultsNum = this.dataciteResults.length;
this.dataciteStatus = this.errorCodes.DONE; this.dataciteStatus = this.errorCodes.DONE;
if (this.dataciteResultsNum == 0) { 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 => { data => {
this.dataciteResults = data[1]; this.dataciteResults = data[1];
this.datacitePage = page; this.datacitePage = page;
@ -712,15 +718,15 @@ export class ClaimResultSearchFormComponent {
console.log(err); console.log(err);
ClaimResultSearchFormComponent.handleError("Error getting datacite results for term: " + term, err); ClaimResultSearchFormComponent.handleError("Error getting datacite results for term: " + term, err);
}); }));
} }
} }
); ));
} else { } 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 => { data => {
this.dataciteResults = data[1]; this.dataciteResults = data[1];
this.datacitePage = page; this.datacitePage = page;
@ -737,7 +743,7 @@ export class ClaimResultSearchFormComponent {
//console.log(err); //console.log(err);
ClaimResultSearchFormComponent.handleError("Error getting datacite results for term: " + term, err); ClaimResultSearchFormComponent.handleError("Error getting datacite results for term: " + term, err);
} }
); ));
} }
} }

View File

@ -1,6 +1,5 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {ClaimEntity} from './claimHelper.class'; import {ClaimEntity} from './claimHelper.class';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
declare var UIkit: any; declare var UIkit: any;

View File

@ -1,7 +1,7 @@
import {Component, Input, ViewChild} from '@angular/core'; import {Component, Input, ViewChild} from '@angular/core';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Subject} from 'rxjs'; import {Subject, Subscriber} from 'rxjs';
import {debounceTime, distinctUntilChanged} from 'rxjs/operators'; import {debounceTime, distinctUntilChanged} from 'rxjs/operators';
import {ClaimsService} from '../service/claims.service'; import {ClaimsService} from '../service/claims.service';
import {ModalLoading} from '../../../utils/modal/loading.component'; import {ModalLoading} from '../../../utils/modal/loading.component';
@ -28,11 +28,9 @@ import {properties} from "../../../../../environments/environment";
export class DisplayClaimsComponent { export class DisplayClaimsComponent {
@Input() piwikSiteId = null; @Input() piwikSiteId = null;
@Input() title: string = ""; @Input() title: string = "";
piwiksub: any;
properties: EnvProperties; properties: EnvProperties;
public searchTermStream = new Subject<string>(); public searchTermStream = new Subject<string>();
sub: any; subscriptions: any = [];
//string because comes as input from component directive //string because comes as input from component directive
@Input() enableDelete: boolean = false; @Input() enableDelete: boolean = false;
@Input() showUserEmail: boolean = true; @Input() showUserEmail: boolean = true;
@ -99,16 +97,16 @@ export class DisplayClaimsComponent {
this.updateDescription(description); this.updateDescription(description);
this.updateUrl(this.url); this.updateUrl(this.url);
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { 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.pageContents = contents;
}); }));
this.indexInfoService.getLastIndexDate(this.properties).subscribe(res => { this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(res => {
this.lastIndexDate = 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); this.seoService.createLinkForCanonicalURL(this.url, false);
if (this.myClaims) { if (this.myClaims) {
@ -133,26 +131,26 @@ export class DisplayClaimsComponent {
this.setTypes(params['types']); // check the appropriate checkboxes this.setTypes(params['types']); // check the appropriate checkboxes
this.setSortby(params['sort']); this.setSortby(params['sort']);
this.getClaims(); this.getClaims();
this.searchTermStream this.subscriptions.push(this.searchTermStream
.pipe(debounceTime(300), distinctUntilChanged()) .pipe(debounceTime(300), distinctUntilChanged())
.subscribe((term: string) => { .subscribe((term: string) => {
this.keyword = term; this.keyword = term;
this.page = 1; this.page = 1;
this.goTo(); this.goTo();
}); }));
}); }));
} }
ngOnDestroy() { ngOnDestroy() {
this.sub.unsubscribe(); this.subscriptions.forEach(subscription => {
if (this.piwiksub) { if (subscription instanceof Subscriber) {
this.piwiksub.unsubscribe(); subscription.unsubscribe();
} }
//this.searchTermStreamSub.unsubscribe(); });
} }
getClaims() { getClaims() {
@ -174,7 +172,7 @@ export class DisplayClaimsComponent {
} }
this.pageLoading = true; this.pageLoading = true;
if (this.fetchBy == "Project") { 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 => { data => {
this.manageAPIData(data); this.manageAPIData(data);
this.pageLoading = false; this.pageLoading = false;
@ -182,9 +180,9 @@ export class DisplayClaimsComponent {
err => { err => {
this.handleErrors(err, "Error getting claims for project with id: " + this.fetchId); this.handleErrors(err, "Error getting claims for project with id: " + this.fetchId);
} }
); ));
} else if (this.fetchBy == "User") { } 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 => { data => {
this.manageAPIData(data); this.manageAPIData(data);
this.pageLoading = false; this.pageLoading = false;
@ -193,9 +191,9 @@ export class DisplayClaimsComponent {
this.handleErrors(err, "Error getting claims for user with id: " + this.fetchId); this.handleErrors(err, "Error getting claims for user with id: " + this.fetchId);
this.pageLoading = false; this.pageLoading = false;
} }
); ));
} else if (this.fetchBy == "Result") { } 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 => { data => {
this.manageAPIData(data); this.manageAPIData(data);
this.pageLoading = false; this.pageLoading = false;
@ -204,9 +202,9 @@ export class DisplayClaimsComponent {
this.handleErrors(err, "Error getting claims for entity with id: " + this.fetchId); this.handleErrors(err, "Error getting claims for entity with id: " + this.fetchId);
this.pageLoading = false; this.pageLoading = false;
} }
); ));
} else if (this.fetchBy == "Context") { } 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 => { data => {
this.manageAPIData(data); this.manageAPIData(data);
this.pageLoading = false; this.pageLoading = false;
@ -215,9 +213,9 @@ export class DisplayClaimsComponent {
this.handleErrors(err, "Error getting claims for context with id: " + this.fetchId); this.handleErrors(err, "Error getting claims for context with id: " + this.fetchId);
this.pageLoading = false; this.pageLoading = false;
} }
); ));
} else { } 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 => { data => {
this.manageAPIData(data); this.manageAPIData(data);
this.pageLoading = false; this.pageLoading = false;
@ -226,7 +224,7 @@ export class DisplayClaimsComponent {
this.handleErrors(err, "Error getting claims"); this.handleErrors(err, "Error getting claims");
this.pageLoading = false; this.pageLoading = false;
} }
); ));
} }
} }
} }
@ -547,7 +545,7 @@ export class DisplayClaimsComponent {
}); });
} else { } else {
//console.warn("Deleting claim with ids:"+ids); //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 => { res => {
//console.info('Delete response'+res.code ); //console.info('Delete response'+res.code );
//console.warn("Deleted ids:"+ res.deletedIds); //console.warn("Deleted ids:"+ res.deletedIds);
@ -588,7 +586,7 @@ export class DisplayClaimsComponent {
this.showErrorMessage = true; this.showErrorMessage = true;
this.loading.close(); this.loading.close();
}); }));
} }
} }

View File

@ -1,6 +1,5 @@
import { NgModule} from '@angular/core'; import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import {ProjectTitleFormatter} from './projectTitleFormatter.component'; import {ProjectTitleFormatter} from './projectTitleFormatter.component';

View File

@ -57,6 +57,9 @@ export class ContextsService {
} }
await this.promise; await this.promise;
if(this.sub){
this.sub.unsubscribe();
}
if(getAll) { if(getAll) {
return this.communitiesSubject.getValue(); return this.communitiesSubject.getValue();
} else { } else {
@ -102,7 +105,7 @@ export class ContextsService {
.pipe(map(res => (parsing)?this.parse(res):res)); .pipe(map(res => (parsing)?this.parse(res):res));
} }
public getSubConcepts(subConceptID :string, keyword: string, parsing:boolean, apiUrl:string):any { 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 url= apiUrl + '/category/concept/' + subConceptID;
let key = url+"_parsing="+parsing; let key = url+"_parsing="+parsing;

View File

@ -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'; import {AlertModal} from '../../utils/modal/alert';

View File

@ -1,9 +1,10 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {Title, Meta} from '@angular/platform-browser'; 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 {UserManagementService} from "../../services/user-management.service";
import {LoginErrorCodes} from "../../login/utils/guardHelper.class"; import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {Subscriber} from "rxjs";
@Component({ @Component({
@ -45,7 +46,7 @@ export class ClaimsAdminComponent {
@Input() claimsInfoURL: string; @Input() claimsInfoURL: string;
@Input() userInfoURL: string; @Input() userInfoURL: string;
public user: User = null; public user: User = null;
sub;
constructor(private _meta: Meta, private _title: Title, constructor(private _meta: Meta, private _title: Title,
private userManagementService: UserManagementService, private _router: Router) { private userManagementService: UserManagementService, private _router: Router) {
var titleConnect = "OpenAIRE Connect | Manage links "; var titleConnect = "OpenAIRE Connect | Manage links ";
@ -59,9 +60,13 @@ export class ClaimsAdminComponent {
} }
ngOnDestroy() {
if (this.sub instanceof Subscriber) {
this.sub.unsubscribe();
}
}
ngOnInit() { ngOnInit() {
this.userManagementService.getUserInfo().subscribe(user => { this.sub = this.userManagementService.getUserInfo().subscribe(user => {
this.user = user; this.user = user;
if (!user) { if (!user) {
this._router.navigate(['/user-info'], { this._router.navigate(['/user-info'], {

View File

@ -1,17 +1,13 @@
import {Component, ViewChild, ViewChildren, QueryList, Input, ViewEncapsulation} from '@angular/core'; import {Component, ViewChild, ViewChildren, QueryList, ViewEncapsulation} from '@angular/core';
import {Location} from '@angular/common';
import {ActivatedRoute, Params, Router} from '@angular/router'; import {ActivatedRoute, Params, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser'; import {Title, Meta} from '@angular/platform-browser';
import {DataTableDirective} from 'angular-datatables'; import {DataTableDirective} from 'angular-datatables';
import {Observable, Subject } from 'rxjs'; import {Subject, Subscriber} from 'rxjs';
import{EnvProperties} from '../../utils/properties/env-properties'; import{EnvProperties} from '../../utils/properties/env-properties';
import {ErrorCodes} from '../../utils/properties/errorCodes'; import {ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe';
import {RouterHelper} from '../../utils/routerHelper.class'; import {RouterHelper} from '../../utils/routerHelper.class';
import {ModalSelect} from '../../utils/modal/selectModal.component'; import {ModalSelect} from '../../utils/modal/selectModal.component';
@ -39,7 +35,7 @@ import {properties} from "../../../../environments/environment";
}) })
export class ClaimsByTokenComponent { export class ClaimsByTokenComponent {
public openaireId: string = ""; public openaireId: string = "";
public sub: any; public subscriptions: any =[];
public project: any; public project: any;
private claims:any = []; private claims:any = [];
public pending_claims: any = []; public pending_claims: any = [];
@ -96,7 +92,7 @@ export class ClaimsByTokenComponent {
this.curated_status = this.errorCodes.LOADING; this.curated_status = this.errorCodes.LOADING;
} }
ngOnInit() { ngOnInit() {
this.sub = this.route.queryParams.subscribe(params => { this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.mode = "pending"; this.mode = "pending";
this.openaireId = params['openaireId']; this.openaireId = params['openaireId'];
this.selectedRight_PendingMode = new Set<string>(); this.selectedRight_PendingMode = new Set<string>();
@ -107,7 +103,7 @@ export class ClaimsByTokenComponent {
this.validateJWTandToken(); this.validateJWTandToken();
this.updateTitle("Claims For Project Managers"); this.updateTitle("Claims For Project Managers");
} }
); ));
this.dtOptions[0] = { this.dtOptions[0] = {
//"paging": false, //"paging": false,
@ -161,6 +157,11 @@ export class ClaimsByTokenComponent {
// Do not forget to unsubscribe the event // Do not forget to unsubscribe the event
this.dtTrigger[0].unsubscribe(); this.dtTrigger[0].unsubscribe();
this.dtTrigger[1].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.activeCuratedPage.page = 1;
this.totalCuratedResults.count = 0; 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 => { data => {
//this.closeLoading(); //this.closeLoading();
this.accessStatus = "valid"; this.accessStatus = "valid";
@ -347,7 +348,7 @@ export class ClaimsByTokenComponent {
this.accessStatus = "invalid"; this.accessStatus = "invalid";
//console.log(err); //console.log(err);
} }
); ));
} else { } else {
this.accessStatus = "invalid"; this.accessStatus = "invalid";
} }
@ -463,7 +464,7 @@ export class ClaimsByTokenComponent {
} else { } else {
let claimCurationInfo: {"id": string, "approved": boolean} = {"id": claim.id, "approved": approved}; 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 => { data => {
this.selectedRight_CuratedMode.delete(claim.id); this.selectedRight_CuratedMode.delete(claim.id);
this.selectedWrong_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.handleError("Error updating claim curation: "+JSON.stringify(claimCurationInfo), err);
this.curated_status = this.errorCodes.NOT_SAVED; this.curated_status = this.errorCodes.NOT_SAVED;
} }
); ));
} }
} }
} }
@ -488,7 +489,7 @@ export class ClaimsByTokenComponent {
this.pending_status = this.errorCodes.LOADING; this.pending_status = this.errorCodes.LOADING;
//this.openLoading(); //this.openLoading();
//console.info("Changes Saved!, right-wrong", this.selectedRight_PendingMode, this.selectedWrong_PendingMode); //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 => { data => {
//this.closeLoading(); //this.closeLoading();
this.mode = "curated"; 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.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; this.pending_status = this.errorCodes.NOT_SAVED;
} }
); ));
} }
} }

View File

@ -1,6 +1,5 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {RequestOptions, Headers} from '@angular/http'; import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http";
import {throwError} from 'rxjs'; import {throwError} from 'rxjs';

View File

@ -1,13 +1,12 @@
import {Component, Input, ViewChild} from '@angular/core'; import {Component, Input, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Meta, Title} from '@angular/platform-browser';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {ClaimEntity, ClaimProject, ShowOptions} from '../claim-utils/claimHelper.class'; import {ClaimEntity, ClaimProject, ShowOptions} from '../claim-utils/claimHelper.class';
import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service'; import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service';
import {SearchResearchResultsService} from '../../services/searchResearchResults.service'; import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
import {LinkingGenericComponent} from "../linking/linkingGeneric.component"; import {LinkingGenericComponent} from "../linking/linkingGeneric.component";
import {ClaimResultSearchFormComponent} from "../claim-utils/claimResultSearchForm.component"; import {ClaimResultSearchFormComponent} from "../claim-utils/claimResultSearchForm.component";
import {Subscriber} from "rxjs";
@Component({ @Component({
@ -31,21 +30,27 @@ export class DirectLinkingComponent {
validEntityTypes = ["dataset", "publication", "software", "orp", "project", "context"]; validEntityTypes = ["dataset", "publication", "software", "orp", "project", "context"];
sources: ClaimEntity[] = []; sources: ClaimEntity[] = [];
inlineEntity: ClaimEntity = null; inlineEntity: ClaimEntity = null;
sub: any = null;
validInput: boolean = null;//'true; validInput: boolean = null;//'true;
properties: EnvProperties; properties: EnvProperties;
@Input() communityId: string = null; @Input() communityId: string = null;
localStoragePrefix: string = ""; localStoragePrefix: string = "";
constructor(private _router: Router, private route: ActivatedRoute,private entitySearch:EntitiesSearchService, constructor(private _router: Router, private route: ActivatedRoute,private entitySearch:EntitiesSearchService,
private _searchResearchResultsService: SearchResearchResultsService) {} private _searchResearchResultsService: SearchResearchResultsService) {}
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.data this.subscriptions.push(this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
}); }));
this.sub = this.route.queryParams.subscribe(params => { this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.id = params['id']; this.id = params['id'];
this.type = params['type']; this.type = params['type'];
this.showOptions.linkTo = params['linkTo']; this.showOptions.linkTo = params['linkTo'];
@ -104,7 +109,7 @@ export class DirectLinkingComponent {
} }
}); }));
} }
isValidInput(result: ClaimEntity) { isValidInput(result: ClaimEntity) {
@ -122,7 +127,7 @@ export class DirectLinkingComponent {
} }
getProjectById(id: string) { 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 => { data => {
this.createClaimEntity(data, "project"); this.createClaimEntity(data, "project");
}, },
@ -130,18 +135,18 @@ export class DirectLinkingComponent {
this.validInput = this.isValidInput(null); this.validInput = this.isValidInput(null);
//console.log("An error occured") //console.log("An error occured")
this.handleError("Error getting project by id: " + id, err); this.handleError("Error getting project by id: " + id, err);
}); }));
} }
getResearchResultById(resultType: string, id: string) { 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); this.createClaimEntity(data, resultType);
}, },
err => { err => {
this.validInput = this.isValidInput(null); this.validInput = this.isValidInput(null);
//console.log("An error occured") //console.log("An error occured")
this.handleError("Error getting "+this.getEntityName(resultType, false, true)+" by id: " + id, err); this.handleError("Error getting "+this.getEntityName(resultType, false, true)+" by id: " + id, err);
}); }));
} }
createClaimEntity(data, type: string) { createClaimEntity(data, type: string) {

View File

@ -6,6 +6,7 @@ import {ModalLoading} from '../../../utils/modal/loading.component';
import {Dates, DOI} from '../../../utils/string-utils.class'; import {Dates, DOI} from '../../../utils/string-utils.class';
import {EnvProperties} from '../../../utils/properties/env-properties'; import {EnvProperties} from '../../../utils/properties/env-properties';
import {ClaimEntity} from "../../claim-utils/claimHelper.class"; import {ClaimEntity} from "../../claim-utils/claimHelper.class";
import {Subscriber} from "rxjs";
declare var UIkit: any; declare var UIkit: any;
@ -123,7 +124,14 @@ export class BulkClaimComponent {
ngOnInit() { ngOnInit() {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
upload() { upload() {
this.enableUpload = false; this.enableUpload = false;
this.showReport = false; this.showReport = false;
@ -238,7 +246,7 @@ export class BulkClaimComponent {
} }
fetchResult(id: string, accessMode: string, date: string, row: number) { 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 => { data => {
const result:ClaimEntity = data[1][0]; const result:ClaimEntity = data[1][0];
@ -264,11 +272,11 @@ export class BulkClaimComponent {
this.notFoundIdsRow.push(row); this.notFoundIdsRow.push(row);
this.endOfFetching(); this.endOfFetching();
} }
); ));
} }
searchInDatacite(id: string, accessMode: string, date: string, row: number) { 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 => { result => {
if (result) { if (result) {
@ -293,7 +301,7 @@ export class BulkClaimComponent {
this.notFoundIdsRow.push(row); this.notFoundIdsRow.push(row);
this.endOfFetching(); this.endOfFetching();
} }
); ));
} }
endOfFetching() { endOfFetching() {

View File

@ -9,7 +9,7 @@ import {HelperModule} from '../../../utils/helper/helper.module';
@NgModule({ @NgModule({
imports: [ imports: [
SharedModule, LoadingModalModule, SearchCrossrefServiceModule, HelperModule SharedModule, LoadingModalModule, SearchCrossrefServiceModule,SearchDataciteServiceModule, HelperModule
], ],
declarations: [ declarations: [
BulkClaimComponent BulkClaimComponent

View File

@ -4,7 +4,6 @@ import {ClaimsService} from '../../claim-utils/service/claims.service';
import {ModalLoading} from '../../../utils/modal/loading.component'; import {ModalLoading} from '../../../utils/modal/loading.component';
import {AlertModal} from '../../../utils/modal/alert'; import {AlertModal} from '../../../utils/modal/alert';
import {Md5} from 'ts-md5/dist/md5'; import {Md5} from 'ts-md5/dist/md5';
import {Session, User} from '../../../login/utils/helper.class';
import {LoginErrorCodes} from '../../../login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../../login/utils/guardHelper.class';
import {EnvProperties} from '../../../utils/properties/env-properties'; import {EnvProperties} from '../../../utils/properties/env-properties';
import { import {
@ -15,6 +14,7 @@ import {
Message Message
} from "../../claim-utils/claimHelper.class"; } from "../../claim-utils/claimHelper.class";
import {UserManagementService} from "../../../services/user-management.service"; import {UserManagementService} from "../../../services/user-management.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'claim-insert', selector: 'claim-insert',
@ -55,12 +55,19 @@ export class ClaimInsertComponent {
constructor(private claimService: ClaimsService, private _router: Router, private route: ActivatedRoute, constructor(private claimService: ClaimsService, private _router: Router, private route: ActivatedRoute,
private userManagementService: UserManagementService) { private userManagementService: UserManagementService) {
} }
subscriptions = [];
ngOnInit() { ngOnDestroy() {
this.route.queryParams.subscribe(params => { this.subscriptions.forEach(subscription => {
this.params = params; if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
}); });
} }
ngOnInit() {
this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.params = params;
}));
}
params = {}; params = {};
@ -106,7 +113,7 @@ export class ClaimInsertComponent {
this.errorInClaims = []; this.errorInClaims = [];
this.insertedRecords = []; this.insertedRecords = [];
this.errorInRecords = []; this.errorInRecords = [];
this.userManagementService.getUserInfo().subscribe(user => { this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
if (!user) { if (!user) {
this.saveAndNavigate(); this.saveAndNavigate();
} else { } else {
@ -178,7 +185,7 @@ export class ClaimInsertComponent {
// console.log("directclaims"); // console.log("directclaims");
// console.log(directclaims); // console.log(directclaims);
if (directclaims.length > 0 && this.properties.environment != "development"){ 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 => { data => {
this.insertedRecords = data.insertedIds; this.insertedRecords = data.insertedIds;
@ -200,19 +207,19 @@ export class ClaimInsertComponent {
ClaimInsertComponent.handleError("Error inserting direct records: " + JSON.stringify(directclaims), err); ClaimInsertComponent.handleError("Error inserting direct records: " + JSON.stringify(directclaims), err);
} }
); ));
} else { } else {
this.isertBulkClaims(claims); this.isertBulkClaims(claims);
} }
} }
}); }));
} }
private isertBulkClaims(claims: ClaimRecord2Insert[]) { private isertBulkClaims(claims: ClaimRecord2Insert[]) {
console.log("claims"); console.log("claims");
console.log(claims); console.log(claims);
this.errors.splice(0, this.errors.length); 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 => { data => {
this.insertedClaims = data.insertedIds; this.insertedClaims = data.insertedIds;
this.errorInClaims = data.errorInClaims; this.errorInClaims = data.errorInClaims;
@ -265,7 +272,7 @@ export class ClaimInsertComponent {
ClaimInsertComponent.handleError("Error inserting bulk claims: " + JSON.stringify(claims), err); ClaimInsertComponent.handleError("Error inserting bulk claims: " + JSON.stringify(claims), err);
} }
); ));
} }
createErrorMessagesPerEntity(applyToAll: boolean) { createErrorMessagesPerEntity(applyToAll: boolean) {

View File

@ -9,6 +9,7 @@ import {AlertModal} from "../../utils/modal/alert";
import {HelperFunctions} from "../../utils/HelperFunctions.class"; import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {HelperService} from "../../utils/helper/helper.service"; import {HelperService} from "../../utils/helper/helper.service";
import {PiwikService} from "../../utils/piwik/piwik.service"; import {PiwikService} from "../../utils/piwik/piwik.service";
import {Subscriber} from "rxjs";
declare var UIkit:any; declare var UIkit:any;
@ -36,7 +37,6 @@ export class LinkingGenericComponent {
// show linkToEntities /values: result, project, context // show linkToEntities /values: result, project, context
@Input() sources:ClaimEntity[] =[]; @Input() sources:ClaimEntity[] =[];
sub:any =null;
properties:EnvProperties; properties:EnvProperties;
@Input() localStoragePrefix:string = "linking_"; @Input() localStoragePrefix:string = "linking_";
url=null; url=null;
@ -48,6 +48,8 @@ export class LinkingGenericComponent {
private _meta: Meta, private _title: Title, private _piwikService:PiwikService, private _meta: Meta, private _title: Title, private _piwikService:PiwikService,
private seoService: SEOService, private helper: HelperService ) { private seoService: SEOService, private helper: HelperService ) {
} }
subscriptions = [];
ngOnInit() { ngOnInit() {
this.showOptions.show = 'source'; this.showOptions.show = 'source';
if(this.inlineEntity){ if(this.inlineEntity){
@ -55,7 +57,7 @@ export class LinkingGenericComponent {
this.showOptions.basketShowLinksTo = true; this.showOptions.basketShowLinksTo = true;
this.showOptions.show = this.showOptions.linkTo; this.showOptions.show = this.showOptions.linkTo;
} }
this.route.data this.subscriptions.push(this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
this.url = this.properties.domain + this.properties.baseLink+this._router.url; this.url = this.properties.domain + this.properties.baseLink+this._router.url;
@ -68,14 +70,14 @@ export class LinkingGenericComponent {
this.seoService.createLinkForCanonicalURL(this.url, false); this.seoService.createLinkForCanonicalURL(this.url, false);
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ 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.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.pageContents = contents; this.pageContents = contents;
}) })
}); }));
if( typeof localStorage !== 'undefined') { if( typeof localStorage !== 'undefined') {
this.localStoragePrefix +=(this.communityId?this.communityId+"_":""); this.localStoragePrefix +=(this.communityId?this.communityId+"_":"");
if(localStorage.getItem(this.localStoragePrefix + "results")){ if(localStorage.getItem(this.localStoragePrefix + "results")){
@ -89,9 +91,11 @@ export class LinkingGenericComponent {
} }
ngOnDestroy() { ngOnDestroy() {
if(this.piwiksub){ this.subscriptions.forEach(subscription => {
this.piwiksub.unsubscribe(); if (subscription instanceof Subscriber) {
subscription.unsubscribe();
} }
});
} }
openSelectionModal() { openSelectionModal() {

View File

@ -5,7 +5,6 @@ import { SharedModule } from '../../shared/shared.module';
import {SelectedProjectsModule} from './selected/selectedProjects.module'; import {SelectedProjectsModule} from './selected/selectedProjects.module';
import {SelectedContextsModule} from './selected/selectedContexts.module'; import {SelectedContextsModule} from './selected/selectedContexts.module';
import {SelectedPublicationsModule} from './selected/selectedResults.module'; import {SelectedPublicationsModule} from './selected/selectedResults.module';
import {InsertClaimsModule} from './insertClaim/insertClaim.module';
import {LinkingGenericComponent} from './linkingGeneric.component'; import {LinkingGenericComponent} from './linkingGeneric.component';
import {StartOverModule} from '../claim-utils/startOver.module'; import {StartOverModule} from '../claim-utils/startOver.module';
import {LoginGuard} from'../../login/loginGuard.guard'; import {LoginGuard} from'../../login/loginGuard.guard';

View File

@ -1,6 +1,5 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {ClaimEntity} from '../../claim-utils/claimHelper.class'; import {ClaimEntity} from '../../claim-utils/claimHelper.class';
import {StringUtils} from "../../../utils/string-utils.class";
@Component({ @Component({
selector: 'claim-project-metadata', selector: 'claim-project-metadata',

View File

@ -1,6 +1,5 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {ClaimEntity} from '../../claim-utils/claimHelper.class'; import {ClaimEntity} from '../../claim-utils/claimHelper.class';
import {StringUtils} from "../../../utils/string-utils.class";
@Component({ @Component({
selector: 'claim-result-metadata', selector: 'claim-result-metadata',
@ -51,10 +50,6 @@ export class ClaimEntityResultMetadataComponent {
return array.join("; "); return array.join("; ");
} }
addStringToNumber(str: string, num: number) {
return (+str) + num;
}
getProjectDurationMessage(result: ClaimEntity) { getProjectDurationMessage(result: ClaimEntity) {
if(!result.warningMessages){ if(!result.warningMessages){
return null; return null;
@ -67,13 +62,5 @@ export class ClaimEntityResultMetadataComponent {
return null; 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;
// }
} }

View File

@ -63,28 +63,4 @@ export class ClaimEntityTitleComponent {
return mystr; 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;
}
} }

View File

@ -50,7 +50,6 @@ export class ClaimSelectedContextsComponent {
//The following need to be kept in case we have to save the current state //The following need to be kept in case we have to save the current state
@Input() public projects; @Input() public projects;
@Input() public results; @Input() public results;
// @Input() public inlineEntity;
@Input() componentClass:string = ""; //"" or "col-sm-6" for horizontal display (besides projects) @Input() componentClass:string = ""; //"" or "col-sm-6" for horizontal display (besides projects)
@Input() show='home'; @Input() show='home';
@Input() title='Communities'; @Input() title='Communities';
@ -65,16 +64,6 @@ export class ClaimSelectedContextsComponent {
todayDate = ''; todayDate = '';
nextDate = ''; nextDate = '';
showType(type){
if(type != this.show){
this.show = type;
this.showChange.emit({
value: this.show
});
}
}
removeContext(item:any){ removeContext(item:any){
var index:number =this.contexts.indexOf(item); var index:number =this.contexts.indexOf(item);
if (index > -1) { if (index > -1) {
@ -85,8 +74,5 @@ export class ClaimSelectedContextsComponent {
} }
} }
contextSelected($event) {
// this.showsearch = false;
}
} }

View File

@ -2,12 +2,10 @@ import { NgModule } from '@angular/core';
import { SharedModule } from '../../../shared/shared.module'; import { SharedModule } from '../../../shared/shared.module';
import {ClaimSelectedContextsComponent} from './selectedContexts.component'; import {ClaimSelectedContextsComponent} from './selectedContexts.component';
// import {ClaimContextSearchFormModule} from '../../claim-utils/claimContextSearchForm.module';
@NgModule({ @NgModule({
imports: [ imports: [
SharedModule, SharedModule
// ClaimContextSearchFormModule
], ],
declarations: [ declarations: [
ClaimSelectedContextsComponent ClaimSelectedContextsComponent

View File

@ -72,19 +72,4 @@ export class ClaimSelectedProjectsComponent {
value: this.projects value: this.projects
}); });
} }
showType(type) {
if (type != this.show) {
this.show = type;
this.showChange.emit({
value: this.show
});
}
}
projectSelected($event) {
// this.showsearch = false;
}
} }

View File

@ -4,12 +4,10 @@ import { RouterModule } from '@angular/router';
import { SharedModule } from '../../../shared/shared.module'; import { SharedModule } from '../../../shared/shared.module';
import {ClaimSelectedProjectsComponent} from './selectedProjects.component'; import {ClaimSelectedProjectsComponent} from './selectedProjects.component';
// import {ClaimProjectsSearchFormModule} from '../../claim-utils/claimProjectSearchForm.module';
@NgModule({ @NgModule({
imports: [ imports: [
SharedModule, RouterModule, SharedModule, RouterModule,
// ClaimProjectsSearchFormModule
], ],
declarations: [ declarations: [
ClaimSelectedProjectsComponent ClaimSelectedProjectsComponent

View File

@ -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 ? '...' : '');
}
} }

View File

@ -1,9 +1,9 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {Meta, Title} from '@angular/platform-browser';
import {User} from "../../login/utils/helper.class"; import {User} from "../../login/utils/helper.class";
import {UserManagementService} from "../../services/user-management.service"; import {UserManagementService} from "../../services/user-management.service";
import {LoginErrorCodes} from "../../login/utils/guardHelper.class"; import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'my-claims', selector: 'my-claims',
@ -42,8 +42,14 @@ export class MyClaimsComponent {
constructor(private userManagementService: UserManagementService, private _router: Router) {} constructor(private userManagementService: UserManagementService, private _router: Router) {}
sub;
ngOnDestroy() {
if (this.sub instanceof Subscriber) {
this.sub.unsubscribe();
}
}
ngOnInit() { ngOnInit() {
this.userManagementService.getUserInfo().subscribe(user => { this.sub = this.userManagementService.getUserInfo().subscribe(user => {
this.user = user; this.user = user;
if (!user) { if (!user) {
this._router.navigate(['/user-info'], { this._router.navigate(['/user-info'], {

View File

@ -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 {Injectable} from '@angular/core';
import { import {
Router, Router,
@ -30,7 +30,7 @@ export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
check(community: string, path: string): Observable<boolean> | boolean { check(community: string, path: string): Observable<boolean> | boolean {
let errorCode = LoginErrorCodes.NOT_LOGIN; let errorCode = LoginErrorCodes.NOT_LOGIN;
let email = null; 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) { if (user) {
email = user.email; email = user.email;
if (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || Session.isManager('community', community, user)) { if (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || Session.isManager('community', community, user)) {
@ -38,7 +38,7 @@ export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
} else { } else {
errorCode = LoginErrorCodes.NOT_ADMIN; errorCode = LoginErrorCodes.NOT_ADMIN;
return this.communityService.isCommunityManagerByState(properties, properties['communityAPI'] + community, return this.communityService.isCommunityManagerByState(properties, properties['communityAPI'] + community,
email); email).pipe(take(1));
} }
} else { } else {
return of(false); return of(false);

View File

@ -1,18 +1,14 @@
import {take, tap} from 'rxjs/operators';
import {filter, map, mergeMap} from 'rxjs/operators'; import {Injectable} from '@angular/core';
import { Injectable } from '@angular/core';
import { import {
Router, Router,
CanActivate, CanActivate,
ActivatedRouteSnapshot, ActivatedRouteSnapshot,
RouterStateSnapshot, RouterStateSnapshot,
CanLoad,
Route
} from '@angular/router'; } from '@angular/router';
import {Observable, Subscription} from 'rxjs'; import {Observable, Subscription} from 'rxjs';
import {CommunityService} from '../community/community.service'; import {CommunityService} from '../community/community.service';
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper';
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
@Injectable() @Injectable()
@ -24,11 +20,10 @@ export class ConnectCommunityGuard implements CanActivate {
} }
check(community: string): Observable<boolean> | boolean { check(community: string): Observable<boolean> | boolean {
return this.communityService.isCommunityTypeByState(properties, properties['communityAPI'] + community).pipe(map(isCommunity => { return this.communityService.isCommunityTypeByState(properties, properties['communityAPI'] + community).pipe(take(1), tap(isCommunity => {
if(!isCommunity) { if (!isCommunity) {
this.router.navigate(['errorcommunity']); this.router.navigate(['errorcommunity']);
} }
return isCommunity;
})); }));
} }

View File

@ -1,5 +1,4 @@
import {tap} from 'rxjs/operators';
import {filter, mergeMap} from 'rxjs/operators';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { import {
Router, Router,
@ -25,13 +24,12 @@ export class ConnectRIGuard implements CanActivate, CanLoad {
} }
check(community: string): Observable<boolean> | boolean { check(community: string): Observable<boolean> | boolean {
const obs = this.communityService.isRITypeByState(properties, properties['communityAPI'] + community); return this.communityService.isRITypeByState(properties, properties['communityAPI'] + community).pipe(tap(authorized => {
if (!authorized) {
this.sub = obs.pipe(filter(enabled => !enabled)) this.router.navigate(['errorcommunity']);
.subscribe(() => this.router.navigate(['errorcommunity'])); }
return obs; }));
} }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(route.queryParams['communityId']); return this.check(route.queryParams['communityId']);
} }

View File

@ -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 {Injectable} from '@angular/core';
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, Route} from '@angular/router'; import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, Route} from '@angular/router';
import {Observable, of} from 'rxjs'; import {Observable, of} from 'rxjs';
import {Session} from '../../login/utils/helper.class'; import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {CommunityService} from '../community/community.service'; import {CommunityService} from '../community/community.service';
import {EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper'; import {ConnectHelper} from '../connectHelper';
import {UserManagementService} from "../../services/user-management.service"; import {UserManagementService} from "../../services/user-management.service";
import {SubscribeService} from "../../utils/subscribe/subscribe.service"; import {SubscribeService} from "../../utils/subscribe/subscribe.service";
@ -16,14 +15,13 @@ export class ConnectSubscriberGuard implements CanActivate {
constructor(private router: Router, constructor(private router: Router,
private communityService: CommunityService, private communityService: CommunityService,
private subscribeService: SubscribeService, private subscribeService: SubscribeService,
private userManagementService: UserManagementService, private userManagementService: UserManagementService) {
private propertiesService: EnvironmentSpecificService) {
} }
check(community: string, path: string): Observable<boolean> | boolean { check(community: string, path: string): Observable<boolean> | boolean {
let errorCode = LoginErrorCodes.NOT_LOGIN; let errorCode = LoginErrorCodes.NOT_LOGIN;
let email = null; 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) { if (user) {
errorCode = LoginErrorCodes.NOT_SUBSCRIBER; errorCode = LoginErrorCodes.NOT_SUBSCRIBER;
email = user.email; email = user.email;
@ -34,7 +32,7 @@ export class ConnectSubscriberGuard implements CanActivate {
if (Session.isSubscribedTo('community', community, user)) { if (Session.isSubscribedTo('community', community, user)) {
return of(true); return of(true);
} }
return this.subscribeService.isSubscribedToCommunity(properties, community) return this.subscribeService.isSubscribedToCommunity(properties, community).pipe(take(1));
} else { } else {
return of(false); return of(false);
} }

View File

@ -8,6 +8,8 @@ import {RouterHelper} from "../utils/routerHelper.class";
import {SEOService} from "../sharedComponents/SEO/SEO.service"; import {SEOService} from "../sharedComponents/SEO/SEO.service";
import {Meta, Title} from "@angular/platform-browser"; import {Meta, Title} from "@angular/platform-browser";
import {Breadcrumb} from "../utils/breadcrumbs/breadcrumbs.component"; import {Breadcrumb} from "../utils/breadcrumbs/breadcrumbs.component";
import {properties} from "../../../environments/environment";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'deposit-first-page', selector: 'deposit-first-page',
@ -212,7 +214,6 @@ export class DepositFirstPageComponent {
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass(); @Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
@Input() piwikSiteId = null; @Input() piwikSiteId = null;
piwiksub:any;
@Input() communityId = null; @Input() communityId = null;
@ -226,6 +227,7 @@ export class DepositFirstPageComponent {
public routerHelper:RouterHelper = new RouterHelper(); public routerHelper:RouterHelper = new RouterHelper();
@Input() showBreadcrumb:boolean = false; @Input() showBreadcrumb:boolean = false;
breadcrumbs:Breadcrumb[] = []; breadcrumbs:Breadcrumb[] = [];
subscriptions = [];
constructor (private route: ActivatedRoute, private _piwikService:PiwikService, constructor (private route: ActivatedRoute, private _piwikService:PiwikService,
private helper: HelperService, private helper: HelperService,
private _router: Router, private _router: Router,
@ -235,9 +237,7 @@ export class DepositFirstPageComponent {
ngOnInit() { ngOnInit() {
this.route.data this.properties = properties;
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.url = this.properties.domain+this.properties.baseLink + this._router.url; this.url = this.properties.domain+this.properties.baseLink + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url, false); this.seoService.createLinkForCanonicalURL(this.url, false);
@ -260,28 +260,29 @@ export class DepositFirstPageComponent {
} }
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ 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}); this.breadcrumbs.push({name: 'home', route: '/'}, {name: "Deposit", route: null});
});
} }
public getPageContents() { 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; this.pageContents = contents;
}) }));
} }
public getDivContents() { 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; this.divContents = contents;
}) }));
} }
ngOnDestroy() { ngOnDestroy() {
if(this.piwiksub){ this.subscriptions.forEach(subscription => {
this.piwiksub.unsubscribe(); if (subscription instanceof Subscriber) {
subscription.unsubscribe();
} }
});
} }
private updateDescription(description:string) { private updateDescription(description:string) {

View File

@ -126,7 +126,7 @@ export class SearchDataprovidersToDepositComponent {
// this.searchPage.keywordFields = this.keywordFields; // this.searchPage.keywordFields = this.keywordFields;
// var firstLoad =true; // var firstLoad =true;
// //
// this.sub = this.route.queryParams.subscribe(params => { // this.subscriptions = this.route.queryParams.subscribe(params => {
// this.loadPaging = true; // this.loadPaging = true;
// if(params['page'] && this.searchUtils.page != params['page']) { // if(params['page'] && this.searchUtils.page != params['page']) {
// this.loadPaging = false; // this.loadPaging = false;

View File

@ -9,8 +9,6 @@ import {SearchResultsModule } from '../searchPages/searchUtils/searchResults.mod
import {DataProvidersServiceModule} from '../services/dataProvidersService.module'; import {DataProvidersServiceModule} from '../services/dataProvidersService.module';
import {SearchFormModule} from '../searchPages/searchUtils/searchForm.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 {IsRouteEnabled} from '../error/isRouteEnabled.guard';
import {SearchDataProvidersModule} from "../searchPages/searchDataProviders.module"; import {SearchDataProvidersModule} from "../searchPages/searchDataProviders.module";
import {BreadcrumbsModule} from "../utils/breadcrumbs/breadcrumbs.module"; import {BreadcrumbsModule} from "../utils/breadcrumbs/breadcrumbs.module";
@ -26,7 +24,7 @@ import {BreadcrumbsModule} from "../utils/breadcrumbs/breadcrumbs.module";
declarations: [ declarations: [
SearchDataprovidersToDepositComponent SearchDataprovidersToDepositComponent
], ],
providers:[FreeGuard, IsRouteEnabled], providers:[ IsRouteEnabled],
exports: [ exports: [
SearchDataprovidersToDepositComponent SearchDataprovidersToDepositComponent
] ]

View File

@ -6,6 +6,7 @@ import {EnvProperties} from '../utils/properties/env-properties';
import {ZenodoInformationClass} from "./utils/zenodoInformation.class"; import {ZenodoInformationClass} from "./utils/zenodoInformation.class";
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute} from "@angular/router";
import {ResultPreview} from "../utils/result-preview/result-preview"; import {ResultPreview} from "../utils/result-preview/result-preview";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'deposit-result', selector: 'deposit-result',
@ -26,9 +27,13 @@ export class SearchResultsInDepositComponent {
public errorMessage: string = "No results found"; public errorMessage: string = "No results found";
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass(); @Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
sub;
constructor (private route: ActivatedRoute) {} constructor (private route: ActivatedRoute) {}
ngOnDestroy() {
if (this.sub instanceof Subscriber) {
this.sub.unsubscribe();
}
}
ngOnInit() { ngOnInit() {
if(this.type == "publication") { if(this.type == "publication") {
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications; this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications;
@ -53,7 +58,7 @@ export class SearchResultsInDepositComponent {
this.urlParam = "datasourceId"; this.urlParam = "datasourceId";
} }
this.route.data this.sub = this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;

View File

@ -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 {Location} from '@angular/common';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser'; import {Title, Meta} from '@angular/platform-browser';
import {RESPONSE} from "@nguniversal/express-engine/tokens"; import {RESPONSE} from "@nguniversal/express-engine/tokens";
import {EnvProperties} from "../utils/properties/env-properties";
import {SEOService} from "../sharedComponents/SEO/SEO.service"; import {SEOService} from "../sharedComponents/SEO/SEO.service";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";

View File

@ -1,32 +1,24 @@
import {Observable, Subscription} from 'rxjs';
import {of as observableOf, Observable, Subject, Subscription} from 'rxjs'; import {tap, take} from 'rxjs/operators';
import {map, filter, mergeMap, tap} from 'rxjs/operators';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { import {
Router, Router,
CanActivate, CanActivate,
CanLoad,
ActivatedRouteSnapshot, ActivatedRouteSnapshot,
RouterStateSnapshot, RouterStateSnapshot,
Route, Data Data
} from '@angular/router'; } from '@angular/router';
import { ConfigurationService } from '../utils/configuration/configuration.service'; import { ConfigurationService } from '../utils/configuration/configuration.service';
import { EnvironmentSpecificService} from '../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connect/connectHelper'; import {ConnectHelper} from '../connect/connectHelper';
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {LoginErrorCodes} from "../login/utils/guardHelper.class";
import {of} from 'rxjs';
import {Page} from "../utils/entities/adminTool/page";
@Injectable() @Injectable()
export class IsRouteEnabled implements CanActivate { export class IsRouteEnabled implements CanActivate {
sub: Subscription = null; sub: Subscription = null;
constructor(private router: Router, constructor(private router: Router,
private config: ConfigurationService, private config: ConfigurationService) {}
private propertiesService: EnvironmentSpecificService) {}
// check(data: Data, community: string, path: string): Observable<boolean> | boolean { // check(data: Data, community: string, path: string): Observable<boolean> | boolean {
// const customRedirect = data['redirect']; // const customRedirect = data['redirect'];
@ -72,27 +64,16 @@ export class IsRouteEnabled implements CanActivate {
community = properties.adminToolsCommunity; community = properties.adminToolsCommunity;
} }
const obs = return this.config.isPageEnabledByState(properties, community, '/'+path).pipe(take(1),tap((enabled) => {
//this.config.isPageEnabled(properties, community, '/' + path); if(!enabled){
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}}); this.router.navigate([redirect], {queryParams: {'page': path}});
}); }
}));
return obs;
} }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(route.data, route.queryParams['communityId'], state.url); return this.check(route.data, route.queryParams['communityId'], state.url);
} }
canDeactivate() {
if(this.sub) {
this.sub.unsubscribe();
}
return true;
}
} }

View File

@ -159,13 +159,13 @@ export class AnnotationComponent implements OnInit, OnDestroy {
if(!this.annotations || this.annotations.length === 0) { if(!this.annotations || this.annotations.length === 0) {
this.loading = true; 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 = annotations;
this.annotations.forEach(annotation => { this.annotations.forEach(annotation => {
annotation.urlSize = 3; annotation.urlSize = 3;
}); });
this.loading = false; this.loading = false;
}); }));
} }
ngOnDestroy(): void { ngOnDestroy(): void {

View File

@ -3,8 +3,6 @@ import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs"; import {Observable} from "rxjs";
import {EnvProperties} from "../../utils/properties/env-properties"; import {EnvProperties} from "../../utils/properties/env-properties";
import {map} from "rxjs/operators"; import {map} from "rxjs/operators";
import {response} from "express";
import {el} from "@angular/platform-browser/testing/src/browser_util";
export interface Annotation { export interface Annotation {
text: string; text: string;

View File

@ -1,4 +1,3 @@
import {merge as observableMerge} from 'rxjs';
import {Component, Input, ViewChild} from '@angular/core'; import {Component, Input, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Meta, Title} from '@angular/platform-browser'; 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 {ResultPreview} from "../../utils/result-preview/result-preview";
import {IndexInfoService} from "../../utils/indexInfo.service"; import {IndexInfoService} from "../../utils/indexInfo.service";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {Subscriber} from "rxjs";
@Component({ @Component({
@ -44,10 +44,6 @@ export class DataProviderComponent {
public errorMessage = ""; public errorMessage = "";
public showLoading: boolean = true; public showLoading: boolean = true;
// Variable to specify requests with either collectedFrom or hostedBy
public paramsForSearchLink = {};
public resultParamsForSearchLink = {};
// Metrics tab variables // Metrics tab variables
public metricsClicked: boolean; public metricsClicked: boolean;
public viewsFrameUrl: string; public viewsFrameUrl: string;
@ -58,11 +54,6 @@ export class DataProviderComponent {
// Statistics tab variables // Statistics tab variables
public statsClicked: boolean = false; public statsClicked: boolean = false;
public docsTimelineUrl: string;
public docsTypesUrl: string;
public docsFunderUrl: string;
public dataProjectsUrl: string;
public pubsProjectsUrl: string;
@ViewChild('statisticsModal') statisticsModal; @ViewChild('statisticsModal') statisticsModal;
@ViewChild('relatedDatasourcesModal') relatedDatasourcesModal; @ViewChild('relatedDatasourcesModal') relatedDatasourcesModal;
@ -74,10 +65,6 @@ export class DataProviderComponent {
public fetchOrps: FetchResearchResults; public fetchOrps: FetchResearchResults;
public fetchProjects: FetchProjects; public fetchProjects: FetchProjects;
public fetchDataproviders: FetchDataproviders; public fetchDataproviders: FetchDataproviders;
public fetchAggregatorsPublications: FetchResearchResults;
public fetchAggregatorsDatasets: FetchResearchResults;
public fetchAggregatorsSoftware: FetchResearchResults;
public fetchAggregatorsOrps: FetchResearchResults;
public fetchAggregatorsResults: FetchResearchResults; public fetchAggregatorsResults: FetchResearchResults;
public searchNumber: number = 5; public searchNumber: number = 5;
@ -89,7 +76,6 @@ export class DataProviderComponent {
public activeTab: string = ""; public activeTab: string = "";
public showTabs: boolean = false; public showTabs: boolean = false;
public firstTab: string = "";
public _numberOfTabs: number = 0; public _numberOfTabs: number = 0;
public tabsAreInitialized: boolean = false; public tabsAreInitialized: boolean = false;
@ -123,10 +109,7 @@ export class DataProviderComponent {
public showFeedback: boolean = false; public showFeedback: boolean = false;
public feedbackFields: string [] = ['Name', 'Organizations', 'Country', 'Other']; public feedbackFields: string [] = ['Name', 'Organizations', 'Country', 'Other'];
sub: any; subscriptions = [];
piwiksub: any;
subInfo: any;
relatedDatasourcesSub: any;
properties: EnvProperties = properties; properties: EnvProperties = properties;
constructor(private _dataproviderService: DataProviderService, constructor(private _dataproviderService: DataProviderService,
@ -153,16 +136,16 @@ export class DataProviderComponent {
ngOnInit() { ngOnInit() {
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
if (lastIndexUpdate) { if (lastIndexUpdate) {
this.indexUpdateDate = new Date(lastIndexUpdate); this.indexUpdateDate = new Date(lastIndexUpdate);
} }
}); }));
} }
//this.getDivContents(); //this.getDivContents();
this.getPageContents(); this.getPageContents();
this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url); 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.updateTitle("Content provider");
this.updateDescription(""); this.updateDescription("");
this.datasourceId = data['datasourceId']; this.datasourceId = data['datasourceId'];
@ -180,7 +163,7 @@ export class DataProviderComponent {
} }
HelperFunctions.scroll(); HelperFunctions.scroll();
}); }));
} }
public initializeValues() { public initializeValues() {
@ -205,31 +188,29 @@ export class DataProviderComponent {
} }
private getPageContents() { 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; this.pageContents = contents;
}) }));
} }
private getDivContents() { 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; this.divContents = contents;
}) }));
} }
ngOnDestroy() { ngOnDestroy() {
if (this.sub) { this.subscriptions.forEach(subscription => {
this.sub.unsubscribe(); if (subscription instanceof Subscriber) {
} subscription.unsubscribe();
if (this.piwiksub) {
this.piwiksub.unsubscribe();
}
if (this.subInfo) {
this.subInfo.unsubscribe();
}
if (this.relatedDatasourcesSub) {
this.relatedDatasourcesSub.unsubscribe();
} }
});
this.fetchDatasets.clearSubscriptions();
this.fetchPublications.clearSubscriptions();
this.fetchSoftware.clearSubscriptions();
this.fetchPublications.clearSubscriptions();
this.fetchDataproviders.clearSubscriptions();
this.fetchProjects.clearSubscriptions();
} }
private getDataProviderInfo(id: string) { private getDataProviderInfo(id: string) {
@ -244,7 +225,7 @@ export class DataProviderComponent {
this.showLoading = false; this.showLoading = false;
this.warningMessage = "No valid datasource id"; this.warningMessage = "No valid datasource id";
} else { } else {
this.subInfo = this._dataproviderService.getDataproviderInfo(this.datasourceId, this.properties).subscribe( this.subscriptions.push(this._dataproviderService.getDataproviderInfo(this.datasourceId, this.properties).subscribe(
data => { data => {
this.dataProviderInfo = data; this.dataProviderInfo = data;
this.seoService.createLinkForCanonicalURL(this.properties.domain +this.properties.baseLink + this._router.url); 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.updateTitle(this.dataProviderInfo.title.name);
this.updateDescription("Content provider, " + this.dataProviderInfo.title.name); this.updateDescription("Content provider, " + this.dataProviderInfo.title.name);
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { 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; this.showLoading = false;
@ -284,12 +265,12 @@ export class DataProviderComponent {
this.showLoading = false; this.showLoading = false;
this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToDataProviders); this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToDataProviders);
} }
); ));
} }
} }
private getDataProviderAggregationStatus(originalId: string) { private getDataProviderAggregationStatus(originalId: string) {
this.subInfo = this._dataproviderService.getDataproviderAggregationStatus(originalId, this.properties).subscribe( this.subscriptions.push(this._dataproviderService.getDataproviderAggregationStatus(originalId, this.properties).subscribe(
data => { data => {
this.dataProviderInfo.aggregationStatus = data; this.dataProviderInfo.aggregationStatus = data;
}, },
@ -300,7 +281,7 @@ export class DataProviderComponent {
() => { () => {
this.aggregationStatusIsInitialized = true; this.aggregationStatusIsInitialized = true;
} }
); ));
} }
private updateDescription(description: string) { private updateDescription(description: string) {
@ -340,48 +321,12 @@ export class DataProviderComponent {
this.metricsClicked = false; 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":"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":"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); 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 = "") { public getParamsForSearchLink(type: string = "") {
let resultsBy: string = "";
// if(this.dataProviderInfo.resultsBy == "collectedFrom") {
// resultsBy = "collectedfromdatasourceid"
// } else if (this.dataProviderInfo.resultsBy == "hostedBy") {
// resultsBy = "resulthostingdatasourceid";
// }
if (type) { if (type) {
return this.routerHelper.createQueryParams(['f0', 'fv0', 'f1', 'fv1', 'type', 'qf', 'sortBy'], ["collectedfromdatasourceid", this.datasourceId, "resulthostingdatasourceid,or", this.datasourceId, type, "false", 'resultdateofacceptance,descending']); return this.routerHelper.createQueryParams(['f0', 'fv0', 'f1', 'fv1', 'type', 'qf', 'sortBy'], ["collectedfromdatasourceid", this.datasourceId, "resulthostingdatasourceid,or", this.datasourceId, type, "false", 'resultdateofacceptance,descending']);
@ -391,25 +336,14 @@ export class DataProviderComponent {
} }
private count(page: number, size: number) { 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); this.countPublications(page, size);
//} else if (content == 'datasetsTab') {
this.countDatasets(page, size); this.countDatasets(page, size);
//} else if (content == 'softwareTab') {
this.countSoftware(page, size); this.countSoftware(page, size);
//} else if (content == 'orpsTab') {
this.countOrps(page, size); this.countOrps(page, size);
//} else if (content == 'projectsTab') {
this.countProjects(page, size); this.countProjects(page, size);
//} else if (content == 'datasourcesTab') {
this.countDatasources(page, size); this.countDatasources(page, size);
//}// else if(content=='relatedDatasourcesTab') {
// this.countRelatedDatasources(page, size);
//}
//}
} }
public search(content: string, page: number, size: number) { 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.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 => { data => {
}, },
err => { err => {
@ -570,7 +504,7 @@ export class DataProviderComponent {
this.dataProviderInfo.relatedDatasources = this.fetchAggregatorsResults.results; this.dataProviderInfo.relatedDatasources = this.fetchAggregatorsResults.results;
this.loadingRelatedDatasources = false; this.loadingRelatedDatasources = false;
} }
); ));
this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties); this.fetchAggregatorsResults.getAggregatorResults("results", this.datasourceId, page, size, this.properties);
} else { } else {
@ -582,79 +516,9 @@ export class DataProviderComponent {
} }
private countRelatedDatasources(page: number, size: number) { 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); 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<string, { "name": string, "countPublications": string, "countDatasets": string, "countSoftware": string, "countOrps": string }>();
// }
// 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) { public metricsResults($event) {
this.totalViews = $event.totalViews; this.totalViews = $event.totalViews;
this.totalDownloads = $event.totalDownloads; this.totalDownloads = $event.totalDownloads;
@ -777,73 +641,4 @@ export class DataProviderComponent {
); );
} }
// 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;
// }
} }

View File

@ -5,7 +5,6 @@ import { RouterModule } from '@angular/router';
import {IFrameModule} from '../../utils/iframe.module'; import {IFrameModule} from '../../utils/iframe.module';
import {ErrorMessagesModule} from '../../utils/errorMessages.module'; import {ErrorMessagesModule} from '../../utils/errorMessages.module';
// import { ResultLandingModule } from '../resultLanding.module';
import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module';
import {MetricsModule} from '../landing-utils/metrics/metrics.module'; import {MetricsModule} from '../landing-utils/metrics/metrics.module';
import {LandingModule} from '../landing-utils/landing.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 {ProjectsServiceModule} from '../../services/projectsService.module';
import {SearchResearchResultsServiceModule} from '../../services/searchResearchResultsService.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 {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module'; import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module';
import {ShowPublisherModule} from "../landing-utils/showPublisher.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 RelatedDatasourcesTabComponent, DataProviderComponent, SoftwareTabComponent, OrpsTabComponent
], ],
providers:[ providers:[
DataProviderService, FreeGuard, IsRouteEnabled], DataProviderService],
exports: [ exports: [
DataProviderComponent DataProviderComponent
] ]

View File

@ -1,11 +1,7 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Http, Response,Headers, RequestOptions} from '@angular/http';
import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/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 {DataProviderInfo} from '../../utils/entities/dataProviderInfo';
import{EnvProperties} from '../../utils/properties/env-properties'; import{EnvProperties} from '../../utils/properties/env-properties';
import {map} from "rxjs/operators"; import {map} from "rxjs/operators";

View File

@ -36,6 +36,4 @@ export class OrpsTabComponent {
ngOnInit() { ngOnInit() {
this.linkToSearchOrps = this.properties.searchLinkToAdvancedOrps; this.linkToSearchOrps = this.properties.searchLinkToAdvancedOrps;
} }
ngOnDestroy() {}
} }

View File

@ -37,5 +37,4 @@ export class SoftwareTabComponent {
this.linkToSearchSoftware = this.properties.searchLinkToAdvancedSoftware; this.linkToSearchSoftware = this.properties.searchLinkToAdvancedSoftware;
} }
ngOnDestroy() {}
} }

View File

@ -4,6 +4,7 @@ import {FetchResearchResults} from '../../utils/fetchEntitiesClasses/fetchResear
import {ErrorCodes} from '../../utils/properties/errorCodes'; import {ErrorCodes} from '../../utils/properties/errorCodes';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {StringUtils} from "../../utils/string-utils.class"; import {StringUtils} from "../../utils/string-utils.class";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'statisticsTab', selector: 'statisticsTab',
@ -67,10 +68,11 @@ export class StatisticsTabComponent {
private pubsProjectsUrl:string; private pubsProjectsUrl:string;
public errorCodes:ErrorCodes = new ErrorCodes(); public errorCodes:ErrorCodes = new ErrorCodes();
properties:EnvProperties; properties:EnvProperties;
sub;
constructor (private route: ActivatedRoute) {} constructor (private route: ActivatedRoute) {}
ngOnInit() { ngOnInit() {
this.route.data this.sub = this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
@ -95,5 +97,8 @@ export class StatisticsTabComponent {
}); });
} }
ngOnDestroy() {} ngOnDestroy() {
} if (this.sub instanceof Subscriber) {
this.sub.unsubscribe();
}
}}

View File

@ -19,6 +19,7 @@ import {ProjectInfo} from "../../utils/entities/projectInfo";
import {DataProviderInfo} from "../../utils/entities/dataProviderInfo"; import {DataProviderInfo} from "../../utils/entities/dataProviderInfo";
import {EmailService} from "../../utils/email/email.service"; import {EmailService} from "../../utils/email/email.service";
import {Composer} from "../../utils/email/composer"; import {Composer} from "../../utils/email/composer";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'feedback', selector: 'feedback',
@ -44,11 +45,17 @@ export class FeedbackComponent implements OnInit, OnChanges {
public form: FormGroup; public form: FormGroup;
public url: string = null; public url: string = null;
public recipients: string[] = []; public recipients: string[] = [];
subscriptions =[];
constructor(private fb: FormBuilder, constructor(private fb: FormBuilder,
private emailService: EmailService) { private emailService: EmailService) {
} }
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit(): void { ngOnInit(): void {
if(typeof window !== "undefined") { if(typeof window !== "undefined") {
this.url = window.location.href; this.url = window.location.href;
@ -117,17 +124,17 @@ export class FeedbackComponent implements OnInit, OnChanges {
public sendReport() { public sendReport() {
this.sending = true; 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 => { Composer.composeEmailForFeedback(this.form.value, this.recipients), this.form.get('recaptcha').value).subscribe(sent => {
this.error = !sent; this.error = !sent;
if(sent) { if(sent) {
if(this.form.get('email').value !== '') { 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 => { Composer.composeEmailForUserAfterFeedback([this.form.get('email').value])).subscribe(sent => {
if(sent) { if(sent) {
//console.log('An email has been sent to user ' + this.form.get('email').value); //console.log('An email has been sent to user ' + this.form.get('email').value);
} }
}) }));
} }
this.init(); this.init();
this.sent = true; this.sent = true;
@ -137,6 +144,6 @@ export class FeedbackComponent implements OnInit, OnChanges {
console.log(error); console.log(error);
this.error = true; this.error = true;
this.sending = false; this.sending = false;
}); }));
} }
} }

View File

@ -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 { }

View File

@ -9,6 +9,7 @@ import {ProjectService} from '../project/project.service';
import {PiwikService} from '../../utils/piwik/piwik.service'; import {PiwikService} from '../../utils/piwik/piwik.service';
import {SEOService} from '../../sharedComponents/SEO/SEO.service'; import {SEOService} from '../../sharedComponents/SEO/SEO.service';
import {HelperService} from "../../utils/helper/helper.service"; import {HelperService} from "../../utils/helper/helper.service";
import {Subscriber} from "rxjs";
declare var UIkit: any; declare var UIkit: any;
@ -62,10 +63,7 @@ export class HtmlProjectReportComponent {
public header2: string = ""; public header2: string = "";
public htmlResult: string = ""; public htmlResult: string = "";
public sub: any; subscriptions = [];
piwiksub: any;
public subHTML: any;
public subHTMLInfo: any;
public warningMessage: string = ""; public warningMessage: string = "";
public errorMessage: string = ""; public errorMessage: string = "";
@ -86,7 +84,7 @@ export class HtmlProjectReportComponent {
} }
ngOnInit() { ngOnInit() {
this.route.data this.subscriptions.push(this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
//this.getDivContents(); //this.getDivContents();
@ -94,8 +92,8 @@ export class HtmlProjectReportComponent {
this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url); this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url);
this.seoService.createLinkForCanonicalURL(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']; this.projectId = params['projectId'];
if (params['size'] == parseInt(params['size'], 10)) { if (params['size'] == parseInt(params['size'], 10)) {
@ -136,40 +134,35 @@ export class HtmlProjectReportComponent {
this.warningMessage = "No valid project id"; this.warningMessage = "No valid project id";
} }
} }
}); }));
} }
private getPageContents() { private getPageContents() {
if(this.communityId) { 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; this.pageContents = contents;
}); }));
} }
} }
private getDivContents() { private getDivContents() {
if(this.communityId) { 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; this.divContents = contents;
}); }));
} }
} }
ngOnDestroy() { ngOnDestroy() {
this.sub.unsubscribe(); this.subscriptions.forEach(subscription => {
if (this.piwiksub) { if (subscription instanceof Subscriber) {
this.piwiksub.unsubscribe(); subscription.unsubscribe();
}
if (this.subHTML) {
this.subHTML.unsubscribe();
}
if (this.subHTMLInfo) {
this.subHTMLInfo.unsubscribe();
} }
});
} }
private createHeaders() { private createHeaders() {
this.subHTMLInfo = this._projectService.getHTMLInfo(this.projectId, this.properties).subscribe( this.subscriptions.push(this._projectService.getHTMLInfo(this.projectId, this.properties).subscribe(
data => { data => {
this.createHeader1(data); this.createHeader1(data);
if (data.acronym) { if (data.acronym) {
@ -178,7 +171,7 @@ export class HtmlProjectReportComponent {
this.updateTitle(data.title + " " + this.resultsType + " report"); this.updateTitle(data.title + " " + this.resultsType + " report");
} }
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { 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 => { err => {
@ -186,7 +179,7 @@ export class HtmlProjectReportComponent {
//console.log(err); //console.log(err);
this.createClipboard(); this.createClipboard();
} }
); ));
if (this.resultsType == "publication") { if (this.resultsType == "publication") {
this.header2 += this.totalResults.toLocaleString('en-US') + " publications"; this.header2 += this.totalResults.toLocaleString('en-US') + " publications";
@ -207,7 +200,7 @@ export class HtmlProjectReportComponent {
intro += '</head>'; intro += '</head>';
if (typeof window !== 'undefined') { 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 => { data => {
//let body: string = intro+'<body><h1>'+this.header1+'</h1><h2>'+this.header2+'</h2>'+data+'</body></html>'; //let body: string = intro+'<body><h1>'+this.header1+'</h1><h2>'+this.header2+'</h2>'+data+'</body></html>';
let body: string = intro + '<body><h1>' + this.header1 + '</h1><h2>' + this.header2 + '</h2>'; let body: string = intro + '<body><h1>' + this.header1 + '</h1><h2>' + this.header2 + '</h2>';
@ -238,7 +231,7 @@ export class HtmlProjectReportComponent {
this.errorMessage = 'Service not available'; this.errorMessage = 'Service not available';
this.showLoading = false; this.showLoading = false;
} }
); ));
} }
} }

View File

@ -7,8 +7,6 @@ import { ProjectServiceModule} from '../project/projectService.module';
import {HtmlProjectReportService} from './htmlProjectReport.service'; import {HtmlProjectReportService} from './htmlProjectReport.service';
import {HtmlProjectReportComponent} from './htmlProjectReport.component'; 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 {PiwikServiceModule} from '../../utils/piwik/piwikService.module';
import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module'; import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module';
import {HelperModule} from "../../utils/helper/helper.module"; import {HelperModule} from "../../utils/helper/helper.module";
@ -23,7 +21,7 @@ import {RouterModule} from '@angular/router';
HtmlProjectReportComponent HtmlProjectReportComponent
], ],
providers:[ providers:[
HtmlProjectReportService, FreeGuard HtmlProjectReportService
], ],
exports: [ exports: [
HtmlProjectReportComponent HtmlProjectReportComponent

View File

@ -21,12 +21,16 @@ declare var addthis: addthis;
` `
}) })
export class AddThisComponent implements OnInit { export class AddThisComponent implements OnInit {
sub;
constructor(private route: ActivatedRoute, @Inject(DOCUMENT) private document, private rendererFactory: RendererFactory2) {} constructor(private route: ActivatedRoute, @Inject(DOCUMENT) private document, private rendererFactory: RendererFactory2) {}
ngOnDestroy() {
if(this.sub) {
this.sub.unsubscribe();
}
}
ngOnInit() { ngOnInit() {
this.route.queryParams.subscribe(data => { this.sub = this.route.queryParams.subscribe(data => {
try { try {
if (!this.document.getElementById('addThisScript') && typeof document !== 'undefined') { if (!this.document.getElementById('addThisScript') && typeof document !== 'undefined') {
// console.log(" create script AddThis"); // console.log(" create script AddThis");

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,5 @@
import { import {
Component, Component,
ElementRef,
Inject, Inject,
Input, Input,
OnDestroy, OnDestroy,
@ -8,7 +7,6 @@ import {
RendererFactory2, RendererFactory2,
ViewEncapsulation ViewEncapsulation
} from '@angular/core'; } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {Citation, CitationData} from './citation.class'; import {Citation, CitationData} from './citation.class';
import {ResultLandingInfo} from "../../../utils/entities/resultLandingInfo"; import {ResultLandingInfo} from "../../../utils/entities/resultLandingInfo";
import {DOCUMENT} from "@angular/common"; import {DOCUMENT} from "@angular/common";
@ -55,6 +53,7 @@ export class CiteThisComponent implements OnInit, OnDestroy {
public citeproc; public citeproc;
public data; public data;
public clipboard; public clipboard;
timeout;
constructor( @Inject(DOCUMENT) private document, private rendererFactory: RendererFactory2){ 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.setAttribute(script, "type", "text/javascript");
renderer.appendChild(head, script); renderer.appendChild(head, script);
} }
setTimeout(() => { this.timeout = setTimeout(() => {
this.parseData(); this.parseData();
this.selectedStyle = this.citation.templates[0]; this.selectedStyle = this.citation.templates[0];
this.updateCitation(); this.updateCitation();
@ -92,6 +91,7 @@ export class CiteThisComponent implements OnInit, OnDestroy {
ngOnDestroy() { ngOnDestroy() {
delete this.clipboard; delete this.clipboard;
clearTimeout(this.timeout);
} }
private createClipboard() { private createClipboard() {

View File

@ -8,8 +8,6 @@ import {ErrorCodes} from '../../utils/properties/errorCodes';
import {StringUtils} from '../../utils/string-utils.class'; import {StringUtils} from '../../utils/string-utils.class';
import {RouterHelper} from '../../utils/routerHelper.class'; import {RouterHelper} from '../../utils/routerHelper.class';
import {EnvProperties} from '../../utils/properties/env-properties'; 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"; import {AlertModal} from "../../utils/modal/alert";
@Component({ @Component({

View File

@ -4,8 +4,6 @@ import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import {PagingModule} from '../../utils/paging.module'; import {PagingModule} from '../../utils/paging.module';
//import {ShowAuthorsComponent} from './showAuthors.component';
import {ShowIdentifiersComponent} from './showIdentifiers.component'; import {ShowIdentifiersComponent} from './showIdentifiers.component';
import {ShowSubjectsComponent} from './showSubjects.component'; import {ShowSubjectsComponent} from './showSubjects.component';
import {FundedByComponent} from './fundedBy.component'; import {FundedByComponent} from './fundedBy.component';

View File

@ -44,18 +44,6 @@ export class ShowTitleComponent {
@Input() iconClass:string; @Input() iconClass:string;
@Input() classNames: string = ""; @Input() classNames: string = "";
sub: any; constructor () {}
constructor (private route: ActivatedRoute) {}
ngOnInit() {
this.sub = this.route.queryParams.subscribe(
params => {
}
);
}
ngOnDestroy() {
this.sub.unsubscribe();
}
} }

View File

@ -1,6 +1,5 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {RouterHelper} from '../../utils/routerHelper.class'; import {RouterHelper} from '../../utils/routerHelper.class';
//import {PagingModule} from '../utils/paging.module';
import{EnvProperties} from '../../utils/properties/env-properties'; import{EnvProperties} from '../../utils/properties/env-properties';
@Component({ @Component({

View File

@ -1,4 +1,4 @@
import {Component, ViewChild} from '@angular/core'; import {Component} from '@angular/core';
import {ElementRef, Input} from '@angular/core'; import {ElementRef, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
@ -8,9 +8,9 @@ import {RouterHelper} from '../../../utils/routerHelper.class';
import {ErrorCodes} from '../../../utils/properties/errorCodes'; import {ErrorCodes} from '../../../utils/properties/errorCodes';
import {OrganizationsDeletedByInferenceService} from './deletedByInference.service'; import {OrganizationsDeletedByInferenceService} from './deletedByInference.service';
import {ResultLandingInfo} from "../../../utils/entities/resultLandingInfo";
import {ResultPreview} from "../../../utils/result-preview/result-preview"; import {ResultPreview} from "../../../utils/result-preview/result-preview";
import {AlertModal} from "../../../utils/modal/alert"; import {AlertModal} from "../../../utils/modal/alert";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'organizationsDeletedByInference', selector: 'organizationsDeletedByInference',
@ -48,36 +48,40 @@ export class OrganizationsDeletedByInferenceComponent {
public routerHelper:RouterHelper = new RouterHelper(); public routerHelper:RouterHelper = new RouterHelper();
public errorCodes:ErrorCodes = new ErrorCodes(); public errorCodes:ErrorCodes = new ErrorCodes();
sub: any; subscriptions = [];
properties:EnvProperties; properties:EnvProperties;
constructor ( private element: ElementRef, constructor ( private element: ElementRef,
private _deletedByInferenceService: OrganizationsDeletedByInferenceService, private _deletedByInferenceService: OrganizationsDeletedByInferenceService,
private route: ActivatedRoute, private route: ActivatedRoute) {
private _router: Router) {
} }
ngOnInit() { ngOnInit() {
this.route.data this.subscriptions.push(this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
}); }));
this.sub = this.route.queryParams.subscribe(data => { this.subscriptions.push(this.route.queryParams.subscribe(data => {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
this.getDeletedByInference(); this.getDeletedByInference();
}); }));
} }
ngOnDestroy() {} ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
getDeletedByInference() { getDeletedByInference() {
this.results = []; this.results = [];
this.status = this.errorCodes.LOADING; 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 => { data => {
this.results = data; this.results = data;
this.status = this.errorCodes.DONE; this.status = this.errorCodes.DONE;
@ -91,7 +95,7 @@ export class OrganizationsDeletedByInferenceComponent {
this.status = this.errorCodes.NOT_AVAILABLE; this.status = this.errorCodes.NOT_AVAILABLE;
} }
} }
); ));
} }
public getResultPreview(result: OrganizationInfo): ResultPreview { public getResultPreview(result: OrganizationInfo): ResultPreview {

View File

@ -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 { }

View File

@ -22,6 +22,7 @@ import {Location} from "@angular/common";
import {FetchResearchResults} from "../../utils/fetchEntitiesClasses/fetchResearchResults.class"; import {FetchResearchResults} from "../../utils/fetchEntitiesClasses/fetchResearchResults.class";
import {FetchDataproviders} from "../../utils/fetchEntitiesClasses/fetchDataproviders.class"; import {FetchDataproviders} from "../../utils/fetchEntitiesClasses/fetchDataproviders.class";
import {IndexInfoService} from "../../utils/indexInfo.service"; import {IndexInfoService} from "../../utils/indexInfo.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'organization', selector: 'organization',
@ -63,10 +64,6 @@ export class OrganizationComponent {
// Active tab variable for responsiveness // Active tab variable for responsiveness
public activeTab: string = ""; public activeTab: string = "";
public firstTab: string = "";
public _numberOfTabs: number = 0;
public tabsAreInitialized: boolean = false;
@ViewChild('downloadReportModal') downloadReportModal; @ViewChild('downloadReportModal') downloadReportModal;
@ViewChild('downloadFunderReportModal') downloadFunderReportModal; @ViewChild('downloadFunderReportModal') downloadFunderReportModal;
@ -93,14 +90,7 @@ export class OrganizationComponent {
public funder: any = ""; public funder: any = "";
private funderId: string; private funderId: string;
private funderCount: number; private funderCount: number;
sub: any; subscriptions = [];
infoSub: any;
piwiksub: any;
downloadFileSub: any;
downloadFilePiwikSub: any;
countProjectsSub: any;
countPublSub: any;
downloadProjectPublSub: any;
properties: EnvProperties; properties: EnvProperties;
public indexUpdateDate: Date; public indexUpdateDate: Date;
public showFeedback: boolean = false; public showFeedback: boolean = false;
@ -110,7 +100,6 @@ export class OrganizationComponent {
@ViewChild('projectsModal') projectsModal; @ViewChild('projectsModal') projectsModal;
public deleteByInferenceOpened: boolean = false; public deleteByInferenceOpened: boolean = false;
//private ngUnsubscribe: Subject<void> = new Subject<void>();
constructor(private element: ElementRef, constructor(private element: ElementRef,
private _organizationService: OrganizationService, private _organizationService: OrganizationService,
@ -136,21 +125,21 @@ export class OrganizationComponent {
} }
ngOnInit() { ngOnInit() {
this.route.data this.subscriptions.push(this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
if (lastIndexUpdate) { if (lastIndexUpdate) {
this.indexUpdateDate = new Date(lastIndexUpdate); this.indexUpdateDate = new Date(lastIndexUpdate);
} }
}); }));
} }
//this.getDivContents(); //this.getDivContents();
this.getPageContents(); this.getPageContents();
this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url); 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.organizationInfo = null;
this.updateTitle("Organization"); this.updateTitle("Organization");
this.updateDescription(""); this.updateDescription("");
@ -174,7 +163,7 @@ export class OrganizationComponent {
this.csvParamsTail = '" and relorganizationid exact "' + this.organizationId + '" ))'; this.csvParamsTail = '" and relorganizationid exact "' + this.organizationId + '" ))';
}); }));
this.downloadURLAPI = this.properties.csvAPIURL; 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 + "\"))"; //this.csvAffiliatedPublications = this.downloadURLAPI + "?format=csv&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relorganizationid exact \"" + this.organizationId + "\"))";
@ -184,51 +173,32 @@ export class OrganizationComponent {
private getPageContents() { private getPageContents() {
if(this.communityId) { 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; this.pageContents = contents;
}); }));
} }
} }
private getDivContents() { private getDivContents() {
if(this.communityId) { 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; this.divContents = contents;
}); }));
} }
} }
ngOnDestroy() { ngOnDestroy() {
if (this.sub) { this.subscriptions.forEach(subscription => {
this.sub.unsubscribe(); if (subscription instanceof Subscriber) {
subscription.unsubscribe();
} }
if (this.piwiksub) { });
this.piwiksub.unsubscribe(); this.fetchDatasets.clearSubscriptions();
} this.fetchPublications.clearSubscriptions();
if (this.infoSub) { this.fetchSoftware.clearSubscriptions();
this.infoSub.unsubscribe(); this.fetchPublications.clearSubscriptions();
} this.fetchDataproviders.clearSubscriptions();
if (this.downloadFileSub) { this.fetchProjects.clearSubscriptions();
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();
*/
} }
private getTotalResearchResults() { private getTotalResearchResults() {
@ -320,7 +290,7 @@ export class OrganizationComponent {
this.organizationInfo = null; 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 => { data => {
if (data == null) { if (data == null) {
this.showLoading = false; this.showLoading = false;
@ -340,7 +310,7 @@ export class OrganizationComponent {
((this.organizationInfo.title.name && this.organizationInfo.title.name != this.organizationInfo.name) ? (', ') : '') + ((this.organizationInfo.title.name && this.organizationInfo.title.name != this.organizationInfo.name) ? (', ') : '') +
(this.organizationInfo.name?this.organizationInfo.name:'')); (this.organizationInfo.name?this.organizationInfo.name:''));
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { 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"]; var refineFields: string [] = ["funder"];
@ -368,14 +338,14 @@ export class OrganizationComponent {
this.errorMessage = 'No organization found'; this.errorMessage = 'No organization found';
this.showLoading = false; this.showLoading = false;
} }
); ));
} }
public downloadFile(url: string, filename: string) { public downloadFile(url: string, filename: string) {
this.openLoading(); this.openLoading();
this.setMessageLoading("Downloading CSV file"); this.setMessageLoading("Downloading CSV file");
this.downloadFileSub = this._reportsService.downloadCSVFile(url).subscribe( this.subscriptions.push(this._reportsService.downloadCSVFile(url).subscribe(
data => { data => {
this.closeLoading(); this.closeLoading();
@ -391,7 +361,7 @@ export class OrganizationComponent {
//window.open(window.URL.createObjectURL(data)); //window.open(window.URL.createObjectURL(data));
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { 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 => { err => {
@ -402,7 +372,7 @@ export class OrganizationComponent {
this.confirmOpenCsvError(); this.confirmOpenCsvError();
}/*, }/*,
() => console.log('Completed file download.')*/ () => console.log('Completed file download.')*/
); ));
} }
private downloadFileByFunder() { private downloadFileByFunder() {
@ -419,11 +389,11 @@ export class OrganizationComponent {
let filename: string = 'funder-project-' + this.funderContentType + '-report'; 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 => { data => {
projects = data[1]; projects = data[1];
for (let index = 0; index < projects.length; index++) { 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 => { data => {
//if(data == 0 && title) { // if no publications for this project //if(data == 0 && title) { // if no publications for this project
if (data == 0 && (counter > 1 || title)) { // if no publications for this project if (data == 0 && (counter > 1 || title)) { // if no publications for this project
@ -465,7 +435,7 @@ export class OrganizationComponent {
} }
title = true; title = true;
this.downloadProjectPublSub = this._reportsService.getCSVResponse(url).subscribe( this.subscriptions.push(this._reportsService.getCSVResponse(url).subscribe(
data => { data => {
counter--; counter--;
response[index] = data; response[index] = data;
@ -502,12 +472,12 @@ export class OrganizationComponent {
this.confirmOpenCsvError(); this.confirmOpenCsvError();
}/*, }/*,
() => console.log('Completed file download.')*/ () => console.log('Completed file download.')*/
); ) );
} }
}, },
err => { err => {
this.handleError("Error getting number of publications for project with id: " + projects[index].id, err); this.handleError("Error getting number of publications for project with id: " + projects[index].id, err);
}); }));
} }
}, },
err => { err => {
@ -516,7 +486,7 @@ export class OrganizationComponent {
this.closeLoading(); this.closeLoading();
this.confirmOpenCsvError(); this.confirmOpenCsvError();
} }
); ));
} }
private updateDescription(description: string) { private updateDescription(description: string) {

View File

@ -17,8 +17,7 @@ import {SearchResearchResultsServiceModule} from '../../services/searchResearchR
import {ProjectsServiceModule} from '../../services/projectsService.module'; import {ProjectsServiceModule} from '../../services/projectsService.module';
import {ProjectsInModalModule} from '../landing-utils/projects-in-modal.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 {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
import {SEOServiceModule} from '../../sharedComponents/SEO/SEOService.module'; import {SEOServiceModule} from '../../sharedComponents/SEO/SEOService.module';
import {HelperModule} from "../../utils/helper/helper.module"; import {HelperModule} from "../../utils/helper/helper.module";
@ -51,9 +50,7 @@ import {SearchTabModule} from "../../utils/tabs/contents/search-tab.module";
declarations: [ declarations: [
OrganizationComponent, OrganizationComponent,
], ],
providers: [ providers: [],
FreeGuard, IsRouteEnabled
],
exports: [ exports: [
OrganizationComponent OrganizationComponent
] ]

View File

@ -22,10 +22,10 @@ import {HelperService} from "../../utils/helper/helper.service";
import {Location} from "@angular/common"; import {Location} from "@angular/common";
import {HtmlProjectReportService} from "../htmlProjectReport/htmlProjectReport.service"; import {HtmlProjectReportService} from "../htmlProjectReport/htmlProjectReport.service";
import {StringUtils} from "../../utils/string-utils.class"; import {StringUtils} from "../../utils/string-utils.class";
import {ResultLandingInfo} from "../../utils/entities/resultLandingInfo";
import {ResultPreview} from "../../utils/result-preview/result-preview"; import {ResultPreview} from "../../utils/result-preview/result-preview";
import {SearchResult} from "../../utils/entities/searchResult"; import {SearchResult} from "../../utils/entities/searchResult";
import {IndexInfoService} from "../../utils/indexInfo.service"; import {IndexInfoService} from "../../utils/indexInfo.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'project', selector: 'project',
@ -75,12 +75,7 @@ export class ProjectComponent {
// Active tab variable for responsiveness // Active tab variable for responsiveness
public activeTab: string = ""; public activeTab: string = "";
public firstTab: string = "";
public _numberOfTabs: number = 0;
public tabsAreInitialized: boolean = false;
@ViewChild('statisticsModal') statisticsModal; @ViewChild('statisticsModal') statisticsModal;
@ViewChild('linkProjectModal') linkProjectModal; @ViewChild('linkProjectModal') linkProjectModal;
@ViewChild('shareResultsModal') shareResultsModal; @ViewChild('shareResultsModal') shareResultsModal;
@ViewChild('downloadReportModal') downloadReportModal; @ViewChild('downloadReportModal') downloadReportModal;
@ -125,15 +120,9 @@ export class ProjectComponent {
public thresholdOrganizations: number = 20; public thresholdOrganizations: number = 20;
public showNumOrganizations: number = 20; public showNumOrganizations: number = 20;
sub: any; subscriptions = [];
piwiksub: any;
infoSub: any;
downloadFilePiwikSub: any;
downloadHtmlFilePiwikSub: any;
properties: EnvProperties; properties: EnvProperties;
public subHTML: any;
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private _router: Router, private _router: Router,
private _location: Location, private _location: Location,
@ -149,22 +138,22 @@ export class ProjectComponent {
private indexInfoService: IndexInfoService) {} private indexInfoService: IndexInfoService) {}
ngOnInit() { ngOnInit() {
this.route.data this.subscriptions.push(this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
if (lastIndexUpdate) { if (lastIndexUpdate) {
this.indexUpdateDate = new Date(lastIndexUpdate); this.indexUpdateDate = new Date(lastIndexUpdate);
} }
}); }));
} }
//this.getDivContents(); //this.getDivContents();
this.getPageContents(); this.getPageContents();
this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url); 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.metricsClicked = false;
this.statsClicked = false; this.statsClicked = false;
this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService); this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService);
@ -200,7 +189,7 @@ export class ProjectComponent {
this.createClipboard(); this.createClipboard();
HelperFunctions.scroll(); HelperFunctions.scroll();
}); }));
} }
public getFileNameType(type: string) { public getFileNameType(type: string) {
@ -227,17 +216,17 @@ export class ProjectComponent {
private getPageContents() { private getPageContents() {
if(this.communityId) { 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; this.pageContents = contents;
}); }));
} }
} }
private getDivContents() { private getDivContents() {
if(this.communityId) { 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; this.divContents = contents;
}); }));
} }
} }
@ -267,21 +256,15 @@ export class ProjectComponent {
} }
ngOnDestroy() { ngOnDestroy() {
if (this.sub) { this.subscriptions.forEach(subscription => {
this.sub.unsubscribe(); if (subscription instanceof Subscriber) {
} subscription.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.fetchDatasets.clearSubscriptions();
this.fetchPublications.clearSubscriptions();
this.fetchSoftware.clearSubscriptions();
this.fetchPublications.clearSubscriptions();
} }
private createClipboard() { private createClipboard() {
@ -344,7 +327,7 @@ export class ProjectComponent {
this.projectInfo = null; this.projectInfo = null;
this.infoSub = this._projectService.getProjectInfo(id, this.properties).subscribe( this.subscriptions.push(this._projectService.getProjectInfo(id, this.properties).subscribe(
data => { data => {
this.projectInfo = data; this.projectInfo = data;
@ -360,7 +343,7 @@ export class ProjectComponent {
this.errorMessage = 'No project found'; this.errorMessage = 'No project found';
this.showLoading = false; this.showLoading = false;
} }
); ));
} }
private getProjectInfoByGrantId(grantId: string, funder: string) { private getProjectInfoByGrantId(grantId: string, funder: string) {
@ -370,7 +353,7 @@ export class ProjectComponent {
this.projectInfo = null; this.projectInfo = null;
this._projectService.getProjectInfoByGrantId(grantId, funder, this.properties).subscribe( this.subscriptions.push(this._projectService.getProjectInfoByGrantId(grantId, funder, this.properties).subscribe(
data => { data => {
this.projectInfo = data; this.projectInfo = data;
@ -389,7 +372,7 @@ export class ProjectComponent {
this.errorMessage = 'No project found'; this.errorMessage = 'No project found';
this.showLoading = false; this.showLoading = false;
} }
); ));
} }
actionsAfterGettingProjectInfo() { actionsAfterGettingProjectInfo() {
@ -401,7 +384,7 @@ export class ProjectComponent {
this.updateTitle(this.projectName); 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:""))); 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')) { 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 = { this.project = {
@ -441,7 +424,7 @@ export class ProjectComponent {
this.openLoading(); this.openLoading();
this.setMessageLoading("Downloading CSV file"); this.setMessageLoading("Downloading CSV file");
this._reportsService.downloadCSVFile(url).subscribe( this.subscriptions.push(this._reportsService.downloadCSVFile(url).subscribe(
data => { data => {
this.closeLoading(); this.closeLoading();
@ -449,7 +432,7 @@ export class ProjectComponent {
this.download(url, filename+".csv"); this.download(url, filename+".csv");
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { 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 => { error => {
@ -460,7 +443,7 @@ export class ProjectComponent {
this.confirmOpenFileDownloadError("CSV"); this.confirmOpenFileDownloadError("CSV");
}/*, }/*,
() => console.log('Completed file download.')*/ () => console.log('Completed file download.')*/
); ));
} }
public metricsResults($event) { public metricsResults($event) {
@ -541,7 +524,7 @@ export class ProjectComponent {
intro += '</head>'; intro += '</head>';
if (typeof window !== 'undefined') { 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 => { data => {
//console.info(data); //console.info(data);
this.htmlResultDownload = intro + '<body><div>' + this.header1 + '</div><div><h4>' + this.header2 + '</h4></div>'; this.htmlResultDownload = intro + '<body><div>' + this.header1 + '</div><div><h4>' + this.header2 + '</h4></div>';
@ -555,7 +538,7 @@ export class ProjectComponent {
this.download(url, filename+".html"); this.download(url, filename+".html");
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { 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 => { err => {
@ -564,7 +547,7 @@ export class ProjectComponent {
this.closeLoading(); this.closeLoading();
this.confirmOpenFileDownloadError("HTML"); this.confirmOpenFileDownloadError("HTML");
} }
); ));
} else { } else {
this.closeLoading(); this.closeLoading();
this.confirmOpenFileDownloadError("HTML"); this.confirmOpenFileDownloadError("HTML");
@ -657,20 +640,6 @@ export class ProjectComponent {
a.remove(); // remove the element 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) { public onSelectActiveTab(activeTabId) {
if(this.activeTab != activeTabId) { // tab really changed if(this.activeTab != activeTabId) { // tab really changed

View File

@ -21,8 +21,6 @@ import {ErrorMessagesModule} from '../../utils/errorMessages.module';
import {HelperModule} from "../../utils/helper/helper.module"; import {HelperModule} from "../../utils/helper/helper.module";
import {IFrameModule} from '../../utils/iframe.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 {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
import {SEOServiceModule} from '../../sharedComponents/SEO/SEOService.module'; import {SEOServiceModule} from '../../sharedComponents/SEO/SEOService.module';
import {FeedbackModule} from "../feedback/feedback.module"; import {FeedbackModule} from "../feedback/feedback.module";
@ -44,7 +42,7 @@ import {SearchTabModule} from "../../utils/tabs/contents/search-tab.module";
ProjectComponent ProjectComponent
], ],
providers:[ providers:[
FreeGuard, IsRouteEnabled, HtmlProjectReportService HtmlProjectReportService
], ],
exports: [ exports: [
ProjectComponent ProjectComponent

View File

@ -1,7 +1,6 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {HttpClient, HttpErrorResponse} from "@angular/common/http"; import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {Observable, throwError} from 'rxjs'; import {throwError} from 'rxjs';
import {ProjectInfo} from '../../utils/entities/projectInfo'; import {ProjectInfo} from '../../utils/entities/projectInfo';

View File

@ -1,4 +1,4 @@
import {Component, ViewChild} from '@angular/core'; import {Component} from '@angular/core';
import {ElementRef, Input} from '@angular/core'; import {ElementRef, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
@ -8,9 +8,9 @@ import {RouterHelper} from '../../../utils/routerHelper.class';
import {ErrorCodes} from '../../../utils/properties/errorCodes'; import {ErrorCodes} from '../../../utils/properties/errorCodes';
import {DeletedByInferenceService} from './deletedByInference.service'; import {DeletedByInferenceService} from './deletedByInference.service';
import {SearchResult} from "../../../utils/entities/searchResult";
import {ResultPreview} from "../../../utils/result-preview/result-preview"; import {ResultPreview} from "../../../utils/result-preview/result-preview";
import {AlertModal} from "../../../utils/modal/alert"; import {AlertModal} from "../../../utils/modal/alert";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'deletedByInference', selector: 'deletedByInference',
@ -49,7 +49,7 @@ export class DeletedByInferenceComponent {
public routerHelper: RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
public errorCodes: ErrorCodes = new ErrorCodes(); public errorCodes: ErrorCodes = new ErrorCodes();
sub: any; subscriptions = [];
properties: EnvProperties; properties: EnvProperties;
constructor(private element: ElementRef, constructor(private element: ElementRef,
@ -59,26 +59,31 @@ export class DeletedByInferenceComponent {
} }
ngOnInit() { ngOnInit() {
this.route.data this.subscriptions.push(this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
}); }));
this.sub = this.route.queryParams.subscribe(data => { this.subscriptions.push(this.route.queryParams.subscribe(data => {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
this.getDeletedByInference(); this.getDeletedByInference();
}); }));
} }
ngOnDestroy() { ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
} }
getDeletedByInference() { getDeletedByInference() {
this.results = []; this.results = [];
this.status = this.errorCodes.LOADING; 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 => { data => {
this.results = data; this.results = data;
this.status = this.errorCodes.DONE; this.status = this.errorCodes.DONE;
@ -92,7 +97,7 @@ export class DeletedByInferenceComponent {
this.status = this.errorCodes.NOT_AVAILABLE; this.status = this.errorCodes.NOT_AVAILABLE;
} }
} }
); ));
} }
public getResultPreview(result: ResultLandingInfo): ResultPreview { public getResultPreview(result: ResultLandingInfo): ResultPreview {

View File

@ -19,6 +19,7 @@ import {FormBuilder} from "@angular/forms";
import {StringUtils} from "../../utils/string-utils.class"; import {StringUtils} from "../../utils/string-utils.class";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabularies.service"; import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabularies.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
@ -37,7 +38,6 @@ export class ResultLandingComponent {
public deleteByInferenceOpened: boolean = false; public deleteByInferenceOpened: boolean = false;
public resultLandingInfo: ResultLandingInfo; public resultLandingInfo: ResultLandingInfo;
public relatedResults: RelationResult[];
public supplementaryResults: RelationResult[]; public supplementaryResults: RelationResult[];
public relation: string = 'trust'; public relation: string = 'trust';
public id: string; public id: string;
@ -78,7 +78,6 @@ export class ResultLandingComponent {
// Map counting variables // Map counting variables
public bioentitiesNum: number = 0; public bioentitiesNum: number = 0;
public relatedResultsNum: number = 0; public relatedResultsNum: number = 0;
public supplementaryResultsNum: number = 0;
// Message variables // Message variables
public warningMessage = ""; public warningMessage = "";
@ -89,9 +88,7 @@ export class ResultLandingComponent {
public routerHelper: RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
public activeTab: string = null; public activeTab: string = null;
private doi: string; private doi: string;
sub: any; subscriptions = [];
piwiksub: any;
infoSub: any;
properties: EnvProperties = properties; properties: EnvProperties = properties;
public indexUpdateDate: Date; public indexUpdateDate: Date;
public pageContents = null; public pageContents = null;
@ -121,16 +118,16 @@ export class ResultLandingComponent {
ngOnInit() { ngOnInit() {
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
if (lastIndexUpdate) { if (lastIndexUpdate) {
this.indexUpdateDate = new Date(lastIndexUpdate); this.indexUpdateDate = new Date(lastIndexUpdate);
} }
}); }));
} }
//this.getDivContents(); //this.getDivContents();
this.getPageContents(); this.getPageContents();
this.updateUrl(this.properties.domain +this.properties.baseLink + this._router.url); 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; this.resultLandingInfo = null;
if (data['articleId']) { if (data['articleId']) {
this.type = "publication"; 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.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(); this.scroll();
}); }));
} }
private getPageContents() { private getPageContents() {
if (this.communityId) { 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; this.pageContents = contents;
}); }));
} }
} }
private getDivContents() { private getDivContents() {
if (this.communityId) { 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; this.divContents = contents;
}); }));
} }
} }
ngOnDestroy() { ngOnDestroy() {
if (this.sub) { this.subscriptions.forEach(subscription => {
this.sub.unsubscribe(); if (subscription instanceof Subscriber) {
} subscription.unsubscribe();
if (this.piwiksub) {
this.piwiksub.unsubscribe();
}
if (this.infoSub) {
this.infoSub.unsubscribe();
} }
});
this._vocabulariesService.clearSubscriptions();
} }
public getTypeName(): string { public getTypeName(): string {
@ -244,14 +238,14 @@ export class ResultLandingComponent {
} }
private getOpenCitations() { private getOpenCitations() {
this._resultLaningService.getOpenCitations(this.id, this.properties).subscribe( this.subscriptions.push(this._resultLaningService.getOpenCitations(this.id, this.properties).subscribe(
data => { data => {
this.resultLandingInfo.openCitations = data[1]; this.resultLandingInfo.openCitations = data[1];
}, },
err => { err => {
this.handleError("Error getting open citation for " + this.type + " with id: " + this.id, err); this.handleError("Error getting open citation for " + this.type + " with id: " + this.id, err);
} }
); ));
} }
private getProvenanceVocabularyAndResultLandingInfo() { private getProvenanceVocabularyAndResultLandingInfo() {
@ -262,14 +256,14 @@ export class ResultLandingComponent {
this.resultLandingInfo = null; this.resultLandingInfo = null;
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
this._vocabulariesService.getProvenanceActionVocabulary(this.properties).subscribe( this.subscriptions.push(this._vocabulariesService.getProvenanceActionVocabulary(this.properties).subscribe(
provenanceActionVocabulary => { provenanceActionVocabulary => {
this.getResultLandingInfo(provenanceActionVocabulary); this.getResultLandingInfo(provenanceActionVocabulary);
}, err => { }, err => {
this.getResultLandingInfo(null); this.getResultLandingInfo(null);
this.handleError("Error getting provenance action vocabulary for " + this.type + " with id: " + this.id, err); this.handleError("Error getting provenance action vocabulary for " + this.type + " with id: " + this.id, err);
} }
); ));
} else { } else {
this.getResultLandingInfo(null); this.getResultLandingInfo(null);
} }
@ -315,7 +309,7 @@ export class ResultLandingComponent {
// } // }
private getResultLandingInfo(provenanceActionVocabulary: any) { 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 => { data => {
this.resultLandingInfo = data; this.resultLandingInfo = data;
if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType 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))); this.updateDescription((this.resultLandingInfo.description ? (this.resultLandingInfo.description) : ("," + this.resultLandingInfo.title)));
} }
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { 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; let bioentitiesNum = 0;
@ -344,11 +338,11 @@ export class ResultLandingComponent {
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
if (this.resultLandingInfo.identifiers != undefined && this.resultLandingInfo.identifiers.has('doi')) { if (this.resultLandingInfo.identifiers != undefined && this.resultLandingInfo.identifiers.has('doi')) {
this.doi = this.resultLandingInfo.identifiers.get('doi')[0]; 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; this.hasAltMetrics = hasAltMetrics;
}, error => { }, error => {
this.hasAltMetrics = false; this.hasAltMetrics = false;
}); }));
} }
} }
this.showLoading = false; this.showLoading = false;
@ -371,7 +365,7 @@ export class ResultLandingComponent {
this.showLoading = false; this.showLoading = false;
this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink + this.linkToSearchPage); this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink + this.linkToSearchPage);
} }
); ));
} }
public metricsResults($event) { public metricsResults($event) {

View File

@ -11,8 +11,6 @@ import {IFrameModule} from '../../utils/iframe.module';
import {AltMetricsModule} from '../../utils/altmetrics.module'; import {AltMetricsModule} from '../../utils/altmetrics.module';
import {PagingModule} from '../../utils/paging.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 {ResultLandingService} from './resultLanding.service';
import {ResultLandingComponent} from './resultLanding.component'; import {ResultLandingComponent} from './resultLanding.component';
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
@ -42,7 +40,7 @@ import {LoadingModule} from "../../utils/loading/loading.module";
ResultLandingComponent ResultLandingComponent
], ],
providers: [ providers: [
ResultLandingService, FreeGuard, IsRouteEnabled ResultLandingService
], ],
exports: [ exports: [
ResultLandingComponent ResultLandingComponent

View File

@ -4,7 +4,7 @@ import {throwError} from 'rxjs';
import {ResultLandingInfo} from '../../utils/entities/resultLandingInfo'; import {ResultLandingInfo} from '../../utils/entities/resultLandingInfo';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {ParsingFunctions} from '../landing-utils/parsingFunctions.class'; 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 {HostedByCollectedFrom, Organization} from "../../utils/result-preview/result-preview";
import {Dates} from "../../utils/string-utils.class"; import {Dates} from "../../utils/string-utils.class";

View File

@ -4,7 +4,7 @@ import {Observable} from 'rxjs';
import {Session} from './utils/helper.class'; import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.class'; import {LoginErrorCodes} from './utils/guardHelper.class';
import {UserManagementService} from "../services/user-management.service"; import {UserManagementService} from "../services/user-management.service";
import {filter, map} from "rxjs/operators"; import {map, tap} from "rxjs/operators";
@Injectable() @Injectable()
export class AdminLoginGuard implements CanActivate { export class AdminLoginGuard implements CanActivate {
@ -15,21 +15,22 @@ export class AdminLoginGuard implements CanActivate {
check(path: string): Observable<boolean> { check(path: string): Observable<boolean> {
let errorCode = LoginErrorCodes.NOT_LOGIN; let errorCode = LoginErrorCodes.NOT_LOGIN;
const obs = this.userManagementService.getUserInfo(false).pipe(map(user => { return this.userManagementService.getUserInfo(false).pipe(map(user => {
if (user) { if (user) {
errorCode = LoginErrorCodes.NOT_ADMIN; errorCode = LoginErrorCodes.NOT_ADMIN;
} }
return Session.isPortalAdministrator(user); return Session.isPortalAdministrator(user);
})); }),tap(isAdmin => {
obs.pipe(filter(isAdmin => !isAdmin)).subscribe(() => { if(!isAdmin) {
this.router.navigate(['/user-info'], { this.router.navigate(['/user-info'], {
queryParams: { queryParams: {
'errorCode': errorCode, 'errorCode': errorCode,
'redirectUrl': path 'redirectUrl': path
} }
}); });
}); }
return obs; }));
} }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {

View File

@ -3,7 +3,7 @@ import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {Session} from './utils/helper.class'; import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.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"; import {UserManagementService} from "../services/user-management.service";
@Injectable() @Injectable()
@ -15,21 +15,21 @@ export class ClaimsCuratorGuard implements CanActivate {
check(path: string): Observable<boolean> | boolean { check(path: string): Observable<boolean> | boolean {
let errorCode = LoginErrorCodes.NOT_LOGIN; let errorCode = LoginErrorCodes.NOT_LOGIN;
const obs = this.userManagementService.getUserInfo(false).pipe(map(user => { return this.userManagementService.getUserInfo(false).pipe(map(user => {
if (user) { if (user) {
errorCode = LoginErrorCodes.NOT_ADMIN; errorCode = LoginErrorCodes.NOT_ADMIN;
} }
return Session.isClaimsCurator(user) || Session.isPortalAdministrator(user); return Session.isClaimsCurator(user) || Session.isPortalAdministrator(user);
})); }),tap(isAdmin => {
obs.pipe(filter(isAdmin => !isAdmin)).subscribe(() => { if(!isAdmin) {
this.router.navigate(['/user-info'], { this.router.navigate(['/user-info'], {
queryParams: { queryParams: {
'errorCode': errorCode, 'errorCode': errorCode,
'redirectUrl': path 'redirectUrl': path
} }
}); });
}); }
return obs; }));
} }
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {

View File

@ -4,8 +4,6 @@ import {
CanActivate, CanActivate,
ActivatedRouteSnapshot, ActivatedRouteSnapshot,
RouterStateSnapshot, RouterStateSnapshot,
Route,
CanLoad
} from '@angular/router'; } from '@angular/router';
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {LoginErrorCodes} from './utils/guardHelper.class'; import {LoginErrorCodes} from './utils/guardHelper.class';

View File

@ -3,7 +3,7 @@ import {ActivatedRouteSnapshot, CanActivate, CanLoad, Route, Router, RouterState
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {Session} from './utils/helper.class'; import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.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"; import {UserManagementService} from "../services/user-management.service";
@Injectable() @Injectable()
@ -15,13 +15,18 @@ export class LoginGuard implements CanActivate, CanLoad {
check(path: string): Observable<boolean> | boolean { check(path: string): Observable<boolean> | boolean {
if (Session.isLoggedIn()) { if (Session.isLoggedIn()) {
const obs = this.userManagementService.getUserInfo(false).pipe(map(user => { return this.userManagementService.getUserInfo(false).pipe(map(user => {
return user !== null; return user !== null;
})); }),tap(isLoggedIn => {
obs.pipe(filter(isLoggedIn => !isLoggedIn)).subscribe(() => { if(!isLoggedIn) {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN,'redirectUrl': path}}); this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_LOGIN,
'redirectUrl': path
}
}); });
return obs; }
}));
} else { } else {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, 'redirectUrl':path}}); this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, 'redirectUrl':path}});
return false; return false;

View File

@ -8,6 +8,7 @@ import {RouterHelper} from '../utils/routerHelper.class';
import {EnvProperties} from '../utils/properties/env-properties'; import {EnvProperties} from '../utils/properties/env-properties';
import {UserManagementService} from "../services/user-management.service"; import {UserManagementService} from "../services/user-management.service";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {Subscriber} from "rxjs";
import {StringUtils} from "../utils/string-utils.class"; import {StringUtils} from "../utils/string-utils.class";
@Component({ @Component({
@ -21,8 +22,7 @@ export class UserComponent {
public server: boolean = true; public server: boolean = true;
public errorMessage: string = ""; public errorMessage: string = "";
public password: string = ""; public password: string = "";
private sub: any; private subscriptions = [];
private sublogin: any;
public errorCode: string = ""; public errorCode: string = "";
public redirectUrl: string = ""; public redirectUrl: string = "";
public routerHelper: RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
@ -41,38 +41,37 @@ export class UserComponent {
} }
ngOnInit() { ngOnInit() {
this.route.data this.subscriptions.push(this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
this.loginUrl = this.properties.loginUrl; this.loginUrl = this.properties.loginUrl;
}); }));
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
this.server = false; this.server = false;
this.userManagementsService.getUserInfo().subscribe(user => { this.subscriptions.push(this.userManagementsService.getUserInfo().subscribe(user => {
this.user = user; this.user = user;
this.loggedIn = !!this.user; this.loggedIn = !!this.user;
this.errorMessage = ""; this.errorMessage = "";
this.sub = this.route.queryParams.subscribe(params => { this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.errorCode = params["errorCode"]; this.errorCode = params["errorCode"];
this.redirectUrl = params["redirectUrl"]; this.redirectUrl = params["redirectUrl"];
this.errorMessage = ""; this.errorMessage = "";
if (this.loggedIn && this.errorCode == '1') { if (this.loggedIn && this.errorCode == '1') {
this.redirect(); this.redirect();
} }
}); }));
}); }));
} }
} }
ngOnDestroy() { ngOnDestroy() {
if(this.sub) { this.subscriptions.forEach(subscription => {
this.sub.unsubscribe(); if (subscription instanceof Subscriber) {
} subscription.unsubscribe();
if (this.sublogin) {
this.sublogin.unsubscribe();
} }
});
} }
redirect() { redirect() {

View File

@ -8,15 +8,13 @@ import {UserRoutingModule} from './user-routing.module';
import {UserComponent} from './user.component'; import {UserComponent} from './user.component';
import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard';
import {FreeGuard} from './freeGuard.guard';
import {LoginGuard} from './loginGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, UserRoutingModule, RouterModule CommonModule, FormsModule, UserRoutingModule, RouterModule
], ],
providers: [ providers: [
PreviousRouteRecorder, FreeGuard, LoginGuard PreviousRouteRecorder
], ],
declarations: [ declarations: [
UserComponent UserComponent

View File

@ -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 {ActivatedRoute, NavigationStart, Router} from '@angular/router';
import {Location} from '@angular/common';
import {User, Session} from './utils/helper.class'; import {User, Session} from './utils/helper.class';
import {RouterHelper} from '../utils/routerHelper.class'; import {RouterHelper} from '../utils/routerHelper.class';
import {StringUtils} from '../utils/string-utils.class'; import {StringUtils} from '../utils/string-utils.class';
import {EnvProperties} from '../utils/properties/env-properties';
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {Subscriber} from "rxjs";
// declare var logoutClicked; // declare var logoutClicked;
@Component({ @Component({
@ -180,23 +179,23 @@ export class UserMiniComponent implements OnInit, OnChanges {
@Input() redirectUrl: string; @Input() redirectUrl: string;
@Input() dark: boolean = false; @Input() dark: boolean = false;
search: string = ''; search: string = '';
sub: any; subscriptions = [];
constructor(private router: Router, private route: ActivatedRoute) { constructor(private router: Router, private route: ActivatedRoute) {
this.router.events.forEach(event => { this.subscriptions.push(this.router.events.forEach(event => {
if (event instanceof NavigationStart) { if (event instanceof NavigationStart) {
this.initialize(event.url); this.initialize(event.url);
} }
}); }));
} }
ngOnInit() { ngOnInit() {
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
this.server = false; this.server = false;
} }
this.sub = this.route.queryParams.subscribe(params => { this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.initialize(); this.initialize();
}); }));
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
@ -206,9 +205,11 @@ export class UserMiniComponent implements OnInit, OnChanges {
} }
ngOnDestroy() { ngOnDestroy() {
if (this.sub) { this.subscriptions.forEach(subscription => {
this.sub.unsubscribe(); if (subscription instanceof Subscriber) {
subscription.unsubscribe();
} }
});
} }
initialize(url: string = null) { initialize(url: string = null) {

View File

@ -2,13 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{ReloadComponent} from './reload.component'; import{ReloadComponent} from './reload.component';
import {FreeGuard} from'../login/freeGuard.guard';
import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: ReloadComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } { path: '', component: ReloadComponent, canDeactivate: [PreviousRouteRecorder] }
]) ])
] ]

View File

@ -7,7 +7,6 @@ import{ReloadRoutingModule } from './reload-routing.module';
import{ReloadComponent} from './reload.component'; import{ReloadComponent} from './reload.component';
import {FreeGuard} from'../login/freeGuard.guard';
import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard';
@NgModule({ @NgModule({
@ -20,7 +19,7 @@ import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard'
ReloadComponent ReloadComponent
], ],
providers:[ providers:[
FreeGuard, PreviousRouteRecorder PreviousRouteRecorder
], ],
exports: [ exports: [
ReloadComponent ReloadComponent

View File

@ -172,33 +172,33 @@ export class RoleVerificationComponent implements OnInit, OnDestroy {
public verifyManager() { public verifyManager() {
this.loading = true; 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.loading = false;
this.managerModal.cancel(); this.managerModal.cancel();
this.error = null; this.error = null;
this.userManagementService.getUserInfo(false).subscribe(user => { this.subs.push(this.userManagementService.getUserInfo(false).subscribe(user => {
this.user = user; this.user = user;
this.router.navigate(['/admin/' + this.verification.entity]); this.router.navigate(['/admin/' + this.verification.entity]);
}); }));
}, error => { }, error => {
this.loading = false; this.loading = false;
this.error = 'The verification code is invalid'; this.error = 'The verification code is invalid';
}); }));
} }
public verifyMember() { public verifyMember() {
this.loading = true; 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.loading = false;
this.error = null; this.error = null;
this.userManagementService.getUserInfo(false).subscribe(user => { this.subs.push(this.userManagementService.getUserInfo(false).subscribe(user => {
this.user = user; this.user = user;
this.memberModal.cancel(); this.memberModal.cancel();
}); }));
}, error => { }, error => {
this.loading = false; this.loading = false;
this.error = 'The verification code is invalid'; this.error = 'The verification code is invalid';
}); }));
} }
public reset() { public reset() {

View File

@ -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: `
<advanced-search-page pageTitle="Advanced Search for Content Providers" entityType="dataprovider"
type = "content providers"
[(results)] = "results"
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
[(searchUtils)] = "searchUtils"
[csvParams]="csvParams" csvPath="datasources" simpleSearchLink="/search/find/dataproviders"
[disableForms]="disableForms"
[loadPaging]="loadPaging"
[oldTotalResults]="oldTotalResults" [piwikSiteId]=piwikSiteId
searchFormClass="datasourcesSearchForm">
</advanced-search-page>
`
})
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);
}
}

View File

@ -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 { }

View File

@ -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: `
<advanced-search-page pageTitle="Advanced Search for Organizations" entityType="organization"
type = "organizations"
[(results)] = "results"
[(searchUtils)] = "searchUtils"
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
[csvParams]="csvParams" csvPath="organizations" simpleSearchLink="/search/find/organizations"
[disableForms]="disableForms"
[loadPaging]="loadPaging"
[oldTotalResults]="oldTotalResults" [piwikSiteId]=piwikSiteId
searchFormClass="organizationsSearchForm">
</advanced-search-page>
`
})
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);
}
}

View File

@ -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 { }

View File

@ -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: `
<advanced-search-page pageTitle="Advanced Search for Projects" entityType="project"
type = "projects"
[(results)] = "results"
[(searchUtils)] = "searchUtils"
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
[csvParams]="csvParams" csvPath="projects" simpleSearchLink="/search/find/projects"
[disableForms]="disableForms"
[loadPaging]="loadPaging"
[oldTotalResults]="oldTotalResults" [piwikSiteId]=piwikSiteId
searchFormClass="projectsSearchForm">
</advanced-search-page>
`
})
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);
}
}

View File

@ -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 { }

View File

@ -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: `
<advanced-search-page
pageTitle="Advanced Search for {{ getEntityName(resultType, true, true) | titlecase }}"
[entityType]="resultType"
[type]="getEntityName(resultType, true, true)"
[(results)] = "results"
[(searchUtils)] = "searchUtils"
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
[csvParams]="csvParams" [csvPath]="getEntityName(resultType, true, false)"
[simpleSearchLink]="simpleSearchLink"
[disableForms]="disableForms"
[loadPaging]="loadPaging"
[oldTotalResults]="oldTotalResults"
[(openaireLink)]=openaireLink
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
searchFormClass="publicationsSearchForm"
[(sort)]=sort >
</advanced-search-page>
`
})
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");
}
}
}

View File

@ -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 { }

View File

@ -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: `
<search-page pageTitle="OpenAIRE Content Providers"
formPlaceholderText = "Search for OpenAIRE Content Providers"
type="content providers" entityType="dataprovider" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[baseUrl] = "baseUrl" [showResultCount]=false
[csvParams]="csvParams" csvPath="datasources"
[disableForms]="disableForms"
[tableViewLink]="'/search/content-providers-table'"
searchFormClass="compatibleDatasourcesSearchForm"
[mapUrl]="mapUrl" [mapTooltipType]="'repositories'"
[newQueryButton]="false">
</search-page>
`
})
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);
}
}

View File

@ -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 { }

View File

@ -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: `
<search-page-table pageTitle="OpenAIRE Content Providers Table"
type="content providers" entityType="dataprovider" [filters] = "filters"
[results] = "results" [searchUtils] = "searchUtils"
[columnNames]="columnNames"
[showResultCount]=false
[disableForms]="disableForms"
[enableSearchView]="enableSearchView"
[searchViewLink]="'/search/content-providers'"
searchFormClass="compatibleDatasourcesTableSearchForm"
formPlaceholderText="Search for OpenAIRE Content Providers"
[mapUrl]="mapUrl" [mapTooltipType]="'repositories'">
</search-page-table>
`
})
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<String>();
var value_name = [];
var value_original_id = [];
let i, j;
for(i=0; i<length; i++) {
let resData = Array.isArray(data) ? data[i] : data;
if(resData.countries) {
let length2 = Array.isArray(resData.countries) ? resData.countries.length : 1;
for(j=0; j<length2; j++) {
let datasourceCountry = Array.isArray(resData.countries) ? resData.countries[j] : resData.countries;
if(!countries.has(datasourceCountry)) {
countries.add(datasourceCountry);
value_name.push(datasourceCountry);
value_original_id.push(datasourceCountry.trim());
}
}
}
}
value_names.push(value_name);
value_original_ids.push(value_original_id);
var filters: Filter[] =[];
for(i =0 ; i < filter_names.length;i++){
var values:Value[] = [];
for(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: filter_valueIsExact[i], filterType: "checkbox" };
filters.push(filter);
}
return filters;
}
private handleError(message: string, error) {
console.error("Compatible Content Providers (Repositories) Search Page - Table view: "+message, error);
}
}

View File

@ -1,26 +0,0 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import{SearchCompatibleDataprovidersTableComponent} from './compatibleDataProvidersTable.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: [
SearchCompatibleDataprovidersTableComponent
],
exports: [
SearchCompatibleDataprovidersTableComponent
]
})
export class CompatibleDataProvidersTableModule { }

View File

@ -1,196 +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 {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
import{EnvProperties} from '../../utils/properties/env-properties';
@Component({
selector: 'search-entity-registries',
template: `
<search-page pageTitle="Registries/ Databases"
formPlaceholderText = "Search for Registries/ Databases"
type="content providers" entityType="dataprovider" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[baseUrl] = "baseUrl" [showResultCount]=false
[csvParams]="csvParams" csvPath="datasources"
[disableForms]="disableForms"
[tableViewLink]="'/search/entity-registries-table'"
searchFormClass="entityRegistriesSearchForm"
[mapUrl]="mapUrl" [mapTooltipType]="'registries'"
[newQueryButton]="false">
</search-page>
`
})
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);
}
}

View File

@ -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 { }

View File

@ -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: `
<search-page-table pageTitle="Registries/ Databases"
type="content providers" entityType="dataprovider" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[columnNames]="columnNames"
[showResultCount]=false
[disableForms]="disableForms"
[enableSearchView]="enableSearchView"
[searchViewLink]="'/search/entity-registries'"
searchFormClass="entityRegistriesTableSearchForm"
formPlaceholderText="Search for Registries/ Databases"
[mapUrl]="mapUrl" [mapTooltipType]="'registries'">
</search-page-table>
`
})
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<String>();
var value_name = [];
var value_original_id = [];
let i, j;
for(i=0; i<length; i++) {
let resData = Array.isArray(data) ? data[i] : data;
if(resData.countries) {
let length2 = Array.isArray(resData.countries) ? resData.countries.length : 1;
for(j=0; j<length2; j++) {
let datasourceCountry = Array.isArray(resData.countries) ? resData.countries[j] : resData.countries;
if(!countries.has(datasourceCountry)) {
countries.add(datasourceCountry);
value_name.push(datasourceCountry);
value_original_id.push(datasourceCountry.trim());
}
}
}
}
value_names.push(value_name);
value_original_ids.push(value_original_id);
var filters: Filter[] =[];
for(i =0 ; i < filter_names.length;i++){
var values:Value[] = [];
for(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: filter_valueIsExact[i], filterType: "checkbox" };
filters.push(filter);
}
return filters;
}
private handleError(message: string, error) {
console.error("Entity Registries Search Page - Table view: "+message, error);
}
}

View File

@ -1,24 +0,0 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import{SearchEntityRegistriesTableComponent} from './entityRegistriesTable.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: [
SearchEntityRegistriesTableComponent
],
exports: [
SearchEntityRegistriesTableComponent
]
})
export class EntityRegistriesTableModule { }

View File

@ -1,200 +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 {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
import{EnvProperties} from '../../utils/properties/env-properties';
@Component({
selector: 'search-journals',
template: `
<search-page pageTitle="OpenAIRE Journals"
formPlaceholderText = "Search for OpenAIRE Journals"
type="content providers" entityType="dataprovider" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[baseUrl] = "baseUrl" [showResultCount]=false
[csvParams]="csvParams" csvPath="datasources"
[disableForms]="disableForms"
searchFormClass="journalsSearchForm"
[mapUrl]="mapUrl" [mapTooltipType]="'journals'"
[newQueryButton]="false">
</search-page>
<!--[tableViewLink]="'/search/journals-table'"-->
`
})
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);
}
}

View File

@ -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 { }

View File

@ -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: `
<search-page-table pageTitle="OpenAIRE Journals Table"
type="content providers" entityType="dataprovider" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[columnNames]="columnNames"
[showResultCount]=false
[disableForms]="disableForms"
[enableSearchView]="enableSearchView"
[searchViewLink]="'/search/journals'"
searchFormClass="journalsTableSearchForm"
formPlaceholderText="Search for Journals"
[mapUrl]="mapUrl" [mapTooltipType]="'journals'">
</search-page-table>
`
})
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);
}
}

View File

@ -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 { }

Some files were not shown because too many files have changed in this diff Show More