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,30 +361,36 @@ 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("server configuration");
var base = $('base').attr('href');
$.getJSON(base + '.well-known/openid-configuration', function(data) {
app.serverConfiguration = data;
$("#content .progress .bar").css("width", "20%");
$("#loading").html("scopes"); $("#loading").html("scopes");
this.systemScopeList.fetch({ app.systemScopeList.fetch({
success: function(collection, response) { success: function(collection, response) {
$("#content .progress .bar").css("width", "25%"); $("#content .progress .bar").css("width", "40%");
$("#loading").html("clients"); $("#loading").html("clients");
app.clientList.fetch({ app.clientList.fetch({
success: function(collection, response) { success: function(collection, response) {
$("#content .progress .bar").css("width", "50%"); $("#content .progress .bar").css("width", "60%");
$("#loading").html("whitelists"); $("#loading").html("whitelists");
app.whiteListList.fetch({ app.whiteListList.fetch({
success: function(collection, response) { success: function(collection, response) {
$("#content .progress .bar").css("width", "75%"); $("#content .progress .bar").css("width", "80%");
$("#loading").html("statistics"); $("#loading").html("statistics");
app.clientStats.fetch({ app.clientStats.fetch({
success: function(model, response) { success: function(model, response) {
$("#content .progress .bar").css("width", "100%"); $("#content .progress .bar").css("width", "100%");
$("#loading").html("console"); $("#loading").html("console");
var baseUrl = $.url($('base').attr('href')); var baseUrl = $.url(app.serverConfiguration.issuer);
Backbone.history.start({pushState: true, root: baseUrl.attr('relative') + 'manage/'}); Backbone.history.start({pushState: true, root: baseUrl.attr('relative') + 'manage/'});
} }
}); });
@ -394,6 +400,7 @@ var AppRouter = Backbone.Router.extend({
}); });
} }
}); });
});
}, },