Commit d248a0f8 authored by Leigh Stoller's avatar Leigh Stoller

Beef up the usage summary, show the user's 30 day rank.

Also add an admin option from the Class page.
parent a5ff53ac
...@@ -39,11 +39,46 @@ function (_, sup, moment, mainString, ...@@ -39,11 +39,46 @@ function (_, sup, moment, mainString,
window.location.hash = e.target.hash; window.location.hash = e.target.hash;
}); });
LoadUsage();
LoadExperimentTab(); LoadExperimentTab();
// Should we do these on demand? // Should we do these on demand?
LoadProfileListTab(); LoadProfileListTab();
LoadProjectsTab(); LoadProjectsTab();
LoadProfileTab(); LoadProfileTab();
/*
* Handlers for inline operations.
*/
$('#sendtestmessage').click(function () {
SendTestMessage();
});
}
function LoadUsage()
{
var callback = function(json) {
console.info(json);
if (json.code) {
console.info(json.value);
return;
}
var blob = json.value;
if (blob.rank) {
var html =
"<div>" + blob.rankdays + " Day Usage Ranking: #" +
blob.rank + " of " + blob.ranktotal + " active users" +
"</div>";
$('#usage-summary').html(html);
}
}
var xmlthing = sup.CallServerMethod(null,
"user-dashboard", "UsageSummary",
{"uid" : window.TARGET_USER});
xmlthing.done(callback);
} }
function LoadExperimentTab() function LoadExperimentTab()
...@@ -121,7 +156,25 @@ function (_, sup, moment, mainString, ...@@ -121,7 +156,25 @@ function (_, sup, moment, mainString,
var table = $('#profiles_table') var table = $('#profiles_table')
.tablesorter({ .tablesorter({
theme : 'green', 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, var xmlthing = sup.CallServerMethod(null,
"user-dashboard", "ProfileList", "user-dashboard", "ProfileList",
...@@ -131,7 +184,6 @@ function (_, sup, moment, mainString, ...@@ -131,7 +184,6 @@ function (_, sup, moment, mainString,
function ShowTopology(profile) function ShowTopology(profile)
{ {
var profile;
var index; var index;
var callback = function(json) { var callback = function(json) {
...@@ -244,5 +296,20 @@ function (_, sup, moment, mainString, ...@@ -244,5 +296,20 @@ function (_, sup, moment, mainString,
callback); callback);
} }
function SendTestMessage()
{
var callback = function(json) {
if (json.code) {
alert("Test message could not be sent!");
return;
}
alert("Test message has been sent");
}
var xmlthing = sup.CallServerMethod(null,
"user-dashboard", "SendTestMessage",
{"uid" : window.TARGET_USER});
xmlthing.done(callback);
}
$(document).ready(initialize); $(document).ready(initialize);
}); });
...@@ -134,7 +134,9 @@ $routing = array("myprofiles" => ...@@ -134,7 +134,9 @@ $routing = array("myprofiles" =>
"Quarantine" => "Quarantine" =>
"Do_Quarantine", "Do_Quarantine",
"LinktestControl" => "LinktestControl" =>
"Do_Linktest")), "Do_Linktest",
"dismissExtensionDenied" =>
"Do_DismissExtensionDenied")),
"approveuser" => "approveuser" =>
array("file" => "approveuser.ajax", array("file" => "approveuser.ajax",
"guest" => false, "guest" => false,
...@@ -178,6 +180,8 @@ $routing = array("myprofiles" => ...@@ -178,6 +180,8 @@ $routing = array("myprofiles" =>
"Do_ExperimentList", "Do_ExperimentList",
"ProjectList" => "ProjectList" =>
"Do_ProjectList", "Do_ProjectList",
"UsageSummary" =>
"Do_UsageSummary",
"ProfileList" => "ProfileList" =>
"Do_ProfileList", "Do_ProfileList",
"Toggle" => "Toggle" =>
...@@ -195,6 +199,8 @@ $routing = array("myprofiles" => ...@@ -195,6 +199,8 @@ $routing = array("myprofiles" =>
"Do_ProfileList", "Do_ProfileList",
"MemberList" => "MemberList" =>
"Do_MemberList", "Do_MemberList",
"UsageSummary" =>
"Do_UsageSummary",
"ProjectProfile" => "ProjectProfile" =>
"Do_ProjectProfile")), "Do_ProjectProfile")),
); );
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
<div class='panel-body'> <div class='panel-body'>
<div class='row'> <div class='row'>
<div class='col-sm-12'> <div class='col-sm-12'>
<center id="usage-summary"></center>
<div> <div>
<!-- Nav tabs --> <!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist"> <ul class="nav nav-tabs" role="tablist">
...@@ -73,6 +74,9 @@ ...@@ -73,6 +74,9 @@
Manage Account</a></li> Manage Account</a></li>
<li><a href="list-datasets.php?user=<%= target_user %>"> <li><a href="list-datasets.php?user=<%= target_user %>">
List Datasets</a></li> List Datasets</a></li>
<li class='divider'></li>
<li><a role="button" id="sendtestmessage">
Send Test Message</a></li>
<li role="presentation"> <li role="presentation">
<a href='<%- emulablink %>'> <a href='<%- emulablink %>'>
Emulab User Page</a></li> Emulab User Page</a></li>
......
...@@ -154,6 +154,54 @@ function Do_AccountDetails() ...@@ -154,6 +154,54 @@ function Do_AccountDetails()
SPITAJAX_RESPONSE($results); SPITAJAX_RESPONSE($results);
} }
#
# Usage for the user, in pnode hours.
#
function Do_UsageSummary()
{
global $this_user, $target_user;
global $ajax_args;
if (CheckPageArgs()) {
return;
}
list($pcount, $phours) = Instance::CurrentUsage($target_user);
list($weekpcount, $weekphours) = Instance::WeeksUsage($target_user);
list($monthpcount, $monthphours) = Instance::MonthsUsage($target_user);
list($rank, $ranktotal) = Instance::Ranking($target_user, 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" => $monthpnodes,
"monthphours" => $monthphours,
"rankdays" => 30,
"rank" => $rank,
"ranktotal" => $ranktotal
);
SPITAJAX_RESPONSE($blob);
}
# #
# Toggle flags. # Toggle flags.
# #
...@@ -221,6 +269,42 @@ function Do_Toggle() ...@@ -221,6 +269,42 @@ function Do_Toggle()
SPITAJAX_RESPONSE(1); SPITAJAX_RESPONSE(1);
} }
function Do_SendTestMessage()
{
global $this_user, $target_user;
global $APTMAIL;
if (CheckPageArgs()) {
return;
}
if (!ISADMIN()) {
SPITAJAX_ERROR(1, "Only administrators can do this.");
return;
}
$target_idx = $target_user->uid_idx();
$target_uuid = $target_user->uuid();
$target_email = $target_user->email();
$target_name = $target_user->name();
$target_uid = $target_user->uid();
$adminemail = $target_user->adminEmail();
TBMAIL("$target_name '$target_uid' <$target_email>",
"This is a test",
"\n".
"Dear $target_name ($target_uid):\n".
"\n".
"This is a test message to validate the email address that we\n".
"have in our database. Please respond to this message\n".
"as soon as you receive it. If we do not hear back from you, we\n".
"may be forced to freeze your account.\n".
"\n".
"Thank you very much!\n",
"From: $adminemail\n".
"Bcc: stoller");
SPITAJAX_RESPONSE(1);
}
# Local Variables: # Local Variables:
# mode:php # mode:php
# End: # End:
......
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