[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 {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
||||
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
||||
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
|
||||
|
||||
@Component({
|
||||
//changeDetection: ChangeDetectionStrategy.Default,
|
||||
|
@ -54,7 +55,8 @@ export class AppComponent {
|
|||
user: User;
|
||||
|
||||
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) => {
|
||||
if (event instanceof NavigationStart) {
|
||||
// console.log(event.url);
|
||||
|
@ -77,6 +79,7 @@ export class AppComponent {
|
|||
.then(es => {
|
||||
this.propertiesService.setEnvProperties(es);
|
||||
this.properties = this.propertiesService.envSpecific;
|
||||
this.configurationService.initCommunityInformation(this.properties, this.properties.adminToolsCommunity);
|
||||
this.feedbackmail = this.properties.feedbackmail;
|
||||
this.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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 {Location} from '@angular/common';
|
||||
import "rxjs/add/observable/zip";
|
||||
|
@ -27,9 +27,6 @@ import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperCla
|
|||
templateUrl: 'home.component.html',
|
||||
})
|
||||
export class HomeComponent {
|
||||
public piwiksub: any;
|
||||
public subfunders: any;
|
||||
|
||||
// MAX 12 logos in every slide
|
||||
public logos = {
|
||||
"publication": [
|
||||
|
@ -140,9 +137,9 @@ export class HomeComponent {
|
|||
showOrganizations:boolean= false;
|
||||
properties: EnvProperties;
|
||||
public readMore: boolean = false;
|
||||
public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
||||
public subSoft;public subDataLinked; public subSoftLinked;
|
||||
public subOrp;
|
||||
|
||||
subs: Subscription[] = [];
|
||||
|
||||
trelloImg: string = 'trello.svg';
|
||||
trelloImg2: string = 'trello.svg';
|
||||
|
||||
|
@ -185,9 +182,9 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|||
}
|
||||
|
||||
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;
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
public getKeys(obj: {}) {
|
||||
|
@ -207,7 +204,7 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.route.data
|
||||
this.subs.push(this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
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;
|
||||
this._meta.updateTag({content:url},"property='og:url'");
|
||||
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 => {
|
||||
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"];
|
||||
this.getNumbers();
|
||||
// if(this.showDataProviders) {
|
||||
// this.fetchDataproviders.getResultsForHome(this.numResults, this.properties);
|
||||
// }
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting community information", error);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
//this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => {
|
||||
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
||||
if(data) {
|
||||
var showEntity = {};
|
||||
for (var i = 0; i < data['entities'].length; i++) {
|
||||
|
||||
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
|
||||
}
|
||||
this.showPublications = showEntity["publication"];
|
||||
this.showDatasets = showEntity["dataset"];
|
||||
this.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() {
|
||||
if(this.piwiksub){
|
||||
this.piwiksub.unsubscribe();
|
||||
for (let sub of this.subs) {
|
||||
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() {
|
||||
if(this.showPublications){
|
||||
this.subPub = this._searchResearchResultsService.numOfSearchResults("publication", "", this.properties).subscribe(
|
||||
this.subs.push(this._searchResearchResultsService.numOfSearchResults("publication", "", this.properties).subscribe(
|
||||
data => {
|
||||
if(data && data != null && data > 0 ){
|
||||
this.publicationsSize = NumberUtils.roundNumber(data);
|
||||
|
@ -290,10 +264,10 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|||
//console.log(err);
|
||||
this.handleError("Error getting number of publications", err);
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
if(this.showDatasets){
|
||||
this.subData = this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties).subscribe(
|
||||
this.subs.push(this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties).subscribe(
|
||||
data => {
|
||||
if(data && data != null && data > 0 ){
|
||||
this.datasetsSize = NumberUtils.roundNumber(data);
|
||||
|
@ -303,8 +277,8 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|||
//console.log(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 => {
|
||||
if(data && data != null && data > 0 ){
|
||||
this.datasetsLinkedSize = NumberUtils.roundNumber(data);
|
||||
|
@ -314,11 +288,11 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|||
//console.log(err);
|
||||
this.handleError("Error getting number of linkedresearch data", err);
|
||||
}
|
||||
);
|
||||
));
|
||||
|
||||
}
|
||||
if (this.showSoftware) {
|
||||
this.subSoft = this._searchResearchResultsService.numOfSearchResults("software", "", this.properties).subscribe(
|
||||
this.subs.push(this._searchResearchResultsService.numOfSearchResults("software", "", this.properties).subscribe(
|
||||
data => {
|
||||
if (data && data > 0) {
|
||||
this.softwareSize = NumberUtils.roundNumber(data);
|
||||
|
@ -329,8 +303,8 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|||
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 => {
|
||||
if(data && data != null && data > 0 ){
|
||||
this.softwareLinkedSize = NumberUtils.roundNumber(data);
|
||||
|
@ -340,10 +314,10 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|||
//console.log(err);
|
||||
this.handleError("Error getting number of linked software", err);
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
if (this.showOrp) {
|
||||
this.subOrp = this._searchResearchResultsService.numOfSearchResults("other", "", this.properties).subscribe(
|
||||
this.subs.push(this._searchResearchResultsService.numOfSearchResults("other", "", this.properties).subscribe(
|
||||
data => {
|
||||
if (data && data > 0) {
|
||||
this.otherSize = NumberUtils.roundNumber(data);
|
||||
|
@ -354,10 +328,10 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|||
err => {
|
||||
this.handleError("Error getting number of software data", err);
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
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 => {
|
||||
|
||||
|
||||
|
@ -372,10 +346,10 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting 'funder' field results of projects", err);
|
||||
});
|
||||
}));
|
||||
}
|
||||
if(this.showDataProviders){
|
||||
this.subDataPr = this._searchDataprovidersService.numOfSearchDataproviders("", this.properties).subscribe(
|
||||
this.subs.push(this._searchDataprovidersService.numOfSearchDataproviders("", this.properties).subscribe(
|
||||
data => {
|
||||
if(data && data != null && data > 0 ){
|
||||
this.datasourcesSize = NumberUtils.roundNumber(data);
|
||||
|
@ -386,7 +360,7 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
|
|||
//console.log(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 {RefineFieldResultsServiceModule} from '../openaireLibrary/services/refineFieldResultsService.module';
|
||||
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
||||
import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard';
|
||||
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
|
||||
import {Schema2jsonldModule} from '../openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||
|
@ -44,7 +43,7 @@ import {QuickSelectionsModule} from "../openaireLibrary/searchPages/searchUtils/
|
|||
HomeComponent
|
||||
],
|
||||
providers:[
|
||||
FreeGuard, PreviousRouteRecorder, ConfigurationService
|
||||
FreeGuard, PreviousRouteRecorder
|
||||
],
|
||||
exports: [
|
||||
HomeComponent
|
||||
|
|
Loading…
Reference in New Issue