diff --git a/package.json b/package.json index 8dd1110d1a..91130f62a0 100644 --- a/package.json +++ b/package.json @@ -78,9 +78,9 @@ "@angular/upgrade": "2.2.3", "@angularclass/bootloader": "1.0.1", "@angularclass/idle-preload": "1.0.4", - "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.15", + "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.18", "@ngrx/core": "^1.2.0", - "@ngrx/effects": "^2.0.0", + "@ngrx/effects": "2.0.2", "@ngrx/router-store": "^1.2.5", "@ngrx/store": "^2.2.1", "@ngrx/store-devtools": "^3.2.2", @@ -92,7 +92,7 @@ "angular2-universal": "2.1.0-rc.1", "angular2-universal-polyfills": "2.1.0-rc.1", "body-parser": "1.15.2", - "bootstrap": "4.0.0-alpha.5", + "bootstrap": "4.0.0-alpha.6", "cerialize": "^0.1.13", "compression": "1.6.2", "express": "4.14.0", @@ -102,6 +102,7 @@ "jsonschema": "^1.1.1", "methods": "1.1.2", "morgan": "1.7.0", + "ng2-pagination": "^2.0.0", "preboot": "4.5.2", "reflect-metadata": "^0.1.10", "rxjs": "5.0.0-beta.12", diff --git a/resources/i18n/en.json b/resources/i18n/en.json index 5578af2e85..95358dc446 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -20,6 +20,14 @@ "home": "Home" }, + "pagination": { + "results-per-page": "Results Per Page", + "showing": { + "label" : "Now showing items ", + "detail": "{{ range }} of {{ total }}" + } + }, + "title": "DSpace", "404": { diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 9b4aa66bf6..32b2eaae74 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -22,6 +22,7 @@ import { HostWindowResizeAction } from "./shared/host-window.actions"; import { MockTranslateLoader } from "./shared/testing/mock-translate-loader"; import { GLOBAL_CONFIG, EnvConfig } from '../config'; +import { NativeWindowRef, NativeWindowService } from "./shared/window.service"; let comp: AppComponent; let fixture: ComponentFixture; @@ -42,6 +43,7 @@ describe('App component', () => { declarations: [AppComponent], // declare the test component providers: [ { provide: GLOBAL_CONFIG, useValue: EnvConfig }, + { provide: NativeWindowService, useValue: new NativeWindowRef() }, AppComponent ], schemas: [CUSTOM_ELEMENTS_SCHEMA] diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 1cf97e763c..bd8ff3dd96 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -8,9 +8,10 @@ import { import { TranslateService } from "@ngx-translate/core"; import { HostWindowState } from "./shared/host-window.reducer"; import { Store } from "@ngrx/store"; -import { HostWindowResizeAction } from "./shared/host-window.actions"; +import { HostWindowResizeAction } from "./shared/host-window.actions"; import { EnvConfig, GLOBAL_CONFIG, GlobalConfig } from '../config'; +import { NativeWindowRef, NativeWindowService } from "./shared/window.service"; @Component({ changeDetection: ChangeDetectionStrategy.Default, @@ -23,6 +24,7 @@ export class AppComponent implements OnInit { constructor( @Inject(GLOBAL_CONFIG) public EnvConfig: GlobalConfig, + @Inject(NativeWindowService) private _window: NativeWindowRef, private translate: TranslateService, private store: Store ) { @@ -33,6 +35,7 @@ export class AppComponent implements OnInit { } ngOnInit() { + this.onInit(); const env: string = EnvConfig.production ? "Production" : "Development"; const color: string = EnvConfig.production ? "red" : "green"; console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`); @@ -45,4 +48,12 @@ export class AppComponent implements OnInit { ); } + private onInit(): void { + if (typeof this._window !== 'undefined') { + this.store.dispatch( + new HostWindowResizeAction(this._window.nativeWindow.innerWidth, this._window.nativeWindow.innerHeight) + ); + } + } + } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c6060811c2..42304c865e 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -23,7 +23,7 @@ import { PageNotFoundComponent } from './pagenotfound/pagenotfound.component'; HomeModule, ItemPageModule, CoreModule.forRoot(), - AppRoutingModule, + AppRoutingModule ], providers: [ ] diff --git a/src/app/core/cache/models/pagination-options.model.ts b/src/app/core/cache/models/pagination-options.model.ts index 3ab67e1e79..211e9b392d 100644 --- a/src/app/core/cache/models/pagination-options.model.ts +++ b/src/app/core/cache/models/pagination-options.model.ts @@ -1,12 +1,20 @@ -export class PaginationOptions { +import { NgbPaginationConfig } from '@ng-bootstrap/ng-bootstrap'; + +export class PaginationOptions extends NgbPaginationConfig { /** - * The number of results per page. + * ID for the pagination instance. Only useful if you wish to + * have more than once instance at a time in a given component. */ - resultsPerPage: number = 10; + id: string; /** * The active page. */ currentPage: number = 1; + /** + * A number array that represents options for a context pagination limit. + */ + pageSizeOptions: Array = [ 5, 10, 20, 40, 60, 80, 100 ]; + } diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index 5465a60170..be8da28571 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -1,6 +1,7 @@ import { NgModule, Optional, SkipSelf, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; import { SharedModule } from "../shared/shared.module"; + import { isNotEmpty } from "../shared/empty.util"; import { FooterComponent } from "./footer/footer.component"; import { DSpaceRESTv2Service } from "./dspace-rest-v2/dspace-rest-v2.service"; @@ -11,6 +12,7 @@ import { ItemDataService } from "./data/item-data.service"; import { RequestService } from "./data/request.service"; import { RemoteDataBuildService } from "./cache/builders/remote-data-build.service"; import { CommunityDataService } from "./data/community-data.service"; +import { PaginationOptions } from "./cache/models/pagination-options.model"; const IMPORTS = [ CommonModule, @@ -31,6 +33,7 @@ const PROVIDERS = [ ItemDataService, DSpaceRESTv2Service, ObjectCacheService, + PaginationOptions, ResponseCacheService, RequestService, RemoteDataBuildService diff --git a/src/app/header/header.component.html b/src/app/header/header.component.html index a4b7cf117c..5dac95d946 100644 --- a/src/app/header/header.component.html +++ b/src/app/header/header.component.html @@ -1,14 +1,14 @@
-