64387: Upload bitstream component + Edit bitstream placeholder

This commit is contained in:
Kristof De Langhe
2019-08-16 13:35:04 +02:00
parent d1dbe49333
commit 7bd6c9acab
14 changed files with 327 additions and 17 deletions

View File

@@ -0,0 +1,21 @@
import { MetadataMap } from '../../core/shared/metadata.models';
/**
* Properties to send to the REST API for uploading a bitstream
*/
export class UploaderProperties {
/**
* A custom name for the bitstream
*/
name: string;
/**
* Metadata for the bitstream (e.g. dc.description)
*/
metadata: MetadataMap;
/**
* The name of the bundle to upload the bitstream to
*/
bundleName: string;
}

View File

@@ -15,8 +15,9 @@ import { uniqueId } from 'lodash';
import { ScrollToConfigOptions, ScrollToService } from '@nicky-lenaers/ngx-scroll-to';
import { UploaderOptions } from './uploader-options.model';
import { isNotEmpty, isUndefined } from '../empty.util';
import { hasValue, isNotEmpty, isUndefined } from '../empty.util';
import { UploaderService } from './uploader.service';
import { UploaderProperties } from './uploader-properties.model';
@Component({
selector: 'ds-uploader',
@@ -53,6 +54,11 @@ export class UploaderComponent {
*/
@Input() uploadFilesOptions: UploaderOptions;
/**
* Extra properties to be passed with the form-data of the upload
*/
@Input() uploadProperties: UploaderProperties;
/**
* The function to call when upload is completed
*/
@@ -127,6 +133,11 @@ export class UploaderComponent {
};
this.scrollToService.scrollTo(config);
};
if (hasValue(this.uploadProperties)) {
this.uploader.onBuildItemForm = (item, form) => {
form.append('properties', JSON.stringify(this.uploadProperties))
};
}
this.uploader.onCompleteItem = (item: any, response: any, status: any, headers: any) => {
if (isNotEmpty(response)) {
const responsePath = JSON.parse(response);