Skip to content

Commit 1accb50

Browse files
[DURACOM-456] clean up unused property, add guard if selected file is missing, add form value interface
1 parent 5c5003f commit 1accb50

3 files changed

Lines changed: 18 additions & 27 deletions

File tree

src/app/bulk-import/bulk-import-page.component.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,10 @@ <h2 class="mb-3">{{ 'bulk-import.title' | translate }}</h2>
1414
<label for="abortOnError" class="me-5">{{ 'bulk-import.abort-on-error' | translate }}</label>
1515
</div>
1616

17-
<button type="submit" class="btn btn-primary float-end" [dsBtnDisabled]="form.invalid || (isProcessingImport() | async)" >
18-
@if ((isProcessingImport() | async)) {
19-
<span>
20-
<i class='fas fa-circle-notch fa-spin'></i> {{'bulk-import.processing' | translate}}
21-
</span>
22-
} @else {
17+
<button type="submit" class="btn btn-primary float-end" [dsBtnDisabled]="form.invalid" >
2318
<span>
2419
{{'bulk-import.submit' | translate}}
2520
</span>
26-
}
2721
</button>
2822
<button type="button" class="btn btn-outline-secondary float-end me-2" (click)="goBack()">
2923
{{'bulk-import.back' | translate}}

src/app/bulk-import/bulk-import-page.component.ts

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ import {
2222
TranslateModule,
2323
TranslateService,
2424
} from '@ngx-translate/core';
25-
import {
26-
BehaviorSubject,
27-
Observable,
28-
Subscription,
29-
} from 'rxjs';
25+
import { Subscription } from 'rxjs';
3026
import {
3127
map,
3228
take,
@@ -43,6 +39,15 @@ import { Collection } from '../core/shared/collection.model';
4339
import { getFirstCompletedRemoteData } from '../core/shared/operators';
4440
import { FileValidator } from '../shared/utils/require-file.validator';
4541

42+
/**
43+
* Form values for bulk import page
44+
*/
45+
interface BulkImportFormValues {
46+
name: string;
47+
file?: File;
48+
abortOnError: boolean;
49+
}
50+
4651
/**
4752
* Page to perform an items bulk imports into the given collection.
4853
*/
@@ -65,12 +70,6 @@ export class BulkImportPageComponent implements OnInit, OnDestroy {
6570

6671
subs: Subscription[] = [];
6772

68-
/**
69-
* A boolean representing if a create delete operation is pending
70-
* @type {BehaviorSubject<boolean>}
71-
*/
72-
processingImport$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
73-
7473
private selectedFile: File;
7574

7675
constructor(
@@ -113,8 +112,12 @@ export class BulkImportPageComponent implements OnInit, OnDestroy {
113112
* @param form
114113
*/
115114
submit() {
115+
if (!this.selectedFile) {
116+
this.notificationsService.error(this.translationService.get('bulk-import.error.no-file'));
117+
return;
118+
}
116119

117-
const values: any = this.form.value;
120+
const values: BulkImportFormValues = this.form.value;
118121

119122
const stringParameters: ProcessParameter[] = [
120123
{ name: '-c', value: this.collectionId },
@@ -141,14 +144,6 @@ export class BulkImportPageComponent implements OnInit, OnDestroy {
141144
this.router.navigateByUrl(getCollectionPageRoute(this.collectionId));
142145
}
143146

144-
/**
145-
* Return a boolean representing if t import operation is pending.
146-
*
147-
* @return {Observable<boolean>}
148-
*/
149-
isProcessingImport(): Observable<boolean> {
150-
return this.processingImport$.asObservable();
151-
}
152147

153148
private navigateToProcesses() {
154149
this.requestService.setStaleByHrefSubstring('/processes');

src/assets/i18n/en.json5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,8 @@
12131213

12141214
"bulk-import.error": "An error occurred while creating the import process",
12151215

1216+
"bulk-import.error.no-file": "Please select a file to import.",
1217+
12161218
"bulk-import.file": "Source file",
12171219

12181220
"bulk-import.header": "Bulk import",

0 commit comments

Comments
 (0)