Commit d7b5d3b5 authored by Leigh Stoller's avatar Leigh Stoller

Do not prune out node types with zero immediately available from the

free list box. Instead, use a per portal list of types to prune.
parent b9efea4c
......@@ -778,6 +778,28 @@ class Instance
return $row[0];
}
}
#
# Return a list of types not to show user.
#
function NodeTypePruneList() {
global $ISEMULAB, $ISCLOUD, $ISAPT, $ISPNET, $ISPOWDER;
$skiptypes = array("dboxvm" => true,
"pcivy" => true,
"pc2830qx2" => true,
"pc2400hp" => true,
"d2100" => true,
"pc2400w" => true);
if ($ISEMULAB || $ISCLOUD || $ISAPT) {
$skiptypes["sdr"] = true;
$skiptypes["nuc5300"] = true;
$skiptypes["enodeb"] = true;
$skiptypes["nuc6260"] = true;
}
return $skiptypes;
}
}
class InstanceSliver
......
......@@ -13,6 +13,7 @@ $(function ()
var projlist = null;
var amlist = null;
var amorder = [];
var skiptypes = null;
var isadmin = false;
var editing = false;
var buttonstate = "check";
......@@ -26,6 +27,7 @@ $(function ()
fields = JSON.parse(_.unescape($('#form-json')[0].textContent));
projlist = JSON.parse(_.unescape($('#projects-json')[0].textContent));
amlist = JSON.parse(_.unescape($('#amlist-json')[0].textContent));
skiptypes= JSON.parse(_.unescape($('#skiptypes-json')[0].textContent));
GeneratePageBody(fields);
......@@ -334,6 +336,7 @@ $(function ()
ShowResGraph({"forecast" : json.value.forecast,
"selector" : id,
"skiptypes" : skiptypes,
"click_callback" : SetDates});
$('#' + id + ' .resgraph-fullscreen')
......@@ -342,9 +345,13 @@ $(function ()
// Panel title in the modal.
$('#resgraph-modal .cluster-name')
.html(details.nickname);
// Clear the existing graph first.
$('#resgraph-modal svg').html("");
// Modal needs to show before we can draw the graph.
$('#resgraph-modal').on('shown.bs.modal', function() {
ShowResGraph({"forecast" : json.value.forecast,
"selector" : "resgraph-modal",
"skiptypes" : skiptypes,
"click_callback" : SetDates});
});
sup.ShowModal('#resgraph-modal', function () {
......
......@@ -10,12 +10,16 @@ window.ShowResGraph = (function ()
var forecast = args.forecast;
// For the availablity page instead of reserve page.
var foralloc = args.foralloc;
var skiptypes= args.skiptypes;
var index = 0;
var datums = [];
if (foralloc === undefined) {
foralloc = false;
}
if (skiptypes === undefined) {
skiptypes = null;
}
/*
* For the interactive tooltip to work, every has data set has to
......@@ -27,6 +31,9 @@ window.ShowResGraph = (function ()
// Each node type
for (var type in forecast) {
if (skiptypes && _.has(skiptypes, type)) {
continue;
}
// This is an array of objects.
var array = forecast[type];
......@@ -38,9 +45,15 @@ window.ShowResGraph = (function ()
if (free == 0) {
continue;
}
// Need two points to make a line. Gove the second point
// just a day, we do not want to push the right side of
// the graph out too much, we want decent scaling.
/*
* Need two points to make a line. Gove the second point
* just a day, we do not want to push the right side of
* the graph out too much, we want decent scaling.
*
* XXX Do not mess with the original array, we want the
* original data for popping up the graph in a modal.
*/
array = array.slice();
array.push($.extend({}, array[0]));
array[1].t = parseInt(array[1].t) + (1 * 3600 * 24);
}
......
......@@ -12,13 +12,15 @@ $(function ()
var totalsTemplate = _.template(templates["resinfo-totals"]);
var amlist = null;
var isadmin = false;
var skiptypes = null;
function initialize()
{
window.APT_OPTIONS.initialize(sup);
isadmin = window.ISADMIN;
amlist = JSON.parse(_.unescape($('#amlist-json')[0].textContent));
skiptypes= JSON.parse(_.unescape($('#skiptypes-json')[0].textContent));
GeneratePageBody();
......@@ -95,6 +97,7 @@ $(function ()
ShowResGraph({"forecast" : json.value.forecast,
"selector" : graphid,
"foralloc" : true,
"skiptypes" : skiptypes,
"click_callback" : null});
/*
......@@ -106,18 +109,20 @@ $(function ()
// Each node type
for (var type in forecast) {
// Skip types we do not want to show.
if (_.has(skiptypes, type)) {
continue;
}
// This is an array of objects.
var array = forecast[type];
var data = array[0];
var free = parseInt(data.free) + parseInt(data.held);
if (free) {
html +=
"<tr>" +
" <td>" + type + "</td>" +
" <td>" + free + "</td>" +
"</tr>";
}
html +=
"<tr>" +
" <td>" + type + "</td>" +
" <td>" + free + "</td>" +
"</tr>";
}
$('#' + countid + ' tbody').html(html);
$('#' + countid + ' table').removeClass("hidden");
......
......@@ -124,6 +124,10 @@ echo "<script type='text/plain' id='amlist-json'>\n";
echo htmlentities(json_encode($amlist));
echo "</script>\n";
echo "<script type='text/plain' id='skiptypes-json'>\n";
echo htmlentities(json_encode(Instance::NodeTypePruneList()));
echo "</script>\n";
$defaults = array();
$defaults["pid"] = '';
# Default project.
......
......@@ -94,6 +94,10 @@ echo "<script type='text/javascript'>\n";
echo " window.ISADMIN = $isadmin;\n";
echo "</script>\n";
echo "<script type='text/plain' id='skiptypes-json'>\n";
echo htmlentities(json_encode(Instance::NodeTypePruneList()));
echo "</script>\n";
REQUIRE_UNDERSCORE();
REQUIRE_SUP();
REQUIRE_MOMENT();
......
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