mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
64387: Upload bitstream component + Edit bitstream placeholder
This commit is contained in:
21
src/app/shared/uploader/uploader-properties.model.ts
Normal file
21
src/app/shared/uploader/uploader-properties.model.ts
Normal 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;
|
||||
}
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user