[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:
konstantina.galouni 2020-07-15 15:53:19 +00:00
parent 988bbc570f
commit b4df338564
5 changed files with 58 additions and 31 deletions

View File

@ -81,6 +81,17 @@
"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": {
"browserTarget": "ng-universal-demo:build:beta"
},
"development": {
"browserTarget": "ng-universal-demo:build:development"
}
}
},
@ -162,7 +176,8 @@
"with": "src/environments/environment.beta.ts"
}
]
}
},
"development": {}
}
}
}

View File

@ -13,13 +13,18 @@
"start:prerender": "npm run build:prerender && npm run serve:prerender",
"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: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:client-and-server-bundles": "ng build --prod --sourceMap --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": "ng build --prod --stats-json=true && ng run ng-universal-demo:server:production",
"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: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: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",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors",
"serve:prerender": "cd dist/browser && http-server",

View File

@ -10,6 +10,7 @@ import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
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,
@ -81,7 +82,8 @@ export class AppComponent {
// community: {id:string, name:string, logoUrl:string};
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
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) => {
if (event instanceof NavigationStart) {
HelperFunctions.scroll();
@ -103,7 +105,8 @@ export class AppComponent {
this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
this.init();
});
},
error => this.init());
}, error => {
console.log("App couldn't fetch properties");
console.log(error);
@ -117,11 +120,13 @@ export class AppComponent {
this.showMenu = false;
this.route.queryParams.subscribe(params => {
communityId = (params['communityId']) ? params['communityId'] : ConnectHelper.getCommunityFromDomain(this.properties.domain);
this.configurationService.initCommunityInformation(this.properties, communityId);
this.buildMenu(communityId);
})
} else {
this.showMenu = false;
communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
this.configurationService.initCommunityInformation(this.properties, communityId);
this.buildMenu(communityId);
}
this.communityId = communityId;

View File

@ -25,6 +25,7 @@ import {SubscribeComponent} from "../utils/subscribe/subscribe.component";
import {SearchCustomFilter} from "../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {FetchResearchResults} from "../openaireLibrary/utils/fetchEntitiesClasses/fetchResearchResults.class";
import {ErrorCodes} from "../openaireLibrary/utils/properties/errorCodes";
import {Subscription} from "rxjs";
@Component({
selector: 'community',
@ -34,10 +35,6 @@ import {ErrorCodes} from "../openaireLibrary/utils/properties/errorCodes";
export class CommunityComponent {
public url: string = null;
public sub: any;
public piwiksub: any;
public subfunders: any;
// public publicationTotal = null;
// public researchDataTotal = null;
// public softwareTotal = null;
@ -88,10 +85,8 @@ export class CommunityComponent {
subscribers: number = 0;
// TODO Unsubscribe
public subPublications;
public subResearchData;
public subSoftware;
public subOrps;
subs: Subscription[] = [];
@ViewChild(StatisticsForDashboardComponent) statistics: StatisticsForDashboardComponent = null;
public activeTab = "summary";
public show: string = 'overview';
@ -148,7 +143,7 @@ export class CommunityComponent {
}
public ngOnInit() {
this.route.data
this.subs.push(this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.searchLinkToResults = this.properties.searchLinkToResults;
@ -159,9 +154,9 @@ export class CommunityComponent {
this.url = data.envSpecific.baseLink + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url, false);
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;
});
}));
if (this.communityId != null && this.communityId != '') {
this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, "");
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._title.setTitle(community.title);
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) {
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 => {
this.masterZenodoCommunity = result;
@ -199,9 +194,9 @@ export class CommunityComponent {
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 => {
this.zenodoCommunityIdS = result;
@ -211,17 +206,17 @@ export class CommunityComponent {
//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('System error retrieving community profile', error)
);
));
//console.log(community);
});
}));
this.countResearchResults("publication");
this.countResearchResults("dataset");
this.countResearchResults("software");
this.countResearchResults("other");
this._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId).subscribe(
this.subs.push(this._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId).subscribe(
projectTotal => {
this.projectTotal = projectTotal;
//console.log(projectTotal);
@ -232,9 +227,9 @@ export class CommunityComponent {
() => {
this.projectsCalculated = true;
}
);
));
this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId).subscribe(
this.subs.push(this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId).subscribe(
contentProviderTotal => {
this.contentProviderTotal = contentProviderTotal;
//console.log(contentProviderTotal);
@ -245,7 +240,7 @@ export class CommunityComponent {
() => {
this.contentProvidersCalculated = true;
}
);
));
// this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/organizations').subscribe(
// organizationTotal => {
@ -255,7 +250,7 @@ export class CommunityComponent {
/**/
this.config.getCommunityInformation(this.properties, this.communityId).subscribe(
this.subs.push(this.config.communityInformationState.subscribe(
res => {
this.communityInfo = res;
},
@ -263,9 +258,9 @@ export class CommunityComponent {
//console.log(error)
this.handleError("Error getting community with id: " + this.communityId, error);
}
);
));
}
});
}));
}
private searchPublications(page: number, size: number) {
@ -370,8 +365,8 @@ export class CommunityComponent {
// }
public ngOnDestroy() {
if (this.piwiksub) {
this.piwiksub.unsubscribe();
for (let sub of this.subs) {
sub.unsubscribe();
}
}

View File

@ -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';