<script src="{{ STATIC_URL }}/js/vendor/backbone.babysitter.js"></script>
<script src="{{ STATIC_URL }}/js/vendor/backbone.marionette.js"></script>
+<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="{% static 'css/xosAdminDashboard.css' %}" media="all" >
<link rel="stylesheet" type="text/css" href="{% static 'css/xosAdminSite.css' %}" media="all" >
<script src="{{ STATIC_URL }}/js/vendor/backbone.babysitter.js"></script>
<script src="{{ STATIC_URL }}/js/vendor/backbone.marionette.js"></script>
+<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="{% static 'css/xosAdminWholePage.css' %}" media="all" >
<link rel="stylesheet" type="text/css" href="{% static 'css/xosAdminSite.css' %}" media="all" >
display: none;
}
+/* undo what planetstack.css does to the progressbar */
+#xos-startup-progress .ui-progressbar-value {
+ background-color: rgb(204,204,204) !important;
+ background-image: url(http://code.jquery.com/ui/1.11.2/themes/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png) !important;
+ border-top: 1px !important;
+ border-right: 1px !important;
+ border-left: 1px !important;
+}
+
+#xos-detail-button-box {
+ display: none;
+}
+
+#xos-listview-button-box {
+ display: none;
+}
+
});\r
};\r
\r
+XOSAdminApp.startNavigation = function() {\r
+ Backbone.history.start();\r
+ XOSAdminApp.navigationStarted = true;\r
+}\r
+\r
+XOSAdminApp.collectionLoadChange = function() {\r
+ stats = xos.getCollectionStatus();\r
+\r
+ if (!XOSAdminApp.navigationStarted) {\r
+ if (stats["isLoaded"] + stats["failedLoad"] >= stats["startedLoad"]) {\r
+ XOSAdminApp.startNavigation();\r
+ } else {\r
+ $("#detail").html("<h3>Loading...</h3><div id='xos-startup-progress'></div>");\r
+ $("#xos-startup-progress").progressbar({value: stats["completedLoad"], max: stats["startedLoad"]});\r
+ }\r
+ }\r
+};\r
+\r
XOSAdminApp.on("start", function() {\r
XOSAdminApp.buildViews();
XOSAdminApp.rewriteLinks();
- if (Backbone.history) {
- console.log("history start");
- Backbone.history.start();
- }
+ // fire it once to initially show the progress bar
+ XOSAdminApp.collectionLoadChange();
+
+ // fire it each time the collection load status is updated
+ Backbone.on("xoslib:collectionLoadChange", XOSAdminApp.collectionLoadChange);
});
$(document).ready(function(){
initialize: function(){
this.isLoaded = false;
+ this.failedLoad = false;
+ this.startedLoad = false;
this.sortVar = 'name';\r
this.sortOrder = 'asc';\r
this.on( "sort", this.sorted );\r
foreignCollections: [],\r
\r
sorted: function() {\r
- this.isLoaded = true;\r
+ //console.log("sorted " + this.modelName);\r
},\r
\r
simpleComparator: function( model ){\r
}\r
},\r
\r
+ fetchSuccess: function(collection, response, options) {\r
+ this.failedLoad = false;\r
+ if (!this.isLoaded) {\r
+ this.isLoaded = true;\r
+ Backbone.trigger("xoslib:collectionLoadChange", this);\r
+ }\r
+ if (options["orig_success"]) {\r
+ options["orig_success"](collection, response, options);\r
+ }\r
+ },\r
+\r
+ fetchFailure: function(collection, response, options) {\r
+ if ((!this.isLoaded) && (!this.failedLoad)) {\r
+ this.failedLoad=true;\r
+ Backbone.trigger("xoslib:collectionLoadChange", this);\r
+ }\r
+ if (options["orig_failure"]) {\r
+ options["orig_failure"](collection, response, options);\r
+ }\r
+ },\r
+\r
+ fetch: function(options) {\r
+ var self=this;\r
+ if (!this.startedLoad) {\r
+ this.startedLoad=true;\r
+ Backbone.trigger("xoslib:collectionLoadChange", this);\r
+ }\r
+ if (options == undefined) {\r
+ options = {};\r
+ }\r
+ options["orig_success"] = options["success"];\r
+ options["orig_failure"] = options["failure"];\r
+ options["success"] = function(collection, response, options) { self.fetchSuccess.call(self, collection, response, options); };\r
+ options["failure"] = this.fetchFailure;\r
+ Backbone.Collection.prototype.fetch.call(this, options);\r
+ },\r
+\r
startPolling: function() {\r
if (!this._polling) {\r
var collection=this;
lib[collectionName] = new lib[collectionClassName]();
lib.allCollectionNames.push(collectionName);
+ lib.allCollections.push(lib[collectionName]);
};
function xoslib() {
this.allCollectionNames = [];
+ this.allCollections = [];
define_model(this, {urlRoot: SLIVER_API,
relatedCollections: {"networkSlivers": "sliver"},
modelName: "slicePlus"});
this.listObjects = function() { return this.allCollectionNames; };
+
+ this.getCollectionStatus = function() {
+ stats = {isLoaded: 0, failedLoad: 0, startedLoad: 0};
+ for (index in this.allCollections) {
+ collection = this.allCollections[index];
+ if (collection.isLoaded) {
+ stats["isLoaded"] = stats["isLoaded"] + 1;
+ }
+ if (collection.failedLoad) {
+ stats["failedLoad"] = stats["failedLoad"] + 1;
+ }
+ if (collection.startedLoad) {
+ stats["startedLoad"] = stats["startedLoad"] + 1;
+ }
+ }
+ stats["completedLoad"] = stats["failedLoad"] + stats["isLoaded"];
+ return stats;
+ };
};
xos = new xoslib();
detailShower: function(detailName, collection_name, regionName, title) {\r
var app=this;\r
showModelId = function(model_id) {\r
- showModel = function(model) {\r
- detailViewClass = app[detailName];\r
- detailView = new detailViewClass({model: model});\r
- app[regionName].show(detailView);\r
- detailView.showLinkedItems();\r
- $("#xos-detail-button-box").show();\r
- $("#xos-listview-button-box").hide();\r
- }\r
-\r
$("#contentTitle").html(templateFromId("#xos-title-detail")({"title": title}));\r
\r
collection = xos[collection_name];\r
model = collection.get(model_id);\r
if (model == undefined) {\r
- if (!collection.isLoaded) {\r
- // If the model cannot be found, then maybe it's because\r
- // we haven't finished loading the collection yet. So wait for\r
- // the sort event to complete, then try again.\r
- collection.once("sort", function() {\r
- collection = xos[collection_name];\r
- model = collection.get(model_id);\r
- if (model == undefined) {\r
- // We tried. It's not here. Complain to the user.\r
- app[regionName].show(new HTMLView({html: "failed to load object " + model_id + " from collection " + collection_name}));\r
- } else {\r
- showModel(model);\r
- }\r
- });\r
- } else {\r
- // The collection was loaded, the user must just be asking for something we don't have.\r
- app[regionName].show(new HTMLView({html: "failed to load object " + model_id + " from collection " + collection_name}));\r
- }\r
+ app[regionName].show(new HTMLView({html: "failed to load object " + model_id + " from collection " + collection_name}));\r
} else {\r
- showModel(model);\r
+ detailViewClass = app[detailName];\r
+ detailView = new detailViewClass({model: model});\r
+ app[regionName].show(detailView);\r
+ detailView.showLinkedItems();\r
+ $("#xos-detail-button-box").show();\r
+ $("#xos-listview-button-box").hide();\r
}\r
}\r
return showModelId;\r