[Explore | Trunk]: Remove properties resolver subscriptions

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@60774 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2021-04-01 14:40:10 +00:00
parent 85af86976e
commit 743992cd62
3 changed files with 268 additions and 289 deletions

View File

@ -1,35 +1,22 @@
import {Component} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {properties} from "../../../environments/environment";
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'openaire-claims-admin', selector: 'openaire-claims-admin',
template: ` template: `
<claims-admin *ngIf="claimsInfoURL && userInfoURL" [claimsInfoURL]=claimsInfoURL [userInfoURL]="userInfoURL"> <claims-admin *ngIf="claimsInfoURL && userInfoURL" [claimsInfoURL]=claimsInfoURL [userInfoURL]="userInfoURL">
</claims-admin> </claims-admin>
`,
`,
}) })
export class OpenaireClaimsAdminComponent { export class OpenaireClaimsAdminComponent implements OnInit {
claimsInfoURL: string;
claimsInfoURL:string;
userInfoURL: string; userInfoURL: string;
sub;
constructor (private route: ActivatedRoute) { constructor() {
} }
ngOnDestroy() {
if (this.sub instanceof Subscriber) {
this.sub.unsubscribe();
}
}
public ngOnInit() { public ngOnInit() {
this.sub = this.route.data this.claimsInfoURL = properties.claimsInformationLink;
.subscribe((data: { envSpecific: EnvProperties }) => { this.userInfoURL = properties.userInfoUrl;
this.claimsInfoURL = data.envSpecific.claimsInformationLink;
this.userInfoURL = data.envSpecific.userInfoUrl;
});
} }
} }

View File

@ -1,34 +1,24 @@
import {Component} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {properties} from "../../../environments/environment";
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'openaire-my-claims', selector: 'openaire-my-claims',
template: ` template: `
<my-claims *ngIf="userInfoURL && claimsInfoURL" [claimsInfoURL]=claimsInfoURL [userInfoURL]="userInfoURL"> <my-claims *ngIf="userInfoURL && claimsInfoURL" [claimsInfoURL]=claimsInfoURL [userInfoURL]="userInfoURL">
</my-claims> </my-claims>
` `
}) })
export class OpenaireMyClaimsComponent { export class OpenaireMyClaimsComponent implements OnInit {
claimsInfoURL:string; claimsInfoURL: string;
userInfoURL: string; userInfoURL: string;
sub;
constructor (private route: ActivatedRoute) { constructor() {
} }
ngOnDestroy() {
if (this.sub instanceof Subscriber) { public ngOnInit() {
this.sub.unsubscribe(); this.claimsInfoURL = properties.claimsInformationLink;
} this.userInfoURL = properties.userInfoUrl;
} }
public ngOnInit() {
this.sub = this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.claimsInfoURL = data.envSpecific.claimsInformationLink;
this.userInfoURL = data.envSpecific.userInfoUrl;
});
}
} }

View File

@ -3,27 +3,28 @@ import {Subscription} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import "rxjs/add/observable/zip"; import "rxjs/add/observable/zip";
import {Title, Meta} from '@angular/platform-browser'; import {Title, Meta} from '@angular/platform-browser';
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service'; import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
import { SearchDataprovidersService} from '../openaireLibrary/services/searchDataproviders.service'; import {SearchDataprovidersService} from '../openaireLibrary/services/searchDataproviders.service';
import { SearchProjectsService} from '../openaireLibrary/services/searchProjects.service'; import {SearchProjectsService} from '../openaireLibrary/services/searchProjects.service';
import { SearchOrganizationsService} from '../openaireLibrary/services/searchOrganizations.service'; import {SearchOrganizationsService} from '../openaireLibrary/services/searchOrganizations.service';
import { RefineFieldResultsService} from '../openaireLibrary/services/refineFieldResults.service'; import {RefineFieldResultsService} from '../openaireLibrary/services/refineFieldResults.service';
import { SearchFields} from '../openaireLibrary/utils/properties/searchFields'; import {SearchFields} from '../openaireLibrary/utils/properties/searchFields';
import { NumberUtils} from '../openaireLibrary/utils/number-utils.class'; import {NumberUtils} from '../openaireLibrary/utils/number-utils.class';
import { RouterHelper} from '../openaireLibrary/utils/routerHelper.class'; import {RouterHelper} from '../openaireLibrary/utils/routerHelper.class';
import { EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import { ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes'; import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import { SEOService } from '../openaireLibrary/sharedComponents/SEO/SEO.service'; import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service"; import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
import {HelperService} from "../openaireLibrary/utils/helper/helper.service"; import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class"; import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
import {properties} from "../../environments/environment";
@Component({ @Component({
selector: 'home', selector: 'home',
templateUrl: 'home.component.html', templateUrl: 'home.component.html',
}) })
export class HomeComponent { export class HomeComponent {
// MAX 12 logos in every slide // MAX 12 logos in every slide
@ -106,38 +107,38 @@ export class HomeComponent {
] ]
] ]
}; };
public pageTitle = "OpenAIRE"; public pageTitle = "OpenAIRE";
public keyword:string = ""; public keyword: string = "";
public searchFields:SearchFields = new SearchFields(); public searchFields: SearchFields = new SearchFields();
public errorCodes:ErrorCodes = new ErrorCodes(); public errorCodes: ErrorCodes = new ErrorCodes();
public routerHelper:RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
public publicationsSize:any = null; public publicationsSize: any = null;
public datasetsSize:any = null; public datasetsSize: any = null;
public datasetsLinkedSize:any = null; public datasetsLinkedSize: any = null;
public softwareLinkedSize:any = null; public softwareLinkedSize: any = null;
public softwareSize: any = null; public softwareSize: any = null;
public otherSize: any = null; public otherSize: any = null;
public fundersSize:any = null; public fundersSize: any = null;
public projectsSize:any = null; public projectsSize: any = null;
public datasourcesSize:any = null; public datasourcesSize: any = null;
private numResults: number = 2; private numResults: number = 2;
showPublications:boolean= false; showPublications: boolean = false;
showDatasets:boolean= false; showDatasets: boolean = false;
showSoftware: boolean = false; showSoftware: boolean = false;
showOrp: boolean = false; showOrp: boolean = false;
showProjects:boolean= false; showProjects: boolean = false;
showDataProviders:boolean= false; showDataProviders: boolean = false;
showOrganizations:boolean= false; showOrganizations: boolean = false;
properties: EnvProperties; properties: EnvProperties = properties;
public readMore: boolean = false; public readMore: boolean = false;
subs: Subscription[] = []; subs: Subscription[] = [];
resultsQuickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = { resultsQuickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
filter: null, filter: null,
selected: true, selected: true,
@ -147,246 +148,247 @@ export class HomeComponent {
selectedEntity = "all"; selectedEntity = "all";
selectedEntitySimpleUrl; selectedEntitySimpleUrl;
selectedEntityAdvancedUrl; selectedEntityAdvancedUrl;
resultTypes:Filter = {values:[],filterId:"type", countSelectedValues: 0, filterType: 'checkbox', originalFilterId: "", valueIsExact: true, title: "Result Types",filterOperator:"or"}; resultTypes: Filter = {
values: [],
filterId: "type",
countSelectedValues: 0,
filterType: 'checkbox',
originalFilterId: "",
valueIsExact: true,
title: "Result Types",
filterOperator: "or"
};
public pageContents = null; public pageContents = null;
constructor ( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private _router: Router, private _router: Router,
private _searchResearchResultsService: SearchResearchResultsService, private _searchResearchResultsService: SearchResearchResultsService,
private _searchDataprovidersService: SearchDataprovidersService, private _searchDataprovidersService: SearchDataprovidersService,
private _searchProjectsService: SearchProjectsService, private _searchProjectsService: SearchProjectsService,
private _searchOrganizationsService: SearchOrganizationsService, private _searchOrganizationsService: SearchOrganizationsService,
private _refineFieldResultsService:RefineFieldResultsService, private _refineFieldResultsService: RefineFieldResultsService,
private location: Location, private _piwikService:PiwikService, private location: Location, private _piwikService: PiwikService,
private config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService, private config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService,
private helper: HelperService, private router: Router private helper: HelperService
) { ) {
let description = "OpenAIRE Explore: Over 100M of research deduplicated, 170K research software, 11M research data. One of the largest open scholarly records collection worldwide.";
let description = "OpenAIRE Explore: Over 100M of research deduplicated, 170K research software, 11M research data. One of the largest open scholarly records collection worldwide."; let title = "OpenAIRE | Find and Share research";
let title = "OpenAIRE | Find and Share research"; this._title.setTitle(title);
this._meta.updateTag({content: description}, "name='description'");
this._title.setTitle(title); this._meta.updateTag({content: description}, "property='og:description'");
this._meta.updateTag({content:description},"name='description'"); this._meta.updateTag({content: title}, "property='og:title'");
this._meta.updateTag({content:description},"property='og:description'");
this._meta.updateTag({content:title},"property='og:title'");
} }
private getPageContents() { private getPageContents() {
this.subs.push(this.helper.getPageHelpContents(this.properties, 'openaire', this._router.url).subscribe(contents => { this.subs.push(this.helper.getPageHelpContents(this.properties, 'openaire', this._router.url).subscribe(contents => {
this.pageContents = contents; this.pageContents = contents;
})); }));
} }
public getKeys(obj: {}) { public getKeys(obj: {}) {
return Object.keys(obj); return Object.keys(obj);
} }
createRange(number){ createRange(number) {
var items: number[] = []; var items: number[] = [];
for(var i = 1; i <= number; i++){ for (var i = 1; i <= number; i++) {
items.push(i); items.push(i);
} }
return items; return items;
} }
public ceil(num: number) { public ceil(num: number) {
return Math.ceil(num); return Math.ceil(num);
} }
public ngOnInit() { public ngOnInit() {
this.subs.push(this.route.data this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this._router.url, false);
.subscribe((data: { envSpecific: EnvProperties }) => { this.getPageContents();
this.properties = data.envSpecific; if (this.properties != null) {
this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink+this._router.url, false); var url = this.properties.domain + this.properties.baseLink + this._router.url;
this.getPageContents(); this._meta.updateTag({content: url}, "property='og:url'");
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
if(this.properties!=null){ this.subs.push(this._piwikService.trackView(this.properties, "OpenAIRE").subscribe());
var url = this.properties.domain + this.properties.baseLink+this._router.url; }
this._meta.updateTag({content:url},"property='og:url'"); //this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => {
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ this.subs.push(this.config.communityInformationState.subscribe(data => {
this.subs.push(this._piwikService.trackView(this.properties, "OpenAIRE").subscribe()); if (data) {
var showEntity = {};
for (var i = 0; i < data['entities'].length; i++) {
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
}
this.showPublications = showEntity["publication"];
this.showDatasets = showEntity["dataset"];
this.showSoftware = showEntity["software"];
this.showOrp = showEntity["orp"];
this.showProjects = showEntity["project"];
this.showDataProviders = showEntity["datasource"];
this.showOrganizations = showEntity["organization"];
if (this.showPublications) {
this.resultTypes.values.push({name: "Publications", id: "publications", selected: true, number: 0});
}
if (this.showDatasets) {
this.resultTypes.values.push({name: "Research data", id: "datasets", selected: true, number: 0});
}
if (this.showSoftware) {
this.resultTypes.values.push({name: "Software", id: "software", selected: true, number: 0});
}
if (this.showOrp) {
this.resultTypes.values.push({name: "Other research products", id: "other", selected: true, number: 0});
}
this.getNumbers();
} }
},
//this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => { error => {
this.subs.push(this.config.communityInformationState.subscribe(data => { this.handleError("Error getting community information", error);
if(data) { }
var showEntity = {}; ));
for (var i = 0; i < data['entities'].length; i++) { }
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
}
this.showPublications = showEntity["publication"];
this.showDatasets = showEntity["dataset"];
this.showSoftware = showEntity["software"];
this.showOrp = showEntity["orp"];
this.showProjects = showEntity["project"];
this.showDataProviders = showEntity["datasource"];
this.showOrganizations = showEntity["organization"];
if(this.showPublications){
this.resultTypes.values.push({name: "Publications" , id:"publications",selected:true, number:0});
}
if(this.showDatasets){
this.resultTypes.values.push({name: "Research data" , id:"datasets",selected:true, number:0});
}
if(this.showSoftware){
this.resultTypes.values.push({name: "Software" , id:"software",selected:true, number:0});
}
if(this.showOrp){
this.resultTypes.values.push({name: "Other research products" , id:"other",selected:true, number:0});
}
this.getNumbers();
}
},
error => {
this.handleError("Error getting community information", error);
}
));
}
}));
} }
public ngOnDestroy() { public ngOnDestroy() {
for (let sub of this.subs) { for (let sub of this.subs) {
sub.unsubscribe(); sub.unsubscribe();
} }
} }
private getNumbers() { private getNumbers() {
if(this.showPublications){ if (this.showPublications) {
this.subs.push(this._searchResearchResultsService.numOfSearchResults("publication", "", this.properties).subscribe( this.subs.push(this._searchResearchResultsService.numOfSearchResults("publication", "", this.properties).subscribe(
data => { data => {
if(data && data != null && data > 0 ){ if (data && data != null && data > 0) {
this.publicationsSize = NumberUtils.roundNumber(data); this.publicationsSize = NumberUtils.roundNumber(data);
}
},
err => {
//console.log(err);
this.handleError("Error getting number of publications", err);
}
));
}
if(this.showDatasets){
this.subs.push(this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties).subscribe(
data => {
if(data && data != null && data > 0 ){
this.datasetsSize = NumberUtils.roundNumber(data);
}
},
err => {
//console.log(err);
this.handleError("Error getting number of research data", err);
}
));
this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties).subscribe(
data => {
if(data && data != null && data > 0 ){
this.datasetsLinkedSize = NumberUtils.roundNumber(data);
}
},
err => {
//console.log(err);
this.handleError("Error getting number of linkedresearch data", err);
} }
)); },
err => {
} //console.log(err);
if (this.showSoftware) { this.handleError("Error getting number of publications", err);
this.subs.push(this._searchResearchResultsService.numOfSearchResults("software", "", this.properties).subscribe( }
data => { ));
if (data && data > 0) { }
this.softwareSize = NumberUtils.roundNumber(data); if (this.showDatasets) {
}else{ this.subs.push(this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties).subscribe(
this.showSoftware = false; data => {
} if (data && data != null && data > 0) {
}, this.datasetsSize = NumberUtils.roundNumber(data);
err => { }
this.handleError("Error getting number of software data", err); },
} err => {
)); //console.log(err);
this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties).subscribe( this.handleError("Error getting number of research data", err);
data => { }
if(data && data != null && data > 0 ){ ));
this.softwareLinkedSize = NumberUtils.roundNumber(data); this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties).subscribe(
} data => {
}, if (data && data != null && data > 0) {
err => { this.datasetsLinkedSize = NumberUtils.roundNumber(data);
//console.log(err); }
this.handleError("Error getting number of linked software", err); },
} err => {
)); //console.log(err);
} this.handleError("Error getting number of linkedresearch data", err);
if (this.showOrp) { }
this.subs.push(this._searchResearchResultsService.numOfSearchResults("other", "", this.properties).subscribe( ));
data => {
if (data && data > 0) { }
this.otherSize = NumberUtils.roundNumber(data); if (this.showSoftware) {
}else{ this.subs.push(this._searchResearchResultsService.numOfSearchResults("software", "", this.properties).subscribe(
this.showOrp = false; data => {
} if (data && data > 0) {
}, this.softwareSize = NumberUtils.roundNumber(data);
err => { } else {
this.handleError("Error getting number of software data", err); this.showSoftware = false;
} }
)); },
} err => {
if(this.showProjects){ this.handleError("Error getting number of software data", err);
this.subs.push(this._refineFieldResultsService.getRefineFieldsResultsByEntityName(["funder"],"project", this.properties).subscribe( }
data => { ));
this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties).subscribe(
data => {
if(data[0] && data[0] > 0 ){ if (data && data != null && data > 0) {
this.projectsSize = NumberUtils.roundNumber(data[0]); this.softwareLinkedSize = NumberUtils.roundNumber(data);
} }
if(data[1].length > 0 && data[1][0].filterId == "funder" && data[1][0].values ){ },
this.fundersSize = NumberUtils.roundNumber(data[1][0].values.length); err => {
} //console.log(err);
this.handleError("Error getting number of linked software", err);
}, }
err => { ));
//console.log(err); }
this.handleError("Error getting 'funder' field results of projects", err); if (this.showOrp) {
this.subs.push(this._searchResearchResultsService.numOfSearchResults("other", "", this.properties).subscribe(
data => {
if (data && data > 0) {
this.otherSize = NumberUtils.roundNumber(data);
} else {
this.showOrp = false;
}
},
err => {
this.handleError("Error getting number of software data", err);
}
));
}
if (this.showProjects) {
this.subs.push(this._refineFieldResultsService.getRefineFieldsResultsByEntityName(["funder"], "project", this.properties).subscribe(
data => {
if (data[0] && data[0] > 0) {
this.projectsSize = NumberUtils.roundNumber(data[0]);
}
if (data[1].length > 0 && data[1][0].filterId == "funder" && data[1][0].values) {
this.fundersSize = NumberUtils.roundNumber(data[1][0].values.length);
}
},
err => {
//console.log(err);
this.handleError("Error getting 'funder' field results of projects", err);
})); }));
} }
if(this.showDataProviders){ if (this.showDataProviders) {
this.subs.push(this._searchDataprovidersService.numOfSearchDataproviders("", this.properties).subscribe( this.subs.push(this._searchDataprovidersService.numOfSearchDataproviders("", this.properties).subscribe(
data => { data => {
if(data && data != null && data > 0 ){ if (data && data != null && data > 0) {
this.datasourcesSize = NumberUtils.roundNumber(data); this.datasourcesSize = NumberUtils.roundNumber(data);
} }
}, },
err => { err => {
//console.log(err); //console.log(err);
this.handleError("Error getting number of content providers", err); this.handleError("Error getting number of content providers", err);
} }
)); ));
} }
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Home Page: "+message, error); console.error("Home Page: " + message, error);
} }
entityChanged($event){
entityChanged($event) {
this.selectedEntity = $event.entity; this.selectedEntity = $event.entity;
this.selectedEntitySimpleUrl = $event.simpleUrl; this.selectedEntitySimpleUrl = $event.simpleUrl;
this.selectedEntityAdvancedUrl = $event.advancedUrl; this.selectedEntityAdvancedUrl = $event.advancedUrl;
} }
goTo(simple:boolean){
let url = (simple)?this.selectedEntitySimpleUrl:this.selectedEntityAdvancedUrl; goTo(simple: boolean) {
let url = (simple) ? this.selectedEntitySimpleUrl : this.selectedEntityAdvancedUrl;
let parameterNames = []; let parameterNames = [];
let parameterValues = []; let parameterValues = [];
if (this.selectedEntity == "result") { if (this.selectedEntity == "result") {
if (this.resultTypes) { if (this.resultTypes) {
let values = []; let values = [];
for(let value of this.resultTypes.values){ for (let value of this.resultTypes.values) {
if (value.selected) { if (value.selected) {
values.push(value.id); values.push(value.id);
} }
} }
if (values.length > 0 && values.length !=4) { if (values.length > 0 && values.length != 4) {
parameterNames.push("type"); parameterNames.push("type");
parameterValues.push(values.join(",")); parameterValues.push(values.join(","));
} }
@ -395,19 +397,19 @@ export class HomeComponent {
parameterValues.push("" + this.resultsQuickFilter.selected); parameterValues.push("" + this.resultsQuickFilter.selected);
} }
} }
}else if(this.selectedEntity == "all"){ } else if (this.selectedEntity == "all") {
if (this.resultsQuickFilter) { if (this.resultsQuickFilter) {
parameterNames.push("qf"); parameterNames.push("qf");
parameterValues.push("true"); parameterValues.push("true");
} }
} }
if(this.keyword.length > 0) { if (this.keyword.length > 0) {
parameterNames.push("fv0"); parameterNames.push("fv0");
parameterValues.push(this.keyword); parameterValues.push(this.keyword);
parameterNames.push("f0"); parameterNames.push("f0");
parameterValues.push("q"); parameterValues.push("q");
} }
console.log( this.routerHelper.createQueryParams(parameterNames, parameterValues)) console.log(this.routerHelper.createQueryParams(parameterNames, parameterValues))
this._router.navigate([url], {queryParams: this.routerHelper.createQueryParams(parameterNames, parameterValues)}); this._router.navigate([url], {queryParams: this.routerHelper.createQueryParams(parameterNames, parameterValues)});
} }
} }