From f1651849cdc16630a128229fda085056bd6852e5 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 2 Jul 2018 14:58:44 -0400 Subject: [PATCH] LP#1779158 Ang vandelay import form cont. Signed-off-by: Bill Erickson --- .../app/staff/cat/vandelay/import.component.css | 1 + .../app/staff/cat/vandelay/import.component.html | 39 ++++++++++-- .../src/app/staff/cat/vandelay/import.component.ts | 69 +++++++++++++++++++--- .../src/app/staff/cat/vandelay/vandelay.module.ts | 2 + 4 files changed, 99 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.css b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.css index 310131c2e1..a6404125a6 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.css +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.css @@ -13,6 +13,7 @@ .import-form .row:nth-child(even) { background-color: rgba(0,0,0,.03); + border-top: 1px solid rgba(0,0,0,.125); border-bottom: 1px solid rgba(0,0,0,.125); } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html index 3286fc57dd..ca70ad2a57 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html @@ -8,9 +8,10 @@
- + + i18n-entryLabel>
+ (onChange)="selectedBibSource=$event.id" + placeholder="Record Source..." i18n-placeholder>
@@ -32,7 +34,8 @@
+ (onChange)="selectedQueue=$event" i18n-placeholder + [allowFreeText]="true" placeholder="Select or Create a Queue...">
@@ -40,6 +43,7 @@
@@ -49,6 +53,8 @@
@@ -63,6 +69,7 @@
@@ -78,6 +85,7 @@
@@ -92,6 +100,7 @@
@@ -116,6 +125,28 @@
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts index c5b7f0585b..ee49b5fe27 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts @@ -1,9 +1,15 @@ import {Component, OnInit, AfterViewInit, Input, ViewChild} from '@angular/core'; import {IdlObject} from '@eg/core/idl.service'; import {OrgService} from '@eg/core/org.service'; +import {ToastService} from '@eg/share/toast/toast.service'; import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; import {VandelayService} from './vandelay.service'; -import {ProgressDialogComponent} from '@eg/share/dialog/progress.component'; +import {HttpClient, HttpRequest, HttpEventType} from '@angular/common/http'; +import {HttpResponse, HttpErrorResponse} from '@angular/common/http'; +import {ProgressInlineComponent} from '@eg/share/dialog/progress-inline.component'; +import {Subject} from 'rxjs/Subject'; + +const VAND_UPLOAD_URL = '/vandelay-upload'; @Component({ templateUrl: 'import.component.html', @@ -12,7 +18,15 @@ import {ProgressDialogComponent} from '@eg/share/dialog/progress.component'; export class ImportComponent implements OnInit, AfterViewInit { recordType: string; - newQueueName: string; + selectedQueue: ComboboxEntry; // freetext enabled + selectedBucket: number; + selectedBibSource: number; + selectedMatchSet: number; + selectedHoldingsProfile: number; + selectedMergeProfile: number; + selectedFallThruMergeProfile: number; + selectedFile: File; + attrDefs: {[atype: string]: IdlObject[]}; defaultMatchSet: string; @@ -23,10 +37,15 @@ export class ImportComponent implements OnInit, AfterViewInit { minQualityRatio: number; autoOverlayAcqCopies: boolean; - @ViewChild('progressDialog') - private progressDialog: ProgressDialogComponent; + showProgress: boolean; + + @ViewChild('fileSelector') private fileSelector; + @ViewChild('uploadProgress') + private uploadProgress: ProgressInlineComponent; constructor( + private http: HttpClient, + private toast: ToastService, private org: OrgService, private vandelay: VandelayService ) { @@ -38,13 +57,10 @@ export class ImportComponent implements OnInit, AfterViewInit { ngOnInit() {} ngAfterViewInit() { - // loading startup data changes our data in the midst of a - // lifecycle hook. Run after timeout. - //setTimeout(() => this.loadStartupData()); this.loadStartupData(); } - loadStartupData(): Promise{ + loadStartupData(): Promise { // Note displaying and manipulating a progress dialog inside // the AfterViewInit cycle leads to errors because the child // component is modifed after dirty checking. @@ -104,5 +120,42 @@ export class ImportComponent implements OnInit, AfterViewInit { return {id: item.id(), label: item.name()}; }); } + + fileSelected($event) { + this.selectedFile = $event.target.files[0]; + } + + upload() { + this.showProgress = true; + this.uploadProgress.reset(); + + const formData: FormData = new FormData(); + + formData.append( + 'marc_upload', this.selectedFile, this.selectedFile.name); + // TODO: fill in other fields + + const req = new HttpRequest('POST', VAND_UPLOAD_URL, formData, + {reportProgress: true, responseType: 'text'}); + + this.http.request(req).subscribe( + evt => { + if (evt.type === HttpEventType.UploadProgress) { + this.uploadProgress.update( + {value: evt.loaded, max: evt.total}); + + } else if (evt instanceof HttpResponse) { + console.log('file uploaded OK'); + } + }, + + (err: HttpErrorResponse) => { + //this.progressDialog.close(); + console.error(err); + this.toast.danger(err.error.error); + } + ); + + } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts index c65a44f164..675894534b 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts @@ -6,6 +6,7 @@ import {VandelayComponent} from './vandelay.component'; import {ImportComponent} from './import.component'; import {ExportComponent} from './export.component'; import {GridModule} from '@eg/share/grid/grid.module'; +import {HttpClientModule} from '@angular/common/http'; @NgModule({ declarations: [ @@ -16,6 +17,7 @@ import {GridModule} from '@eg/share/grid/grid.module'; imports: [ StaffCommonModule, VandelayRoutingModule, + HttpClientModule, GridModule ], providers: [ -- 2.11.0