-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch '4Science-bitbucket/main' into CST-5249_…
…suggestion
- Loading branch information
Showing
40 changed files
with
5,613 additions
and
7,006 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; | ||
import { Bitstream } from '../shared/bitstream.model'; | ||
import { BitstreamDataService } from '../data/bitstream-data.service'; | ||
import { BITSTREAM_PAGE_LINKS_TO_FOLLOW } from '../../bitstream-page/bitstream-page.resolver'; | ||
import { DSOBreadcrumbResolver } from './dso-breadcrumb.resolver'; | ||
import { BitstreamBreadcrumbsService } from './bitstream-breadcrumbs.service'; | ||
|
||
/** | ||
* The class that resolves the BreadcrumbConfig object for an Item | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class BitstreamBreadcrumbResolver extends DSOBreadcrumbResolver<Bitstream> { | ||
constructor( | ||
protected breadcrumbService: BitstreamBreadcrumbsService, protected dataService: BitstreamDataService) { | ||
super(breadcrumbService, dataService); | ||
} | ||
|
||
/** | ||
* Method that returns the follow links to already resolve | ||
* The self links defined in this list are expected to be requested somewhere in the near future | ||
* Requesting them as embeds will limit the number of requests | ||
*/ | ||
get followLinks(): FollowLinkConfig<Bitstream>[] { | ||
return BITSTREAM_PAGE_LINKS_TO_FOLLOW; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
import { Observable, of as observableOf } from 'rxjs'; | ||
import { map, switchMap } from 'rxjs/operators'; | ||
|
||
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model'; | ||
import { DSONameService } from './dso-name.service'; | ||
import { ChildHALResource } from '../shared/child-hal-resource.model'; | ||
import { LinkService } from '../cache/builders/link.service'; | ||
import { DSpaceObject } from '../shared/dspace-object.model'; | ||
import { RemoteData } from '../data/remote-data'; | ||
import { hasValue, isNotEmpty } from '../../shared/empty.util'; | ||
import { getDSORoute } from '../../app-routing-paths'; | ||
import { DSOBreadcrumbsService } from './dso-breadcrumbs.service'; | ||
import { BitstreamDataService } from '../data/bitstream-data.service'; | ||
import { getFirstCompletedRemoteData, getRemoteDataPayload } from '../shared/operators'; | ||
import { Bitstream } from '../shared/bitstream.model'; | ||
import { Bundle } from '../shared/bundle.model'; | ||
import { Item } from '../shared/item.model'; | ||
import { BITSTREAM_PAGE_LINKS_TO_FOLLOW } from '../../bitstream-page/bitstream-page.resolver'; | ||
|
||
/** | ||
* Service to calculate DSpaceObject breadcrumbs for a single part of the route | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class BitstreamBreadcrumbsService extends DSOBreadcrumbsService { | ||
constructor( | ||
protected bitstreamService: BitstreamDataService, | ||
protected linkService: LinkService, | ||
protected dsoNameService: DSONameService | ||
) { | ||
super(linkService, dsoNameService); | ||
} | ||
|
||
/** | ||
* Method to recursively calculate the breadcrumbs | ||
* This method returns the name and url of the key and all its parent DSOs recursively, top down | ||
* @param key The key (a DSpaceObject) used to resolve the breadcrumb | ||
* @param url The url to use as a link for this breadcrumb | ||
*/ | ||
getBreadcrumbs(key: ChildHALResource & DSpaceObject, url: string): Observable<Breadcrumb[]> { | ||
const label = this.dsoNameService.getName(key); | ||
const crumb = new Breadcrumb(label, url); | ||
|
||
return this.getOwningItem(key.uuid).pipe( | ||
switchMap((parentRD: RemoteData<ChildHALResource & DSpaceObject>) => { | ||
if (isNotEmpty(parentRD) && hasValue(parentRD.payload)) { | ||
const parent = parentRD.payload; | ||
return super.getBreadcrumbs(parent, getDSORoute(parent)); | ||
} | ||
return observableOf([]); | ||
|
||
}), | ||
map((breadcrumbs: Breadcrumb[]) => [...breadcrumbs, crumb]) | ||
); | ||
} | ||
|
||
getOwningItem(uuid: string): Observable<RemoteData<Item>> { | ||
return this.bitstreamService.findById(uuid, true, true, ...BITSTREAM_PAGE_LINKS_TO_FOLLOW).pipe( | ||
getFirstCompletedRemoteData(), | ||
getRemoteDataPayload(), | ||
switchMap((bitstream: Bitstream) => { | ||
if (hasValue(bitstream)) { | ||
return bitstream.bundle.pipe( | ||
getFirstCompletedRemoteData(), | ||
getRemoteDataPayload(), | ||
switchMap((bundle: Bundle) => { | ||
if (hasValue(bundle)) { | ||
return bundle.item.pipe( | ||
getFirstCompletedRemoteData(), | ||
); | ||
} else { | ||
return observableOf(undefined); | ||
} | ||
}) | ||
); | ||
} else { | ||
return observableOf(undefined); | ||
} | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/item-page/bitstreams/upload/upload-bitstream.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.