Skip to content

Commit

Permalink
Merge 23facb5 into 6203fb4
Browse files Browse the repository at this point in the history
  • Loading branch information
LotteHofstede committed May 9, 2019
2 parents 6203fb4 + 23facb5 commit 9910839
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 58 deletions.
45 changes: 25 additions & 20 deletions src/app/+admin/admin-sidebar/admin-sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,18 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
parentID: 'new',
active: false,
visible: true,
// model: {
// type: MenuItemType.ONCLICK,
// text: 'menu.section.new_item',
// function: () => {
// this.modalService.open(CreateItemParentSelectorComponent);
// }
// } as OnClickMenuItemModel,
model: {
type: MenuItemType.ONCLICK,
type: MenuItemType.LINK,
text: 'menu.section.new_item',
function: () => {
this.modalService.open(CreateItemParentSelectorComponent);
}
} as OnClickMenuItemModel,
link: '/submit'
} as LinkMenuItemModel,
},
{
id: 'new_item_version',
Expand All @@ -154,7 +159,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.new_item_version',
link: '#'
link: ''
} as LinkMenuItemModel,
},

Expand Down Expand Up @@ -230,7 +235,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.import_metadata',
link: '#'
link: ''
} as LinkMenuItemModel,
},
{
Expand All @@ -241,7 +246,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.import_batch',
link: '#'
link: ''
} as LinkMenuItemModel,
},
/* Export */
Expand All @@ -264,7 +269,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.export_community',
link: '#'
link: ''
} as LinkMenuItemModel,
},
{
Expand All @@ -275,7 +280,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.export_collection',
link: '#'
link: ''
} as LinkMenuItemModel,
},
{
Expand All @@ -286,7 +291,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.export_item',
link: '#'
link: ''
} as LinkMenuItemModel,
}, {
id: 'export_metadata',
Expand All @@ -296,7 +301,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.export_metadata',
link: '#'
link: ''
} as LinkMenuItemModel,
},

Expand All @@ -320,7 +325,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.access_control_people',
link: '#'
link: ''
} as LinkMenuItemModel,
},
{
Expand All @@ -331,7 +336,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.access_control_groups',
link: '#'
link: ''
} as LinkMenuItemModel,
},
{
Expand All @@ -342,7 +347,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.access_control_authorizations',
link: '#'
link: ''
} as LinkMenuItemModel,
},

Expand Down Expand Up @@ -377,7 +382,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.find_withdrawn_items',
link: '#'
link: ''
} as LinkMenuItemModel,
},
{
Expand All @@ -388,7 +393,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.find_private_items',
link: '/admin/items'
link: ''
} as LinkMenuItemModel,
},

Expand Down Expand Up @@ -435,7 +440,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.curation_task',
link: '/curation'
link: ''
} as LinkMenuItemModel,
icon: 'filter',
index: 7
Expand All @@ -449,7 +454,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.statistics_task',
link: '#'
link: ''
} as LinkMenuItemModel,
icon: 'chart-bar',
index: 8
Expand All @@ -463,7 +468,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
model: {
type: MenuItemType.LINK,
text: 'menu.section.control_panel',
link: '#'
link: ''
} as LinkMenuItemModel,
icon: 'cogs',
index: 9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { rendersSectionForMenu } from '../../../shared/menu/menu-section.decorat
templateUrl: './expandable-admin-sidebar-section.component.html',
styleUrls: ['./expandable-admin-sidebar-section.component.scss'],
animations: [rotate, slide, bgColor]

})

@rendersSectionForMenu(MenuID.ADMIN, true)
export class ExpandableAdminSidebarSectionComponent extends AdminSidebarSectionComponent implements OnInit {
/**
Expand Down
10 changes: 6 additions & 4 deletions src/app/+collection-page/collection-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable, Subscription } from 'rxjs';
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
import { CollectionDataService } from '../core/data/collection-data.service';
Expand All @@ -18,7 +18,7 @@ import { PaginationComponentOptions } from '../shared/pagination/pagination-comp
import { filter, flatMap, map, tap } 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 { redirectToPageNotFoundOn404, toDSpaceObjectListRD } from '../core/shared/operators';
import { DSpaceObjectType } from '../core/shared/dspace-object-type.model';

@Component({
Expand All @@ -44,7 +44,8 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
private collectionDataService: CollectionDataService,
private searchService: SearchService,
private metadata: MetadataService,
private route: ActivatedRoute
private route: ActivatedRoute,
private router: Router
) {
this.paginationConfig = new PaginationComponentOptions();
this.paginationConfig.id = 'collection-page-pagination';
Expand All @@ -55,7 +56,8 @@ export class CollectionPageComponent implements OnInit, OnDestroy {

ngOnInit(): void {
this.collectionRD$ = this.route.data.pipe(
map((data) => data.collection),
map((data) => data.collection as RemoteData<Collection>),
redirectToPageNotFoundOn404(this.router),
tap((data) => this.collectionId = data.payload.id)
);
this.logoRD$ = this.collectionRD$.pipe(
Expand Down
8 changes: 5 additions & 3 deletions src/app/+collection-page/collection-page.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Collection } from '../core/shared/collection.model';
import { Observable } from 'rxjs';
import { CollectionDataService } from '../core/data/collection-data.service';
import { RemoteData } from '../core/data/remote-data';
import { getSucceededRemoteData } from '../core/shared/operators';
import { find } from 'rxjs/operators';
import { hasValue } from '../shared/empty.util';

/**
* This class represents a resolver that requests a specific collection before the route is activated
Expand All @@ -18,11 +19,12 @@ export class CollectionPageResolver implements Resolve<RemoteData<Collection>> {
* 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<<RemoteData<Collection>> Emits the found collection based on the parameters in the current route
* @returns Observable<<RemoteData<Collection>> Emits the found collection based on the parameters in the current route,
* or an error if something went wrong
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<Collection>> {
return this.collectionService.findById(route.params.id).pipe(
getSucceededRemoteData()
find((RD) => hasValue(RD.error) || RD.hasSucceeded),
);
}
}
11 changes: 8 additions & 3 deletions src/app/+community-page/community-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mergeMap, filter, map } from 'rxjs/operators';
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';

import { Subscription, Observable } from 'rxjs';
import { CommunityDataService } from '../core/data/community-data.service';
Expand All @@ -13,6 +13,7 @@ import { MetadataService } from '../core/metadata/metadata.service';

import { fadeInOut } from '../shared/animations/fade';
import { hasValue } from '../shared/empty.util';
import { redirectToPageNotFoundOn404 } from '../core/shared/operators';

@Component({
selector: 'ds-community-page',
Expand All @@ -37,13 +38,17 @@ export class CommunityPageComponent implements OnInit {
constructor(
private communityDataService: CommunityDataService,
private metadata: MetadataService,
private route: ActivatedRoute
private route: ActivatedRoute,
private router: Router
) {

}

ngOnInit(): void {
this.communityRD$ = this.route.data.pipe(map((data) => data.community));
this.communityRD$ = this.route.data.pipe(
map((data) => data.community as RemoteData<Community>),
redirectToPageNotFoundOn404(this.router)
);
this.logoRD$ = this.communityRD$.pipe(
map((rd: RemoteData<Community>) => rd.payload),
filter((community: Community) => hasValue(community)),
Expand Down
8 changes: 5 additions & 3 deletions src/app/+community-page/community-page.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { RemoteData } from '../core/data/remote-data';
import { getSucceededRemoteData } from '../core/shared/operators';
import { Community } from '../core/shared/community.model';
import { CommunityDataService } from '../core/data/community-data.service';
import { find } from 'rxjs/operators';
import { hasValue } from '../shared/empty.util';

/**
* This class represents a resolver that requests a specific community before the route is activated
Expand All @@ -18,11 +19,12 @@ export class CommunityPageResolver implements Resolve<RemoteData<Community>> {
* Method for resolving a community based on the parameters in the current route
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
* @returns Observable<<RemoteData<Community>> Emits the found community based on the parameters in the current route
* @returns Observable<<RemoteData<Community>> Emits the found community based on the parameters in the current route,
* or an error if something went wrong
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<Community>> {
return this.communityService.findById(route.params.id).pipe(
getSucceededRemoteData()
find((RD) => hasValue(RD.error) || RD.hasSucceeded)
);
}
}
6 changes: 3 additions & 3 deletions src/app/+item-page/full/full-item-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import {filter, map} from 'rxjs/operators';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';

import { Observable } from 'rxjs';

Expand Down Expand Up @@ -36,8 +36,8 @@ export class FullItemPageComponent extends ItemPageComponent implements OnInit {

metadata$: Observable<MetadataMap>;

constructor(route: ActivatedRoute, items: ItemDataService, metadataService: MetadataService) {
super(route, items, metadataService);
constructor(route: ActivatedRoute, router: Router, items: ItemDataService, metadataService: MetadataService) {
super(route, router, items, metadataService);
}

/*** AoT inheritance fix, will hopefully be resolved in the near future **/
Expand Down
13 changes: 8 additions & 5 deletions src/app/+item-page/item-page.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { RemoteData } from '../core/data/remote-data';
import { getSucceededRemoteData } from '../core/shared/operators';
import { ItemDataService } from '../core/data/item-data.service';
import { Item } from '../core/shared/item.model';
import { hasValue } from '../shared/empty.util';
import { find } from 'rxjs/operators';

/**
* This class represents a resolver that requests a specific item before the route is activated
Expand All @@ -18,11 +19,13 @@ export class ItemPageResolver implements Resolve<RemoteData<Item>> {
* Method for resolving an item based on the parameters in the current route
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
* @returns Observable<<RemoteData<Item>> Emits the found item based on the parameters in the current route
* @returns Observable<<RemoteData<Item>> Emits the found item based on the parameters in the current route,
* or an error if something went wrong
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<Item>> {
return this.itemService.findById(route.params.id).pipe(
getSucceededRemoteData()
);
return this.itemService.findById(route.params.id)
.pipe(
find((RD) => hasValue(RD.error) || RD.hasSucceeded),
);
}
}
15 changes: 9 additions & 6 deletions src/app/+item-page/simple/item-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import {mergeMap, filter, map} from 'rxjs/operators';
import { mergeMap, filter, map, take } from 'rxjs/operators';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';

import { Observable } from 'rxjs';
import { ItemDataService } from '../../core/data/item-data.service';
Expand All @@ -14,6 +14,7 @@ import { MetadataService } from '../../core/metadata/metadata.service';

import { fadeInOut } from '../../shared/animations/fade';
import { hasValue } from '../../shared/empty.util';
import { redirectToPageNotFoundOn404 } from '../../core/shared/operators';

/**
* This component renders a simple item page.
Expand All @@ -31,26 +32,28 @@ export class ItemPageComponent implements OnInit {

id: number;

private sub: any;

itemRD$: Observable<RemoteData<Item>>;

thumbnail$: Observable<Bitstream>;

constructor(
private route: ActivatedRoute,
private router: Router,
private items: ItemDataService,
private metadataService: MetadataService
) {

}

ngOnInit(): void {
this.itemRD$ = this.route.data.pipe(map((data) => data.item));
this.itemRD$ = this.route.data.pipe(
map((data) => data.item as RemoteData<Item>),
redirectToPageNotFoundOn404(this.router)
);
this.metadataService.processRemoteData(this.itemRD$);
this.thumbnail$ = this.itemRD$.pipe(
map((rd: RemoteData<Item>) => rd.payload),
filter((item: Item) => hasValue(item)),
mergeMap((item: Item) => item.getThumbnail()),);
mergeMap((item: Item) => item.getThumbnail()));
}
}

0 comments on commit 9910839

Please sign in to comment.