Commit 6906021e authored by Jonathon Duerig's avatar Jonathon Duerig

Add logic to make sure that the context is loaded before Jacks starts.

parent 2832ea5f
......@@ -37,17 +37,28 @@ function (_, editModalString)
}
};
var waitingInstances = [];
var contextFetched = false;
var contextUrl = 'https://www.emulab.net/protogeni/jacks-context/cloudlab-utah.json';
if (window.ISCLOUD)
{
$('#edit_topo_modal_button').prop('disabled', true);
$.get(contextUrl).then(contextReady, contextFail);
}
else
{
contextFetched = true;
}
function contextReady(data)
{
$('#edit_topo_modal_button').prop('disabled', false);
context = data;
contextFetched = true;
_.each(waitingInstances, function (f) {
f();
});
}
function contextFail(fail1, fail2)
......@@ -68,6 +79,7 @@ function (_, editModalString)
{
this.mode = 'viewer';
}
this.shown = false;
this.render();
}
......@@ -84,6 +96,7 @@ function (_, editModalString)
this.root.find('#edit-save').click(_.bind(this.fetchXml, this));
this.root.find('#edit-cancel, #edit-dismiss')
.click(_.bind(this.cancelEdit, this));
var makeInstance = function () {
this.instance = new window.Jacks({
mode: this.mode,
source: 'rspec',
......@@ -100,6 +113,16 @@ function (_, editModalString)
canvasOptions: context.canvasOptions,
constraints: context.constraints
});
}.bind(this);
if (contextFetched)
{
makeInstance();
}
else
{
waitingInstances.push(makeInstance);
}
},
// Show a modal that lets the user edit their rspec. Callback
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment