[Trunk | Explore]:
1. app.component.ts: Initialize communityFull info from app component (call configurationService.initCommunityInformation). 2. home.component.ts: Get communityFull info from state (call configurationService.communityInformationState) | Add subscriptions in array to unsubscribe in ngOnDestroy. 3. home.module.ts: Remove ConfigurationService from providers (singleton service, initialized in app component). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@59076 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
23b951fa6d
commit
e9eca1f4f1
|
@ -8,6 +8,7 @@ import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/env
|
||||||
import {Session, User} from './openaireLibrary/login/utils/helper.class';
|
import {Session, User} from './openaireLibrary/login/utils/helper.class';
|
||||||
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
||||||
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
||||||
|
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
//changeDetection: ChangeDetectionStrategy.Default,
|
//changeDetection: ChangeDetectionStrategy.Default,
|
||||||
|
@ -54,7 +55,8 @@ export class AppComponent {
|
||||||
user: User;
|
user: User;
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
||||||
private router: Router, private userManagementService: UserManagementService) {
|
private router: Router, private userManagementService: UserManagementService,
|
||||||
|
private configurationService: ConfigurationService) {
|
||||||
router.events.forEach((event) => {
|
router.events.forEach((event) => {
|
||||||
if (event instanceof NavigationStart) {
|
if (event instanceof NavigationStart) {
|
||||||
// console.log(event.url);
|
// console.log(event.url);
|
||||||
|
@ -77,6 +79,7 @@ export class AppComponent {
|
||||||
.then(es => {
|
.then(es => {
|
||||||
this.propertiesService.setEnvProperties(es);
|
this.propertiesService.setEnvProperties(es);
|
||||||
this.properties = this.propertiesService.envSpecific;
|
this.properties = this.propertiesService.envSpecific;
|
||||||
|
this.configurationService.initCommunityInformation(this.properties, this.properties.adminToolsCommunity);
|
||||||
this.feedbackmail = this.properties.feedbackmail;
|
this.feedbackmail = this.properties.feedbackmail;
|
||||||
this.userManagementService.getUserInfo().subscribe(user => {
|
this.userManagementService.getUserInfo().subscribe(user => {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {Component, Input, Output, EventEmitter, ViewChild, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
|
import {Component, Input, Output, EventEmitter, ViewChild, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable, 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";
|
||||||
|
@ -27,9 +27,6 @@ import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperCla
|
||||||
templateUrl: 'home.component.html',
|
templateUrl: 'home.component.html',
|
||||||
})
|
})
|
||||||
export class HomeComponent {
|
export class HomeComponent {
|
||||||
public piwiksub: any;
|
|
||||||
public subfunders: any;
|
|
||||||
|
|
||||||
// MAX 12 logos in every slide
|
// MAX 12 logos in every slide
|
||||||
public logos = {
|
public logos = {
|
||||||
"publication": [
|
"publication": [
|
||||||
|
@ -140,9 +137,9 @@ export class HomeComponent {
|
||||||
showOrganizations:boolean= false;
|
showOrganizations:boolean= false;
|
||||||
properties: EnvProperties;
|
properties: EnvProperties;
|
||||||
public readMore: boolean = false;
|
public readMore: boolean = false;
|
||||||
public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|
||||||
public subSoft;public subDataLinked; public subSoftLinked;
|
subs: Subscription[] = [];
|
||||||
public subOrp;
|
|
||||||
trelloImg: string = 'trello.svg';
|
trelloImg: string = 'trello.svg';
|
||||||
trelloImg2: string = 'trello.svg';
|
trelloImg2: string = 'trello.svg';
|
||||||
|
|
||||||
|
@ -185,9 +182,9 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getPageContents() {
|
private getPageContents() {
|
||||||
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: {}) {
|
||||||
|
@ -207,7 +204,7 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
this.route.data
|
this.subs.push(this.route.data
|
||||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||||
this.properties = data.envSpecific;
|
this.properties = data.envSpecific;
|
||||||
this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url, false);
|
this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url, false);
|
||||||
|
@ -217,69 +214,46 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||||
var url = this.properties.baseLink+this._router.url;
|
var url = this.properties.baseLink+this._router.url;
|
||||||
this._meta.updateTag({content:url},"property='og:url'");
|
this._meta.updateTag({content:url},"property='og:url'");
|
||||||
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
||||||
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE").subscribe();
|
this.subs.push(this._piwikService.trackView(this.properties, "OpenAIRE").subscribe());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => {
|
//this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => {
|
||||||
var showEntity = {};
|
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
||||||
for(var i=0; i< data['entities'].length; i++){
|
if(data) {
|
||||||
|
var showEntity = {};
|
||||||
showEntity[""+data['entities'][i]["pid"]+""] = data['entities'][i]["isEnabled"];
|
for (var i = 0; i < data['entities'].length; i++) {
|
||||||
}
|
|
||||||
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"];
|
|
||||||
this.getNumbers();
|
|
||||||
// if(this.showDataProviders) {
|
|
||||||
// this.fetchDataproviders.getResultsForHome(this.numResults, this.properties);
|
|
||||||
// }
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
this.handleError("Error getting community information", error);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
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"];
|
||||||
|
this.getNumbers();
|
||||||
|
// if(this.showDataProviders) {
|
||||||
|
// this.fetchDataproviders.getResultsForHome(this.numResults, this.properties);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.handleError("Error getting community information", error);
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
if(this.piwiksub){
|
for (let sub of this.subs) {
|
||||||
this.piwiksub.unsubscribe();
|
sub.unsubscribe();
|
||||||
}
|
}
|
||||||
if(this.subfunders){
|
|
||||||
this.subfunders.unsubscribe();
|
|
||||||
}
|
|
||||||
if(this.subPub){
|
|
||||||
this.subPub.unsubscribe();
|
|
||||||
}
|
|
||||||
if(this.subData){
|
|
||||||
this.subData.unsubscribe();
|
|
||||||
}
|
|
||||||
if(this.subDataLinked){
|
|
||||||
this.subDataLinked.unsubscribe();
|
|
||||||
}
|
|
||||||
if(this.subSoftLinked){
|
|
||||||
this.subSoftLinked.unsubscribe();
|
|
||||||
}
|
|
||||||
// if(this.subProjects){
|
|
||||||
// this.subProjects.unsubscribe();
|
|
||||||
// }
|
|
||||||
// if(this.subOrg){
|
|
||||||
// this.subOrg.unsubscribe();
|
|
||||||
// }
|
|
||||||
if(this.subDataPr){
|
|
||||||
this.subDataPr.unsubscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getNumbers() {
|
private getNumbers() {
|
||||||
if(this.showPublications){
|
if(this.showPublications){
|
||||||
this.subPub = 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);
|
||||||
|
@ -290,10 +264,10 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||||
//console.log(err);
|
//console.log(err);
|
||||||
this.handleError("Error getting number of publications", err);
|
this.handleError("Error getting number of publications", err);
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
if(this.showDatasets){
|
if(this.showDatasets){
|
||||||
this.subData = this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties).subscribe(
|
this.subs.push(this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties).subscribe(
|
||||||
data => {
|
data => {
|
||||||
if(data && data != null && data > 0 ){
|
if(data && data != null && data > 0 ){
|
||||||
this.datasetsSize = NumberUtils.roundNumber(data);
|
this.datasetsSize = NumberUtils.roundNumber(data);
|
||||||
|
@ -303,8 +277,8 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||||
//console.log(err);
|
//console.log(err);
|
||||||
this.handleError("Error getting number of research data", err);
|
this.handleError("Error getting number of research data", err);
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
this.subDataLinked = this._searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties).subscribe(
|
this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties).subscribe(
|
||||||
data => {
|
data => {
|
||||||
if(data && data != null && data > 0 ){
|
if(data && data != null && data > 0 ){
|
||||||
this.datasetsLinkedSize = NumberUtils.roundNumber(data);
|
this.datasetsLinkedSize = NumberUtils.roundNumber(data);
|
||||||
|
@ -314,11 +288,11 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||||
//console.log(err);
|
//console.log(err);
|
||||||
this.handleError("Error getting number of linkedresearch data", err);
|
this.handleError("Error getting number of linkedresearch data", err);
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
if (this.showSoftware) {
|
if (this.showSoftware) {
|
||||||
this.subSoft = this._searchResearchResultsService.numOfSearchResults("software", "", this.properties).subscribe(
|
this.subs.push(this._searchResearchResultsService.numOfSearchResults("software", "", this.properties).subscribe(
|
||||||
data => {
|
data => {
|
||||||
if (data && data > 0) {
|
if (data && data > 0) {
|
||||||
this.softwareSize = NumberUtils.roundNumber(data);
|
this.softwareSize = NumberUtils.roundNumber(data);
|
||||||
|
@ -329,8 +303,8 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||||
err => {
|
err => {
|
||||||
this.handleError("Error getting number of software data", err);
|
this.handleError("Error getting number of software data", err);
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
this.subSoftLinked = this._searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties).subscribe(
|
this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties).subscribe(
|
||||||
data => {
|
data => {
|
||||||
if(data && data != null && data > 0 ){
|
if(data && data != null && data > 0 ){
|
||||||
this.softwareLinkedSize = NumberUtils.roundNumber(data);
|
this.softwareLinkedSize = NumberUtils.roundNumber(data);
|
||||||
|
@ -340,10 +314,10 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||||
//console.log(err);
|
//console.log(err);
|
||||||
this.handleError("Error getting number of linked software", err);
|
this.handleError("Error getting number of linked software", err);
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
if (this.showOrp) {
|
if (this.showOrp) {
|
||||||
this.subOrp = this._searchResearchResultsService.numOfSearchResults("other", "", this.properties).subscribe(
|
this.subs.push(this._searchResearchResultsService.numOfSearchResults("other", "", this.properties).subscribe(
|
||||||
data => {
|
data => {
|
||||||
if (data && data > 0) {
|
if (data && data > 0) {
|
||||||
this.otherSize = NumberUtils.roundNumber(data);
|
this.otherSize = NumberUtils.roundNumber(data);
|
||||||
|
@ -354,10 +328,10 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||||
err => {
|
err => {
|
||||||
this.handleError("Error getting number of software data", err);
|
this.handleError("Error getting number of software data", err);
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
if(this.showProjects){
|
if(this.showProjects){
|
||||||
this.subfunders = this._refineFieldResultsService.getRefineFieldsResultsByEntityName(["funder"],"project", this.properties).subscribe(
|
this.subs.push(this._refineFieldResultsService.getRefineFieldsResultsByEntityName(["funder"],"project", this.properties).subscribe(
|
||||||
data => {
|
data => {
|
||||||
|
|
||||||
|
|
||||||
|
@ -372,10 +346,10 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||||
err => {
|
err => {
|
||||||
//console.log(err);
|
//console.log(err);
|
||||||
this.handleError("Error getting 'funder' field results of projects", err);
|
this.handleError("Error getting 'funder' field results of projects", err);
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
if(this.showDataProviders){
|
if(this.showDataProviders){
|
||||||
this.subDataPr = 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);
|
||||||
|
@ -386,7 +360,7 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||||
//console.log(err);
|
//console.log(err);
|
||||||
this.handleError("Error getting number of content providers", err);
|
this.handleError("Error getting number of content providers", err);
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import { PiwikServiceModule} from '../openaireLibrary/utils/piwik/piwikService.m
|
||||||
import {HelperModule} from '../openaireLibrary/utils/helper/helper.module';
|
import {HelperModule} from '../openaireLibrary/utils/helper/helper.module';
|
||||||
|
|
||||||
import {RefineFieldResultsServiceModule} from '../openaireLibrary/services/refineFieldResultsService.module';
|
import {RefineFieldResultsServiceModule} from '../openaireLibrary/services/refineFieldResultsService.module';
|
||||||
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
|
||||||
import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard';
|
import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard';
|
||||||
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
|
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
|
||||||
import {Schema2jsonldModule} from '../openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module';
|
import {Schema2jsonldModule} from '../openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||||
|
@ -44,7 +43,7 @@ import {QuickSelectionsModule} from "../openaireLibrary/searchPages/searchUtils/
|
||||||
HomeComponent
|
HomeComponent
|
||||||
],
|
],
|
||||||
providers:[
|
providers:[
|
||||||
FreeGuard, PreviousRouteRecorder, ConfigurationService
|
FreeGuard, PreviousRouteRecorder
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
HomeComponent
|
HomeComponent
|
||||||
|
|
Loading…
Reference in New Issue