load server configuration into JS app

pull/477/head
Justin Richer 2013-08-19 14:36:59 -04:00
parent e40b1cf850
commit 8c91861188
1 changed files with 33 additions and 26 deletions

View File

@ -361,38 +361,45 @@ var AppRouter = Backbone.Router.extend({
this.breadCrumbView.render(); this.breadCrumbView.render();
// //
// Several items depend on the clients and whitelists being loaded, so we're going to pre-fetch them here // Several items depend on the clients and whitelists being loaded, so we're going to pre-fetch them here
// and not start the app router until they're loaded. // and not start the app router until they're loaded.
// //
// load things in the right order: // load things in the right order:
$("#loading").html("scopes"); $("#loading").html("server configuration");
this.systemScopeList.fetch({ var base = $('base').attr('href');
success: function(collection, response) { $.getJSON(base + '.well-known/openid-configuration', function(data) {
$("#content .progress .bar").css("width", "25%"); app.serverConfiguration = data;
$("#loading").html("clients"); $("#content .progress .bar").css("width", "20%");
app.clientList.fetch({ $("#loading").html("scopes");
success: function(collection, response) { app.systemScopeList.fetch({
$("#content .progress .bar").css("width", "50%"); success: function(collection, response) {
$("#loading").html("whitelists"); $("#content .progress .bar").css("width", "40%");
app.whiteListList.fetch({ $("#loading").html("clients");
success: function(collection, response) { app.clientList.fetch({
$("#content .progress .bar").css("width", "75%"); success: function(collection, response) {
$("#loading").html("statistics"); $("#content .progress .bar").css("width", "60%");
app.clientStats.fetch({ $("#loading").html("whitelists");
success: function(model, response) { app.whiteListList.fetch({
$("#content .progress .bar").css("width", "100%"); success: function(collection, response) {
$("#loading").html("console"); $("#content .progress .bar").css("width", "80%");
var baseUrl = $.url($('base').attr('href')); $("#loading").html("statistics");
Backbone.history.start({pushState: true, root: baseUrl.attr('relative') + 'manage/'}); app.clientStats.fetch({
} success: function(model, response) {
}); $("#content .progress .bar").css("width", "100%");
} $("#loading").html("console");
}); var baseUrl = $.url(app.serverConfiguration.issuer);
} Backbone.history.start({pushState: true, root: baseUrl.attr('relative') + 'manage/'});
}); }
} });
}
});
}
});
}
});
}); });
}, },