fixed core and shared module usage, lazy loading modules

This commit is contained in:
William Welling
2017-09-26 11:44:07 -05:00
parent 88120dd85b
commit 3d02e660da
71 changed files with 89 additions and 95 deletions

View File

@@ -6,7 +6,7 @@ import { CollectionPageComponent } from './collection-page.component';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: 'collections/:id', component: CollectionPageComponent } { path: ':id', component: CollectionPageComponent, pathMatch: 'full' }
]) ])
] ]
}) })

View File

@@ -9,10 +9,9 @@ import { CollectionPageRoutingModule } from './collection-page-routing.module';
@NgModule({ @NgModule({
imports: [ imports: [
CollectionPageRoutingModule,
CommonModule, CommonModule,
SharedModule, SharedModule,
TranslateModule, CollectionPageRoutingModule
], ],
declarations: [ declarations: [
CollectionPageComponent, CollectionPageComponent,

View File

@@ -6,7 +6,7 @@ import { CommunityPageComponent } from './community-page.component';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: 'communities/:id', component: CommunityPageComponent } { path: ':id', component: CommunityPageComponent, pathMatch: 'full' }
]) ])
] ]
}) })

View File

@@ -1,6 +1,5 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@@ -11,11 +10,9 @@ import { CommunityPageRoutingModule } from './community-page-routing.module';
@NgModule({ @NgModule({
imports: [ imports: [
CommunityPageRoutingModule,
CommonModule, CommonModule,
TranslateModule,
RouterModule,
SharedModule, SharedModule,
CommunityPageRoutingModule
], ],
declarations: [ declarations: [
CommunityPageComponent, CommunityPageComponent,

View File

@@ -6,7 +6,7 @@ import { HomeComponent } from './home.component';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: 'home', component: HomeComponent } { path: '', component: HomeComponent, pathMatch: 'full' }
]) ])
] ]
}) })

View File

@@ -1,21 +1,20 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { HomeComponent } from './home.component'; import { HomeComponent } from './home.component';
import { HomeRoutingModule } from './home-routing.module'; import { HomeRoutingModule } from './home-routing.module';
import { CommonModule } from '@angular/common';
import { TopLevelCommunityListComponent } from './top-level-community-list/top-level-community-list.component'; import { TopLevelCommunityListComponent } from './top-level-community-list/top-level-community-list.component';
import { HomeNewsComponent } from './home-news/home-news.component'; import { HomeNewsComponent } from './home-news/home-news.component';
import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import { SharedModule } from '../shared/shared.module'; import { SharedModule } from '../shared/shared.module';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
HomeRoutingModule,
RouterModule,
SharedModule, SharedModule,
TranslateModule HomeRoutingModule
], ],
declarations: [ declarations: [
HomeComponent, HomeComponent,

View File

@@ -5,12 +5,13 @@ import { ItemPageComponent } from './simple/item-page.component';
import { FullItemPageComponent } from './full/full-item-page.component'; import { FullItemPageComponent } from './full/full-item-page.component';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: 'items/:id', pathMatch: 'full', component: ItemPageComponent }, { path: ':id', component: ItemPageComponent, pathMatch: 'full' },
{ path: 'items/:id/full', component: FullItemPageComponent }, { path: ':id/full', component: FullItemPageComponent }
]) ])
] ]
}) })
export class ItemPageRoutingModule { export class ItemPageRoutingModule {
} }

View File

@@ -19,27 +19,28 @@ import { FullItemPageComponent } from './full/full-item-page.component';
import { FullFileSectionComponent } from './full/field-components/file-section/full-file-section.component'; import { FullFileSectionComponent } from './full/field-components/file-section/full-file-section.component';
@NgModule({ @NgModule({
declarations: [ imports: [
ItemPageComponent, CommonModule,
FullItemPageComponent, SharedModule,
MetadataValuesComponent, ItemPageRoutingModule
MetadataUriValuesComponent, ],
MetadataFieldWrapperComponent, declarations: [
ItemPageAuthorFieldComponent, ItemPageComponent,
ItemPageDateFieldComponent, FullItemPageComponent,
ItemPageAbstractFieldComponent, MetadataValuesComponent,
ItemPageUriFieldComponent, MetadataUriValuesComponent,
ItemPageTitleFieldComponent, MetadataFieldWrapperComponent,
ItemPageSpecificFieldComponent, ItemPageAuthorFieldComponent,
FileSectionComponent, ItemPageDateFieldComponent,
CollectionsComponent, ItemPageAbstractFieldComponent,
FullFileSectionComponent ItemPageUriFieldComponent,
], ItemPageTitleFieldComponent,
imports: [ ItemPageSpecificFieldComponent,
ItemPageRoutingModule, FileSectionComponent,
CommonModule, CollectionsComponent,
SharedModule FullFileSectionComponent
] ]
}) })
export class ItemPageModule { export class ItemPageModule {
} }

View File

@@ -7,6 +7,10 @@ import { PageNotFoundComponent } from './pagenotfound/pagenotfound.component';
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', redirectTo: '/home', pathMatch: 'full' }, { path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', loadChildren: './+home/home.module#HomeModule' },
{ path: 'communities', loadChildren: './+community-page/community-page.module#CommunityPageModule' },
{ path: 'collections', loadChildren: './+collection-page/collection-page.module#CollectionPageModule' },
{ path: 'items', loadChildren: './+item-page/item-page.module#ItemPageModule' },
{ path: '**', pathMatch: 'full', component: PageNotFoundComponent }, { path: '**', pathMatch: 'full', component: PageNotFoundComponent },
]) ])
], ],

View File

@@ -1,10 +1,16 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpModule } from '@angular/http'; import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { StoreModule } from '@ngrx/store'; import { StoreModule } from '@ngrx/store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools'; import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { TranslateModule } from '@ngx-translate/core';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { appReducers } from './app.reducer'; import { appReducers } from './app.reducer';
import { appEffects } from './app.effects'; import { appEffects } from './app.effects';
@@ -15,13 +21,9 @@ import { AppRoutingModule } from './app-routing.module';
import { TransferHttpModule } from '../modules/transfer-http/transfer-http.module'; import { TransferHttpModule } from '../modules/transfer-http/transfer-http.module';
import { HomeModule } from './home/home.module';
import { ItemPageModule } from './item-page/item-page.module';
import { CollectionPageModule } from './collection-page/collection-page.module';
import { CommunityPageModule } from './community-page/community-page.module';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component'; import { HeaderComponent } from './header/header.component';
import { FooterComponent } from './footer/footer.component';
import { PageNotFoundComponent } from './pagenotfound/pagenotfound.component'; import { PageNotFoundComponent } from './pagenotfound/pagenotfound.component';
import { GLOBAL_CONFIG, ENV_CONFIG } from '../config'; import { GLOBAL_CONFIG, ENV_CONFIG } from '../config';
@@ -34,27 +36,27 @@ export function getConfig() {
@NgModule({ @NgModule({
imports: [ imports: [
SharedModule, CommonModule,
FormsModule, FormsModule,
CoreModule.forRoot(),
HttpModule, HttpModule,
TransferHttpModule, RouterModule,
HomeModule,
ItemPageModule,
CollectionPageModule,
CommunityPageModule,
AppRoutingModule, AppRoutingModule,
TransferHttpModule,
CoreModule.forRoot(),
NgbModule.forRoot(),
TranslateModule.forRoot(),
EffectsModule.forRoot(appEffects),
StoreModule.forRoot(appReducers, { metaReducers: appMetaReducers }), StoreModule.forRoot(appReducers, { metaReducers: appMetaReducers }),
StoreDevtoolsModule.instrument({ maxAge: 50 }), StoreDevtoolsModule.instrument({ maxAge: 50 })
EffectsModule.forRoot(appEffects)
], ],
providers: [ providers: [
{ provide: GLOBAL_CONFIG, useFactory: (getConfig) }, { provide: GLOBAL_CONFIG, useFactory: (getConfig) }
], ],
declarations: [ declarations: [
AppComponent, AppComponent,
HeaderComponent, HeaderComponent,
PageNotFoundComponent, FooterComponent,
PageNotFoundComponent
], ],
exports: [AppComponent] exports: [AppComponent]
}) })

View File

@@ -3,15 +3,12 @@ import { Http } from '@angular/http';
import { HttpClientModule, HttpClient } from '@angular/common/http'; import { HttpClientModule, HttpClient } from '@angular/common/http';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { IdlePreload, IdlePreloadModule } from '@angularclass/idle-preload'; import { IdlePreload, IdlePreloadModule } from '@angularclass/idle-preload';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { EffectsModule } from '@ngrx/effects'; import { EffectsModule } from '@ngrx/effects';
import { TransferState } from '../modules/transfer-state/transfer-state'; import { TransferState } from '../modules/transfer-state/transfer-state';
@@ -36,7 +33,7 @@ export function init(cache: TransferState) {
} }
export function createTranslateLoader(http: HttpClient) { export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json'); return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
} }
@NgModule({ @NgModule({
@@ -55,14 +52,12 @@ export function createTranslateLoader(http: HttpClient) {
deps: [HttpClient] deps: [HttpClient]
} }
}), }),
NgbModule.forRoot(),
BrowserCookiesModule, BrowserCookiesModule,
BrowserDataLoaderModule, BrowserDataLoaderModule,
BrowserTransferStateModule, BrowserTransferStateModule,
BrowserTransferStoreModule, BrowserTransferStoreModule,
EffectsModule.forRoot([BrowserTransferStoreEffects]), EffectsModule.forRoot([BrowserTransferStoreEffects]),
StoreRouterConnectingModule, StoreRouterConnectingModule,
BrowserAnimationsModule,
AppModule AppModule
], ],
providers: [ providers: [

View File

@@ -4,7 +4,6 @@ import { CommonModule } from '@angular/common';
import { SharedModule } from '../shared/shared.module'; import { SharedModule } from '../shared/shared.module';
import { isNotEmpty } from '../shared/empty.util'; import { isNotEmpty } from '../shared/empty.util';
import { FooterComponent } from './footer/footer.component';
import { DSpaceRESTv2Service } from './dspace-rest-v2/dspace-rest-v2.service'; import { DSpaceRESTv2Service } from './dspace-rest-v2/dspace-rest-v2.service';
import { ObjectCacheService } from './cache/object-cache.service'; import { ObjectCacheService } from './cache/object-cache.service';
import { ResponseCacheService } from './cache/response-cache.service'; import { ResponseCacheService } from './cache/response-cache.service';
@@ -19,31 +18,41 @@ import { EffectsModule } from '@ngrx/effects';
import { StoreModule } from '@ngrx/store'; import { StoreModule } from '@ngrx/store';
import { coreReducers } from './core.reducers'; import { coreReducers } from './core.reducers';
import { ApiService } from '../shared/api.service';
import { HostWindowService } from '../shared/host-window.service';
import { NativeWindowFactory, NativeWindowService } from '../shared/window.service';
import { ServerResponseService } from '../shared/server-response.service';
const IMPORTS = [ const IMPORTS = [
CommonModule, CommonModule,
SharedModule, StoreModule.forFeature('core', coreReducers, {}),
StoreModule.forFeature('core', coreReducers, { }),
EffectsModule.forFeature(coreEffects) EffectsModule.forFeature(coreEffects)
]; ];
const DECLARATIONS = [ const DECLARATIONS = [
FooterComponent
]; ];
const EXPORTS = [ const EXPORTS = [
FooterComponent
]; ];
const PROVIDERS = [ const PROVIDERS = [
ApiService,
CommunityDataService, CommunityDataService,
CollectionDataService, CollectionDataService,
ItemDataService,
DSpaceRESTv2Service, DSpaceRESTv2Service,
HostWindowService,
ItemDataService,
ObjectCacheService, ObjectCacheService,
PaginationComponentOptions, PaginationComponentOptions,
ResponseCacheService, ResponseCacheService,
RequestService, RequestService,
RemoteDataBuildService RemoteDataBuildService,
ServerResponseService,
{ provide: NativeWindowService, useFactory: NativeWindowFactory }
]; ];
@NgModule({ @NgModule({

View File

@@ -1,5 +1,5 @@
@import '../../../styles/variables.scss'; @import '../../styles/variables.scss';
@import '../../../../node_modules/bootstrap/scss/_variables.scss'; @import '../../../node_modules/bootstrap/scss/_variables.scss';
$footer-bg: $gray-lighter; $footer-bg: $gray-lighter;
$footer-border: 1px solid darken($footer-bg, 10%); $footer-border: 1px solid darken($footer-bg, 10%);
$footer-padding: $spacer * 1.5; $footer-padding: $spacer * 1.5;

View File

@@ -5,7 +5,6 @@ import { ApplicationRef, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core'
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { ServerModule } from '@angular/platform-server'; import { ServerModule } from '@angular/platform-server';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { Request } from 'express'; import { Request } from 'express';
@@ -13,8 +12,6 @@ import { REQUEST } from '@nguniversal/express-engine/tokens';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects'; import { EffectsModule } from '@ngrx/effects';
@@ -67,14 +64,12 @@ export function createTranslateLoader() {
deps: [] deps: []
} }
}), }),
NgbModule.forRoot(),
ServerModule, ServerModule,
ServerCookiesModule, ServerCookiesModule,
ServerDataLoaderModule, ServerDataLoaderModule,
ServerTransferStateModule, ServerTransferStateModule,
ServerTransferStoreModule, ServerTransferStoreModule,
EffectsModule.forRoot([ServerTransferStoreEffects]), EffectsModule.forRoot([ServerTransferStoreEffects]),
NoopAnimationsModule,
AppModule AppModule
], ],
providers: [ providers: [

View File

@@ -186,10 +186,10 @@ export class PaginationComponent implements OnChanges, OnDestroy, OnInit {
this.checkConfig(this.paginationOptions); this.checkConfig(this.paginationOptions);
if (this.pageInfoState) { if (this.pageInfoState) {
this.subs.push(this.pageInfoState.subscribe((pageInfo) => { this.subs.push(this.pageInfoState.subscribe((pageInfo) => {
/* TODO: this is a temporary fix for the pagination start index (0 or 1) discrepancy between the rest and the frontend respectively */ /* TODO: this is a temporary fix for the pagination start index (0 or 1) discrepancy between the rest and the frontend respectively */
this.currentPageState = pageInfo.currentPage + 1; this.currentPageState = pageInfo.currentPage + 1;
})); }));
} }
this.id = this.paginationOptions.id || null; this.id = this.paginationOptions.id || null;

View File

@@ -7,13 +7,11 @@ import { NgxPaginationModule } from 'ngx-pagination';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { ApiService } from './api.service';
import { PaginationComponent } from './pagination/pagination.component'; import { PaginationComponent } from './pagination/pagination.component';
import { FileSizePipe } from './utils/file-size-pipe'; import { FileSizePipe } from './utils/file-size-pipe';
import { ThumbnailComponent } from '../thumbnail/thumbnail.component'; import { ThumbnailComponent } from '../thumbnail/thumbnail.component';
import { SafeUrlPipe } from './utils/safe-url-pipe'; import { SafeUrlPipe } from './utils/safe-url-pipe';
import { HostWindowService } from './host-window.service';
import { NativeWindowFactory, NativeWindowService } from './window.service';
import { ComcolPageContentComponent } from './comcol-page-content/comcol-page-content.component'; import { ComcolPageContentComponent } from './comcol-page-content/comcol-page-content.component';
import { ComcolPageHeaderComponent } from './comcol-page-header/comcol-page-header.component'; import { ComcolPageHeaderComponent } from './comcol-page-header/comcol-page-header.component';
import { ComcolPageLogoComponent } from './comcol-page-logo/comcol-page-logo.component'; import { ComcolPageLogoComponent } from './comcol-page-logo/comcol-page-logo.component';
@@ -24,7 +22,6 @@ import { ItemListElementComponent } from '../object-list/item-list-element/item-
import { CommunityListElementComponent } from '../object-list/community-list-element/community-list-element.component'; import { CommunityListElementComponent } from '../object-list/community-list-element/community-list-element.component';
import { CollectionListElementComponent } from '../object-list/collection-list-element/collection-list-element.component'; import { CollectionListElementComponent } from '../object-list/collection-list-element/collection-list-element.component';
import { TruncatePipe } from './utils/truncate.pipe'; import { TruncatePipe } from './utils/truncate.pipe';
import { ServerResponseService } from './server-response.service';
const MODULES = [ const MODULES = [
// Do NOT include UniversalModule, HttpModule, or JsonpModule here // Do NOT include UniversalModule, HttpModule, or JsonpModule here
@@ -38,11 +35,11 @@ const MODULES = [
]; ];
const PIPES = [ const PIPES = [
// put shared pipes here
FileSizePipe, FileSizePipe,
SafeUrlPipe, SafeUrlPipe,
EnumKeysPipe, EnumKeysPipe,
TruncatePipe TruncatePipe
// put pipes here
]; ];
const COMPONENTS = [ const COMPONENTS = [
@@ -60,10 +57,7 @@ const COMPONENTS = [
]; ];
const PROVIDERS = [ const PROVIDERS = [
ApiService,
HostWindowService,
{ provide: NativeWindowService, useFactory: NativeWindowFactory },
ServerResponseService
]; ];
@NgModule({ @NgModule({

View File

@@ -1,6 +1,7 @@
{ {
"extends": "../tsconfig.json", "extends": "../tsconfig.json",
"angularCompilerOptions": { "angularCompilerOptions": {
"genDir": ".",
"entryModule": "./app/browser-app.module#BrowserAppModule" "entryModule": "./app/browser-app.module#BrowserAppModule"
} }
} }

View File

@@ -1,6 +1,7 @@
{ {
"extends": "../tsconfig.json", "extends": "../tsconfig.json",
"angularCompilerOptions": { "angularCompilerOptions": {
"genDir": ".",
"entryModule": "./app/server-app.module#ServerAppModule" "entryModule": "./app/server-app.module#ServerAppModule"
} }
} }

View File

@@ -8,10 +8,6 @@ const {
getAotPlugin getAotPlugin
} = require('./webpack/webpack.aot'); } = require('./webpack/webpack.aot');
const {
root
} = require('./webpack/helpers');
module.exports = function(options, webpackOptions) { module.exports = function(options, webpackOptions) {
options = options || {}; options = options || {};