+ *ngVar="(collectionRD$ | async) as collectionRD">
@@ -8,8 +8,8 @@
[name]="collection.name">
-
@@ -38,14 +38,14 @@
-
+
{{'collection.page.browse.recent.head' | translate}}
diff --git a/src/app/+collection-page/collection-page.component.ts b/src/app/+collection-page/collection-page.component.ts
index 4a935b73b9..89567c4a54 100644
--- a/src/app/+collection-page/collection-page.component.ts
+++ b/src/app/+collection-page/collection-page.component.ts
@@ -5,7 +5,6 @@ import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
import { CollectionDataService } from '../core/data/collection-data.service';
-import { ItemDataService } from '../core/data/item-data.service';
import { PaginatedList } from '../core/data/paginated-list';
import { RemoteData } from '../core/data/remote-data';
@@ -18,6 +17,11 @@ import { Item } from '../core/shared/item.model';
import { fadeIn, fadeInOut } from '../shared/animations/fade';
import { hasValue, isNotEmpty } from '../shared/empty.util';
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
+import { filter, flatMap, map } from 'rxjs/operators';
+import { SearchService } from '../+search-page/search-service/search.service';
+import { PaginatedSearchOptions } from '../+search-page/paginated-search-options.model';
+import { toDSpaceObjectListRD } from '../core/shared/operators';
+import { DSpaceObjectType } from '../core/shared/dspace-object-type.model';
@Component({
selector: 'ds-collection-page',
@@ -30,9 +34,9 @@ import { PaginationComponentOptions } from '../shared/pagination/pagination-comp
]
})
export class CollectionPageComponent implements OnInit, OnDestroy {
- collectionRDObs: Observable>;
- itemRDObs: Observable>>;
- logoRDObs: Observable>;
+ collectionRD$: Observable>;
+ itemRD$: Observable>>;
+ logoRD$: Observable>;
paginationConfig: PaginationComponentOptions;
sortConfig: SortOptions;
private subs: Subscription[] = [];
@@ -40,7 +44,7 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
constructor(
private collectionDataService: CollectionDataService,
- private itemDataService: ItemDataService,
+ private searchService: SearchService,
private metadata: MetadataService,
private route: ActivatedRoute
) {
@@ -48,52 +52,41 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
this.paginationConfig.id = 'collection-page-pagination';
this.paginationConfig.pageSize = 5;
this.paginationConfig.currentPage = 1;
- this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
+ this.sortConfig = new SortOptions('dc.date.accessioned', SortDirection.DESC);
}
ngOnInit(): void {
+ this.collectionRD$ = this.route.data.map((data) => data.collection);
+ this.logoRD$ = this.collectionRD$.pipe(
+ map((rd: RemoteData) => rd.payload),
+ filter((collection: Collection) => hasValue(collection)),
+ flatMap((collection: Collection) => collection.logo)
+ );
this.subs.push(
- Observable.combineLatest(
- this.route.params,
- this.route.queryParams,
- (params, queryParams, ) => {
- return Object.assign({}, params, queryParams);
- })
- .subscribe((params) => {
- this.collectionId = params.id;
- this.collectionRDObs = this.collectionDataService.findById(this.collectionId);
- this.metadata.processRemoteData(this.collectionRDObs);
- this.subs.push(this.collectionRDObs
- .map((rd: RemoteData) => rd.payload)
- .filter((collection: Collection) => hasValue(collection))
- .subscribe((collection: Collection) => this.logoRDObs = collection.logo));
-
- const page = +params.page || this.paginationConfig.currentPage;
- const pageSize = +params.pageSize || this.paginationConfig.pageSize;
- const sortDirection = +params.page || this.sortConfig.direction;
- const pagination = Object.assign({},
- this.paginationConfig,
- { currentPage: page, pageSize: pageSize }
- );
- const sort = Object.assign({},
- this.sortConfig,
- { direction: sortDirection, field: params.sortField }
- );
- this.updatePage({
- pagination: pagination,
- sort: sort
- });
- }));
+ this.route.queryParams.subscribe((params) => {
+ this.metadata.processRemoteData(this.collectionRD$);
+ const page = +params.page || this.paginationConfig.currentPage;
+ const pageSize = +params.pageSize || this.paginationConfig.pageSize;
+ const pagination = Object.assign({},
+ this.paginationConfig,
+ { currentPage: page, pageSize: pageSize }
+ );
+ this.updatePage({
+ pagination: pagination,
+ sort: this.sortConfig
+ });
+ }));
}
updatePage(searchOptions) {
- this.itemRDObs = this.itemDataService.findAll({
- scopeID: this.collectionId,
- currentPage: searchOptions.pagination.currentPage,
- elementsPerPage: searchOptions.pagination.pageSize,
- sort: searchOptions.sort
- });
+ this.itemRD$ = this.searchService.search(
+ new PaginatedSearchOptions({
+ scope: this.collectionId,
+ pagination: searchOptions.pagination,
+ sort: searchOptions.sort,
+ dsoType: DSpaceObjectType.ITEM
+ })).pipe(toDSpaceObjectListRD()) as Observable>>;
}
ngOnDestroy(): void {
diff --git a/src/app/+collection-page/collection-page.module.ts b/src/app/+collection-page/collection-page.module.ts
index d0bc918b22..85462e67a3 100644
--- a/src/app/+collection-page/collection-page.module.ts
+++ b/src/app/+collection-page/collection-page.module.ts
@@ -5,11 +5,13 @@ import { SharedModule } from '../shared/shared.module';
import { CollectionPageComponent } from './collection-page.component';
import { CollectionPageRoutingModule } from './collection-page-routing.module';
+import { SearchPageModule } from '../+search-page/search-page.module';
@NgModule({
imports: [
CommonModule,
SharedModule,
+ SearchPageModule,
CollectionPageRoutingModule
],
declarations: [
diff --git a/src/app/+collection-page/collection-page.resolver.ts b/src/app/+collection-page/collection-page.resolver.ts
new file mode 100644
index 0000000000..c049901bf2
--- /dev/null
+++ b/src/app/+collection-page/collection-page.resolver.ts
@@ -0,0 +1,28 @@
+import { Injectable } from '@angular/core';
+import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
+import { Collection } from '../core/shared/collection.model';
+import { Observable } from 'rxjs/Observable';
+import { CollectionDataService } from '../core/data/collection-data.service';
+import { RemoteData } from '../core/data/remote-data';
+import { getSucceededRemoteData } from '../core/shared/operators';
+
+/**
+ * This class represents a resolver that requests a specific collection before the route is activated
+ */
+@Injectable()
+export class CollectionPageResolver implements Resolve> {
+ constructor(private collectionService: CollectionDataService) {
+ }
+
+ /**
+ * Method for resolving a collection based on the parameters in the current route
+ * @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
+ * @param {RouterStateSnapshot} state The current RouterStateSnapshot
+ * @returns Observable<> Emits the found collection based on the parameters in the current route
+ */
+ resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable> {
+ return this.collectionService.findById(route.params.id).pipe(
+ getSucceededRemoteData()
+ );
+ }
+}
diff --git a/src/app/+community-page/community-page-routing.module.ts b/src/app/+community-page/community-page-routing.module.ts
index 6fd5cc8cb5..4cc927d341 100644
--- a/src/app/+community-page/community-page-routing.module.ts
+++ b/src/app/+community-page/community-page-routing.module.ts
@@ -2,12 +2,23 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { CommunityPageComponent } from './community-page.component';
+import { CommunityPageResolver } from './community-page.resolver';
@NgModule({
imports: [
RouterModule.forChild([
- { path: ':id', component: CommunityPageComponent, pathMatch: 'full' }
+ {
+ path: ':id',
+ component: CommunityPageComponent,
+ pathMatch: 'full',
+ resolve: {
+ community: CommunityPageResolver
+ }
+ }
])
+ ],
+ providers: [
+ CommunityPageResolver,
]
})
export class CommunityPageRoutingModule {
diff --git a/src/app/+community-page/community-page.component.html b/src/app/+community-page/community-page.component.html
index 976e1091e5..637e37af0c 100644
--- a/src/app/+community-page/community-page.component.html
+++ b/src/app/+community-page/community-page.component.html
@@ -1,11 +1,11 @@
-