[Aggregator]: Create view on app rotue base on id param.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-aggregator-portal/trunk@57403 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-10-17 12:21:24 +00:00
parent 15daa488f8
commit 4a7c099125
5 changed files with 207 additions and 51 deletions

View File

@ -0,0 +1,131 @@
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {EnvironmentSpecificResolver} from "../openaireLibrary/utils/properties/environmentSpecificResolver";
import {EnvironmentSpecificService} from "../openaireLibrary/utils/properties/environment-specific.service";
const routes: Routes = [
{path: '', loadChildren: './home/home.module#HomeModule', resolve: {envSpecific: EnvironmentSpecificResolver}},
{
path: 'search/publication',
loadChildren: './landingPages/publication/libPublication.module#LibPublicationModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/dataset',
loadChildren: './landingPages/dataset/libDataset.module#LibDatasetModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/software',
loadChildren: './landingPages/software/libSoftware.module#LibSoftwareModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/other',
loadChildren: './landingPages/orp/libOrp.module#LibOrpModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/project',
loadChildren: './landingPages/project/libProject.module#LibProjectModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/dataprovider',
loadChildren: '././landingPages/dataProvider/libDataProvider.module#LibDataProviderModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/organization',
loadChildren: './landingPages/organization/libOrganization.module#LibOrganizationModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/find',
loadChildren: './searchPages/find/libSearch.module#LibMainSearchModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/find/publications',
loadChildren: './searchPages/simple/searchPublications.module#LibSearchPublicationsModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/find/datasets',
loadChildren: './searchPages/simple/searchDatasets.module#LibSearchDatasetsModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/find/software',
loadChildren: './searchPages/simple/searchSoftware.module#LibSearchSoftwareModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/find/other',
loadChildren: './searchPages/simple/searchOrps.module#LibSearchOrpsModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/find/projects',
loadChildren: './searchPages/simple/searchProjects.module#LibSearchProjectsModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/find/dataproviders',
loadChildren: './searchPages/simple/searchDataProviders.module#LibSearchDataProvidersModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/find/organizations',
loadChildren: './searchPages/simple/searchOrganizations.module#LibSearchOrganizationsModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/advanced/publications',
loadChildren: './searchPages/advanced/advancedSearchPublications.module#LibAdvancedSearchPublicationsModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/advanced/datasets',
loadChildren: './searchPages/advanced/advancedSearchDatasets.module#LibAdvancedSearchDatasetsModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/advanced/software',
loadChildren: './searchPages/advanced/advancedSearchSoftware.module#LibAdvancedSearchSoftwareModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/advanced/other',
loadChildren: './searchPages/advanced/advancedSearchOrps.module#LibAdvancedSearchOrpsModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/advanced/organizations',
loadChildren: './searchPages/advanced/advancedSearchOrganizations.module#LibAdvancedSearchOrganizationsModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/advanced/dataproviders',
loadChildren: './searchPages/advanced/advancedSearchDataProviders.module#LibAdvancedSearchDataProvidersModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'search/advanced/projects',
loadChildren: './searchPages/advanced/advancedSearchProjects.module#LibAdvancedSearchProjectsModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'project-report',
loadChildren: './landingPages/htmlProjectReport/libHtmlProjectReport.module#LibHtmlProjectReportModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
providers: [EnvironmentSpecificResolver, EnvironmentSpecificService]
})
export class AggregatorRoutingModule {
}

View File

@ -0,0 +1,22 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {HttpClientModule} from "@angular/common/http";
import {AggregatorRoutingModule} from "./aggregator-routing.module";
import {EnvironmentSpecificResolver} from "../openaireLibrary/utils/properties/environmentSpecificResolver";
import {SharedModule} from "../shared/shared.module";
@NgModule({
imports: [
SharedModule,
CommonModule,
HttpClientModule,
AggregatorRoutingModule
],
providers: [
EnvironmentSpecificResolver
],
})
export class AggregatorModule {
}

View File

@ -8,35 +8,8 @@ import { EnvironmentSpecificService} from './openaireLibrary/utils/properties/en
import { OpenaireErrorPageComponent } from './error/errorPage.component';
const routes: Routes = [
{ path: '', loadChildren: './home/home.module#HomeModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: ':id', loadChildren: './home/home.module#HomeModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/publication', loadChildren: './landingPages/publication/libPublication.module#LibPublicationModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/dataset', loadChildren: './landingPages/dataset/libDataset.module#LibDatasetModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/software', loadChildren: './landingPages/software/libSoftware.module#LibSoftwareModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/other', loadChildren: './landingPages/orp/libOrp.module#LibOrpModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/project', loadChildren: './landingPages/project/libProject.module#LibProjectModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/dataprovider', loadChildren: '././landingPages/dataProvider/libDataProvider.module#LibDataProviderModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/organization', loadChildren: './landingPages/organization/libOrganization.module#LibOrganizationModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: ':id/search/find', loadChildren: './searchPages/find/libSearch.module#LibMainSearchModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/find', loadChildren: './searchPages/find/libSearch.module#LibMainSearchModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/find/publications', loadChildren: './searchPages/simple/searchPublications.module#LibSearchPublicationsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/find/datasets', loadChildren: './searchPages/simple/searchDatasets.module#LibSearchDatasetsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/find/software', loadChildren: './searchPages/simple/searchSoftware.module#LibSearchSoftwareModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/find/other', loadChildren: './searchPages/simple/searchOrps.module#LibSearchOrpsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/find/projects', loadChildren: './searchPages/simple/searchProjects.module#LibSearchProjectsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/find/dataproviders', loadChildren: './searchPages/simple/searchDataProviders.module#LibSearchDataProvidersModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/find/organizations', loadChildren: './searchPages/simple/searchOrganizations.module#LibSearchOrganizationsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/advanced/publications', loadChildren: './searchPages/advanced/advancedSearchPublications.module#LibAdvancedSearchPublicationsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/advanced/datasets', loadChildren: './searchPages/advanced/advancedSearchDatasets.module#LibAdvancedSearchDatasetsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/advanced/software', loadChildren: './searchPages/advanced/advancedSearchSoftware.module#LibAdvancedSearchSoftwareModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/advanced/other', loadChildren: './searchPages/advanced/advancedSearchOrps.module#LibAdvancedSearchOrpsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/advanced/organizations', loadChildren: './searchPages/advanced/advancedSearchOrganizations.module#LibAdvancedSearchOrganizationsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/advanced/dataproviders', loadChildren: './searchPages/advanced/advancedSearchDataProviders.module#LibAdvancedSearchDataProvidersModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/advanced/projects', loadChildren: './searchPages/advanced/advancedSearchProjects.module#LibAdvancedSearchProjectsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'project-report', loadChildren: './landingPages/htmlProjectReport/libHtmlProjectReport.module#LibHtmlProjectReportModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
// { path: 'reload', loadChildren: './reload/libReload.module#LibReloadModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
// { path: 'user-info', loadChildren: './login/libUser.module#LibUserModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: '', loadChildren: './aggregator/aggregator.module#AggregatorModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: ':id', loadChildren: './aggregator/aggregator.module#AggregatorModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'error', component: OpenaireErrorPageComponent, resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: '**',pathMatch: 'full',component: OpenaireErrorPageComponent, resolve: { envSpecific: EnvironmentSpecificResolver }}
];

View File

@ -1,5 +1,5 @@
import {Component} from '@angular/core';
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
import {ActivatedRoute, NavigationEnd, NavigationStart, Router} from '@angular/router';
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
@ -18,14 +18,14 @@ import {User} from "./openaireLibrary/login/utils/helper.class";
template: `
<navbar *ngIf="properties && loginCheck" portal="aggregator" [properties]=properties [onlyTop]=false [user]="user"
[communityId]="properties.adminToolsCommunity" [menuItems]=menuItems
[communityId]="properties.adminToolsCommunity" [menuItems]=menuItems
[userMenu]="false" [community]="community" [showCommunityName]="true"></navbar>
<div class="custom-main-content">
<main>
<router-outlet></router-outlet>
</main>
</div>
<cookie-law *ngIf="isClient" position="bottom">
<cookie-law *ngIf="isClient" position="bottom">
OpenAIRE uses cookies in order to function properly.<br>
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
experience possible.
@ -57,11 +57,13 @@ export class AppComponent {
}
];
community = null;
id: string = null;
properties: EnvProperties;
user: User;
loginCheck: boolean = false;
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
private router: Router, private userManagementService: UserManagementService) {
@ -69,19 +71,49 @@ export class AppComponent {
if (event instanceof NavigationStart) {
HelperFunctions.scroll();
} else if (event instanceof NavigationEnd) {
let r = this.route;
while (r.firstChild) {
r = r.firstChild;
}
r.params.subscribe(params => {
if(!this.id) {
this.id = params['id'];
let agg: FilterInfo = PortalAggregators.getFilterInfoByMenuId(this.id);
if (agg) {
this.community = {id: agg.menuId, name: agg.title, logoUrl: agg.logoUrl};
}
if (this.id) {
this.buildMenu();
}
} else {
if(this.router.url === '/') {
this.router.navigate([this.id]);
}
}
});
}
});
}
private buildMenu() {
this.menuItems = [
{rootItem: new MenuItem("home", "Home", "", "/" + this.id, false, [], null, {}), items: []},
{
rootItem: new MenuItem("search", "Search", "", "/" + this.id + "/search/find", false, [], null, {}),
items: [new MenuItem("", "Publications", "", "/" + this.id + "/search/find/publications", false, [], [], {}),
new MenuItem("", "Research Data", "", "/" + this.id + "/search/find/datasets", false, [], [], {}),
new MenuItem("", "Software", "", "/" + this.id + "/search/find/software", false, [], [], {}),
new MenuItem("", "Other Research Products", "", "/" + this.id + "/search/find/other", false, [], [], {}),
new MenuItem("", "Projects", "", "/" + this.id + "/search/find/projects/", false, [], [], {}),
new MenuItem("", "Content Providers", "", "/" + this.id + "/search/find/dataproviders", false, [], [], {}),
new MenuItem("", "Organizations", "", "/" + this.id + "/search/find/organizations/", false, [], [], {})
]
}
];
}
ngOnInit() {
let id = this.router.url;
console.log("Id is:"+id);
let agg:FilterInfo = PortalAggregators.getFilterInfoByMenuId(id);
if(agg){
this.community = {id: agg.menuId, name: agg.title, logoUrl:agg.logoUrl};
}
if (typeof document !== 'undefined') {
try {
this.isClient = true;
@ -97,7 +129,6 @@ export class AppComponent {
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
this.loginCheck = true;
console.log(this.user)
});
}, error => {
console.log("App couldn't fetch properties");

View File

@ -17,7 +17,6 @@ import {ErrorModule} from './openaireLibrary/error/error.module';
import {OpenaireErrorPageComponent} from './error/errorPage.component';
import {AppRoutingModule} from './app-routing.module';
// import {AggregatorNavBarComponent} from "./utils/aggregatorNavBar.component";
@NgModule({
@ -27,18 +26,18 @@ import {AppRoutingModule} from './app-routing.module';
CommonModule,
HttpClientModule,
ErrorModule,
NavigationBarModule, FeedbackModule, BottomModule,
NavigationBarModule, FeedbackModule, BottomModule,
CookieLawModule,
BrowserModule.withServerTransition({appId: 'my-app'}),
AppRoutingModule
],
declarations: [ AppComponent, OpenaireErrorPageComponent],
exports: [ AppComponent ],
providers:[
EnvironmentSpecificResolver
],
bootstrap: [AppComponent]
declarations: [AppComponent, OpenaireErrorPageComponent],
exports: [AppComponent],
providers: [
EnvironmentSpecificResolver
],
bootstrap: [AppComponent]
})
export class AppModule {}
export class AppModule {
}