Commit 6acb7fe0 authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Use jacks-utah instance by default. Constrain custom images properly.

Fools! I will constrain you all!
parent 957e2f6e
......@@ -68,8 +68,13 @@ function (_, editModalString, editInlineString)
}
function JacksEditor (root, isViewer, isInline,
withoutSelection, withoutMenu, withoutMultiSite)
withoutSelection, withoutMenu, withoutMultiSite, options)
{
this.showRspec = false;
if (options)
{
this.showRspec = (options.showRspec == true);
}
this.root = root;
this.instance = null;
this.input = null;
......@@ -131,7 +136,7 @@ function (_, editModalString, editInlineString)
nodeSelect: this.selectionPane,
readyCallback: _.bind(this.jacksReady, this),
show: {
rspec: false,
rspec: this.showRspec,
tour: false,
version: false,
menu: this.menu,
......
(function ()
{
var getQueryParams = function(qs) {
qs = qs.split('+').join(' ');
var params = {};
var re = /[?&]?([^=]+)=([^&]*)/g;
var tokens = re.exec(qs);
while (tokens) {
params[decodeURIComponent(tokens[1])]
= decodeURIComponent(tokens[2]);
tokens = re.exec(qs);
}
return params;
};
var params = getQueryParams(window.location.search);
if (! params.source)
{
window.JACKS_LOADER = { params: { source: 'utah' } };
}
}
)();
window.APT_OPTIONS = window.APT_OPTIONS || {};
window.APT_OPTIONS.configObject = {
......@@ -14,8 +39,8 @@ window.APT_OPTIONS.configObject = {
'underscore': 'js/lib/underscore-min',
'filesize': 'js/lib/filesize.min',
'contextmenu': 'js/lib/bootstrap-contextmenu',
'jacks': 'https://www.emulab.net/protogeni/jacks-stable/js/jacks',
'constraints': 'https://www.emulab.net/protogeni/jacks-devel/js/Constraints'
'jacks': 'https://www.emulab.net/protogeni/jacks-utah/js/jacks',
'constraints': 'https://www.emulab.net/protogeni/jacks-utah/js/Constraints'
},
shim: {
'jquery-ui': { },
......
......@@ -294,6 +294,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, aboutaptString, aboutcloudS
* is changed.
*/
$('#profile_pid').change(function (event) {
console.log('profile-pid change');
UpdateImageConstraints();
return true;
});
......@@ -675,10 +676,11 @@ function (_, Constraints, sup, ppstart, JacksEditor, aboutaptString, aboutcloudS
}
var constraints;
var context;
function contextReady(data)
{
var context = data;
context = data;
if (typeof(context) === 'string')
{
context = JSON.parse(context);
......@@ -711,7 +713,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, aboutaptString, aboutcloudS
function onFoundImages(images)
{
if (1) {
return true;
// return true;
}
if (! _.isEqual(foundImages, images)) {
foundImages = images;
......@@ -729,16 +731,20 @@ function (_, Constraints, sup, ppstart, JacksEditor, aboutaptString, aboutcloudS
return;
}
$('#stepsContainer .actions a[href="#finish"]').attr('disabled', true);
var callback = function(json) {
if (json.code) {
alert("Could not get image info: " + json.value);
return;
}
console.log(json.value);
console.log('json', json.value);
console.log('foundImages', foundImages);
if (1) {
constraints.addPossibles({ images: json.value.images });
constraints.allowAllSets(json.value.constraints);
updateWhere();
constraints = new Constraints(context);
constraints.addPossibles({ images: foundImages });
allowWithSites(json.value[0].constraints);
updateWhere();
$('#stepsContainer .actions a[href="#finish"]').removeAttr('disabled');
}
};
/*
......@@ -758,6 +764,49 @@ function (_, Constraints, sup, ppstart, JacksEditor, aboutaptString, aboutcloudS
return true;
}
function allowWithSites(newConstraints)
{
console.log('newConstraints', newConstraints);
var sites = context.canvasOptions.site_info;
var finalItems = [];
_.each(newConstraints, function (item) {
console.log('item:', item);
var valid = [];
_.each(_.keys(sites), function (key) {
if ((item.node.hardware &&
_.contains(sites[key].hardware, item.node.hardware[0])) ||
(item.node.types &&
_.contains(sites[key].types, item.node.types[0])))
{
valid.push(key);
}
});
if (valid.length > 0)
{
item.node.aggregates = valid;
finalItems.push(item);
}
});
console.log(finalItems);
constraints.allowAllSets(finalItems);
constraints.allowAllSets([
{
node: {
aggregates: ['!'],
images: ['!'],
hardware: ['!']
}
},
{
node: {
aggregates: ['!'],
images: ['!'],
types: ['!']
}
},
]);
}
function contextFail(fail1, fail2)
{
console.log('Failed to fetch context', fail1, fail2);
......@@ -778,6 +827,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, aboutaptString, aboutcloudS
function finishUpdateWhere(allNodes, nodesBySite)
{
console.log('finishUpdateWhere');
if (!multisite || Object.keys(sites).length <= 1) {
updateSiteConstraints(allNodes, $('#nosite_selector'));
} else {
......
Supports Markdown
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