Skip to content

Commit a10761b

Browse files
committed
lazy load for client list
1 parent 5fdfbbd commit a10761b

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

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

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
******************************************************************************/
17+
18+
Backbone.Model.prototype.fetchIfNeeded = function(options) {
19+
if (!this.isFetched) {
20+
return this.fetch(options);
21+
} else {
22+
return options.success(this, null);
23+
}
24+
};
25+
Backbone.Collection.prototype.fetchIfNeeded = function(options) {
26+
if (!this.isFetched) {
27+
return this.fetch(options);
28+
} else {
29+
return options.success(this, null);
30+
}
31+
};
32+
33+
1734
var URIModel = Backbone.Model.extend({
1835

1936
validate: function(attrs){
@@ -418,11 +435,12 @@ var AppRouter = Backbone.Router.extend({
418435

419436
// load things in the right order:
420437

438+
$('#loadingbox').show('slow');
421439
$("#loading").html("server configuration");
422440
var base = $('base').attr('href');
423441
$.getJSON(base + '.well-known/openid-configuration', function(data) {
424442
app.serverConfiguration = data;
425-
/**/
443+
/** /
426444
$("#content .progress .bar").css("width", "20%");
427445
$("#loading").html("scopes");
428446
app.systemScopeList.fetch({
@@ -440,11 +458,12 @@ var AppRouter = Backbone.Router.extend({
440458
app.clientStats.fetch({
441459
success: function(model, response) {
442460
/**/
443-
$("#content .progress .bar").css("width", "100%");
461+
$("#loadingbox .progress .bar").css("width", "100%");
444462
$("#loading").html("console");
445463
var baseUrl = $.url(app.serverConfiguration.issuer);
446464
Backbone.history.start({pushState: true, root: baseUrl.attr('relative') + 'manage/'});
447-
/**/
465+
$('#loadingbox').hide('slow');
466+
/** /
448467
}
449468
});
450469
}
@@ -471,9 +490,11 @@ var AppRouter = Backbone.Router.extend({
471490
{text:"Manage Clients", href:"manage/#admin/clients"}
472491
]);
473492

474-
$('#content').html(this.clientListView.render().el);
475-
this.clientListView.delegateEvents();
476-
setPageTitle("Manage Clients");
493+
this.clientListView.load(function() {
494+
$('#content').html(app.clientListView.render().el);
495+
app.clientListView.delegateEvents();
496+
setPageTitle("Manage Clients");
497+
});
477498

478499
},
479500

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,24 @@ var ClientListView = Backbone.View.extend({
233233
tagName: 'span',
234234

235235
initialize:function () {
236-
//this.model.bind("reset", this.render, this);
236+
},
237+
238+
load:function(callback) {
239+
var cleanup = function() {
240+
$('#loadingbox').hide('slow');
241+
callback();
242+
}
243+
244+
$('#loadingbox').show('slow');
245+
$('#loading').html('clients');
246+
247+
$.when(this.model.fetchIfNeeded(),
248+
this.options.whiteListList.fetchIfNeeded(),
249+
this.options.stats.fetchIfNeeded(),
250+
this.options.systemScopeList.fetchIfNeeded()).done(cleanup);
251+
252+
//this.model.fetchIfNeeded({success:cleanup});
253+
237254
},
238255

239256
events:{

0 commit comments

Comments
 (0)