@@ -98,7 +98,6 @@ jQuery(document).ready(function () {
98
98
} ) ;
99
99
// END OF EI Backend Server check #########################################
100
100
101
-
102
101
// /Start ## Knockout ####################################################
103
102
104
103
// Subscription model
@@ -146,7 +145,6 @@ jQuery(document).ready(function () {
146
145
this . jmespath = ko . observable ( jmespath . jmespath ) ;
147
146
}
148
147
149
-
150
148
// ViewModel - SubscriptionViewModel
151
149
var SubscriptionViewModel = function ( ) {
152
150
var self = this ;
@@ -181,38 +179,15 @@ jQuery(document).ready(function () {
181
179
182
180
self . repeat_in = ko . observableArray ( [ true , false ] ) ;
183
181
184
- self . add_requirement = function ( data , event ) {
185
-
186
- var conditions_array = [ ] ;
187
- conditions_array . push ( new jmespath_model ( { "jmespath" : ko . observable ( "" ) } ) ) ;
188
- self . subscription ( ) [ 0 ] . requirements ( ) . push ( new conditions_model ( conditions_array ) ) ;
189
-
190
- // Force update
191
- var data = self . subscription ( ) . slice ( 0 ) ;
192
- self . subscription ( [ ] ) ;
193
- self . subscription ( data ) ;
194
- self . subscription . valueHasMutated ( ) ;
195
- loadTooltip ( ) ;
196
- } ;
197
-
198
-
199
182
self . choosen_subscription_template . subscribe ( function ( template_var ) {
200
183
if ( self . choosen_subscription_template ( ) != null ) { // only execute if value exists
201
184
json_obj_clone = JSON . parse ( JSON . stringify ( template_vars [ template_var ] ) ) ;
202
185
populate_json ( json_obj_clone , "add" ) ;
203
186
}
204
187
} ) ;
205
188
206
-
207
189
self . addNotificationMsgKeyValuePair = function ( data , event ) {
208
190
self . subscription ( ) [ 0 ] . notificationMessageKeyValues . push ( new formdata_model ( defaultFormKeyValuePair ) ) ;
209
-
210
- // Force update
211
- var data = self . subscription ( ) . slice ( 0 ) ;
212
- self . subscription ( [ ] ) ;
213
- self . subscription ( data ) ;
214
- self . subscription . valueHasMutated ( ) ;
215
- loadTooltip ( ) ;
216
191
} ;
217
192
218
193
self . addNotificationMsgKeyValuePairAuth = function ( data , event ) {
@@ -222,22 +197,27 @@ jQuery(document).ready(function () {
222
197
223
198
} )
224
199
} ) ;
225
- // ko.observable(value);
226
- // Force update
227
- var data = self . subscription ( ) . slice ( 0 ) ;
228
- self . subscription ( [ ] ) ;
229
- self . subscription ( data ) ;
230
- self . subscription . valueHasMutated ( ) ;
231
- loadTooltip ( ) ;
232
200
} ;
233
201
234
-
235
202
self . getUTCDate = function ( epochtime ) {
236
203
var d = new Date ( 0 ) ; // The 0 there is the key, which sets the date to the epoch
237
204
d . setUTCMilliseconds ( epochtime ) ;
238
205
return d ; // Is now a date (in client time zone)
239
206
}
240
207
208
+ self . add_requirement = function ( data , event ) {
209
+
210
+ var conditions_array = [ ] ;
211
+ conditions_array . push ( new jmespath_model ( { "jmespath" : ko . observable ( "" ) } ) ) ;
212
+ self . subscription ( ) [ 0 ] . requirements ( ) . push ( new conditions_model ( conditions_array ) ) ;
213
+ // Force update
214
+ var data = self . subscription ( ) . slice ( 0 ) ;
215
+ self . subscription ( [ ] ) ;
216
+ self . subscription ( data ) ;
217
+ self . subscription . valueHasMutated ( ) ;
218
+ closeTooltip ( ) ;
219
+ loadTooltip ( ) ;
220
+ } ;
241
221
242
222
self . add_condition = function ( data , event , requirement_index ) {
243
223
self . subscription ( ) [ 0 ] . requirements ( ) [ ko . toJSON ( requirement_index ) ] . conditions ( ) . push ( new jmespath_model ( { "jmespath" : ko . observable ( "" ) } ) ) ;
@@ -246,25 +226,23 @@ jQuery(document).ready(function () {
246
226
self . subscription ( [ ] ) ;
247
227
self . subscription ( data ) ;
248
228
self . subscription . valueHasMutated ( ) ;
229
+ closeTooltip ( ) ;
249
230
loadTooltip ( ) ;
250
231
} ;
251
232
252
-
253
233
self . delete_condition = function ( data , event , requirement_item , condition_index , requirement_index ) {
254
234
self . subscription ( ) [ 0 ] . requirements ( ) [ ko . toJSON ( requirement_index ) ] . conditions . remove ( data ) ;
255
235
if ( self . subscription ( ) [ 0 ] . requirements ( ) [ ko . toJSON ( requirement_index ) ] . conditions ( ) . length <= 0 ) {
256
236
self . subscription ( ) [ 0 ] . requirements . remove ( self . subscription ( ) [ 0 ] . requirements ( ) [ ko . toJSON ( requirement_index ) ] ) ;
257
237
}
258
238
} ;
259
239
260
-
261
240
self . delete_NotificationMsgKeyValuePair = function ( data , event , index ) {
262
241
if ( self . subscription ( ) [ 0 ] . notificationMessageKeyValues ( ) . length > 1 ) {
263
242
self . subscription ( ) [ 0 ] . notificationMessageKeyValues . remove ( self . subscription ( ) [ 0 ] . notificationMessageKeyValues ( ) [ ko . toJSON ( index ) ] ) ;
264
243
}
265
244
} ;
266
245
267
-
268
246
self . delete_BulkNotificationMsgKeyValuePair = function ( ) {
269
247
$ . each ( self . subscription ( ) [ 0 ] . notificationMessageKeyValues ( ) , function ( index , value ) {
270
248
if ( self . subscription ( ) [ 0 ] . notificationMessageKeyValues ( ) . length > 1 ) {
@@ -274,7 +252,6 @@ jQuery(document).ready(function () {
274
252
} ;
275
253
} ;
276
254
277
-
278
255
// Start to check is backend secured
279
256
var isSecured = false ;
280
257
$ . ajax ( {
@@ -307,6 +284,7 @@ jQuery(document).ready(function () {
307
284
var currentUser = localStorage . getItem ( "currentUser" ) ;
308
285
table = $ ( '#table' ) . DataTable ( {
309
286
"responsive" : true ,
287
+ "autoWidth" : false ,
310
288
"processing" : true , //Feature control the processing indicator.
311
289
"serverSide" : false , //Feature control DataTables' server-side processing mode.
312
290
"fixedHeader" : true ,
@@ -415,7 +393,6 @@ jQuery(document).ready(function () {
415
393
} ) ;
416
394
// /Stop ## Datatables ##################################################
417
395
418
-
419
396
// /Start ## check all subscriptions ####################################
420
397
$ ( "#check-all" ) . click ( function ( ) {
421
398
$ ( ".data-check" ) . prop ( 'checked' , $ ( this ) . prop ( 'checked' ) ) ;
@@ -436,7 +413,6 @@ jQuery(document).ready(function () {
436
413
} ) ;
437
414
// /Stop ## Reload Table#################################################
438
415
439
-
440
416
// /Start ## Bulk delete#################################################
441
417
$ ( "#bulkDelete" ) . click ( function ( ) {
442
418
var subscriptionsToDelete = [ ] ;
@@ -499,8 +475,6 @@ jQuery(document).ready(function () {
499
475
} ) ;
500
476
// /Stop ## Bulk delete##################################################
501
477
502
-
503
-
504
478
function getTemplate ( ) {
505
479
var req = new XMLHttpRequest ( ) ;
506
480
req . open ( "GET" , frontendServiceUrl + '/download/subscriptionsTemplate' , true ) ;
@@ -522,8 +496,6 @@ jQuery(document).ready(function () {
522
496
} ) ;
523
497
// /END ## get_subscription_template #################################################
524
498
525
-
526
-
527
499
function validateJsonAndCreateSubscriptions ( subscriptionFile ) {
528
500
var reader = new FileReader ( ) ;
529
501
reader . onload = function ( ) {
@@ -583,7 +555,6 @@ jQuery(document).ready(function () {
583
555
ajaxHttpSender . sendAjax ( frontendServiceUrl + "/subscriptions" , "POST" , ko . toJSON ( subscriptionJson ) , callback ) ;
584
556
}
585
557
586
-
587
558
// /Start ## upload_subscriptions #################################################
588
559
$ ( "#uploadSubscription" ) . click ( function ( ) {
589
560
function createUploadWindow ( ) {
@@ -685,7 +656,6 @@ jQuery(document).ready(function () {
685
656
item [ 0 ] . notificationMessageKeyValues [ i ] = new formdata_model ( item [ 0 ] . notificationMessageKeyValues [ i ] )
686
657
}
687
658
688
-
689
659
return new subscription_model ( item [ 0 ] ) ;
690
660
} ) ;
691
661
// Load data into observable array
@@ -883,19 +853,12 @@ jQuery(document).ready(function () {
883
853
}
884
854
} ;
885
855
886
-
887
856
// Perform AJAX
888
857
var ajaxHttpSender = new AjaxHttpSender ( ) ;
889
858
ajaxHttpSender . sendAjax ( url , type , ko . toJSON ( vm . subscription ( ) ) , callback ) ;
890
-
891
-
892
-
893
859
} ) ;
894
860
// /Stop ## Save Subscription ###########################################
895
861
896
-
897
-
898
-
899
862
// /Start ## Delete Subscription ########################################
900
863
$ ( '#table' ) . on ( 'click' , 'tbody tr td button.delete_record' , function ( event ) {
901
864
event . stopPropagation ( ) ;
@@ -923,7 +886,6 @@ jQuery(document).ready(function () {
923
886
}
924
887
} ;
925
888
926
-
927
889
$ . confirm ( {
928
890
title : 'Confirm!' ,
929
891
content : 'Are you sure delete this subscription?' ,
@@ -949,4 +911,8 @@ jQuery(document).ready(function () {
949
911
function loadTooltip ( ) {
950
912
$ ( '[data-toggle="tooltip"]' ) . tooltip ( { trigger : "click" , html : true } ) ;
951
913
}
914
+
915
+ function closeTooltip ( ) {
916
+ $ ( '.tooltip' ) . tooltip ( 'hide' ) ;
917
+ }
952
918
} ) ;
0 commit comments