Commit b71758d4 authored by Leigh Stoller's avatar Leigh Stoller

Add the stuff Mike requested in issue #339. This closes issue #339.

parent cea4fdf5
......@@ -39,6 +39,7 @@ $isfadmin = (ISFOREIGN_ADMIN() ? 1 : 0);
if (! (ISADMIN() || ISFOREIGN_ADMIN())) {
SPITUSERERROR("You do not have permission to view this page");
}
$optargs = OptionalPageArguments("sortby", PAGEARG_STRING);
SPITHEADER(1);
echo "<link rel='stylesheet'
......@@ -50,6 +51,9 @@ echo "<div id='page-body'></div>\n";
echo "<script type='text/javascript'>\n";
echo " window.ISADMIN = $isadmin;\n";
echo " window.ISFADMIN = $isfadmin;\n";
if (isset($sortby) && $sortby != "") {
echo " window.SORTYBY = '$sortby';\n";
}
echo "</script>\n";
echo "<script src='js/lib/jquery-2.0.3.min.js'></script>\n";
......
......@@ -159,7 +159,10 @@ $(function ()
SetFilters(table);
// Initial sort.
if (hash === "#extending") {
if (window.SORTYBY !== undefined && window.SORTYBY == "created") {
table.find('th:eq(9)').trigger('sort');
}
else if (hash === "#extending") {
table.find('th:eq(10)').trigger('sort');
}
else {
......
......@@ -9,16 +9,19 @@ $(function ()
window.APT_OPTIONS.initialize(sup);
var userlist = decodejson('#user-json');
var projlist = decodejson('#project-json');
var proflist = decodejson('#profile-json');
// Generate the main template.
var html = mainTemplate({
"users" : userlist,
"projects" : projlist,
"profiles" : proflist,
"days" : window.DAYS,
});
$('#main-body').html(html);
InitTable("users");
InitTable("projects");
InitTable("profiles");
// Javascript to enable link to tab
var hash = document.location.hash;
......
......@@ -425,7 +425,7 @@ echo " <li class='divider'></li>
}
echo " <li><a href='dashboard.php'>DashBoard</a></li>";
echo " <li><a href='cluster-status.php'>Cluster Status</a></li>";
$then = time() - (30 * 3600 * 24);
$then = time() - (14 * 3600 * 24);
echo " <li><a href='activity.php?min=$then'>
History Data</a></li>
<li><a href='sumstats.php?min=$then'>Summary Stats</a></li>
......
<?php
#
# Copyright (c) 2000-2016 University of Utah and the Flux Group.
# Copyright (c) 2000-2017 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -97,7 +97,7 @@ function SpitRankList($target, $days)
" as c ".
"$join ".
"group by $which ".
"order by phours desc");
"order by phours desc limit 250");
$results = array();
while ($row = mysql_fetch_array($query_result)) {
......@@ -117,6 +117,40 @@ function SpitRankList($target, $days)
SpitRankList("user", $days);
SpitRankList("project", $days);
#
# Most popular profiles.
#
$profiles = array();
$rank = 1;
$query_result =
DBQueryFatal("select p.uuid,p.name,count(h.profile_id) as count,p.pid, ".
" v.pid,v.name ".
" from apt_instance_history as h ".
"left join apt_profiles as p on ".
" p.profileid=h.profile_id ".
"left join apt_profile_versions as v on ".
" v.profileid=h.profile_id and ".
" v.version=h.profile_version ".
"where h.created>DATE_SUB(now(),INTERVAL $days DAY) ".
"group by profile_id order by count desc limit 100");
while ($row = mysql_fetch_array($query_result)) {
$name = $row["name"];
$count = $row["count"];
$uuid = $row["uuid"];
$pid = $row["pid"];
$profiles[$rank] = array("name" => $name,
"uuid" => $uuid,
"pid" => $pid,
"rank" => $rank++,
"count" => $count);
}
echo "<script type='text/plain' id='profile-json'>\n";
echo json_encode($profiles);
echo "</script>\n";
REQUIRE_UNDERSCORE();
REQUIRE_SUP();
SPITREQUIRE("js/ranking.js",
......
......@@ -102,6 +102,9 @@
<div class='col-sm-10 col-sm-offset-1'>
<div class='panel panel-default' id='experiments-latest-panel'>
<div class="panel-heading">
<a href="experiments.php?sortby=created" target="_blank">
<span style="margin-right: 10px;"
class='glyphicon glyphicon-new-window pull-right'></span></a>
<h5><center>Latest Experiments</center></h5>
</div>
<div class='panel-body panel-body-dashboard'>
......@@ -141,6 +144,9 @@
<div class='col-sm-4'>
<div class='panel panel-default' id='experiments-users-panel'>
<div class="panel-heading">
<a href="ranking.php#users" target="_blank">
<span style="margin-right: 10px;"
class='glyphicon glyphicon-new-window pull-right'></span></a>
<h5><center>Heaviest Users (Current)</center></h5>
</div>
<div class='panel-body panel-body-dashboard'>
......@@ -169,6 +175,9 @@
<div class='col-sm-4'>
<div class='panel panel-default' id='experiments-projects-panel'>
<div class="panel-heading">
<a href="ranking.php#projects" target="_blank">
<span style="margin-right: 10px;"
class='glyphicon glyphicon-new-window pull-right'></span></a>
<h5><center>Heaviest Projects (Current)</center></h5>
</div>
<div class='panel-body panel-body-dashboard'>
......@@ -197,6 +206,9 @@
<div class='col-sm-4'>
<div class='panel panel-default' id='profiles-panel'>
<div class="panel-heading">
<a href="ranking.php#profiles" target="_blank">
<span style="margin-right: 10px;"
class='glyphicon glyphicon-new-window pull-right'></span></a>
<h5><center>Popular Profiles (Epoch)</center></h5>
</div>
<div class='panel-body panel-body-dashboard'>
......@@ -225,6 +237,9 @@
<div class='col-sm-10 col-sm-offset-1'>
<div class='panel panel-default' id='extension-requests-panel'>
<div class="panel-heading">
<a href="experiments.php#extending" target="_blank">
<span style="margin-right: 10px;"
class='glyphicon glyphicon-new-window pull-right'></span></a>
<h5><center>Outstanding Extension Requests</center></h5>
</div>
<div class='panel-body panel-body-dashboard'>
......@@ -261,6 +276,9 @@
<div class='col-sm-10 col-sm-offset-1'>
<div class='panel panel-default' id='error-details-panel'>
<div class="panel-heading">
<a href="instance-errors.php" target="_blank">
<span style="margin-right: 10px;"
class='glyphicon glyphicon-new-window pull-right'></span></a>
<h5><center>Recent Errors (Details)</center></h5>
</div>
<div class='panel-body panel-body-dashboard'>
......
......@@ -22,7 +22,7 @@
<th>PCs</th>
<th>PHours<b>[1]</b></th>
<th>VMs</th>
<th>Created</th>
<th class="sortInitialOrder-desc">Created</th>
<th>Expires</th>
<th class="hidden-column">Filters</th>
</tr>
......
......@@ -23,6 +23,9 @@
<li role="presentation">
<a href="#projects" role="tab"
data-toggle="tab">Projects</a></li>
<li role="presentation">
<a href="#profiles" role="tab"
data-toggle="tab">Profiles</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
......@@ -95,6 +98,43 @@
</table>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="profiles">
<div class="table-responsive">
<input class='form-control search'
type='search' data-column='all'
id='profiles_search' placeholder='Search'>
<table class='tablesorter' id='profiles_table'>
<thead>
<tr>
<th>Name</th>
<th>Rank</th>
<th>PID</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<% _.each(profiles, function(value, rank) { %>
<tr>
<td>
<% if (value.uuid) { %>
<a href='show-profile.php?uuid=<%= value.uuid %>'>
<%= value.name %></a>
<% } else { %>
<%= value.name %>
<% } %>
</td>
<td><%= value.rank %></td>
<td>
<a href='show-project.php?project=<%= value.pid %>'>
<%= value.pid %></a>
</td>
<td><%= value.count %></td>
</tr>
<% }); %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
......
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