Commit d1b41ae1 authored by Keith Downie's avatar Keith Downie Committed by Leigh B Stoller
Browse files

Some fixes for the status picker. Fixed showing VM numbers, can now show both...

Some fixes for the status picker. Fixed showing VM numbers, can now show both VM and PC numbers, fixed a few minor bugs
parent 0ce1edd1
......@@ -596,7 +596,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt,
function CreateClusterStatus() {
//console.log("CreateClusterStatus", monitor);
if (monitor == null || $.isEmptyObject(monitor)) {
return;
return;
}
$('#finalize_options .cluster-group').each(function() {
......@@ -605,10 +605,17 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt,
}
$(this).addClass("pickered");
var resourceType = "PC";
var resourceTypes = ["PC"];
// Have to do look this up based off of the site name since that's
// the only hook Jacks is giving.
var label = $(this).find('.control-label').attr('name');
if (types && label && types[label] && types[label]['emulab-xen']) {
resourceType = "VM";
if (types && label && types[label]) {
if (types[label]['emulab-xen']) {
if (Object.keys(types[label]).length == 1) {
resourceTypes = [];
}
resourceTypes.push("VM");
}
}
var which = $(this).parent().attr('id');
......@@ -617,7 +624,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt,
$('#'+which+' .form-control').after(html);
$('#'+which+' select.form-control').addClass('hidden');
html.find('.dropdown-menu a').on('click', function(){
html.find('.dropdown-menu a').on('click', function() {
wt.StatusClickEvent(html, this);
$('#'+which+' .form-control').val($('#'+which+' .cluster_picker_status .value').html());
});
......@@ -627,7 +634,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt,
var target = $('#'+which+' .cluster_picker_status .dropdown-menu .enabled a:contains("'+name+'")');
if (data && !$.isEmptyObject(data)) {
// Calculate testbed rating and set up tooltips.
var rating = wt.CalculateRating(data, resourceType);
var rating = wt.CalculateRating(data, resourceTypes);
target.parent().attr('data-health', rating[0]).attr('data-rating', rating[1]);
......@@ -654,7 +661,13 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt,
$('#'+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();
var pickerStatus = $('#'+which+' .cluster_picker_status .dropdown-menu .enabled a');
if (pickerStatus.length == 2) {
pickerStatus[1].click();
}
else {
pickerStatus[0].click();
}
});
$('[data-toggle="tooltip"]').tooltip();
......@@ -906,7 +919,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt,
"<div id='nosite_selector' " +
" class='form-horizontal experiment_option'>" +
" <div class='form-group cluster-group'>" +
" <label class='col-sm-4 control-label' " +
" <label class='col-sm-4 control-label' name='" + _.values(sites)[0] + "' " +
" style='text-align: right;'>Cluster:</a>" +
" </label> " +
" <div class='col-sm-6'>" +
......@@ -929,7 +942,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, wt,
"<div id='site"+sitenum+"cluster' " +
" class='form-horizontal experiment_option'>" +
" <div class='form-group cluster-group'>" +
" <label class='col-sm-4 control-label' " +
" <label class='col-sm-4 control-label' name='" + siteid + "' " +
" style='text-align: right;'>"+
" Site " + siteid + " Cluster:</a>" +
" </label> " +
......
......@@ -28,12 +28,14 @@ function(_) {
fed++;
}
else {
var optvalue = $(this).attr('value');
// Look for Please Select option
if (optvalue == "") {
var optvalue = $(this).attr('value');
var opthidden = "";
// Look for Please Select option
if (optvalue == "") {
optvalue = $(this).text();
opthidden = ' hidden';
}
federated.before('<li class="enabled native"><a href="#" value="'+optvalue+'">'+optvalue+'</a></li>');
federated.before('<li class="enabled native'+opthidden+'"><a href="#" value="'+optvalue+'">'+optvalue+'</a></li>');
}
}
});
......@@ -62,6 +64,9 @@ function(_) {
html.find('.dropdown-toggle > .picker_stats').append($(that).find('.picker_stats').html());
}
else {
html.find('.dropdown-toggle > .picker_stats').html('');
}
html.find('.selected').removeClass('selected');
$(that).parent().addClass('selected');
......@@ -72,7 +77,6 @@ function(_) {
var rating = 0;
var tooltip = [];
if (data.status == 'SUCCESS') {
if (data.health) {
health = data.health;
......@@ -95,24 +99,27 @@ function(_) {
return [health, rating, tooltip];
}
var available, max, label;
if (type == 'VM') {
available = parseInt(data.VMsAvailable);
max = parseInt(data.VMsTotal);
label = 'VMs';
}
else {
available = parseInt(data.rawPCsAvailable);
max = parseInt(data.rawPCsTotal);
label = 'PCs';
var available = [], max = [], label = [];
if (_.contains(type, 'PC')) {
available.push(parseInt(data.rawPCsAvailable));
max.push(parseInt(data.rawPCsTotal));
label.push('PCs');
}
if (_.contains(type, 'VM')) {
available.push(parseInt(data.VMsAvailable));
max.push(parseInt(data.VMsTotal));
label.push('VMs');
}
if (!isNaN(available) && !isNaN(max)) {
var ratio = available/max;
rating = available;
tooltip[1] = '<div>'+available+'/'+max+' ('+Math.round(ratio*100)+'%) '+label+' available</div>';
for (var i = 0; i < type.length; i++) {
if (!isNaN(available[i]) && !isNaN(max[i])) {
if (rating == 0) {
rating = available[i];
}
var ratio = available[i]/max[i];
tooltip.push('<div>'+available[i]+'/'+max[i]+' ('+Math.round(ratio*100)+'%) '+label[i]+' available</div>');
}
}
return [health, rating, tooltip];
}
......@@ -144,7 +151,11 @@ function(_) {
function StatsLineHTML(classes, title) {
var title1 = '';
if (title[1]) {
title1 = ' data-toggle="tooltip" data-placement="right" data-html="true" title="'+title[1]+'"';
title1 = ' data-toggle="tooltip" data-placement="right" data-html="true" title="'
for (var i = 1; i < title.length; i++) {
title1 += title[i]+' ';
}
title1 += '"';
}
return '<div class="tooltip_div"'+title1+'><div class="picker_stats" data-toggle="tooltip" data-placement="left" data-html="true" title="'+title[0]+'">'
+'<span class="picker_status '+classes[0]+' '+classes[1]+'"><span class="circle"></span></span>'
......
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