@@ -3,7 +3,7 @@ var save_method;
3
3
var table ;
4
4
var frontendServiceUrl ;
5
5
var defaultFormKeyValuePair = { "formkey" : "" , "formvalue" : "" } ;
6
-
6
+ var defaultFormKeyValuePairAuth = { "formkey" : "Authorization" , "formvalue" : "" } ;
7
7
8
8
jQuery ( document ) . ready ( function ( ) {
9
9
@@ -109,10 +109,14 @@ jQuery(document).ready(function() {
109
109
this . notificationType = ko . observable ( data . notificationType ) ;
110
110
this . restPostBodyMediaType = ko . observable ( data . restPostBodyMediaType ) ;
111
111
this . notificationMessageKeyValues = ko . observableArray ( data . notificationMessageKeyValues ) ;
112
+ this . notificationMessageKeyValuesAuth = ko . observableArray ( data . notificationMessageKeyValuesAuth ) ;
112
113
this . repeat = ko . observable ( data . repeat ) ;
113
114
this . requirements = ko . observableArray ( data . requirements ) ;
114
115
this . subscriptionName = ko . observable ( data . subscriptionName ) ;
115
116
this . aggregationtype = ko . observable ( data . aggregationtype ) ;
117
+ this . authenticationType = ko . observable ( data . authenticationType ) ;
118
+ this . userName = ko . observable ( data . userName ) ;
119
+ this . token = ko . observable ( data . token ) ;
116
120
117
121
this . notificationType . subscribe ( function ( new_value ) {
118
122
vm . subscription ( ) [ 0 ] . restPostBodyMediaType ( null ) ;
@@ -127,7 +131,6 @@ jQuery(document).ready(function() {
127
131
vm . formpostkeyvaluepairs ( false ) ;
128
132
}
129
133
} ) ;
130
-
131
134
}
132
135
133
136
function formdata_model ( formdata ) {
@@ -155,12 +158,20 @@ jQuery(document).ready(function() {
155
158
{ "text" : "Mail Trigger" , value :"templateEmailTrigger" }
156
159
] ) ;
157
160
self . choosen_subscription_template = ko . observable ( ) ;
161
+ self . authenticationType = ko . observable ( ) ;
158
162
self . formpostkeyvaluepairs = ko . observable ( false ) ;
163
+ self . formpostkeyvaluepairsAuth = ko . observable ( false ) ;
159
164
self . notificationType_in = ko . observableArray (
160
165
[
161
166
{ "text" : "REST_POST" , value :"REST_POST" } ,
162
167
{ "text" : "MAIL" , value :"MAIL" }
163
168
] ) ;
169
+ self . authenticationType_in = ko . observableArray (
170
+ [
171
+ { "text" : "NO_AUTH" , value :"NO_AUTH" } ,
172
+ { "text" : "BASIC_AUTH" , value :"BASIC_AUTH" }
173
+ ] ) ;
174
+
164
175
165
176
self . restPostBodyType_in = ko . observableArray (
166
177
[
@@ -203,6 +214,19 @@ jQuery(document).ready(function() {
203
214
self . subscription ( data ) ;
204
215
self . subscription . valueHasMutated ( ) ;
205
216
} ;
217
+
218
+ self . addNotificationMsgKeyValuePairAuth = function ( data , event ) {
219
+ data . notificationMessageKeyValues . push ( { "formkey" : "Authorization" , "formvalue" : ko . computed ( function ( ) {
220
+ return "Basic " + btoa ( data . userName ( ) + ":" + data . token ( ) ) ;
221
+
222
+ } ) } ) ;
223
+ // ko.observable(value);
224
+ // Force update
225
+ var data = self . subscription ( ) . slice ( 0 ) ;
226
+ self . subscription ( [ ] ) ;
227
+ self . subscription ( data ) ;
228
+ self . subscription . valueHasMutated ( ) ;
229
+ } ;
206
230
207
231
208
232
self . getUTCDate = function ( epochtime ) {
@@ -245,11 +269,8 @@ jQuery(document).ready(function() {
245
269
}
246
270
} ) ;
247
271
} ;
248
-
249
-
250
-
251
-
252
272
} ;
273
+
253
274
254
275
// Start to check is backend secured
255
276
var isSecured = false ;
@@ -277,13 +298,11 @@ jQuery(document).ready(function() {
277
298
var vm = new SubscriptionViewModel ( ) ;
278
299
ko . applyBindings ( vm , observableObject ) ;
279
300
280
-
281
301
// /Stop ## Knockout #####################################################
282
302
283
303
284
304
285
305
286
-
287
306
// /Start ## Datatables ##################################################
288
307
var currentUser = localStorage . getItem ( "currentUser" ) ;
289
308
table = $ ( '#table' ) . DataTable ( {
@@ -646,6 +665,8 @@ jQuery(document).ready(function() {
646
665
for ( i = 0 ; i < item [ 0 ] . notificationMessageKeyValues . length ; i ++ ) {
647
666
item [ 0 ] . notificationMessageKeyValues [ i ] = new formdata_model ( item [ 0 ] . notificationMessageKeyValues [ i ] )
648
667
}
668
+
669
+
649
670
return new subscription_model ( item [ 0 ] ) ;
650
671
} ) ;
651
672
// Load data into observable array
@@ -689,6 +710,7 @@ jQuery(document).ready(function() {
689
710
if ( ! vm . formpostkeyvaluepairs ( ) ) {
690
711
notificationMessageKeyValuesArray [ 0 ] . formkey = "" ; // OBS must be empty when NOT using REST POST Form key/value pairs
691
712
}
713
+
692
714
693
715
//START: Make sure all datatables field has a value
694
716
if ( ! ( / [ a - z ] | [ A - Z ] | [ 0 - 9 ] | [ \_ ] / . test ( String ( vm . subscription ( ) [ 0 ] . subscriptionName ( ) ) . slice ( - 1 ) ) ) ) {
@@ -738,8 +760,6 @@ jQuery(document).ready(function() {
738
760
//END OF: Make sure all datatables field has a value
739
761
740
762
741
-
742
-
743
763
//START: Check of other subscription fields values
744
764
for ( i = 0 ; i < notificationMessageKeyValuesArray . length ; i ++ ) {
745
765
var test_key = ko . toJSON ( notificationMessageKeyValuesArray [ i ] . formkey ) ;
0 commit comments