@@ -165,8 +165,6 @@ var ListWidgetView = Backbone.View.extend({
165
165
166
166
tagName : "div" ,
167
167
168
- childView :ListWidgetChildView ,
169
-
170
168
events :{
171
169
"click .btn-add-list-item" :"addItem" ,
172
170
"keypress" :function ( e ) {
@@ -226,7 +224,7 @@ var ListWidgetView = Backbone.View.extend({
226
224
this . $el . html ( this . template ( { placeholder :this . options . placeholder ,
227
225
helpBlockText :this . options . helpBlockText } ) ) ;
228
226
229
- _self = this ;
227
+ var _self = this ;
230
228
231
229
if ( _ . size ( this . collection . models ) == 0 && _ . size ( this . options . autocomplete ) == 0 ) {
232
230
$ ( "tbody" , _self . el ) . html ( $ ( '#tmpl-list-widget-child-empty' ) . html ( ) ) ;
@@ -256,7 +254,7 @@ var ListWidgetView = Backbone.View.extend({
256
254
checked = false ;
257
255
}
258
256
259
- var el = new this . childView ( { model :model , toggle : true , checked : checked , collection : _self . collection } ) . render ( ) . el ;
257
+ var el = new ListWidgetChildView ( { model :model , toggle : true , checked : checked , collection : _self . collection } ) . render ( ) . el ;
260
258
$ ( "tbody" , _self . el ) . append ( el ) ;
261
259
262
260
} , this ) ;
@@ -265,8 +263,7 @@ var ListWidgetView = Backbone.View.extend({
265
263
266
264
// now render everything not in the autocomplete list
267
265
_ . each ( values . models , function ( model ) {
268
-
269
- var el = new this . childView ( { model :model , collection : _self . collection } ) . render ( ) . el ;
266
+ var el = new ListWidgetChildView ( { model :model , collection : _self . collection } ) . render ( ) . el ;
270
267
$ ( "tbody" , _self . el ) . append ( el ) ;
271
268
} , this ) ;
272
269
}
@@ -277,18 +274,6 @@ var ListWidgetView = Backbone.View.extend({
277
274
278
275
} ) ;
279
276
280
- var BlackListModel = Backbone . Model . extend ( {
281
- idAttribute : 'id' ,
282
-
283
- urlRoot : 'api/blacklist'
284
- } ) ;
285
-
286
- var BlackListCollection = Backbone . Collection . extend ( {
287
- initialize : function ( ) { } ,
288
-
289
- url : "api/blacklist"
290
- } ) ;
291
-
292
277
var BreadCrumbView = Backbone . View . extend ( {
293
278
294
279
tagName : 'ul' ,
@@ -329,125 +314,6 @@ var BreadCrumbView = Backbone.View.extend({
329
314
} ) ;
330
315
331
316
332
- var BlackListListView = Backbone . View . extend ( {
333
- tagName : 'span' ,
334
-
335
- initialize :function ( options ) {
336
- this . options = options ;
337
- if ( ! this . template ) {
338
- this . template = _ . template ( $ ( '#tmpl-blacklist-form' ) . html ( ) ) ;
339
- }
340
- } ,
341
-
342
- load :function ( callback ) {
343
- if ( this . model . isFetched ) {
344
- callback ( ) ;
345
- return ;
346
- }
347
-
348
- $ ( '#loadingbox' ) . sheet ( 'show' ) ;
349
- $ ( '#loading' ) . html (
350
- '<span class="label" id="loading-blacklist">' + $ . t ( 'admin.blacklist' ) + '</span> '
351
- ) ;
352
-
353
- $ . when ( this . model . fetchIfNeeded ( ) ) . done ( function ( ) {
354
- $ ( '#loading-blacklist' ) . addClass ( 'label-success' ) ;
355
- $ ( '#loadingbox' ) . sheet ( 'hide' ) ;
356
- callback ( ) ;
357
- } ) ;
358
- } ,
359
-
360
- events : {
361
- "click .refresh-table" :"refreshTable"
362
- } ,
363
-
364
- refreshTable :function ( e ) {
365
- e . preventDefault ( ) ;
366
- var _self = this ;
367
- $ ( '#loadingbox' ) . sheet ( 'show' ) ;
368
- $ ( '#loading' ) . html (
369
- '<span class="label" id="loading-blacklist">' + $ . t ( 'admin.blacklist' ) + '</span> '
370
- ) ;
371
-
372
- $ . when ( this . model . fetch ( ) ) . done ( function ( ) {
373
- $ ( '#loadingbox' ) . sheet ( 'hide' ) ;
374
- _self . render ( ) ;
375
- } ) ;
376
- } ,
377
-
378
- render :function ( eventName ) {
379
-
380
- $ ( this . el ) . html ( this . template ( this . model . toJSON ( ) ) ) ;
381
-
382
- $ ( '#blacklist .controls' , this . el ) . html ( new BlackListWidgetView ( {
383
- type : 'uri' ,
384
- placeholder : 'http://' ,
385
- collection : this . model
386
- } ) . render ( ) . el ) ;
387
-
388
- $ ( this . el ) . i18n ( ) ;
389
- return this ;
390
- }
391
- } ) ;
392
-
393
- var BlackListWidgetView = ListWidgetView . extend ( {
394
-
395
- childView : ListWidgetChildView . extend ( {
396
- render :function ( options ) {
397
- this . options = options ;
398
- var uri = this . model . get ( 'uri' ) ;
399
-
400
- this . $el . html ( this . template ( { item : uri } ) ) ;
401
-
402
- if ( uri . length > 30 ) {
403
- this . $el . tooltip ( { title :uri } ) ;
404
- }
405
- return this ;
406
-
407
- }
408
- } ) ,
409
-
410
- addItem :function ( e ) {
411
- e . preventDefault ( ) ;
412
-
413
- var input_value = $ ( "input" , this . el ) . val ( ) . trim ( ) ;
414
-
415
- if ( input_value === "" ) {
416
- return ;
417
- }
418
-
419
- // TODO: URI/pattern validation, check against existing clients
420
-
421
- var item = new BlackListModel ( {
422
- uri : input_value
423
- } ) ;
424
-
425
- var _self = this ; // closures...
426
-
427
- item . save ( { } , {
428
- success :function ( ) {
429
- _self . collection . add ( item ) ;
430
- } ,
431
- error :function ( error , response ) {
432
- //Pull out the response text.
433
- var responseJson = JSON . parse ( response . responseText ) ;
434
-
435
- //Display an alert with an error message
436
- $ ( '#modalAlert div.modal-header' ) . html ( responseJson . error ) ;
437
- $ ( '#modalAlert div.modal-body' ) . html ( responseJson . error_description ) ;
438
-
439
- $ ( "#modalAlert" ) . modal ( { // wire up the actual modal functionality and show the dialog
440
- "backdrop" : "static" ,
441
- "keyboard" : true ,
442
- "show" : true // ensure the modal is shown immediately
443
- } ) ;
444
- }
445
- } ) ;
446
-
447
- }
448
-
449
- } ) ;
450
-
451
317
// Stats table
452
318
453
319
var StatsModel = Backbone . Model . extend ( {
@@ -469,12 +335,29 @@ var UserProfileView = Backbone.View.extend({
469
335
render :function ( ) {
470
336
471
337
$ ( this . el ) . html ( $ ( '#tmpl-user-profile' ) . html ( ) ) ;
338
+
339
+ var t = this . template ;
472
340
473
341
_ . each ( this . model , function ( value , key ) {
474
342
if ( key && value ) {
475
- $ ( 'dl' , this . el ) . append (
476
- this . template ( { key : key , value : value } )
477
- ) ;
343
+
344
+ if ( typeof ( value ) === 'object' ) {
345
+
346
+ var el = this . el ;
347
+ var k = key ;
348
+
349
+ _ . each ( value , function ( value , key ) {
350
+ $ ( 'dl' , el ) . append (
351
+ t ( { key : key , value : value , category : k } )
352
+ ) ;
353
+ } ) ;
354
+ } else if ( typeof ( value ) === 'array' ) {
355
+ // TODO: handle array types
356
+ } else {
357
+ $ ( 'dl' , this . el ) . append (
358
+ t ( { key : key , value : value } )
359
+ ) ;
360
+ }
478
361
}
479
362
} , this ) ;
480
363
@@ -621,6 +504,7 @@ var AppRouter = Backbone.Router.extend({
621
504
grantTypes : [ "authorization_code" ] ,
622
505
responseTypes : [ "code" ] ,
623
506
subjectType : "PUBLIC" ,
507
+ jwksType : "URI" ,
624
508
contacts : contacts
625
509
} , { silent : true } ) ;
626
510
@@ -659,6 +543,16 @@ var AppRouter = Backbone.Router.extend({
659
543
} , { silent : true } ) ;
660
544
}
661
545
546
+ if ( client . get ( "jwks" ) ) {
547
+ client . set ( {
548
+ jwksType : "VAL"
549
+ } , { silent : true } ) ;
550
+ } else {
551
+ client . set ( {
552
+ jwksType : "URI"
553
+ } , { silent : true } ) ;
554
+ }
555
+
662
556
client . set ( {
663
557
generateClientSecret :false ,
664
558
displayClientSecret :false
@@ -780,7 +674,6 @@ var AppRouter = Backbone.Router.extend({
780
674
this . updateSidebar ( 'user/approved' ) ;
781
675
782
676
var view = new ApprovedSiteListView ( { model :this . approvedSiteList , clientList : this . clientList , systemScopeList : this . systemScopeList } ) ;
783
-
784
677
view . load (
785
678
function ( collection , response , options ) {
786
679
$ ( '#content' ) . html ( view . render ( ) . el ) ;
@@ -836,7 +729,7 @@ var AppRouter = Backbone.Router.extend({
836
729
837
730
this . updateSidebar ( 'admin/blacklist' ) ;
838
731
839
- var view = new BlackListListView ( { model : this . blackListList } ) ;
732
+ var view = new BlackListListView ( { collection : this . blackListList } ) ;
840
733
841
734
view . load (
842
735
function ( collection , response , options ) {
@@ -1230,11 +1123,17 @@ $(function () {
1230
1123
$ . get ( 'resources/template/dynreg.html' , _load ) ,
1231
1124
$ . get ( 'resources/template/rsreg.html' , _load ) ,
1232
1125
$ . get ( 'resources/template/token.html' , _load ) ,
1126
+ $ . get ( 'resources/template/blacklist.html' , _load ) ,
1233
1127
$ . get ( 'resources/template/policy.html' , _load )
1234
1128
) . done ( function ( ) {
1235
1129
$ . ajaxSetup ( { cache :false } ) ;
1236
1130
app = new AppRouter ( ) ;
1237
1131
1132
+ app . on ( 'route' , function ( name , args ) {
1133
+ // scroll to top of page on new route selection
1134
+ $ ( "html, body" ) . animate ( { scrollTop : 0 } , "slow" ) ;
1135
+ } ) ;
1136
+
1238
1137
// grab all hashed URLs and send them through the app router instead
1239
1138
$ ( document ) . on ( 'click' , 'a[href^="manage/#"]' , function ( event ) {
1240
1139
event . preventDefault ( ) ;
0 commit comments