90873: issue 1380 - Fix to make default bundle config work without yml changes

This commit is contained in:
Marie Verdonck
2022-04-20 11:40:35 +02:00
committed by Alexandre Vryghem
parent beae47ef19
commit d51af2739e
7 changed files with 34 additions and 39 deletions

View File

@@ -229,10 +229,8 @@ themes:
href: assets/dspace/images/favicons/manifest.webmanifest href: assets/dspace/images/favicons/manifest.webmanifest
# The default bundles that should always be displayed as suggestions when you upload a new bundle # The default bundles that should always be displayed as suggestions when you upload a new bundle
standardBundles: bundle:
- bundle: ORIGINAL - standardBundles: [ ORIGINAL, THUMBNAIL, LICENSE ]
- bundle: THUMBNAIL
- bundle: LICENSE
# Whether to enable media viewer for image and/or video Bitstreams (i.e. Bitstreams whose MIME type starts with 'image' or 'video'). # 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 images, this enables a gallery viewer where you can zoom or page through images.

View File

@@ -19,7 +19,6 @@ import { RequestService } from '../../../core/data/request.service';
import { getBitstreamModuleRoute } from '../../../app-routing-paths'; import { getBitstreamModuleRoute } from '../../../app-routing-paths';
import { getEntityEditRoute } from '../../item-page-routing-paths'; import { getEntityEditRoute } from '../../item-page-routing-paths';
import { environment } from '../../../../environments/environment'; import { environment } from '../../../../environments/environment';
import { StandardBundleConfig } from '../../../../config/standard-bundle-config.interface';
@Component({ @Component({
selector: 'ds-upload-bitstream', selector: 'ds-upload-bitstream',
@@ -115,29 +114,27 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
if (remoteData.hasSucceeded) { if (remoteData.hasSucceeded) {
if (remoteData.payload.page) { if (remoteData.payload.page) {
this.bundles = remoteData.payload.page; this.bundles = remoteData.payload.page;
} else if (environment.standardBundles) { for (const defaultBundle of environment.bundle.standardBundles) {
this.bundles = environment.standardBundles.map((defaultBundle: StandardBundleConfig) => Object.assign(new Bundle(), {
_name: defaultBundle.bundle,
type: 'bundle'
})
);
}
if (remoteData.payload.page && environment.standardBundles) {
for (const defaultBundle of environment.standardBundles) {
let check = true; let check = true;
remoteData.payload.page.forEach((bundle: Bundle) => { remoteData.payload.page.forEach((bundle: Bundle) => {
// noinspection JSDeprecatedSymbols // noinspection JSDeprecatedSymbols
if (defaultBundle.bundle === bundle.name) { if (defaultBundle === bundle.name) {
check = false; check = false;
} }
}); });
if (check) { if (check) {
this.bundles.push(Object.assign(new Bundle(), { this.bundles.push(Object.assign(new Bundle(), {
_name: defaultBundle.bundle, _name: defaultBundle,
type: 'bundle' type: 'bundle'
})); }));
} }
} }
} else {
this.bundles = environment.bundle.standardBundles.map((defaultBundle: string) => Object.assign(new Bundle(), {
_name: defaultBundle,
type: 'bundle'
})
);
} }
return observableOf(remoteData.payload.page); return observableOf(remoteData.payload.page);
} }
@@ -232,7 +229,9 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
onClick(bundle: Bundle) { onClick(bundle: Bundle) {
this.selectedBundleId = bundle.id; this.selectedBundleId = bundle.id;
this.selectedBundleName = bundle.name; this.selectedBundleName = bundle.name;
this.setUploadUrl(); if (bundle.id) {
this.setUploadUrl();
}
} }
/** /**

View File

@@ -14,7 +14,7 @@ import { AuthConfig } from './auth-config.interfaces';
import { UIServerConfig } from './ui-server-config.interface'; import { UIServerConfig } from './ui-server-config.interface';
import { MediaViewerConfig } from './media-viewer-config.interface'; import { MediaViewerConfig } from './media-viewer-config.interface';
import { BrowseByConfig } from './browse-by-config.interface'; import { BrowseByConfig } from './browse-by-config.interface';
import { StandardBundleConfig } from './standard-bundle-config.interface'; import { BundleConfig } from './bundle-config.interface';
interface AppConfig extends Config { interface AppConfig extends Config {
ui: UIServerConfig; ui: UIServerConfig;
@@ -33,7 +33,7 @@ interface AppConfig extends Config {
collection: CollectionPageConfig; collection: CollectionPageConfig;
themes: ThemeConfig[]; themes: ThemeConfig[];
mediaViewer: MediaViewerConfig; mediaViewer: MediaViewerConfig;
standardBundles: StandardBundleConfig[]; bundle: BundleConfig;
} }
const APP_CONFIG = new InjectionToken<AppConfig>('APP_CONFIG'); 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

@@ -14,6 +14,7 @@ import { ServerConfig } from './server-config.interface';
import { SubmissionConfig } from './submission-config.interface'; import { SubmissionConfig } from './submission-config.interface';
import { ThemeConfig } from './theme.model'; import { ThemeConfig } from './theme.model';
import { UIServerConfig } from './ui-server-config.interface'; import { UIServerConfig } from './ui-server-config.interface';
import { BundleConfig } from './bundle-config.interface';
export class DefaultAppConfig implements AppConfig { export class DefaultAppConfig implements AppConfig {
production = false; production = false;
@@ -301,11 +302,9 @@ 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 // 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. // added to the item yet.
standardBundles: [ bundle: BundleConfig = {
{ bundle: 'ORIGINAL' }, standardBundles: ['ORIGINAL', 'THUMBNAIL', 'LICENSE']
{ bundle: 'THUMBNAIL' }, };
{ bundle: 'LICENSE' }
];
// Whether to enable media viewer for image and/or video Bitstreams (i.e. Bitstreams whose MIME type starts with "image" or "video"). // 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 images, this enables a gallery viewer where you can zoom or page through images.
// For videos, this enables embedded video streaming // For videos, this enables embedded video streaming

View File

@@ -1,10 +0,0 @@
import { Config } from './config.interface';
export interface StandardBundleConfig extends Config {
/**
* Used by {@link UploadBitstreamComponent}.
*/
bundle: string;
}

View File

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