Commit 73acc5e2 authored by Leigh Stoller's avatar Leigh Stoller

Rob request; show project leaders and managers monthly usage on the

member list tab of show-project and show-group pages.
parent 382962e0
<?php
#
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
# Copyright (c) 2000-2019 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -254,7 +254,7 @@ function Do_ProfileList()
function Do_MemberList()
{
global $this_user, $target_group;
global $newTrustMap;
global $newTrustMap, $TB_PROJECT_ADDUSER;
if (CheckPageArgs()) {
return;
......@@ -265,6 +265,10 @@ function Do_MemberList()
$memberlist = $target_group->MemberList(0, 1);
$nonmemberlist = $target_group->NonMemberList();
$leader = $target_group->GetLeader();
# Canapprove is a proxy for group_root or better.
$statsokay = (ISADMIN() ||
$target_group->AccessCheck($this_user,
$TB_PROJECT_ADDUSER));
foreach ($memberlist as $user) {
$membership = $target_group->MemberShipInfo($user);
......@@ -291,6 +295,13 @@ function Do_MemberList()
(ISADMIN() ||
$target_group->CanDeleteUser($this_user, $user) ? 1 : 0);
if ($statsokay) {
list($pcount, $phours) = Instance::MonthsUsage($user,$target_group);
if ($phours) {
$blob["usage"] = array("pcount" => $pcount,
"phours" => intval($phours));
}
}
$members[$user->uid()] = $blob;
}
foreach ($nonmemberlist as $user) {
......
......@@ -664,7 +664,7 @@ class Instance
#
# Usage over the last months Just phours, cause pcount is not very useful.
#
function MonthsUsage($target) {
function MonthsUsage($target, $group = null) {
$monthago = time() - (3600 * 24 * 28);
$pcount = 0;
$phours = 0;
......@@ -673,6 +673,14 @@ class Instance
if (get_class($target) == "User") {
$user_idx = $target->idx();
$clause = "creator_idx='$user_idx'";
#
# Optional group target for user.
#
if ($group) {
$pid = $group->pid();
$gid = $group->gid();
$clause .= " and pid='$pid' and gid='$gid' ";
}
}
else {
$pid_idx = $target->pid_idx();
......
<?php
#
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
# Copyright (c) 2000-2019 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -133,15 +133,20 @@ function Do_ClassicDatasetList()
function Do_MemberList()
{
global $this_user, $target_project;
global $newTrustMap;
global $newTrustMap, $TB_PROJECT_ADDUSER;
if (CheckPageArgs()) {
return;
}
$target_idx = $target_project->pid_idx();
$target_pid = $target_project->pid();
$target_group= $target_project->DefaultGroup();
$results = array();
$members = $target_project->MemberList();
# Canapprove is a proxy for group_root or better.
$statsokay = (ISADMIN() ||
$target_project->AccessCheck($this_user,
$TB_PROJECT_ADDUSER));
foreach ($members as $user) {
$membership = $target_project->MemberShipInfo($user);
......@@ -159,6 +164,14 @@ function Do_MemberList()
(ISADMIN() ||
$target_project->CanDeleteUser($this_user, $user) ? 1 : 0);
if ($statsokay) {
list($pcount, $phours) = Instance::MonthsUsage($user,
$target_group);
if ($phours) {
$blob["usage"] = array("pcount" => $pcount,
"phours" => intval($phours));
}
}
$results[$user->uid()] = $blob;
}
SPITAJAX_RESPONSE($results);
......
......@@ -6,6 +6,15 @@
<th>Name</th>
<th>Email</th>
<th>Joined</th>
<% if (canapprove) { %>
<th>Usage
<span data-toggle="popover"
data-trigger="hover"
data-content="Number of node hours used in the last month."
class='glyphicon glyphicon-question-sign'
style='margin-bottom: 4px;'></span>
</th>
<% } %>
<th class="sorter-false">Privs
<a href='#' class='btn btn-xs' data-toggle='modal'
data-target='#privs-help-modal'>
......@@ -41,6 +50,15 @@
<% if (!value.approved) { %>text-danger<% } %>">
<%- value.joined %></span>
</td>
<% if (canapprove) { %>
<td>
<% if (_.has(value, "usage")) { %>
<%- value.usage.phours %>
<% } else { %>
0
<% } %>
</td>
<% } %>
<% if ((canedit || canapprove) &&
value.trust != "leader" && value.candelete) { %>
<% var trustvalues = ["none", "user","root","manager"]; %>
......
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