@@ -339,40 +339,13 @@ $('.btn-edit-dataset').on('click', function(e){
339
339
} ) ;
340
340
341
341
// Check uri source (fileupload field)
342
- if ( form . find ( "#fileupload" ) . length == 0 || form . find ( "#fileupload" ) [ 0 ] . files . length == 0 ) {
343
- // Ajax call: no file selected
344
- $ . ajax ( {
345
- url : baseURL + "api/definitions/" + identifier ,
346
- data : JSON . stringify ( data ) ,
347
- method : "POST" ,
348
- headers : {
349
- 'Accept' : 'application/json' ,
350
- 'Authorization' : authHeader
351
- } ,
352
- success : function ( e ) {
353
- // Done, redirect to datets page
354
- window . location = baseURL + 'api/admin/datasets' ;
355
- } ,
356
- error : function ( e ) {
357
- if ( e . status != 405 ) {
358
- var error = JSON . parse ( e . responseText ) ;
359
- if ( error . error && error . error . message ) {
360
- $ ( '.error .text' ) . html ( error . error . message ) ;
361
- $ ( '.error' ) . removeClass ( 'hide' ) . show ( ) . focus ( ) ;
362
- }
363
- } else {
364
- // Ajax followed location header -> ignore
365
- window . location = baseURL + 'api/admin/datasets' ;
366
- }
367
- }
368
- } )
369
- } else if ( form . find ( "#fileupload_xslt" ) . length && ( form . find ( "#fileupload_xslt" ) . length != 0 || form . find ( "#fileupload_xslt" ) [ 0 ] . files . length != 0 ) ) {
342
+ if ( form . find ( "#fileupload_xslt" ) . length && ( form . find ( "#fileupload_xslt" ) . length != 0 || form . find ( "#fileupload_xslt" ) [ 0 ] . files . length != 0 ) ) {
370
343
// Upload dataset file
344
+ console . log ( "upload" ) ;
371
345
var file = form . find ( 'input[type=file]' ) [ 0 ] . files [ 0 ] ;
372
346
var fd = new FormData ( ) ;
373
347
fd . append ( "fileupload" , file ) ;
374
348
375
-
376
349
// Upload xslt file
377
350
var fileupload_xslt = form . find ( '#fileupload_xslt' ) [ 0 ] . files [ 0 ] ;
378
351
fd . append ( "fileupload_xslt" , fileupload_xslt ) ;
@@ -417,13 +390,41 @@ $('.btn-edit-dataset').on('click', function(e){
417
390
} ,
418
391
timeout : 10000
419
392
} ) ;
420
- }
393
+ } else if ( form . find ( "#fileupload" ) . length == 0 || form . find ( "#fileupload" ) [ 0 ] . files . length == 0 ) {
394
+ // Ajax call: no file selected
395
+ console . log ( "no upload" ) ;
396
+ $ . ajax ( {
397
+ url : baseURL + "api/definitions/" + identifier ,
398
+ data : JSON . stringify ( data ) ,
399
+ method : "POST" ,
400
+ headers : {
401
+ 'Accept' : 'application/json' ,
402
+ 'Authorization' : authHeader
403
+ } ,
404
+ success : function ( e ) {
405
+ // Done, redirect to datets page
406
+ window . location = baseURL + 'api/admin/datasets' ;
407
+ } ,
408
+ error : function ( e ) {
409
+ if ( e . status != 405 ) {
410
+ var error = JSON . parse ( e . responseText ) ;
411
+ if ( error . error && error . error . message ) {
412
+ $ ( '.error .text' ) . html ( error . error . message ) ;
413
+ $ ( '.error' ) . removeClass ( 'hide' ) . show ( ) . focus ( ) ;
414
+ }
415
+ } else {
416
+ // Ajax followed location header -> ignore
417
+ window . location = baseURL + 'api/admin/datasets' ;
418
+ }
419
+ }
420
+ } )
421
+ }
421
422
else {
422
423
// Upload dataset file
423
424
var file = form . find ( 'input[type=file]' ) [ 0 ] . files [ 0 ] ;
424
425
var fd = new FormData ( ) ;
425
426
fd . append ( "fileupload" , file ) ;
426
-
427
+ console . log ( "upload the normal file" ) ;
427
428
// Ajax call: upload file
428
429
$ . ajax ( {
429
430
async : true ,
0 commit comments