[Trunk | Connect]:
1. src/main.server.ts: Call enableProdMode when not development environment. 2. package.json: Remove "--sourceMap" flag from server build | Development rules added for server side. 3. angular.json: Development configuration added for server side. 4. app.component.ts: Initialize communityFull info from app component (call configurationService.initCommunityInformation). 5. community.component.ts: Get communityFull info from state (call configurationService.communityInformationState) | Add subscriptions in array to unsubscribe in ngOnDestroy. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@59138 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
988bbc570f
commit
b4df338564
17
angular.json
17
angular.json
|
@ -81,6 +81,17 @@
|
||||||
"with": "src/robots.beta.txt"
|
"with": "src/robots.beta.txt"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"development": {
|
||||||
|
"optimization": true,
|
||||||
|
"outputHashing": "all",
|
||||||
|
"sourceMap": false,
|
||||||
|
"extractCss": true,
|
||||||
|
"namedChunks": false,
|
||||||
|
"aot": true,
|
||||||
|
"extractLicenses": true,
|
||||||
|
"vendorChunk": false,
|
||||||
|
"buildOptimizer": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -95,6 +106,9 @@
|
||||||
},
|
},
|
||||||
"beta": {
|
"beta": {
|
||||||
"browserTarget": "ng-universal-demo:build:beta"
|
"browserTarget": "ng-universal-demo:build:beta"
|
||||||
|
},
|
||||||
|
"development": {
|
||||||
|
"browserTarget": "ng-universal-demo:build:development"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -162,7 +176,8 @@
|
||||||
"with": "src/environments/environment.beta.ts"
|
"with": "src/environments/environment.beta.ts"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
"development": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,18 @@
|
||||||
"start:prerender": "npm run build:prerender && npm run serve:prerender",
|
"start:prerender": "npm run build:prerender && npm run serve:prerender",
|
||||||
"start:ssr-beta": "npm run build:ssr-beta && npm run serve:ssr",
|
"start:ssr-beta": "npm run build:ssr-beta && npm run serve:ssr",
|
||||||
"start:prerender-beta": "npm run build:prerender-beta && npm run serve:prerender",
|
"start:prerender-beta": "npm run build:prerender-beta && npm run serve:prerender",
|
||||||
|
"start:ssr-dev": "npm run build:ssr-dev && npm run serve:ssr",
|
||||||
|
"start:prerender-dev": "npm run build:prerender-dev && npm run serve:prerender",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"build:client-and-server-bundles": "ng build --prod --sourceMap --stats-json=true && ng run ng-universal-demo:server:production",
|
"build:client-and-server-bundles": "ng build --prod --stats-json=true && ng run ng-universal-demo:server:production",
|
||||||
"build:client-and-server-bundles-beta": "ng build --configuration=beta --sourceMap --stats-json=true && ng run ng-universal-demo:server:beta",
|
"build:client-and-server-bundles-beta": "ng build --configuration=beta --stats-json=true && ng run ng-universal-demo:server:beta",
|
||||||
|
"build:client-and-server-bundles-dev": "ng build --configuration=development --stats-json=true && ng run ng-universal-demo:server:development",
|
||||||
"build:prerender": "npm run build:client-and-server-bundles && npm run webpack:server && npm run generate:prerender",
|
"build:prerender": "npm run build:client-and-server-bundles && npm run webpack:server && npm run generate:prerender",
|
||||||
"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
|
"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
|
||||||
"build:prerender-beta": "npm run build:client-and-server-bundles-beta && npm run webpack:server && npm run generate:prerender",
|
"build:prerender-beta": "npm run build:client-and-server-bundles-beta && npm run webpack:server && npm run generate:prerender",
|
||||||
"build:ssr-beta": "npm run build:client-and-server-bundles-beta && npm run webpack:server",
|
"build:ssr-beta": "npm run build:client-and-server-bundles-beta && npm run webpack:server",
|
||||||
|
"build:prerender-dev": "npm run build:client-and-server-bundles-dev && npm run webpack:server && npm run generate:prerender",
|
||||||
|
"build:ssr-dev": "npm run build:client-and-server-bundles-dev && npm run webpack:server",
|
||||||
"generate:prerender": "cd dist && node prerender",
|
"generate:prerender": "cd dist && node prerender",
|
||||||
"webpack:server": "webpack --config webpack.server.config.js --progress --colors",
|
"webpack:server": "webpack --config webpack.server.config.js --progress --colors",
|
||||||
"serve:prerender": "cd dist/browser && http-server",
|
"serve:prerender": "cd dist/browser && http-server",
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
|
||||||
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
|
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
|
||||||
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,
|
||||||
|
@ -81,7 +82,8 @@ export class AppComponent {
|
||||||
// community: {id:string, name:string, logoUrl:string};
|
// community: {id:string, name:string, logoUrl:string};
|
||||||
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
||||||
private _communitiesService: CommunitiesService, private _subscribeService: SubscribeService,
|
private _communitiesService: CommunitiesService, private _subscribeService: SubscribeService,
|
||||||
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) {
|
||||||
HelperFunctions.scroll();
|
HelperFunctions.scroll();
|
||||||
|
@ -103,7 +105,8 @@ export class AppComponent {
|
||||||
this.userManagementService.getUserInfo().subscribe(user => {
|
this.userManagementService.getUserInfo().subscribe(user => {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.init();
|
this.init();
|
||||||
});
|
},
|
||||||
|
error => this.init());
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log("App couldn't fetch properties");
|
console.log("App couldn't fetch properties");
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
@ -117,11 +120,13 @@ export class AppComponent {
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
this.route.queryParams.subscribe(params => {
|
this.route.queryParams.subscribe(params => {
|
||||||
communityId = (params['communityId']) ? params['communityId'] : ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
communityId = (params['communityId']) ? params['communityId'] : ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
||||||
|
this.configurationService.initCommunityInformation(this.properties, communityId);
|
||||||
this.buildMenu(communityId);
|
this.buildMenu(communityId);
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
||||||
|
this.configurationService.initCommunityInformation(this.properties, communityId);
|
||||||
this.buildMenu(communityId);
|
this.buildMenu(communityId);
|
||||||
}
|
}
|
||||||
this.communityId = communityId;
|
this.communityId = communityId;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import {SubscribeComponent} from "../utils/subscribe/subscribe.component";
|
||||||
import {SearchCustomFilter} from "../openaireLibrary/searchPages/searchUtils/searchUtils.class";
|
import {SearchCustomFilter} from "../openaireLibrary/searchPages/searchUtils/searchUtils.class";
|
||||||
import {FetchResearchResults} from "../openaireLibrary/utils/fetchEntitiesClasses/fetchResearchResults.class";
|
import {FetchResearchResults} from "../openaireLibrary/utils/fetchEntitiesClasses/fetchResearchResults.class";
|
||||||
import {ErrorCodes} from "../openaireLibrary/utils/properties/errorCodes";
|
import {ErrorCodes} from "../openaireLibrary/utils/properties/errorCodes";
|
||||||
|
import {Subscription} from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'community',
|
selector: 'community',
|
||||||
|
@ -34,10 +35,6 @@ import {ErrorCodes} from "../openaireLibrary/utils/properties/errorCodes";
|
||||||
export class CommunityComponent {
|
export class CommunityComponent {
|
||||||
public url: string = null;
|
public url: string = null;
|
||||||
|
|
||||||
public sub: any;
|
|
||||||
public piwiksub: any;
|
|
||||||
public subfunders: any;
|
|
||||||
|
|
||||||
// public publicationTotal = null;
|
// public publicationTotal = null;
|
||||||
// public researchDataTotal = null;
|
// public researchDataTotal = null;
|
||||||
// public softwareTotal = null;
|
// public softwareTotal = null;
|
||||||
|
@ -88,10 +85,8 @@ export class CommunityComponent {
|
||||||
subscribers: number = 0;
|
subscribers: number = 0;
|
||||||
|
|
||||||
// TODO Unsubscribe
|
// TODO Unsubscribe
|
||||||
public subPublications;
|
subs: Subscription[] = [];
|
||||||
public subResearchData;
|
|
||||||
public subSoftware;
|
|
||||||
public subOrps;
|
|
||||||
@ViewChild(StatisticsForDashboardComponent) statistics: StatisticsForDashboardComponent = null;
|
@ViewChild(StatisticsForDashboardComponent) statistics: StatisticsForDashboardComponent = null;
|
||||||
public activeTab = "summary";
|
public activeTab = "summary";
|
||||||
public show: string = 'overview';
|
public show: string = 'overview';
|
||||||
|
@ -148,7 +143,7 @@ export class CommunityComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
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.searchLinkToResults = this.properties.searchLinkToResults;
|
this.searchLinkToResults = this.properties.searchLinkToResults;
|
||||||
|
@ -159,9 +154,9 @@ export class CommunityComponent {
|
||||||
this.url = data.envSpecific.baseLink + this._router.url;
|
this.url = data.envSpecific.baseLink + this._router.url;
|
||||||
this.seoService.createLinkForCanonicalURL(this.url, false);
|
this.seoService.createLinkForCanonicalURL(this.url, false);
|
||||||
this._meta.updateTag({content: this.url}, "property='og:url'");
|
this._meta.updateTag({content: this.url}, "property='og:url'");
|
||||||
this.userManagementService.getUserInfo().subscribe(user => {
|
this.subs.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
});
|
}));
|
||||||
if (this.communityId != null && this.communityId != '') {
|
if (this.communityId != null && this.communityId != '') {
|
||||||
this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, "");
|
this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, "");
|
||||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
|
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
|
||||||
|
@ -182,10 +177,10 @@ export class CommunityComponent {
|
||||||
this._meta.updateTag({content: community.title}, "property='og:title'");
|
this._meta.updateTag({content: community.title}, "property='og:title'");
|
||||||
this._title.setTitle(community.title);
|
this._title.setTitle(community.title);
|
||||||
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
||||||
this.piwiksub = this._piwikService.trackView(this.properties, community.title, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe();
|
this.subs.push(this._piwikService.trackView(this.properties, community.title, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe());
|
||||||
}
|
}
|
||||||
if (this.community.zenodoCommunity) {
|
if (this.community.zenodoCommunity) {
|
||||||
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.community.zenodoCommunity, null).subscribe(
|
this.subs.push(this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.community.zenodoCommunity, null).subscribe(
|
||||||
result => {
|
result => {
|
||||||
this.masterZenodoCommunity = result;
|
this.masterZenodoCommunity = result;
|
||||||
|
|
||||||
|
@ -199,9 +194,9 @@ export class CommunityComponent {
|
||||||
this.handleError("Error getting Master Zenodo community with id: " + this.community.zenodoCommunityId, error);
|
this.handleError("Error getting Master Zenodo community with id: " + this.community.zenodoCommunityId, error);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe(
|
this.subs.push(this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe(
|
||||||
result => {
|
result => {
|
||||||
this.zenodoCommunityIdS = result;
|
this.zenodoCommunityIdS = result;
|
||||||
|
|
||||||
|
@ -211,17 +206,17 @@ export class CommunityComponent {
|
||||||
//console.error("list of zenodo communities couldn't be loaded");
|
//console.error("list of zenodo communities couldn't be loaded");
|
||||||
this.handleError("Error getting list of zenodo communities for community with openaire id: " + this.communityId, error);
|
this.handleError("Error getting list of zenodo communities for community with openaire id: " + this.communityId, error);
|
||||||
} //this.handleError('System error retrieving community profile', error)
|
} //this.handleError('System error retrieving community profile', error)
|
||||||
);
|
));
|
||||||
|
|
||||||
//console.log(community);
|
//console.log(community);
|
||||||
});
|
}));
|
||||||
|
|
||||||
this.countResearchResults("publication");
|
this.countResearchResults("publication");
|
||||||
this.countResearchResults("dataset");
|
this.countResearchResults("dataset");
|
||||||
this.countResearchResults("software");
|
this.countResearchResults("software");
|
||||||
this.countResearchResults("other");
|
this.countResearchResults("other");
|
||||||
|
|
||||||
this._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId).subscribe(
|
this.subs.push(this._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId).subscribe(
|
||||||
projectTotal => {
|
projectTotal => {
|
||||||
this.projectTotal = projectTotal;
|
this.projectTotal = projectTotal;
|
||||||
//console.log(projectTotal);
|
//console.log(projectTotal);
|
||||||
|
@ -232,9 +227,9 @@ export class CommunityComponent {
|
||||||
() => {
|
() => {
|
||||||
this.projectsCalculated = true;
|
this.projectsCalculated = true;
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
|
|
||||||
this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId).subscribe(
|
this.subs.push(this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId).subscribe(
|
||||||
contentProviderTotal => {
|
contentProviderTotal => {
|
||||||
this.contentProviderTotal = contentProviderTotal;
|
this.contentProviderTotal = contentProviderTotal;
|
||||||
//console.log(contentProviderTotal);
|
//console.log(contentProviderTotal);
|
||||||
|
@ -245,7 +240,7 @@ export class CommunityComponent {
|
||||||
() => {
|
() => {
|
||||||
this.contentProvidersCalculated = true;
|
this.contentProvidersCalculated = true;
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
|
|
||||||
// this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/organizations').subscribe(
|
// this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/organizations').subscribe(
|
||||||
// organizationTotal => {
|
// organizationTotal => {
|
||||||
|
@ -255,7 +250,7 @@ export class CommunityComponent {
|
||||||
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
this.config.getCommunityInformation(this.properties, this.communityId).subscribe(
|
this.subs.push(this.config.communityInformationState.subscribe(
|
||||||
res => {
|
res => {
|
||||||
this.communityInfo = res;
|
this.communityInfo = res;
|
||||||
},
|
},
|
||||||
|
@ -263,9 +258,9 @@ export class CommunityComponent {
|
||||||
//console.log(error)
|
//console.log(error)
|
||||||
this.handleError("Error getting community with id: " + this.communityId, error);
|
this.handleError("Error getting community with id: " + this.communityId, error);
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private searchPublications(page: number, size: number) {
|
private searchPublications(page: number, size: number) {
|
||||||
|
@ -370,8 +365,8 @@ export class CommunityComponent {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
if (this.piwiksub) {
|
for (let sub of this.subs) {
|
||||||
this.piwiksub.unsubscribe();
|
sub.unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1,8 @@
|
||||||
|
import {properties} from "./environments/environment";
|
||||||
|
import {enableProdMode} from "@angular/core";
|
||||||
|
|
||||||
|
if (properties.environment !== "development") {
|
||||||
|
enableProdMode();
|
||||||
|
}
|
||||||
|
|
||||||
export { AppServerModule } from './app/app.server.module';
|
export { AppServerModule } from './app/app.server.module';
|
||||||
|
|
Loading…
Reference in New Issue