Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Port dspace-8_x] Improving the file browser for importing metadata #3232

Merged
merged 1 commit into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<span><i class="fas fa-cloud-upload"
aria-hidden="true"></i> {{ ((fileObject === null || fileObject === undefined) ? dropMessageLabel : dropMessageLabelReplacement) | translate}} {{'uploader.or' | translate}}</span>
<label class="btn btn-link m-0 p-0 ml-1">
<input class="form-control-file d-none" requireFile #file="ngModel" type="file" name="file-upload"
<input class="form-control-file d-none" type="file" name="file-upload"
id="file-upload"
[ngModel]="fileObject" (ngModelChange)="setFile($event)">
(change)="handleFileInput($event)">
{{'uploader.browse' | translate}}
</label>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
/**
* The function to call when file is added
*/
@Output() onFileAdded: EventEmitter<any> = new EventEmitter<any>();
@Output() onFileAdded: EventEmitter<File> = new EventEmitter<File>();

Check warning on line 57 in src/app/shared/upload/file-dropzone-no-uploader/file-dropzone-no-uploader.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/shared/upload/file-dropzone-no-uploader/file-dropzone-no-uploader.component.ts#L57

Added line #L57 was not covered by tests

/**
* The uploader configuration options
Expand Down Expand Up @@ -83,15 +83,17 @@
}

@HostListener('window:drop', ['$event'])
onDrop(event: any) {
onDrop(event: DragEvent) {
event.preventDefault();
event.stopPropagation();

Check warning on line 88 in src/app/shared/upload/file-dropzone-no-uploader/file-dropzone-no-uploader.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/shared/upload/file-dropzone-no-uploader/file-dropzone-no-uploader.component.ts#L88

Added line #L88 was not covered by tests
}

@HostListener('window:dragover', ['$event'])
onDragOver(event: any) {
onDragOver(event: DragEvent) {
// Show drop area on the page
event.preventDefault();
if ((event.target as any).tagName !== 'HTML') {
event.stopPropagation();

Check warning on line 95 in src/app/shared/upload/file-dropzone-no-uploader/file-dropzone-no-uploader.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/shared/upload/file-dropzone-no-uploader/file-dropzone-no-uploader.component.ts#L95

Added line #L95 was not covered by tests
if ((event.target as HTMLElement).tagName !== 'HTML') {
this.isOverDocumentDropZone = observableOf(true);
}
}
Expand All @@ -105,11 +107,18 @@
}
}

public handleFileInput(event: Event) {
const input = event.target as HTMLInputElement;

Check warning on line 111 in src/app/shared/upload/file-dropzone-no-uploader/file-dropzone-no-uploader.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/shared/upload/file-dropzone-no-uploader/file-dropzone-no-uploader.component.ts#L111

Added line #L111 was not covered by tests
if (input.files && input.files.length > 0) {
this.setFile(input.files);

Check warning on line 113 in src/app/shared/upload/file-dropzone-no-uploader/file-dropzone-no-uploader.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/shared/upload/file-dropzone-no-uploader/file-dropzone-no-uploader.component.ts#L113

Added line #L113 was not covered by tests
}
}

/**
* Set file
* @param files
*/
setFile(files) {
public setFile(files: FileList) {
this.fileObject = files.length > 0 ? files[0] : undefined;
this.onFileAdded.emit(this.fileObject);
}
Expand Down
Loading