[CST-7216] Angular: Import saf via URL

This commit is contained in:
Sufiyan Shaikh
2022-11-07 20:56:05 +05:30
committed by Francesco Pio Scognamiglio
parent 1ea7c61315
commit e47b42bc89
5 changed files with 130 additions and 8 deletions

View File

@@ -8,7 +8,7 @@ import { ProcessParameter } from '../../process-page/processes/process-parameter
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
import { RemoteData } from '../../core/data/remote-data';
import { Process } from '../../process-page/processes/process.model';
import { isNotEmpty } from '../../shared/empty.util';
import { isEmpty, isNotEmpty } from '../../shared/empty.util';
import { getProcessDetailRoute } from '../../process-page/process-page-routing.paths';
import {
ImportBatchSelectorComponent
@@ -32,11 +32,22 @@ export class BatchImportPageComponent {
* The validate only flag
*/
validateOnly = true;
/**
* dso object for community or collection
*/
dso: DSpaceObject = null;
/**
* The flag between upload and url
*/
isUpload = true;
/**
* File URL when flag is for url
*/
fileURL: string;
public constructor(private location: Location,
protected translate: TranslateService,
protected notificationsService: NotificationsService,
@@ -72,13 +83,18 @@ export class BatchImportPageComponent {
* Starts import-metadata script with --zip fileName (and the selected file)
*/
public importMetadata() {
if (this.fileObject == null) {
if (this.fileObject == null && isEmpty(this.fileURL)) {
this.notificationsService.error(this.translate.get('admin.metadata-import.page.error.addFile'));
} else {
const parameterValues: ProcessParameter[] = [
Object.assign(new ProcessParameter(), { name: '--zip', value: this.fileObject.name }),
Object.assign(new ProcessParameter(), { name: '--add' })
];
if (this.isUpload) {
parameterValues.push(Object.assign(new ProcessParameter(), { name: '--zip', value: this.fileObject.name }));
} else {
this.fileObject = null;
parameterValues.push(Object.assign(new ProcessParameter(), { name: '--u', value: this.fileURL }));
}
if (this.dso) {
parameterValues.push(Object.assign(new ProcessParameter(), { name: '--collection', value: this.dso.uuid }));
}
@@ -121,4 +137,11 @@ export class BatchImportPageComponent {
removeDspaceObject(): void {
this.dso = null;
}
/**
* toggle the flag between upload and url
*/
toggleUpload() {
this.isUpload = !this.isUpload;
}
}