Merge remote-tracking branch '4Science-bitbucket/main' into CST-5249_suggestion

This commit is contained in:
Luca Giamminonni
2022-05-04 15:28:52 +02:00
40 changed files with 5613 additions and 7006 deletions

View File

@@ -148,6 +148,9 @@ languages:
- code: fi
label: Suomi
active: true
- code: tr
label: Türkçe
active: true
- code: bn
label: বাংলা
active: true
@@ -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

View File

@@ -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';
@@ -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]
},
@@ -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 }
@@ -86,6 +92,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
],
providers: [
BitstreamPageResolver,
BitstreamBreadcrumbResolver,
BitstreamBreadcrumbsService
]
})
export class BitstreamPageRoutingModule {

View File

@@ -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
*/
@@ -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;
}
}

View File

@@ -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)"

View File

@@ -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' }
}
]
}])

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -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);
}
})
);
}
}

View File

@@ -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
) {
}

View File

@@ -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({

View File

@@ -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);
@@ -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 {

View File

@@ -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;
/**
@@ -66,4 +66,8 @@ export class Bitstream extends DSpaceObject implements HALResource {
*/
@link(BUNDLE)
bundle?: Observable<RemoteData<Bundle>>;
getParentLinkKey(): keyof this['_links'] {
return 'format';
}
}

View File

@@ -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">

View File

@@ -21,19 +21,23 @@ import { createPaginatedList } from '../../../shared/testing/utils.test';
import { RouterStub } from '../../../shared/testing/router.stub';
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
import { AuthServiceStub } from '../../../shared/testing/auth-service.stub';
import { getTestScheduler } from 'jasmine-marbles';
import { environment } from '../../../../environments/environment';
import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import { PageInfo } from '../../../core/shared/page-info.model';
describe('UploadBistreamComponent', () => {
describe('UploadBitstreamComponent', () => {
let comp: UploadBitstreamComponent;
let fixture: ComponentFixture<UploadBitstreamComponent>;
const customName = 'customBundleName';
const bundle = Object.assign(new Bundle(), {
id: 'bundle',
uuid: 'bundle',
name: customName,
metadata: {
'dc.title': [
{
value: 'bundleName',
value: customName,
language: null
}
]
@@ -42,14 +46,15 @@ describe('UploadBistreamComponent', () => {
self: { href: 'bundle-selflink' }
}
});
const customName = 'Custom Name';
const customCreatedName = 'customCreatedBundleName';
const createdBundle = Object.assign(new Bundle(), {
id: 'created-bundle',
uuid: 'created-bundle',
name: customCreatedName,
metadata: {
'dc.title': [
{
value: customName,
value: customCreatedName,
language: null
}
]
@@ -72,13 +77,14 @@ describe('UploadBistreamComponent', () => {
},
bundles: createSuccessfulRemoteDataObject$(createPaginatedList([bundle]))
});
const standardBundleSuggestions = environment.bundle.standardBundles;
let routeStub;
const routerStub = new RouterStub();
const restEndpoint = 'fake-rest-endpoint';
const mockItemDataService = jasmine.createSpyObj('mockItemDataService', {
getBitstreamsEndpoint: observableOf(restEndpoint),
createBundle: createSuccessfulRemoteDataObject$(createdBundle),
getBundles: createSuccessfulRemoteDataObject$([bundle])
getBundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [bundle])),
});
const bundleService = jasmine.createSpyObj('bundleService', {
getBitstreamsEndpoint: observableOf(restEndpoint),
@@ -94,22 +100,6 @@ describe('UploadBistreamComponent', () => {
removeByHrefSubstring: {}
});
describe('on init', () => {
beforeEach(waitForAsync(() => {
createUploadBitstreamTestingModule({
bundle: bundle.id
});
}));
beforeEach(() => {
loadFixtureAndComp();
});
it('should initialize the bundles', () => {
expect(comp.bundlesRD$).toBeDefined();
getTestScheduler().expectObservable(comp.bundlesRD$).toBe('(a|)', {a: createSuccessfulRemoteDataObject([bundle])});
});
});
describe('when a file is uploaded', () => {
beforeEach(waitForAsync(() => {
createUploadBitstreamTestingModule({});
@@ -164,12 +154,24 @@ describe('UploadBistreamComponent', () => {
});
describe('and bundle name changed', () => {
beforeEach(() => {
beforeEach(waitForAsync(() => {
jasmine.getEnv().allowRespy(true);
mockItemDataService.getBundles.and.returnValue(createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [bundle])));
loadFixtureAndComp();
}));
it('should clear out the selected id if the name doesn\'t exist', () => {
comp.selectedBundleName = '';
comp.bundleNameChange();
expect(comp.selectedBundleId).toBeUndefined();
});
it('should clear out the selected id', () => {
expect(comp.selectedBundleId).toBeUndefined();
it('should select the correct id if the name exist', () => {
comp.selectedBundleName = customName;
comp.bundleNameChange();
expect(comp.selectedBundleId).toEqual(bundle.id);
});
});
});
@@ -203,6 +205,69 @@ describe('UploadBistreamComponent', () => {
});
});
describe('when item has no bundles yet', () => {
beforeEach(waitForAsync(() => {
createUploadBitstreamTestingModule({
bundle: bundle.id
});
jasmine.getEnv().allowRespy(true);
mockItemDataService.getBundles.and.returnValue(createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])));
loadFixtureAndComp();
}));
it('should display only the standard bundles in dropdown', () => {
expect(comp.bundles.length).toEqual(standardBundleSuggestions.length);
for (let i = 0; i < standardBundleSuggestions.length; i++) {
// noinspection JSDeprecatedSymbols
expect(comp.bundles[i].name).toEqual(standardBundleSuggestions[i]);
}
});
});
describe('when item has a custom bundle', () => {
beforeEach(waitForAsync(() => {
createUploadBitstreamTestingModule({
bundle: bundle.id
});
jasmine.getEnv().allowRespy(true);
mockItemDataService.getBundles.and.returnValue(createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [bundle])));
loadFixtureAndComp();
}));
it('should still display existing bitstream bundles if the bitstream has bundles', () => {
const expectedSuggestions = [bundle.name, ...standardBundleSuggestions];
expect(comp.bundles.length).toEqual(expectedSuggestions.length);
for (let i = 0; i < expectedSuggestions.length; i++) {
// noinspection JSDeprecatedSymbols
expect(comp.bundles[i].name).toEqual(expectedSuggestions[i]);
}
});
});
describe('when item has a standard bundle', () => {
let clonedBundle;
beforeEach(waitForAsync(() => {
clonedBundle = { ...bundle };
expect(standardBundleSuggestions.length).toBeGreaterThan(0);
clonedBundle.name = standardBundleSuggestions[0];
createUploadBitstreamTestingModule({
bundle: clonedBundle.id
});
jasmine.getEnv().allowRespy(true);
mockItemDataService.getBundles.and.returnValue(createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [clonedBundle])));
loadFixtureAndComp();
}));
it('should not show duplicate bundle names', () => {
const expectedSuggestions = [clonedBundle.name, ...standardBundleSuggestions.filter((standardBundleSuggestion: string) => standardBundleSuggestion !== clonedBundle.name)];
expect(comp.bundles.length).toEqual(expectedSuggestions.length);
for (let i = 0; i < expectedSuggestions.length; i++) {
// noinspection JSDeprecatedSymbols
expect(comp.bundles[i].name).toEqual(expectedSuggestions[i]);
}
});
});
/**
* Setup an UploadBitstreamComponent testing module with custom queryParams for the route
* @param queryParams

View File

@@ -1,8 +1,8 @@
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { Observable, Subscription } from 'rxjs';
import { Observable, Subscription, of as observableOf } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data';
import { Item } from '../../../core/shared/item.model';
import { map, take } from 'rxjs/operators';
import { map, take, switchMap } from 'rxjs/operators';
import { ActivatedRoute, Router } from '@angular/router';
import { UploaderOptions } from '../../../shared/uploader/uploader-options.model';
import { hasValue, isEmpty, isNotEmpty } from '../../../shared/empty.util';
@@ -13,11 +13,12 @@ import { TranslateService } from '@ngx-translate/core';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { Bundle } from '../../../core/shared/bundle.model';
import { BundleDataService } from '../../../core/data/bundle-data.service';
import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators';
import { getFirstSucceededRemoteDataPayload, getFirstCompletedRemoteData } from '../../../core/shared/operators';
import { UploaderComponent } from '../../../shared/uploader/uploader.component';
import { RequestService } from '../../../core/data/request.service';
import { getBitstreamModuleRoute } from '../../../app-routing-paths';
import { getEntityEditRoute } from '../../item-page-routing-paths';
import { environment } from '../../../../environments/environment';
@Component({
selector: 'ds-upload-bitstream',
@@ -49,9 +50,9 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
itemRD$: Observable<RemoteData<Item>>;
/**
* The item's bundles
* The item's bundles and default the default bundles that should be suggested (defined in environment)
*/
bundlesRD$: Observable<RemoteData<PaginatedList<Bundle>>>;
bundles: Bundle[] = [];
/**
* The ID of the currently selected bundle to upload a bitstream to
@@ -99,7 +100,6 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
/**
* Initialize component properties:
* itemRD$ Fetched from the current route data (populated by BitstreamPageResolver)
* bundlesRD$ List of bundles on the item
* selectedBundleId Starts off by checking if the route's queryParams contain a "bundle" parameter. If none is found,
* the ID of the first bundle in the list is selected.
* Calls setUploadUrl after setting the selected bundle
@@ -108,16 +108,47 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
this.itemId = this.route.snapshot.params.id;
this.entityType = this.route.snapshot.params['entity-type'];
this.itemRD$ = this.route.data.pipe(map((data) => data.dso));
this.bundlesRD$ = this.itemService.getBundles(this.itemId);
const bundlesRD$ = this.itemService.getBundles(this.itemId).pipe(
getFirstCompletedRemoteData(),
switchMap((remoteData: RemoteData<PaginatedList<Bundle>>) => {
if (remoteData.hasSucceeded) {
if (remoteData.payload.page) {
this.bundles = remoteData.payload.page;
for (const defaultBundle of environment.bundle.standardBundles) {
let check = true;
remoteData.payload.page.forEach((bundle: Bundle) => {
// noinspection JSDeprecatedSymbols
if (defaultBundle === bundle.name) {
check = false;
}
});
if (check) {
this.bundles.push(Object.assign(new Bundle(), {
_name: defaultBundle,
type: 'bundle'
}));
}
}
} else {
this.bundles = environment.bundle.standardBundles.map((defaultBundle: string) => Object.assign(new Bundle(), {
_name: defaultBundle,
type: 'bundle'
})
);
}
return observableOf(remoteData.payload.page);
}
}));
this.selectedBundleId = this.route.snapshot.queryParams.bundle;
if (isNotEmpty(this.selectedBundleId)) {
this.bundleService.findById(this.selectedBundleId).pipe(
this.subs.push(this.bundleService.findById(this.selectedBundleId).pipe(
getFirstSucceededRemoteDataPayload()
).subscribe((bundle: Bundle) => {
this.selectedBundleName = bundle.name;
});
}));
this.setUploadUrl();
}
this.subs.push(bundlesRD$.subscribe());
}
/**
@@ -142,6 +173,13 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
*/
bundleNameChange() {
this.selectedBundleId = undefined;
for (const bundle of this.bundles) {
// noinspection JSDeprecatedSymbols
if (this.selectedBundleName === bundle.name) {
this.selectedBundleId = bundle.id;
break;
}
}
}
/**
@@ -191,8 +229,10 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
onClick(bundle: Bundle) {
this.selectedBundleId = bundle.id;
this.selectedBundleName = bundle.name;
if (bundle.id) {
this.setUploadUrl();
}
}
/**
* When cancel is clicked, navigate back to the item's edit bitstreams page

View File

@@ -2,6 +2,9 @@
<h3 [ngClass]="{'sr-only': parentname }">{{title | translate}}</h3>
<ng-container *ngComponentOutlet="getStartsWithComponent(); injector: objectInjector;"></ng-container>
<div *ngIf="objects?.hasSucceeded && !objects?.isLoading && objects?.payload?.page.length > 0" @fadeIn>
<div *ngIf="shouldDisplayResetButton$ |async" class="mb-2 reset">
<button class="btn btn-secondary" (click)="back()"><i class="fas fa-arrow-left"></i> {{'browse.back.all-results' | translate}}</button>
</div>
<ds-viewable-collection
[config]="paginationConfig"
[sortConfig]="sortConfig"
@@ -13,8 +16,13 @@
</div>
<ds-loading *ngIf="!objects || objects?.isLoading" message="{{'loading.browse-by' | translate}}"></ds-loading>
<ds-error *ngIf="objects?.hasFailed" message="{{'error.browse-by' | translate}}"></ds-error>
<div *ngIf="!objects?.isLoading && objects?.payload?.page.length === 0" class="alert alert-info w-100" role="alert">
<div *ngIf="!objects?.isLoading && objects?.payload?.page.length === 0">
<div *ngIf="shouldDisplayResetButton$ |async" class="d-inline-block mb-4 reset">
<button class="btn btn-secondary" (click)="back()"><i class="fas fa-arrow-left"></i> {{'browse.back.all-results' | translate}}</button>
</div>
<div class="alert alert-info w-100" role="alert">
{{'browse.empty' | translate}}
</div>
</div>
</ng-container>

View File

@@ -18,9 +18,13 @@ import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils';
import { PaginationService } from '../../core/pagination/pagination.service';
import { PaginationServiceStub } from '../testing/pagination-service.stub';
import { FindListOptions } from '../../core/data/find-list-options.model';
import { ListableObjectComponentLoaderComponent } from '../object-collection/shared/listable-object/listable-object-component-loader.component';
import {
ListableObjectComponentLoaderComponent
} from '../object-collection/shared/listable-object/listable-object-component-loader.component';
import { ViewMode } from '../../core/shared/view-mode.model';
import { BrowseEntryListElementComponent } from '../object-list/browse-entry-list-element/browse-entry-list-element.component';
import {
BrowseEntryListElementComponent
} from '../object-list/browse-entry-list-element/browse-entry-list-element.component';
import {
DEFAULT_CONTEXT,
listableObjectComponent,
@@ -31,6 +35,8 @@ import { ThemeService } from '../theme-support/theme.service';
import { SelectableListService } from '../object-list/selectable-list/selectable-list.service';
import { HostWindowServiceStub } from '../testing/host-window-service.stub';
import { HostWindowService } from '../host-window.service';
import { RouteService } from '../../core/services/route.service';
import { routeServiceStub } from '../testing/route-service.stub';
import SpyObj = jasmine.SpyObj;
@listableObjectComponent(BrowseEntry, ViewMode.ListElement, DEFAULT_CONTEXT, 'custom')
@@ -100,6 +106,7 @@ describe('BrowseByComponent', () => {
{ provide: PaginationService, useValue: paginationService },
{ provide: MockThemedBrowseEntryListElementComponent },
{ provide: ThemeService, useValue: themeService },
{provide: RouteService, useValue: routeServiceStub},
{ provide: SelectableListService, useValue: {} },
{ provide: HostWindowService, useValue: new HostWindowServiceStub(800) },
],
@@ -110,6 +117,8 @@ describe('BrowseByComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(BrowseByComponent);
comp = fixture.componentInstance;
comp.paginationConfig = paginationConfig;
fixture.detectChanges();
});
it('should display a loading message when objects is empty', () => {
@@ -193,4 +202,27 @@ describe('BrowseByComponent', () => {
});
});
describe('reset filters button', () => {
it('should not be present when no startsWith or value is present ', () => {
const button = fixture.debugElement.query(By.css('reset'));
expect(button).toBeNull();
});
it('should be present when a startsWith or value is present ', () => {
comp.shouldDisplayResetButton$ = observableOf(true);
fixture.detectChanges();
const button = fixture.debugElement.query(By.css('reset'));
expect(button).toBeDefined();
});
});
describe('back', () => {
it('should navigate back to the main browse page', () => {
comp.back();
expect(paginationService.updateRoute).toHaveBeenCalledWith('test-pagination', {page: 1}, {
value: null,
startsWith: null
});
});
});
});

View File

@@ -4,11 +4,14 @@ import { PaginatedList } from '../../core/data/paginated-list.model';
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { fadeIn, fadeInOut } from '../animations/fade';
import { Observable } from 'rxjs';
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { ListableObject } from '../object-collection/shared/listable-object.model';
import { getStartsWithComponent, StartsWithType } from '../starts-with/starts-with-decorator';
import { PaginationService } from '../../core/pagination/pagination.service';
import { ViewMode } from '../../core/shared/view-mode.model';
import { RouteService } from '../../core/services/route.service';
import { map } from 'rxjs/operators';
import { hasValue } from '../empty.util';
@Component({
selector: 'ds-browse-by',
@@ -67,7 +70,7 @@ export class BrowseByComponent implements OnInit {
/**
* Whether or not the pagination should be rendered as simple previous and next buttons instead of the normal pagination
*/
@Input() showPaginator = false;
@Input() showPaginator = true;
/**
* It is used to hide or show gear
@@ -104,8 +107,14 @@ export class BrowseByComponent implements OnInit {
*/
public sortDirections = SortDirection;
/**
* Observable that tracks if the back button should be displayed based on the path parameters
*/
shouldDisplayResetButton$: Observable<boolean>;
public constructor(private injector: Injector,
protected paginationService: PaginationService,
private routeService: RouteService,
) {
}
@@ -155,6 +164,16 @@ export class BrowseByComponent implements OnInit {
],
parent: this.injector
});
const startsWith$ = this.routeService.getQueryParameterValue('startsWith');
const value$ = this.routeService.getQueryParameterValue('value');
this.shouldDisplayResetButton$ = observableCombineLatest([startsWith$, value$]).pipe(
map(([startsWith, value]) => hasValue(startsWith) || hasValue(value))
);
}
back() {
this.paginationService.updateRoute(this.paginationConfig.id, {page: 1}, {value: null, startsWith: null});
}
}

View File

@@ -45,9 +45,6 @@
<div *ngFor="let columnItems of items" class="col-sm ml-3">
<div *ngFor="let item of columnItems" class="custom-control custom-radio">
<label class="custom-control-label"
[class.disabled]="model.disabled"
[ngClass]="model.layout.element?.control">
<input type="radio" class="custom-control-input"
[checked]="item.value"
[id]="item.id"
@@ -56,6 +53,11 @@
[value]="item.index"
(blur)="onBlur($event)"
(focus)="onFocus($event)"/>
<label class="custom-control-label"
[class.disabled]="model.disabled"
[ngClass]="model.layout.element?.control"
[for]="item.id">
<span [ngClass]="model.layout.element?.label" [innerHTML]="item.label"></span>
</label>
</div>

View File

@@ -7,6 +7,7 @@
[searchFormPlaceholder]="'submission.sections.describe.relationship-lookup.search-tab.search-form.placeholder'"
[selectable]="true"
[selectionConfig]="{ repeatable: repeatable, listId: listId }"
[showScopeSelector]="false"
[showViewModes]="false"
(resultFound)="onResultFound($event)"
(deselectObject)="deselectObject.emit($event)"

View File

@@ -44,7 +44,9 @@
<button id="nav-next" type="button" class="btn btn-outline-primary float-right"
(click)="goNext()"
[disabled]="objects?.payload?.currentPage >= objects?.payload?.totalPages">
<span [ngbTooltip]="objects?.payload?.currentPage >= objects?.payload?.totalPages ? ('pagination.next.button.disabled.tooltip' |translate) : null">
<i class="fas fa-angle-right"></i> {{'pagination.next.button' |translate}}
</span>
</button>
</div>
</div>

View File

@@ -1,4 +1,4 @@
<div *ngIf="(getResourcePolicies() | async)?.length > 0" class="table-responsive">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
@@ -29,7 +29,7 @@
</div>
</th>
</tr>
<tr class="text-center">
<tr *ngIf="(getResourcePolicies() | async)?.length > 0" class="text-center">
<th>
<div class="custom-control custom-checkbox">
<input type="checkbox"
@@ -50,7 +50,7 @@
<th>{{'resource-policies.table.headers.edit' | translate}}</th>
</tr>
</thead>
<tbody>
<tbody *ngIf="(getResourcePolicies() | async)?.length > 0">
<tr *ngFor="let entry of (getResourcePolicies() | async); trackById">
<td class="text-center">
<div class="custom-control custom-checkbox">

View File

@@ -1,7 +1,7 @@
<form #form="ngForm" (ngSubmit)="onSubmit(form.value)" action="/search">
<div>
<div class="form-group input-group">
<div *ngIf="showScopeSelector === true" class="input-group-prepend">
<div *ngIf="showScopeSelector" class="input-group-prepend">
<button class="scope-button btn btn-outline-secondary text-truncate" [ngbTooltip]="(selectedScope | async)?.name" type="button" (click)="openScopeModal()">{{(selectedScope | async)?.name || ('search.form.scope.all' | translate)}}</button>
</div>
<input type="text" [(ngModel)]="query" name="query" class="form-control" attr.aria-label="{{ searchPlaceholder }}" data-test="search-box"

View File

@@ -137,7 +137,7 @@ export class SearchComponent implements OnInit {
/**
* Defines whether or not to show the scope selector
*/
@Input() showScopeSelector = false;
@Input() showScopeSelector = true;
/**
* The current configuration used during the search

View File

@@ -1,4 +1,4 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ThemedComponent } from '../theme-support/themed.component';
import { SearchComponent } from './search.component';
import { SearchConfigurationOption } from './search-switch-configuration/search-configuration-option.model';
@@ -19,7 +19,7 @@ import { ListableObject } from '../object-collection/shared/listable-object.mode
templateUrl: '../theme-support/themed.component.html',
})
export class ThemedSearchComponent extends ThemedComponent<SearchComponent> {
protected inAndOutputNames: (keyof SearchComponent & keyof this)[] = ['configurationList', 'context', 'configuration', 'fixedFilterQuery', 'useCachedVersionIfAvailable', 'inPlaceSearch', 'linkType', 'paginationId', 'searchEnabled', 'sideBarWidth', 'searchFormPlaceholder', 'selectable', 'selectionConfig', 'showSidebar', 'showViewModes', 'useUniquePageId', 'viewModeList', 'resultFound', 'deselectObject', 'selectObject'];
protected inAndOutputNames: (keyof SearchComponent & keyof this)[] = ['configurationList', 'context', 'configuration', 'fixedFilterQuery', 'useCachedVersionIfAvailable', 'inPlaceSearch', 'linkType', 'paginationId', 'searchEnabled', 'sideBarWidth', 'searchFormPlaceholder', 'selectable', 'selectionConfig', 'showSidebar', 'showViewModes', 'useUniquePageId', 'viewModeList', 'showScopeSelector', 'resultFound', 'deselectObject', 'selectObject'];
@Input() configurationList: SearchConfigurationOption[] = [];
@@ -55,6 +55,8 @@ export class ThemedSearchComponent extends ThemedComponent<SearchComponent> {
@Input() viewModeList: ViewMode[];
@Input() showScopeSelector = true;
@Output() resultFound: EventEmitter<SearchObjects<DSpaceObject>> = new EventEmitter<SearchObjects<DSpaceObject>>();
@Output() deselectObject: EventEmitter<ListableObject> = new EventEmitter<ListableObject>();

View File

@@ -85,14 +85,9 @@ describe('StartsWithDateComponent', () => {
let select;
let input;
let expectedValue;
let extras;
beforeEach(() => {
expectedValue = '' + options[0];
extras = {
queryParams: Object.assign({ startsWith: expectedValue }),
queryParamsHandling: 'merge'
};
select = fixture.debugElement.query(By.css('select#year-select')).nativeElement;
input = fixture.debugElement.query(By.css('input')).nativeElement;
@@ -106,7 +101,7 @@ describe('StartsWithDateComponent', () => {
});
it('should add a startsWith query parameter', () => {
expect(router.navigate).toHaveBeenCalledWith([], extras);
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue});
});
it('should automatically fill in the input field', () => {
@@ -128,7 +123,7 @@ describe('StartsWithDateComponent', () => {
});
it('should add a startsWith query parameter', () => {
expect(router.navigate).toHaveBeenCalledWith([], extras);
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue});
});
it('should automatically fill in the input field', () => {
@@ -141,11 +136,6 @@ describe('StartsWithDateComponent', () => {
beforeEach(() => {
expectedValue = `${options[0]}-01`;
extras = {
queryParams: Object.assign({ startsWith: expectedValue }),
queryParamsHandling: 'merge'
};
monthSelect = fixture.debugElement.query(By.css('select#month-select')).nativeElement;
monthSelect.value = monthSelect.options[1].value;
monthSelect.dispatchEvent(new Event('change'));
@@ -157,7 +147,7 @@ describe('StartsWithDateComponent', () => {
});
it('should add a startsWith query parameter', () => {
expect(router.navigate).toHaveBeenCalledWith([], extras);
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue});
});
it('should automatically fill in the input field', () => {
@@ -186,7 +176,7 @@ describe('StartsWithDateComponent', () => {
});
it('should add a startsWith query parameter', () => {
expect(router.navigate).toHaveBeenCalledWith([], extras);
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue});
});
});

View File

@@ -68,7 +68,7 @@ export class StartsWithDateComponent extends StartsWithAbstractComponent {
setStartsWithYearEvent(event: Event) {
this.startsWithYear = +(event.target as HTMLInputElement).value;
this.setStartsWithYearMonth();
this.setStartsWithParam();
this.setStartsWithParam(true);
}
/**
@@ -78,7 +78,7 @@ export class StartsWithDateComponent extends StartsWithAbstractComponent {
setStartsWithMonthEvent(event: Event) {
this.startsWithMonth = (event.target as HTMLInputElement).value;
this.setStartsWithYearMonth();
this.setStartsWithParam();
this.setStartsWithParam(true);
}
/**
@@ -131,7 +131,7 @@ export class StartsWithDateComponent extends StartsWithAbstractComponent {
} else {
this.startsWithYear = +startsWith;
}
this.setStartsWithParam();
this.setStartsWithParam(false);
}
/**

View File

@@ -70,21 +70,25 @@ export abstract class StartsWithAbstractComponent implements OnInit, OnDestroy {
*/
setStartsWith(startsWith: string) {
this.startsWith = startsWith;
this.setStartsWithParam();
this.setStartsWithParam(false);
}
/**
* Add/Change the url query parameter startsWith using the local variable
*/
setStartsWithParam() {
setStartsWithParam(resetPage = true) {
if (this.startsWith === '-1') {
this.startsWith = undefined;
}
if (resetPage) {
this.paginationService.updateRoute(this.paginationId, {page: 1}, { startsWith: this.startsWith });
} else {
this.router.navigate([], {
queryParams: Object.assign({ startsWith: this.startsWith }),
queryParamsHandling: 'merge'
});
}
}
/**
* Submit the form data. Called when clicking a submit button on the form.

View File

@@ -1,24 +1,5 @@
<form class="w-100" [formGroup]="formData" (ngSubmit)="submitForm(formData.value)">
<div class="row">
<div class="col-12 d-none d-sm-inline-block">
<ul class="list-inline">
<li class="list-inline-item" *ngFor="let option of startsWithOptions">
<a [routerLink]="[]" (click)="setStartsWith(option)">{{option}}</a>
</li>
</ul>
</div>
<div class="col-4 col-sm-12 d-sm-none">
<select class="form-control" (change)="setStartsWithEvent($event)">
<option [value]="'-1'" [selected]="!startsWith">
{{'browse.startsWith.choose_start' | translate}}
</option>
<option *ngFor="let option of startsWithOptions"
[value]="option"
[selected]="isSelectedOption(option) ? 'selected': null">
{{option}}
</option>
</select>
</div>
<div class="form-group input-group col-8 col-sm-12 col-md-6">
<input class="form-control" placeholder="{{'browse.startsWith.type_text' | translate}}" type="text" name="startsWith" formControlName="startsWith" [value]="getStartsWith()" />
<span class="input-group-append">

View File

@@ -51,123 +51,9 @@ describe('StartsWithTextComponent', () => {
expect(comp.formData.value.startsWith).toBeDefined();
});
describe('when selecting the first option in the dropdown', () => {
let select;
beforeEach(() => {
select = fixture.debugElement.query(By.css('select')).nativeElement;
select.value = select.options[0].value;
select.dispatchEvent(new Event('change'));
fixture.detectChanges();
});
it('should set startsWith to undefined', () => {
expect(comp.startsWith).toBeUndefined();
});
it('should not add a startsWith query parameter', () => {
route.queryParams.subscribe((params) => {
expect(params.startsWith).toBeUndefined();
});
});
});
describe('when selecting "0-9" in the dropdown', () => {
let select;
let input;
const expectedValue = '0';
const extras: NavigationExtras = {
queryParams: Object.assign({ startsWith: expectedValue }),
queryParamsHandling: 'merge'
};
beforeEach(() => {
select = fixture.debugElement.query(By.css('select')).nativeElement;
input = fixture.debugElement.query(By.css('input')).nativeElement;
select.value = select.options[1].value;
select.dispatchEvent(new Event('change'));
fixture.detectChanges();
});
it('should set startsWith to "0"', () => {
expect(comp.startsWith).toEqual(expectedValue);
});
it('should add a startsWith query parameter', () => {
expect(router.navigate).toHaveBeenCalledWith([], extras);
});
it('should automatically fill in the input field', () => {
expect(input.value).toEqual(expectedValue);
});
});
describe('when selecting an option in the dropdown', () => {
let select;
let input;
const expectedValue = options[1];
const extras: NavigationExtras = {
queryParams: Object.assign({ startsWith: expectedValue }),
queryParamsHandling: 'merge'
};
beforeEach(() => {
select = fixture.debugElement.query(By.css('select')).nativeElement;
input = fixture.debugElement.query(By.css('input')).nativeElement;
select.value = select.options[2].value;
select.dispatchEvent(new Event('change'));
fixture.detectChanges();
});
it('should set startsWith to the expected value', () => {
expect(comp.startsWith).toEqual(expectedValue);
});
it('should add a startsWith query parameter', () => {
expect(router.navigate).toHaveBeenCalledWith([], extras);
});
it('should automatically fill in the input field', () => {
expect(input.value).toEqual(expectedValue);
});
});
describe('when clicking an option in the list', () => {
let optionLink;
let input;
const expectedValue = options[1];
const extras: NavigationExtras = {
queryParams: Object.assign({ startsWith: expectedValue }),
queryParamsHandling: 'merge'
};
beforeEach(() => {
optionLink = fixture.debugElement.query(By.css('.list-inline-item:nth-child(2) > a')).nativeElement;
input = fixture.debugElement.query(By.css('input')).nativeElement;
optionLink.click();
fixture.detectChanges();
});
it('should set startsWith to the expected value', () => {
expect(comp.startsWith).toEqual(expectedValue);
});
it('should add a startsWith query parameter', () => {
expect(router.navigate).toHaveBeenCalledWith([], extras);
});
it('should automatically fill in the input field', () => {
expect(input.value).toEqual(expectedValue);
});
});
describe('when filling in the input form', () => {
let form;
const expectedValue = 'A';
const extras: NavigationExtras = {
queryParams: Object.assign({ startsWith: expectedValue }),
queryParamsHandling: 'merge'
};
beforeEach(() => {
form = fixture.debugElement.query(By.css('form'));
@@ -181,7 +67,7 @@ describe('StartsWithTextComponent', () => {
});
it('should add a startsWith query parameter', () => {
expect(router.navigate).toHaveBeenCalledWith([], extras);
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', {page: 1}, {startsWith: expectedValue});
});
});

View File

@@ -28,11 +28,11 @@ export class StartsWithTextComponent extends StartsWithAbstractComponent {
/**
* Add/Change the url query parameter startsWith using the local variable
*/
setStartsWithParam() {
setStartsWithParam(resetPage = true) {
if (this.startsWith === '0-9') {
this.startsWith = '0';
}
super.setStartsWithParam();
super.setStartsWithParam(resetPage);
}
/**

View File

@@ -1,14 +1,18 @@
import { of as observableOf } from 'rxjs';
import { EMPTY, of as observableOf } from 'rxjs';
export const routeServiceStub: any = {
/* eslint-disable no-empty,@typescript-eslint/no-empty-function */
hasQueryParamWithValue: (param: string, value: string) => {
return EMPTY;
},
hasQueryParam: (param: string) => {
return EMPTY;
},
removeQueryParameterValue: (param: string, value: string) => {
return EMPTY;
},
addQueryParameterValue: (param: string, value: string) => {
return EMPTY;
},
getQueryParameterValues: (param: string) => {
return observableOf({});

View File

@@ -654,6 +654,8 @@
"browse.back.all-results": "All browse results",
"browse.comcol.by.author": "By Author",
"browse.comcol.by.dateissued": "By Issue Date",
@@ -686,13 +688,17 @@
"pagination.previous.button": "Previous",
"pagination.next.button.disabled.tooltip": "No more pages of results",
"browse.startsWith": ", starting with {{ startsWith }}",
"browse.startsWith.choose_start": "(Choose start)",
"browse.startsWith.choose_year": "(Choose year)",
"browse.startsWith.choose_year.label": "Choose the issue year",
"browse.startsWith.jump": "Jump to a point in the index:",
"browse.startsWith.jump": "Filter results by year or month",
"browse.startsWith.months.april": "April",
@@ -724,13 +730,15 @@
"browse.startsWith.submit": "Browse",
"browse.startsWith.type_date": "Or type in a date (year-month) and click 'Browse'",
"browse.startsWith.type_date": "Filter results by date",
"browse.startsWith.type_date.label": "Or type in a date (year-month) and click on the Browse button",
"browse.startsWith.type_text": "Type the first few letters and click on the Browse button",
"browse.startsWith.type_text": "Filter results by typing the first few letters",
"browse.title": "Browsing {{ collection }} by {{ field }} {{ value }}",
"browse.title": "Browsing {{ collection }} by {{ field }}{{ startsWith }} {{ value }}",
"browse.title.page": "Browsing {{ collection }} by {{ field }} {{ value }}",
"chips.remove": "Remove chip",
@@ -1653,7 +1661,7 @@
"item.bitstreams.upload.bundle": "Bundle",
"item.bitstreams.upload.bundle.placeholder": "Select a bundle",
"item.bitstreams.upload.bundle.placeholder": "Select a bundle or input new bundle name",
"item.bitstreams.upload.bundle.new": "Create bundle",

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,7 @@ import { UIServerConfig } from './ui-server-config.interface';
import { MediaViewerConfig } from './media-viewer-config.interface';
import { BrowseByConfig } from './browse-by-config.interface';
import {SuggestionConfig} from './layout-config.interfaces';
import { BundleConfig } from './bundle-config.interface';
interface AppConfig extends Config {
ui: UIServerConfig;
@@ -34,6 +35,7 @@ interface AppConfig extends Config {
themes: ThemeConfig[];
mediaViewer: MediaViewerConfig;
suggestion: SuggestionConfig[];
bundle: BundleConfig;
}
const APP_CONFIG = new InjectionToken<AppConfig>('APP_CONFIG');

View File

@@ -0,0 +1,11 @@
import { Config } from './config.interface';
export interface BundleConfig extends Config {
/**
* List of standard bundles to select in adding bitstreams to items
* Used by {@link UploadBitstreamComponent}.
*/
standardBundles: string[];
}

View File

@@ -15,6 +15,7 @@ import { SubmissionConfig } from './submission-config.interface';
import { ThemeConfig } from './theme.model';
import { UIServerConfig } from './ui-server-config.interface';
import {SuggestionConfig} from './layout-config.interfaces';
import { BundleConfig } from './bundle-config.interface';
export class DefaultAppConfig implements AppConfig {
production = false;
@@ -184,6 +185,7 @@ export class DefaultAppConfig implements AppConfig {
{ code: 'pt-PT', label: 'Português', active: true },
{ code: 'pt-BR', label: 'Português do Brasil', active: true },
{ code: 'fi', label: 'Suomi', active: true },
{ code: 'tr', label: 'Türkçe', active: true },
{ code: 'bn', label: 'বাংলা', active: true }
];
@@ -309,6 +311,11 @@ export class DefaultAppConfig implements AppConfig {
]
},
];
// The default bundles that should always be displayed when you edit or add a bundle even when no bundle has been
// added to the item yet.
bundle: BundleConfig = {
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

View File

@@ -236,6 +236,9 @@ export const environment: BuildConfig = {
name: 'base',
},
],
bundle: {
standardBundles: ['ORIGINAL', 'THUMBNAIL', 'LICENSE'],
},
mediaViewer: {
image: true,
video: true

View File

@@ -6,5 +6,6 @@
</head>
<body>
<div id="mirador"></div>
<script src="mirador.js"></script>
</body>
</html>

View File

@@ -1,4 +1,4 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
module.exports = {
@@ -10,19 +10,16 @@ module.exports = {
path: path.resolve(__dirname, '..' , 'dist/iiif/mirador'),
filename: '[name].js'
},
module: {
rules: [
{
test: /\.html$/i,
loader: 'html-loader',
},
],
},
devServer: {
contentBase: '../dist/iiif/mirador',
},
plugins: [new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/mirador-viewer/mirador.html'
resolve: {
fallback: {
url: false
}},
plugins: [new CopyWebpackPlugin({
patterns: [
{from: './src/mirador-viewer/mirador.html', to: './index.html'}
]
})]
};