Skip to content

Commit

Permalink
Merge remote-tracking branch '4Science-bitbucket/main' into CST-5249_…
Browse files Browse the repository at this point in the history
…suggestion
  • Loading branch information
LucaGiamminonni committed May 4, 2022
2 parents 11d25e6 + 37ebe25 commit a798ded
Show file tree
Hide file tree
Showing 40 changed files with 5,613 additions and 7,006 deletions.
7 changes: 7 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ languages:
- code: fi
label: Suomi
active: true
- code: tr
label: Türkçe
active: true
- code: bn
label: বাংলা
active: true
Expand Down Expand Up @@ -231,6 +234,10 @@ themes:
rel: manifest
href: assets/dspace/images/favicons/manifest.webmanifest

# The default bundles that should always be displayed as suggestions when you upload a new bundle
bundle:
- standardBundles: [ ORIGINAL, THUMBNAIL, LICENSE ]

# Whether to enable media viewer for image and/or video Bitstreams (i.e. Bitstreams whose MIME type starts with 'image' or 'video').
# For images, this enables a gallery viewer where you can zoom or page through images.
# For videos, this enables embedded video streaming
Expand Down
14 changes: 11 additions & 3 deletions src/app/bitstream-page/bitstream-page-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { ResourcePolicyResolver } from '../shared/resource-policies/resolvers/re
import { ResourcePolicyEditComponent } from '../shared/resource-policies/edit/resource-policy-edit.component';
import { BitstreamAuthorizationsComponent } from './bitstream-authorizations/bitstream-authorizations.component';
import { LegacyBitstreamUrlResolver } from './legacy-bitstream-url.resolver';
import { BitstreamBreadcrumbResolver } from '../core/breadcrumbs/bitstream-breadcrumb.resolver';
import { BitstreamBreadcrumbsService } from '../core/breadcrumbs/bitstream-breadcrumbs.service';
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';

const EDIT_BITSTREAM_PATH = ':id/edit';
const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
Expand Down Expand Up @@ -48,7 +51,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
path: EDIT_BITSTREAM_PATH,
component: EditBitstreamPageComponent,
resolve: {
bitstream: BitstreamPageResolver
bitstream: BitstreamPageResolver,
breadcrumb: BitstreamBreadcrumbResolver,
},
canActivate: [AuthenticatedGuard]
},
Expand All @@ -67,15 +71,17 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
{
path: 'edit',
resolve: {
breadcrumb: I18nBreadcrumbResolver,
resourcePolicy: ResourcePolicyResolver
},
component: ResourcePolicyEditComponent,
data: { title: 'resource-policies.edit.page.title', showBreadcrumbs: true }
data: { breadcrumbKey: 'item.edit', title: 'resource-policies.edit.page.title', showBreadcrumbs: true }
},
{
path: '',
resolve: {
bitstream: BitstreamPageResolver
bitstream: BitstreamPageResolver,
breadcrumb: BitstreamBreadcrumbResolver,
},
component: BitstreamAuthorizationsComponent,
data: { title: 'bitstream.edit.authorizations.title', showBreadcrumbs: true }
Expand All @@ -86,6 +92,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
],
providers: [
BitstreamPageResolver,
BitstreamBreadcrumbResolver,
BitstreamBreadcrumbsService
]
})
export class BitstreamPageRoutingModule {
Expand Down
14 changes: 10 additions & 4 deletions src/app/bitstream-page/bitstream-page.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ import { BitstreamDataService } from '../core/data/bitstream-data.service';
import { followLink, FollowLinkConfig } from '../shared/utils/follow-link-config.model';
import { getFirstCompletedRemoteData } from '../core/shared/operators';

/**
* 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
*/
export const BITSTREAM_PAGE_LINKS_TO_FOLLOW: FollowLinkConfig<Bitstream>[] = [
followLink('bundle', {}, followLink('item')),
followLink('format')
];

/**
* This class represents a resolver that requests a specific bitstream before the route is activated
*/
Expand Down Expand Up @@ -34,9 +43,6 @@ export class BitstreamPageResolver implements Resolve<RemoteData<Bitstream>> {
* Requesting them as embeds will limit the number of requests
*/
get followLinks(): FollowLinkConfig<Bitstream>[] {
return [
followLink('bundle', {}, followLink('item')),
followLink('format')
];
return BITSTREAM_PAGE_LINKS_TO_FOLLOW;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
<section class="comcol-page-browse-section">
<div class="browse-by-metadata w-100">
<ds-browse-by *ngIf="startsWithOptions" class="col-xs-12 w-100"
title="{{'browse.title' | translate:{collection: (parent$ | async)?.payload?.name || '', field: 'browse.metadata.' + browseId | translate, value: (value)? '&quot;' + value + '&quot;': ''} }}"
title="{{'browse.title' | translate:
{
collection: (parent$ | async)?.payload?.name || '',
field: 'browse.metadata.' + browseId | translate,
startsWith: (startsWith)? ('browse.startsWith' | translate: { startsWith: '&quot;' + startsWith + '&quot;' }) : '',
value: (value)? '&quot;' + value + '&quot;': ''
} }}"
parentname="{{(parent$ | async)?.payload?.name || ''}}"
[objects$]="(items$ !== undefined)? items$ : browseEntries$"
[paginationConfig]="(currentPagination$ |async)"
Expand Down
2 changes: 1 addition & 1 deletion src/app/browse-by/browse-by-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ThemedBrowseBySwitcherComponent } from './browse-by-switcher/themed-bro
component: ThemedBrowseBySwitcherComponent,
canActivate: [BrowseByGuard],
resolve: { breadcrumb: BrowseByI18nBreadcrumbResolver },
data: { title: 'browse.title', breadcrumbKey: 'browse.metadata' }
data: { title: 'browse.title.page', breadcrumbKey: 'browse.metadata' }
}
]
}])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
return [Object.assign({}, routeParams, queryParams),currentPage,currentSort];
})
).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
this.startsWith = +params.startsWith || params.startsWith;
this.browseId = params.id || this.defaultBrowseId;
this.updatePageWithItems(browseParamsToOptions(params, currentPage, currentSort, this.browseId), undefined, undefined);
this.updateParent(params.scope);
Expand Down
31 changes: 31 additions & 0 deletions src/app/core/breadcrumbs/bitstream-breadcrumb.resolver.ts
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;
}

}
85 changes: 85 additions & 0 deletions src/app/core/breadcrumbs/bitstream-breadcrumbs.service.ts
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);
}
})
);
}
}
4 changes: 2 additions & 2 deletions src/app/core/breadcrumbs/dso-breadcrumbs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { getDSORoute } from '../../app-routing-paths';
})
export class DSOBreadcrumbsService implements BreadcrumbsProviderService<ChildHALResource & DSpaceObject> {
constructor(
private linkService: LinkService,
private dsoNameService: DSONameService
protected linkService: LinkService,
protected dsoNameService: DSONameService
) {

}
Expand Down
16 changes: 16 additions & 0 deletions src/app/core/metadata/metadata.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ describe('MetadataService', () => {
});
}));

it('route titles should overwrite dso titles', fakeAsync(() => {
(translateService.get as jasmine.Spy).and.returnValues(of('DSpace :: '), of('Translated Route Title'));
(metadataService as any).processRouteChange({
data: {
value: {
dso: createSuccessfulRemoteDataObject(ItemMock),
title: 'route.title.key',
}
}
});
tick();
expect(title.setTitle).toHaveBeenCalledTimes(2);
expect((title.setTitle as jasmine.Spy).calls.argsFor(0)).toEqual(['Test PowerPoint Document']);
expect((title.setTitle as jasmine.Spy).calls.argsFor(1)).toEqual(['DSpace :: Translated Route Title']);
}));

it('other navigation should add title and description', fakeAsync(() => {
(translateService.get as jasmine.Spy).and.returnValues(of('DSpace :: '), of('Dummy Title'), of('This is a dummy item component for testing!'));
(metadataService as any).processRouteChange({
Expand Down
10 changes: 5 additions & 5 deletions src/app/core/metadata/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ export class MetadataService {
private processRouteChange(routeInfo: any): void {
this.clearMetaTags();

if (hasValue(routeInfo.data.value.dso) && hasValue(routeInfo.data.value.dso.payload)) {
this.currentObject.next(routeInfo.data.value.dso.payload);
this.setDSOMetaTags();
}

if (routeInfo.data.value.title) {
const titlePrefix = this.translate.get('repository.title.prefix');
const title = this.translate.get(routeInfo.data.value.title, routeInfo.data.value);
Expand All @@ -122,11 +127,6 @@ export class MetadataService {
this.addMetaTag('description', translatedDescription);
});
}

if (hasValue(routeInfo.data.value.dso) && hasValue(routeInfo.data.value.dso.payload)) {
this.currentObject.next(routeInfo.data.value.dso.payload);
this.setDSOMetaTags();
}
}

private getCurrentRoute(route: ActivatedRoute): ActivatedRoute {
Expand Down
8 changes: 6 additions & 2 deletions src/app/core/shared/bitstream.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { BITSTREAM_FORMAT } from './bitstream-format.resource-type';
import { BITSTREAM } from './bitstream.resource-type';
import { DSpaceObject } from './dspace-object.model';
import { HALLink } from './hal-link.model';
import { HALResource } from './hal-resource.model';
import {BUNDLE} from './bundle.resource-type';
import {Bundle} from './bundle.model';
import { ChildHALResource } from './child-hal-resource.model';

@typedObject
@inheritSerialization(DSpaceObject)
export class Bitstream extends DSpaceObject implements HALResource {
export class Bitstream extends DSpaceObject implements ChildHALResource {
static type = BITSTREAM;

/**
Expand Down Expand Up @@ -66,4 +66,8 @@ export class Bitstream extends DSpaceObject implements HALResource {
*/
@link(BUNDLE)
bundle?: Observable<RemoteData<Bundle>>;

getParentLinkKey(): keyof this['_links'] {
return 'format';
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="container" *ngVar="(bundlesRD$ | async)?.payload?.page as bundles">
<div class="container">
<ng-container *ngIf="bundles">
<div class="row">
<div class="col-12 mb-4">
Expand Down
Loading

0 comments on commit a798ded

Please sign in to comment.