Commit 5fc0687b authored by Keith Downie's avatar Keith Downie Committed by Leigh B Stoller

Status dropdown finalized

parent e91cdb6c
...@@ -450,3 +450,15 @@ left: -999em; ...@@ -450,3 +450,15 @@ left: -999em;
.cluster_picker_status .tooltip .tooltip-inner { .cluster_picker_status .tooltip .tooltip-inner {
max-width: 400px; max-width: 400px;
} }
.cluster_picker_status .federatedDivider {
overflow: visible;
margin: 24px 0 0;
}
.cluster_picker_status .federatedDivider > div {
color: #aaa;
position: absolute;
top: -20px;
left: 10px;
}
\ No newline at end of file
...@@ -680,6 +680,15 @@ function SPITFORM($formfields, $newuser, $errors) ...@@ -680,6 +680,15 @@ function SPITFORM($formfields, $newuser, $errors)
echo "<div id='editmodal_div'></div>\n"; echo "<div id='editmodal_div'></div>\n";
SpitOopsModal("oops"); SpitOopsModal("oops");
#TEMPORARILY HARD CODED. Used to separate federated sites
if ($ISCLOUD) {
echo "<script type='text/javascript'>\n";
echo " window.FEDERATEDLIST = ['IG UtahDDC', 'Emulab', 'APT Utah'];\n";
echo "</script>\n";
}
if (isset($this_user) && !$this_user->webonly() && if (isset($this_user) && !$this_user->webonly() &&
($ISCLOUD || ISADMINISTRATOR() || STUDLY())) { ($ISCLOUD || ISADMINISTRATOR() || STUDLY())) {
echo "<script type='text/plain' id='amlist-json'>\n"; echo "<script type='text/plain' id='amlist-json'>\n";
......
...@@ -30,6 +30,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl ...@@ -30,6 +30,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl
var loaded_uuid = null; var loaded_uuid = null;
var ppchanged = false; var ppchanged = false;
var monitor = null; var monitor = null;
var types = null;
function initialize() function initialize()
{ {
...@@ -39,7 +40,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl ...@@ -39,7 +40,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl
$('#instantiate_submit').prop('disabled', true); $('#instantiate_submit').prop('disabled', true);
$.get(contextUrl).then(contextReady, contextFail); $.get(contextUrl).then(contextReady, contextFail);
var jqxhr = $.getJSON('https://clnode095.clemson.cloudlab.us:8081/index.html?names=urn&callback=?') var jqxhr = $.getJSON('https://ops.emulab.net/servicemon/?names=urn&callback=?')
.done(function(data) { .done(function(data) {
monitor = data; monitor = data;
// Check if third tab is already active. // Check if third tab is already active.
...@@ -362,23 +363,15 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl ...@@ -362,23 +363,15 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl
return; return;
} }
console.log(monitor);
// HARDCODED FOR MOCKUP, REMOVE
monitor["urn:publicid:IDN+utahddc.geniracks.net+authority+cm"] = {health:0,status:"FAILURE"};
monitor["urn:publicid:IDN+emulab.net+authority+cm"].rawPCsAvailable = 14;
monitor["urn:publicid:IDN+clemson.cloudlab.us+authority+cm"].health = 49;
monitor["urn:publicid:IDN+wisc.cloudlab.us+authority+cm"].rawPCsAvailable = 20;
$('#finalize_options .cluster-group').each(function() { $('#finalize_options .cluster-group').each(function() {
var resourceType = "PC";
var label = $(this).find('.control-label').attr('name');
if (types && label && types[label] && types[label]['emulab-xen']) {
resourceType = "VM";
}
var which = $(this).parent().parent().attr('class'); var which = $(this).parent().parent().attr('class');
var html = wt.ClusterStatusHTML($('#'+which+' .form-control option')); var html = wt.ClusterStatusHTML($('#'+which+' .form-control option'), window.FEDERATEDLIST);
$('.'+which+' .form-control').after(html); $('.'+which+' .form-control').after(html);
$('.'+which+' select.form-control').addClass('hidden'); $('.'+which+' select.form-control').addClass('hidden');
...@@ -393,7 +386,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl ...@@ -393,7 +386,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl
var target = $('.'+which+' .cluster_picker_status .dropdown-menu .enabled a:contains("'+name+'")'); var target = $('.'+which+' .cluster_picker_status .dropdown-menu .enabled a:contains("'+name+'")');
if (data && !$.isEmptyObject(data)) { if (data && !$.isEmptyObject(data)) {
// Calculate testbed rating and set up tooltips. // Calculate testbed rating and set up tooltips.
var rating = wt.CalculateRating(data); var rating = wt.CalculateRating(data, resourceType);
target.parent().attr('data-health', rating[0]).attr('data-rating', rating[1]); target.parent().attr('data-health', rating[0]).attr('data-rating', rating[1]);
...@@ -404,9 +397,21 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl ...@@ -404,9 +397,21 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl
} }
}); });
$('.'+which+' .cluster_picker_status .dropdown-menu').find('.enabled').sort(function (a, b) { var sort = function (a, b) {
return +b.dataset.rating - +a.dataset.rating; var aHealth = Math.ceil((+a.dataset.health)/50);
}).prependTo($('.'+which+' .cluster_picker_status .dropdown-menu')); var bHealth = Math.ceil((+b.dataset.health)/50);
if (aHealth > bHealth) {
return -1;
}
else if (aHealth < bHealth) {
return 1;
}
return +b.dataset.rating - +a.dataset.rating;
};
$('.'+which+' .cluster_picker_status .dropdown-menu').find('.enabled.native').sort(sort).prependTo($('.'+which+' .cluster_picker_status .dropdown-menu'));
$('.'+which+' .cluster_picker_status .dropdown-menu').find('.enabled.federated').sort(sort).insertAfter($('.'+which+' .cluster_picker_status .dropdown-menu .federatedDivider'));
$('.'+which+' .cluster_picker_status .dropdown-menu .enabled a')[0].click(); $('.'+which+' .cluster_picker_status .dropdown-menu .enabled a')[0].click();
}); });
...@@ -682,6 +687,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl ...@@ -682,6 +687,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl
// Create the dropdown selection lists. // Create the dropdown selection lists.
_.each(sites, function(siteid) { _.each(sites, function(siteid) {
siteIdToSiteNum[siteid] = sitenum; siteIdToSiteNum[siteid] = sitenum;
var options = ""; var options = "";
_.each(amlist, function(name, key) { _.each(amlist, function(name, key) {
options = options + options = options +
...@@ -693,13 +699,14 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl ...@@ -693,13 +699,14 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl
" class='form-horizontal experiment_option'>" + " class='form-horizontal experiment_option'>" +
" <div class='form-group cluster-group'>" + " <div class='form-group cluster-group'>" +
" <label class='col-sm-4 control-label' " + " <label class='col-sm-4 control-label' " +
" style='text-align: right;'>"+ " style='text-align: right;'"+
" name='"+siteid+"'>"+
" " + siteid + " Cluster:</a>" + " " + siteid + " Cluster:</a>" +
" </label> " + " </label> " +
" <div class='col-sm-6'>" + " <div class='col-sm-6'>" +
" <select name=\"formfields[sites][" + siteid + "]\"" + " <select name=\"formfields[sites][" + siteid + "]\"" +
" class='form-control'>" + " class='form-control'>" +
" <option value=''>Please Select</option>" + options + " " + options +
" </select>" + " </select>" +
"</div>" + "</div>" +
"<div class='col-sm-4'></div>" + "<div class='col-sm-4'></div>" +
...@@ -765,6 +772,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl ...@@ -765,6 +772,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl
jacks.output.on('found-images', onFoundImages); jacks.output.on('found-images', onFoundImages);
$('#profile_where').prop('disabled', false); $('#profile_where').prop('disabled', false);
$('#instantiate_submit').prop('disabled', false); $('#instantiate_submit').prop('disabled', false);
jacks.output.on('found-types', onFoundTypes);
updateWhere(); updateWhere();
}, },
canvasOptions: context.canvasOptions, canvasOptions: context.canvasOptions,
...@@ -787,6 +795,14 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl ...@@ -787,6 +795,14 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt, aboutaptString, aboutcl
return true; return true;
} }
function onFoundTypes(t)
{
types = {};
_.each(t, function(item) {
types[item.name] = item.types;
});
}
/* /*
* Update the image constraints if anything changes. * Update the image constraints if anything changes.
*/ */
......
define(['underscore'], define(['underscore'],
function(_) { function(_) {
function ClusterStatusHTML(options) { function ClusterStatusHTML(options, fedlist) {
var html = $('<div class="cluster_picker_status btn-group">' var html = $('<div class="cluster_picker_status btn-group">'
+'<button type="button" class="form-control btn btn-default dropdown-toggle" data-toggle="dropdown">' +'<button type="button" class="form-control btn btn-default dropdown-toggle" data-toggle="dropdown">'
+'<span class="value"></span>' +'<span class="value"></span>'
+'<span class="caret"></span>' +'<span class="caret"></span>'
+'</button>' +'</button>'
+'<ul class="dropdown-menu" role="menu">' +'<ul class="dropdown-menu" role="menu">'
+'<li role="separator" class="divider"></li>' +'<li role="separator" class="divider federatedDivider"><div>Federated Clusters<div></li>'
+'<li role="separator" class="divider disabledDivider"></li>'
+'</ul>' +'</ul>'
+'</div>'); +'</div>');
var dropdown = html.find('.dropdown-menu .divider'); var dropdown = html.find('.dropdown-menu .disabledDivider');
var federated = html.find('.dropdown-menu .federatedDivider');
var disabled = 0;
var fed = 0;
$(options).each(function() { $(options).each(function() {
if ($(this).prop('disabled')) { if ($(this).prop('disabled')) {
dropdown.after('<li class="disabled"><a data-toggle="tooltip" data-placement="right" data-html="true" title="<div>This testbed is incompatible with the selected profile</div>" href="#" value="'+$(this).attr('value')+'">'+$(this).attr('value')+'</a></li>') dropdown.after('<li class="disabled"><a data-toggle="tooltip" data-placement="right" data-html="true" title="<div>This testbed is incompatible with the selected profile</div>" href="#" value="'+$(this).attr('value')+'">'+$(this).attr('value')+'</a></li>')
disabled++;
} }
else { else {
dropdown.before('<li class="enabled"><a href="#" value="'+$(this).attr('value')+'">'+$(this).attr('value')+'</a></li>'); if (_.contains(fedlist, $(this).attr('value'))) {
federated.after('<li class="enabled federated"><a href="#" value="'+$(this).attr('value')+'">'+$(this).attr('value')+'</a></li>');
fed++;
}
else {
federated.before('<li class="enabled native"><a href="#" value="'+$(this).attr('value')+'">'+$(this).attr('value')+'</a></li>');
}
} }
}); });
if (!html.find('.disabled').length) { if (!disabled) {
html.find('.divider').remove(); html.find('.disabledDivider').remove();
}
if (!fed) {
html.find('.federatedDivider').remove();
} }
return html; return html;
...@@ -57,7 +72,7 @@ function(_) { ...@@ -57,7 +72,7 @@ function(_) {
if (data.health) { if (data.health) {
health = data.health; health = data.health;
tooltip[0] = '<div>Testbed is ' tooltip[0] = '<div>Testbed is '
if (health >= 50) { if (health > 50) {
tooltip[0] += 'healthy'; tooltip[0] += 'healthy';
} }
else { else {
......
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