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
# The default bundles that should always be displayed as suggestions when you upload a new bundle
standardBundles:
- bundle: ORIGINAL
- bundle: THUMBNAIL
- bundle: LICENSE
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.

View File

@@ -19,7 +19,6 @@ 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';
import { StandardBundleConfig } from '../../../../config/standard-bundle-config.interface';
@Component({
selector: 'ds-upload-bitstream',
@@ -115,29 +114,27 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy {
if (remoteData.hasSucceeded) {
if (remoteData.payload.page) {
this.bundles = remoteData.payload.page;
} else if (environment.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) {
for (const defaultBundle of environment.bundle.standardBundles) {
let check = true;
remoteData.payload.page.forEach((bundle: Bundle) => {
// noinspection JSDeprecatedSymbols
if (defaultBundle.bundle === bundle.name) {
if (defaultBundle === bundle.name) {
check = false;
}
});
if (check) {
this.bundles.push(Object.assign(new Bundle(), {
_name: defaultBundle.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);
}
@@ -232,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

@@ -14,7 +14,7 @@ import { AuthConfig } from './auth-config.interfaces';
import { UIServerConfig } from './ui-server-config.interface';
import { MediaViewerConfig } from './media-viewer-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 {
ui: UIServerConfig;
@@ -33,7 +33,7 @@ interface AppConfig extends Config {
collection: CollectionPageConfig;
themes: ThemeConfig[];
mediaViewer: MediaViewerConfig;
standardBundles: StandardBundleConfig[];
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

@@ -14,6 +14,7 @@ import { ServerConfig } from './server-config.interface';
import { SubmissionConfig } from './submission-config.interface';
import { ThemeConfig } from './theme.model';
import { UIServerConfig } from './ui-server-config.interface';
import { BundleConfig } from './bundle-config.interface';
export class DefaultAppConfig implements AppConfig {
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
// added to the item yet.
standardBundles: [
{ bundle: 'ORIGINAL' },
{ bundle: 'THUMBNAIL' },
{ bundle: 'LICENSE' }
];
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

@@ -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',
},
],
standardBundles: [
{ bundle: 'ORIGINAL' },
{ bundle: 'THUMBNAIL' },
{ bundle: 'LICENSE' }
],
bundle: {
standardBundles: ['ORIGINAL', 'THUMBNAIL', 'LICENSE'],
},
mediaViewer: {
image: true,
video: true