@@ -420,23 +420,23 @@ jQuery(document).ready(function() {
420
420
421
421
// /Start ## Bulk delete#################################################
422
422
$ ( '.container' ) . on ( 'click' , 'button.bulk_delete' , function ( event ) {
423
- var subScriptionsToDelete = [ ] ;
423
+ var subscriptionsToDelete = [ ] ;
424
424
var data = table . rows ( ) . nodes ( ) ;
425
425
$ . each ( data , function ( index , value ) {
426
426
if ( $ ( this ) . find ( 'input' ) . prop ( 'checked' ) == true ) {
427
- subScriptionsToDelete . push ( table . row ( index ) . data ( ) . subscriptionName )
427
+ subscriptionsToDelete . push ( table . row ( index ) . data ( ) . subscriptionName )
428
428
}
429
429
} ) ;
430
430
431
431
// Check if no Subscription has been marked to be deleted.
432
- if ( subScriptionsToDelete . length < 1 ) {
432
+ if ( subscriptionsToDelete . length < 1 ) {
433
433
$ . alert ( "No subscriptions has been marked to be deleted." ) ;
434
434
return ;
435
435
}
436
436
437
- var subScriptionsToDeleteString = "" ;
438
- for ( i = 0 ; i < subScriptionsToDelete . length ; i ++ ) {
439
- subScriptionsToDeleteString += subScriptionsToDelete [ i ] + "\n" ;
437
+ var subscriptionsToDeleteString = "" ;
438
+ for ( i = 0 ; i < subscriptionsToDelete . length ; i ++ ) {
439
+ subscriptionsToDeleteString += subscriptionsToDelete [ i ] + "\n" ;
440
440
}
441
441
442
442
var callback = {
@@ -452,24 +452,25 @@ jQuery(document).ready(function() {
452
452
reload_table ( ) ;
453
453
} ,
454
454
error : function ( XMLHttpRequest , textStatus , errorThrown ) {
455
- $ . jGrowl ( "Error: " + XMLHttpRequest . responseText , {
456
- sticky : true ,
457
- theme : 'Error'
458
- } ) ;
455
+ reload_table ( ) ;
456
+ var responseJSON = JSON . parse ( XMLHttpRequest . responseText ) ;
457
+ for ( var i = 0 ; i < responseJSON . length ; i ++ ) {
458
+ $ . jGrowl ( responseJSON [ i ] . subscription + " :: " + responseJSON [ i ] . reason , { sticky : true , theme : 'Error' } ) ;
459
+ }
459
460
} ,
460
461
complete : function ( ) {
461
462
}
462
463
} ;
463
464
464
465
$ . confirm ( {
465
466
title : 'Confirm!' ,
466
- content : 'Are you sure you want to delete these subscriptions?<pre>' + subScriptionsToDeleteString ,
467
+ content : 'Are you sure you want to delete these subscriptions?<pre>' + subscriptionsToDeleteString ,
467
468
buttons : {
468
469
confirm : function ( ) {
469
470
var ajaxHttpSender = new AjaxHttpSender ( ) ;
470
- for ( i = 0 ; i < subScriptionsToDelete . length ; i ++ ) {
471
- ajaxHttpSender . sendAjax ( frontendServiceUrl + "/subscriptions/" + subScriptionsToDelete [ i ] , "DELETE" , null , callback ) ;
472
- }
471
+ // replace all /n with comma
472
+ subscriptionsToDeleteString = subscriptionsToDeleteString . replace ( new RegExp ( '\n' , 'g' ) , ',' ) . slice ( 0 , - 1 ) ;
473
+ ajaxHttpSender . sendAjax ( frontendServiceUrl + "/subscriptions/" + subscriptionsToDeleteString , "DELETE" , null , callback ) ;
473
474
} ,
474
475
cancel : function ( ) {
475
476
}
@@ -511,18 +512,20 @@ jQuery(document).ready(function() {
511
512
success : function ( data , textStatus ) {
512
513
var returnData = [ data ] ;
513
514
if ( returnData . length > 0 ) {
514
- $ . jGrowl ( "Successful created subscription " + subscriptionJson . subscriptionName , {
515
+ $ . jGrowl ( "Subscriptions are successfully created" , {
515
516
sticky : false ,
516
517
theme : 'Error'
517
518
} ) ;
518
519
reload_table ( ) ;
519
520
}
520
521
} ,
521
522
error : function ( XMLHttpRequest , textStatus , errorThrown ) {
522
- $ . jGrowl ( "Failed to create Subscription: " + subscriptionJson . subscriptionName + " Error: " + XMLHttpRequest . responseText , {
523
- sticky : false ,
524
- theme : 'Error'
525
- } ) ;
523
+ reload_table ( ) ;
524
+ $ . jGrowl ( "Failed to create next Subscriptions" , { sticky : false , theme : 'Error' } ) ;
525
+ var responseJSON = JSON . parse ( XMLHttpRequest . responseText ) ;
526
+ for ( var i = 0 ; i < responseJSON . length ; i ++ ) {
527
+ $ . jGrowl ( responseJSON [ i ] . subscription + " :: " + responseJSON [ i ] . reason , { sticky : true , theme : 'Error' } ) ;
528
+ }
526
529
} ,
527
530
complete : function ( ) {
528
531
}
@@ -548,7 +551,7 @@ jQuery(document).ready(function() {
548
551
theme : 'Notify'
549
552
} ) ;
550
553
var subscriptionJsonList = JSON . parse ( fileContent ) ;
551
- tryToCreateSubscription ( subscriptionJsonList ) ;
554
+ tryToCreateSubscription ( subscriptionJsonList ) ;
552
555
} ;
553
556
reader . readAsText ( subscriptionFile ) ;
554
557
}
@@ -653,6 +656,9 @@ jQuery(document).ready(function() {
653
656
vm . subscription ( [ ] ) ;
654
657
// Map JSON to Model and observableArray
655
658
var mappedPackageInfo = $ . map ( returnData , function ( item ) {
659
+ if ( item . foundSubscriptions != null ) {
660
+ item = item . foundSubscriptions ;
661
+ }
656
662
// Defining Observable on all parameters in Requirements array(which is defined as ObservableArray)
657
663
for ( i = 0 ; i < item [ 0 ] . requirements . length ; i ++ ) {
658
664
var conditions_array = [ ] ;
@@ -847,10 +853,10 @@ jQuery(document).ready(function() {
847
853
}
848
854
} ,
849
855
error : function ( XMLHttpRequest , textStatus , errorThrown ) {
850
- $ . jGrowl ( "Error: " + XMLHttpRequest . responseText , {
851
- sticky : true ,
852
- theme : 'Error'
853
- } ) ;
856
+ var responseJSON = JSON . parse ( XMLHttpRequest . responseText ) ;
857
+ for ( var i = 0 ; i < responseJSON . length ; i ++ ) {
858
+ $ . jGrowl ( responseJSON [ i ] . subscription + " :: " + responseJSON [ i ] . reason , { sticky : true , theme : 'Error' } ) ;
859
+ }
854
860
} ,
855
861
complete : function ( ) {
856
862
$ ( '#btnSave' ) . text ( 'save' ) ; //change button text
0 commit comments