Commit d697bd57 authored by Leigh B Stoller's avatar Leigh B Stoller

Show project usage on the project page. Also show the ranking. This needs

more work, wrt placement on the page. Waiting for comments.
parent 79f4e906
......@@ -34,12 +34,62 @@ function (_, sup, moment, mainString,
window.location.hash = e.target.hash;
});
LoadUsage();
LoadExperimentTab();
LoadProfileTab();
LoadMembersTab();
LoadProjectTab();
}
function LoadUsage()
{
var callback = function(json) {
console.info(json);
if (json.code) {
console.info(json.value);
return;
}
var blob = json.value;
var html = "";
if (! (blob.pnodes || blob.monthpnodes || blob.weekpnodes)) {
return;
}
if (blob.pnodes) {
html = "<div>Current Usage: " +
blob.pnodes + " Node" + (blob.pnodes > 1 ? "s, " : ", ") +
blob.phours + " Node Hours</div>";
}
if (blob.weekpnodes) {
html = html +
"<div>Previous Week: " +
blob.weekpnodes + " Node" +
(blob.weekpnodes > 1 ? "s, " : ", ") +
blob.weekphours + " Node Hours</div>";
}
if (blob.monthpnodes) {
html = html +
"<div>Previous Month: " +
blob.monthpnodes + " Node" +
(blob.monthpnodes > 1 ? "s, " : ", ") +
blob.monthphours + " Node Hours</div>";
}
if (blob.rank) {
html = html +
"<div>" + blob.rankdays + " Project Usage Ranking: #" +
blob.rank + " of " + blob.ranktotal + " active projects" +
"</div>";
}
$('#usage-summary').html(html);
}
var xmlthing = sup.CallServerMethod(null,
"show-project", "UsageSummary",
{"pid" : window.TARGET_PROJECT});
xmlthing.done(callback);
}
function LoadExperimentTab()
{
var callback = function(json) {
......@@ -115,7 +165,25 @@ function (_, sup, moment, mainString,
var table = $('#profiles_table')
.tablesorter({
theme : 'green',
widgets: ["filter"],
widgetOptions: {
// include child row content while filtering, if true
filter_childRows : true,
// include all columns in the search.
filter_anyMatch : true,
// class name applied to filter row and each input
filter_cssFilter : 'form-control',
// search from beginning
filter_startsWith : false,
// Set this option to false for case sensitive search
filter_ignoreCase : true,
// Only one search box.
filter_columnFilters : false,
// Search as typing
filter_liveSearch : true,
},
});
$.tablesorter.filter.bindSearch(table, $('#profile_search'));
}
var xmlthing = sup.CallServerMethod(null,
"show-project", "ProfileList",
......@@ -125,9 +193,8 @@ function (_, sup, moment, mainString,
function ShowTopology(profile)
{
var profile;
var index;
var callback = function(json) {
if (json.code) {
alert("Failed to get rspec for topology viewer: " + json.value);
......
......@@ -137,6 +137,54 @@ function Do_ProjectProfile()
SPITAJAX_RESPONSE($results);
}
#
# Usage for the user, in pnode hours.
#
function Do_UsageSummary()
{
global $this_user, $target_project;
global $ajax_args;
if (CheckPageArgs()) {
return;
}
list($pcount, $phours) = Instance::CurrentUsage($target_project);
list($weekpcount, $weekphours) = Instance::WeeksUsage($target_project);
list($monthpcount, $monthphours) = Instance::MonthsUsage($target_project);
list($rank, $ranktotal) = Instance::Ranking($target_project, 30);
if ($phours < 2) {
$phours = sprintf("%.1f", $phours);
}
else {
$phours = sprintf("%.0f", $phours);
}
if ($weekphours < 2) {
$weekphours = sprintf("%.1f", $weekphours);
}
else {
$weekphours = sprintf("%.0f", $weekphours);
}
if ($monthphours < 2) {
$monthphours = sprintf("%.1f", $monthphours);
}
else {
$monthphours = sprintf("%.0f", $monthphours);
}
$blob = array("pnodes" => $pcount,
"phours" => $phours,
"weekpnodes" => $weekpcount,
"weekphours" => $weekphours,
"monthpnodes" => $monthpcount,
"monthphours" => $monthphours,
"rankdays" => 30,
"rank" => $rank,
"ranktotal" => $ranktotal
);
SPITAJAX_RESPONSE($blob);
}
# Local Variables:
# mode:php
# End:
......
......@@ -37,35 +37,12 @@
.sidebar-nav .navbar-header{ float: none; }
</style>
<div class='row'>
<div class="col-sm-3 hidden">
<div class="sidebar-nav">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target=".sidebar-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="visible-xs navbar-brand">Project Menu</span>
</div>
<div class="navbar-collapse collapse sidebar-navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="#">Menu Item 1</a></li>
<li><a href="#">Menu Item 2</a></li>
<li><a href="#">Menu Item 3</a></li>
<li><a href="#">Menu Item 4</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class='col-sm-12'>
<div class='panel panel-default'>
<div class='panel-body'>
<div class='row'>
<div class='col-sm-12'>
<center id="usage-summary"></center>
<div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
......
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