File tree 2 files changed +17
-14
lines changed
js/apps/system/_admin/aardvark/APP/frontend/js
2 files changed +17
-14
lines changed Original file line number Diff line number Diff line change 360
360
} ,
361
361
362
362
uploadDocuments : function ( file , callback ) {
363
+ var analyzeResponse = function ( data ) {
364
+ if ( data . hasOwnProperty ( 'error' ) ) {
365
+ delete data . error ;
366
+ }
367
+
368
+ if ( data . errors > 0 ) {
369
+ callback ( true , 'Info: ' + JSON . stringify ( data ) ) ;
370
+ } else {
371
+ callback ( false , 'Info: ' + JSON . stringify ( data ) ) ;
372
+ }
373
+ } ;
374
+
363
375
$ . ajax ( {
364
376
type : 'POST' ,
365
- url : arangoHelper . databaseUrl ( '/_api/import?type=auto&collection=' +
377
+ url : arangoHelper . databaseUrl ( '/_api/import?type=auto&details=true& collection=' +
366
378
encodeURIComponent ( this . collectionID ) +
367
379
'&createCollection=false' ) ,
368
380
data : file ,
369
381
processData : false ,
370
382
contentType : 'json' ,
371
383
dataType : 'json' ,
372
384
complete : function ( xhr ) {
373
- if ( xhr . readyState === 4 && xhr . status === 201 ) {
374
- callback ( false ) ;
375
- } else {
376
- try {
377
- var data = JSON . parse ( xhr . responseText ) ;
378
- if ( data . errors > 0 ) {
379
- var result = 'At least one error occurred during upload' ;
380
- callback ( false , result ) ;
381
- }
382
- } catch ( err ) {
383
- console . log ( err ) ;
384
- }
385
+ if ( xhr . responseJSON ) {
386
+ analyzeResponse ( xhr . responseJSON ) ;
385
387
}
386
388
} ,
387
389
error : function ( msg ) {
Original file line number Diff line number Diff line change 220
220
$ ( '#documents_first' ) . css ( 'visibility' , 'visible' ) ;
221
221
this . addDocumentSwitch = true ;
222
222
this . collection . resetFilter ( ) ;
223
- this . collection . loadTotal ( callback ) ;
223
+ this . collection . loadCollectionConfig ( callback ) ;
224
224
this . restoredFilters = [ ] ;
225
225
226
226
// for resetting json upload
249
249
if ( error ) {
250
250
arangoHelper . arangoError ( 'Upload' , msg ) ;
251
251
} else {
252
+ arangoHelper . arangoMessage ( 'Upload' , msg ) ;
252
253
this . hideImportModal ( ) ;
253
254
this . resetView ( ) ;
254
255
}
You can’t perform that action at this time.
0 commit comments