@@ -76,6 +76,8 @@ export class BulkImportPageComponent implements OnInit, OnDestroy {
7676 */
7777 processingImport$ : BehaviorSubject < boolean > = new BehaviorSubject < boolean > ( false ) ;
7878
79+ private selectedFile : File ;
80+
7981 constructor (
8082 private authService : AuthService ,
8183 private formBuilder : FormBuilder ,
@@ -119,19 +121,16 @@ export class BulkImportPageComponent implements OnInit, OnDestroy {
119121
120122 const values : any = this . form . value ;
121123
122- const files : FileList = values . file ;
123- const file : File = files . item ( 0 ) ;
124-
125124 const stringParameters : ProcessParameter [ ] = [
126125 { name : '-c' , value : this . collectionId } ,
127- { name : '-f' , value : file . name } ,
126+ { name : '-f' , value : this . selectedFile . name } ,
128127 ] ;
129128
130129 if ( values . abortOnError ) {
131130 stringParameters . push ( { name : '-er' , value : values . abortOnError } ) ;
132131 }
133132
134- this . scriptService . invoke ( 'bulk-import' , stringParameters , [ file ] )
133+ this . scriptService . invoke ( 'bulk-import' , stringParameters , [ this . selectedFile ] )
135134 . pipe ( getFirstCompletedRemoteData ( ) )
136135 . subscribe ( ( rd : RemoteData < Process > ) => {
137136 if ( rd . isSuccess ) {
@@ -165,4 +164,15 @@ export class BulkImportPageComponent implements OnInit, OnDestroy {
165164 this . subs . forEach ( ( sub ) => sub . unsubscribe ( ) ) ;
166165 }
167166
167+ public handleFileInput ( event : Event ) {
168+ const input = event . target as HTMLInputElement ;
169+ if ( input . files && input . files . length > 0 ) {
170+ this . setFile ( input . files ) ;
171+ }
172+ }
173+
174+ public setFile ( files : FileList ) {
175+ this . selectedFile = files . length > 0 ? files . item ( 0 ) : undefined ;
176+ }
177+
168178}
0 commit comments