Skip to content
Snippets Groups Projects
Commit f0a53bef authored by Wes Felter's avatar Wes Felter
Browse files

UI: Improve startup responsiveness

It now defers loading any data until the UI has been drawn, avoiding a blank
screen. Now the dashboard is drawn (~1s) and then filled in with data. The
remaining bottleneck is probably the number of XHRs; concatenating JS and
templates and fetching switch data in bulk instead of individually would
reduce the number of XHRs dramatically.
parent 40aec768
No related branches found
No related tags found
No related merge requests found
......@@ -91,11 +91,13 @@ var AppRouter = Backbone.Router.extend({
var swl = new SwitchCollection();
var hl = new HostCollection();
var updating = true;
tpl.loadTemplates(['home', 'status', 'topology', 'header', 'switch', 'switch-list', 'switch-list-item', 'host', 'host-list', 'host-list-item', 'port-list', 'port-list-item', 'flow-list', 'flow-list-item'],
function () {
app = new AppRouter();
Backbone.history.start({pushState: true});
// console.log("started history")
//console.log("started history")
$(document).ready(function () {
// trigger Backbone routing when clicking on links, thanks to Atinux and pbnv
......@@ -113,15 +115,16 @@ tpl.loadTemplates(['home', 'status', 'topology', 'header', 'switch', 'switch-lis
window.addEventListener('popstate', function(e) {
app.navigate(location.pathname.substr(1), true);
});
// wait for the page to be rendered before loading any data
swl.fetch();
hl.fetch();
setInterval(function () {
if(updating) {
swl.fetch();
hl.fetch();
}
}, 3000);
});
});
var updating = true;
setInterval(function () {
if(updating) {
swl.fetch();
hl.fetch();
}
}, 3000);
......@@ -31,7 +31,7 @@ window.HostCollection = Backbone.Collection.extend({
model:Host,
initialize:function () {
fetch:function () {
var self = this;
//console.log("fetching host list")
$.ajax({
......@@ -66,10 +66,6 @@ window.HostCollection = Backbone.Collection.extend({
},
fetch:function () {
this.initialize();
}
/*
* findByName:function (key) { // TODO: Modify service to include firstName
* in search var url = (key == '') ? '/host/' : "/host/search/" + key;
......
......@@ -265,7 +265,7 @@ window.SwitchCollection = Backbone.Collection.extend({
model:Switch,
initialize:function () {
fetch:function () {
var self = this;
//console.log("fetching switch list")
$.ajax({
......@@ -292,9 +292,4 @@ window.SwitchCollection = Backbone.Collection.extend({
});
},
fetch:function () {
this.initialize()
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment