Skip to content

Commit c620917

Browse files
committed
added paginator to the token page
1 parent 17b4f12 commit c620917

File tree

4 files changed

+77
-15
lines changed

4 files changed

+77
-15
lines changed

openid-connect-server-webapp/src/main/webapp/resources/js/client.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ var ClientListView = Backbone.View.extend({
304304
"click .refresh-table":"refreshTable",
305305
'keyup .search-query':'searchTable',
306306
'click .form-search button':'clearSearch',
307-
'page #paginator':'changePage'
307+
'page .paginator':'changePage'
308308
},
309309

310310
newClient:function (e) {
@@ -328,13 +328,13 @@ var ClientListView = Backbone.View.extend({
328328
// set up pagination
329329
var numPages = Math.ceil(this.filteredModel.length / 10);
330330
if (numPages > 1) {
331-
$('#paginator').show();
332-
$('#paginator', this.el).bootpag({
331+
$('.paginator', this.el).show();
332+
$('.paginator', this.el).bootpag({
333333
total: numPages,
334334
page: 1
335335
});
336336
} else {
337-
$('#paginator', this.el).hide();
337+
$('.paginator', this.el).hide();
338338
}
339339

340340
// render the rows
@@ -377,9 +377,7 @@ var ClientListView = Backbone.View.extend({
377377
},
378378

379379
changePage:function(event, num) {
380-
this.page = num;
381380
$('#client-table tbody tr', this.el).each(function(index, element) {
382-
console.log([num, index]);
383381
if (Math.ceil((index + 1) / 10) != num) {
384382
$(element).hide();
385383
} else {

openid-connect-server-webapp/src/main/webapp/resources/js/token.js

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,12 @@ var RefreshTokenView = Backbone.View.extend({
290290
// hide it
291291
$('.moreInformation', this.el).hide('fast');
292292
$('.toggleMoreInformation i', this.el).attr('class', 'icon-chevron-right');
293+
$('.moreInformationContainer', this.el).removeClass('alert').removeClass('alert-info').addClass('muted');
293294
} else {
294295
// show it
295296
$('.moreInformation', this.el).show('fast');
296297
$('.toggleMoreInformation i', this.el).attr('class', 'icon-chevron-down');
298+
$('.moreInformationContainer', this.el).addClass('alert').addClass('alert-info').removeClass('muted');
297299
}
298300

299301
},
@@ -314,7 +316,9 @@ var TokenListView = Backbone.View.extend({
314316
tagName: 'span',
315317

316318
events:{
317-
"click .refresh-table":"refreshTable"
319+
"click .refresh-table":"refreshTable",
320+
'page .paginator-access':'changePageAccess',
321+
'page .paginator-refresh':'changePageRefresh'
318322
},
319323

320324
load:function(callback) {
@@ -344,6 +348,28 @@ var TokenListView = Backbone.View.extend({
344348

345349
},
346350

351+
changePageAccess:function(event, num) {
352+
$('.paginator-access', this.el).bootpag({page: num});
353+
$('#access-token-table tbody tr', this.el).each(function(index, element) {
354+
if (Math.ceil((index + 1) / 10) != num) {
355+
$(element).hide();
356+
} else {
357+
$(element).show();
358+
}
359+
});
360+
},
361+
362+
changePageRefresh:function(event, num) {
363+
$('.paginator-refresh', this.el).bootpag({page: num});
364+
$('#refresh-token-table tbody tr', this.el).each(function(index, element) {
365+
if (Math.ceil((index + 1) / 10) != num) {
366+
$(element).hide();
367+
} else {
368+
$(element).show();
369+
}
370+
});
371+
},
372+
347373
refreshTable:function(e) {
348374
e.preventDefault();
349375
$('#loadingbox').sheet('show');
@@ -387,19 +413,49 @@ var TokenListView = Backbone.View.extend({
387413

388414
var _self = this;
389415

390-
_.each(this.model.access.models, function (token) {
416+
// set up pagination
417+
var numPagesAccess = Math.ceil(this.model.access.length / 10);
418+
if (numPagesAccess > 1) {
419+
$('.paginator-access', this.el).show();
420+
$('.paginator-access', this.el).bootpag({
421+
total: numPagesAccess,
422+
page: 1
423+
});
424+
} else {
425+
$('.paginator-access', this.el).hide();
426+
}
427+
428+
_.each(this.model.access.models, function (token, index) {
391429
// look up client
392430
var client = _self.options.clientList.getByClientId(token.get('clientId'));
393-
394-
$('#access-token-table', _self.el).append(new AccessTokenView({model: token, client: client, systemScopeList: _self.options.systemScopeList}).render().el);
431+
var element = new AccessTokenView({model: token, client: client, systemScopeList: _self.options.systemScopeList}).render().el;
432+
$('#access-token-table', _self.el).append(element);
433+
if (Math.ceil((index + 1) / 10) != 1) {
434+
$(element).hide();
435+
}
395436

396437
});
397438

398-
_.each(this.model.refresh.models, function (token) {
439+
// set up pagination
440+
var numPagesRefresh = Math.ceil(this.model.refresh.length / 10);
441+
if (numPagesRefresh > 1) {
442+
$('.paginator-refresh', this.el).show();
443+
$('.paginator-refresh', this.el).bootpag({
444+
total: numPagesRefresh,
445+
page: 1
446+
});
447+
} else {
448+
$('.paginator-refresh', this.el).hide();
449+
}
450+
451+
_.each(this.model.refresh.models, function (token, index) {
399452
// look up client
400453
var client = _self.options.clientList.getByClientId(token.get('clientId'));
401-
402-
$('#refresh-token-table', _self.el).append(new RefreshTokenView({model: token, client: client, systemScopeList: _self.options.systemScopeList}).render().el);
454+
var element = new RefreshTokenView({model: token, client: client, systemScopeList: _self.options.systemScopeList}).render().el;
455+
$('#refresh-token-table', _self.el).append(element);
456+
if (Math.ceil((index + 1) / 10) != 1) {
457+
$(element).hide();
458+
}
403459

404460
});
405461

openid-connect-server-webapp/src/main/webapp/resources/template/client.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
<script type="text/html" id="tmpl-client-more-info-block">
5555
<% if (client.clientDescription || client.clientUri || client.policyUri || client.tosUri || client.contacts != null && client.contacts.length > 0) { %>
5656
<div class="muted moreInformationContainer">
57-
<%=client.clientDescription%>
5857
<% if (client.clientUri || client.policyUri || client.tosUri || client.contacts) { %>
5958
<div class="toggleMoreInformation" style="cursor: pointer;">
6059
<i class="icon-chevron-right"></i> <small>more information</small>
6160
</div>
6261
<div class="moreInformation hide">
62+
<%=client.clientDescription%>
6363
<ul>
6464
<% if (client.clientUri) { %>
6565
<li>Home page: <a href="<%= client.clientUri %>"><%= client.clientUri %></a></li>
@@ -114,7 +114,7 @@
114114
</tbody>
115115
</table>
116116

117-
<div id="paginator" class="pagination"> </div>
117+
<div class="pagination paginator"></div>
118118

119119
<div class="well well-small">
120120
<button class="btn btn-small refresh-table"><i class="icon-refresh"></i> Refresh</button> &nbsp;

openid-connect-server-webapp/src/main/webapp/resources/template/token.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ <h2>Access Tokens</h2>
2828
There are no active access tokens.
2929
</div>
3030

31+
<div class="pagination paginator-access"></div>
32+
3133
<table id="access-token-table" class="table table-hover table-striped">
3234
<thead>
3335
<tr>
@@ -41,6 +43,8 @@ <h2>Access Tokens</h2>
4143
</tbody>
4244
</table>
4345

46+
<div class="pagination paginator-access"></div>
47+
4448
<h2>Refresh Tokens</h2>
4549

4650
<div><p>Refresh tokens are usually long-lived and provide clients with the ability to get new access tokens without end-user involvement.</p></div>
@@ -49,6 +53,8 @@ <h2>Refresh Tokens</h2>
4953
There are no active refresh tokens.
5054
</div>
5155

56+
<div class="pagination paginator-refresh"></div>
57+
5258
<table id="refresh-token-table" class="table table-hover table-striped">
5359
<thead>
5460
<tr>
@@ -62,6 +68,8 @@ <h2>Refresh Tokens</h2>
6268
</tbody>
6369
</table>
6470

71+
<div class="pagination paginator-refresh"></div>
72+
6573
<div class="well well-small">
6674
<button class="btn btn-small refresh-table"><i class="icon-refresh"></i> Refresh</button> &nbsp;
6775
</div>

0 commit comments

Comments
 (0)