All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 490b86e7 authored by Leigh B Stoller's avatar Leigh B Stoller

Add Freeze/Thaw user to the admin tab.

parent 83750bc5
......@@ -475,6 +475,20 @@ $(function ()
$('#admin_content .toggle').click(function() {
Toggle(this);
});
// Freeze or Thaw.
if (json.value.status == "active" ||
json.value.status == "frozen") {
if (json.value.status == "active") {
$('#admin_content .freeze').html("Freeze");
}
else {
$('#admin_content .freeze').html("Thaw");
}
$('#admin_content .freezethaw').removeClass("hidden");
$('#admin_content .freeze').click(function (event) {
FreezeOrThaw(json.value.status);
});
}
}
$('#myprofile_content')
.html(template({"fields" : json.value,
......@@ -600,6 +614,45 @@ $(function ()
callback);
}
//
// Freeze or Thaw
//
function FreezeOrThaw(status) {
var tag = (status == "active" ? "Freeze" : "Thaw");
console.info("FreezeOrThaw: ", status, tag);
// Handler for hide modal to unbind the click handler.
$('#confirm-freezethaw-modal').on('hidden.bs.modal', function (event) {
$(this).unbind(event);
$('#confirm-freezethaw').unbind("click.freezethaw");
});
$('#confirm-freezethaw').bind("click.freezethaw", function (event) {
var callback = function(json) {
sup.HideWaitWait();
if (json.code) {
sup.SpitOops("oops",
"Failed to " + tag + " user");
return;
}
LoadProfileTab();
};
var doit = function () {
sup.ShowWaitWait("This will take a minute. Patience please.");
var xmlthing =
sup.CallServerMethod(null, "user-dashboard",
"FreezeOrThaw",
{"uid" : window.TARGET_USER,
"which" : tag});
xmlthing.done(callback);
};
sup.HideModal('#confirm-freezethaw-modal', doit);
});
$('#confirm-freezethaw-modal .which').html(tag);
sup.ShowModal('#confirm-freezethaw-modal');
}
function SendTestMessage()
{
var callback = function(json) {
......
......@@ -274,6 +274,8 @@ $routing = array("geni-login" =>
"Do_ProjectProfileList",
"Toggle" =>
"Do_Toggle",
"FreezeOrThaw" =>
"Do_FreezeOrThaw",
"SendTestMessage" =>
"Do_SendTestMessage",
"NagPI" =>
......
......@@ -203,6 +203,23 @@
</div>
</div>
</div>
<!-- Confirm Freeze or Thaw -->
<div id='confirm-freezethaw-modal' class='modal fade'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<center><h4>Confirm to <span class="which"></span></h4>
<button class='btn btn-primary btn-sm'
data-dismiss='modal'
style="margin-right: 10px;"
id='cancel-freezethaw'>Cancel</button>
<button class='btn btn-danger btn-sm'
id='confirm-freezethaw'>Confirm</button>
</center>
</div>
</div>
</div>
</div>
<div id='waitwait_div'></div>
<div id='oops_div'></div>
<div id='conversion_help_div'></div>
<style>
.toggle {
cursor: pointer;
cursor: pointer;
}
.freeze {
cursor: pointer;
}
</style>
<div>
......@@ -51,7 +54,11 @@
</tr>
<tr>
<td>Status</td>
<td><%= fields.status %></td>
<td><%= fields.status %>
<span class="freezethaw hidden">
(<a class="freeze text-danger">foo</a>)
</span>
</td>
</tr>
<% if (fields.nonlocal_id != "") { %>
<tr>
......
......@@ -298,7 +298,7 @@ function Do_UsageSummary()
function Do_Toggle()
{
global $this_user, $target_user;
global $ajax_args;
global $ajax_args, $suexec_output;
global $TBMAIL_OPS, $TBMAIL_AUDIT, $TBMAIL_WWW, $TBADMINGROUP;
if (CheckPageArgs()) {
......@@ -372,6 +372,49 @@ function Do_Toggle()
SPITAJAX_RESPONSE(1);
}
#
# Freeze or Thaw.
#
function Do_FreezeOrThaw()
{
global $this_user, $target_user;
global $ajax_args, $suexec_output;
global $TBADMINGROUP;
if (CheckPageArgs()) {
return;
}
if (!ISADMIN()) {
SPITAJAX_ERROR(-1, "Not enough permission");
return;
}
if ($target_user->status() != TBDB_USERSTATUS_ACTIVE &&
$target_user->status() != TBDB_USERSTATUS_FROZEN) {
SPITAJAX_ERROR(-1, "User is not active or frozen!");
return;
}
$target_idx = $target_user->uid_idx();
$target_uid = $target_user->uid();
$this_uid = $this_user->uid();
if (!isset($ajax_args["which"])) {
SPITAJAX_ERROR(-1, "What am I supposed to do?");
return -1;
}
$which = strtolower($ajax_args["which"]);
if ($which != "freeze" && $which != "thaw") {
SPITAJAX_ERROR(-1, "Cannot do that: $which");
return -1;
}
# Use -u (update) and -f (force) to make it happen.
if (SUEXEC($this_uid, $TBADMINGROUP,
"webtbacct -u -f $which $target_uid", SUEXEC_ACTION_CONTINUE)) {
SPITAJAX_ERROR(-1, $suexec_output);
return -1;
}
SPITAJAX_RESPONSE(1);
}
function Do_SendTestMessage()
{
global $this_user, $target_user;
......
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