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 9e3beb50 authored by Leigh B Stoller's avatar Leigh B Stoller

Web UI part of reservation approval and reservation status for the

instantiate page.
parent 5fd335a0
......@@ -44,6 +44,7 @@ $(function ()
var ppchanged = false;
var monitor = null;
var types = null;
var resinfo = null;
var mainTemplate = _.template(instantiateString);
function initialize()
......@@ -107,7 +108,10 @@ $(function ()
}
}
});
var projcategories = MakeProfileCategories(profilelist);
var projcategories = MakeProfileCategories(profilelist);
// Fire this off right away.
LoadReservationInfo();
var html = mainTemplate({
formfields: decodejson('#form-json'),
......@@ -1732,5 +1736,20 @@ $(function ()
$('#group_selector').removeClass("hidden");
}
function LoadReservationInfo()
{
var callback = function(json) {
if (json.code) {
console.info("Could not get reservation info: " + json.value);
return;
}
console.info(json.value);
resinfo = json.value;
};
var $xmlthing =
sup.CallServerMethod(null, "reserve", "ReservationInfo", null);
$xmlthing.done(callback);
}
$(document).ready(initialize);
});
......@@ -317,7 +317,27 @@ $(function ()
"Reserve", reserve_callback,
"Submitting your reservation request; "+
"patience please");
}
/*
* Approve a reservation
*/
function Approve()
{
var callback = function(json) {
sup.HideWaitWait();
if (json.code) {
sup.SpitOops("oops", json.value);
return;
}
window.location.reload(true);
};
sup.ShowWaitWait();
var xmlthing = sup.CallServerMethod(null, "reserve",
"Approve",
{"cluster" : window.CLUSTER,
"idx" : window.IDX});
xmlthing.done(callback);
}
function PopulateReservation()
......@@ -356,6 +376,21 @@ $(function ()
.datepicker("setDate", start.format("MM/DD/YYYY"));
$("#reserve-request-form #end_day")
.datepicker("setDate", end.format("MM/DD/YYYY"));
if (!details.approved) {
$('#unapproved-warning').removeClass("hidden");
}
/*
* If this is an admin looking at an unapproved reservation,
* show the approve button
*/
if (isadmin && !details.approved) {
$('#reserve-approve-button').removeClass("hidden");
$('#reserve-approve-button').click(function(event) {
event.preventDefault();
Approve();
});
}
};
sup.ShowWaitWait();
var xmlthing = sup.CallServerMethod(null, "reserve",
......@@ -395,6 +430,9 @@ $(function ()
$('#reserve-submit-button').text("Check");
$('#reserve-submit-button').removeClass("btn-success");
$('#reserve-submit-button').addClass("btn-primary");
if (editing) {
$('#reserve-approve-button').attr("disabled", "disabled");
}
}
if (enable) {
$('#reserve-submit-button').removeAttr("disabled");
......
......@@ -293,6 +293,55 @@ function Do_Delete()
SPITAJAX_RESPONSE(1);
}
#
# Approve a reservation.
#
function Do_Approve()
{
global $this_user;
global $ajax_args;
global $TB_PROJECT_CREATEEXPT, $suexec_output;
if (!isset($ajax_args["idx"])) {
SPITAJAX_ERROR(-1, "Missing idx");
return -1;
}
$idx = $ajax_args["idx"];
if (!TBvalid_integer($idx)) {
SPITAJAX_ERROR(-1, "Invalid index");
return;
}
if (!isset($ajax_args["cluster"])) {
SPITAJAX_ERROR(-1, "Missing cluster");
return;
}
if (!preg_match("/^[-\w]+$/", $ajax_args["cluster"])) {
SPITAJAX_ERROR(-1, "Invalid cluster name");
return;
}
$aggregate = Aggregate::LookupByNickname($ajax_args["cluster"]);
if (!$aggregate) {
SPITAJAX_ERROR(-1, "No such cluster");
return;
}
if (!ISADMIN()) {
SPITAJAX_ERROR(-1, "Only administrators can approve reservations");
return;
}
$this_uid = $this_user->uid();
$urn = $aggregate->urn();
$retval = SUEXEC($this_uid, "nobody",
"webmanage_reservations -a '$urn' approve $idx",
SUEXEC_ACTION_CONTINUE);
if ($retval) {
SPITAJAX_ERROR(-1, $suexec_output);
return;
}
SPITAJAX_RESPONSE("list-reservations.php");
}
#
# List reservations at a cluster (for a user).
#
......@@ -350,6 +399,12 @@ function Do_ListReservations()
$blob["creator_uid"] = $details['uid'];
$blob["creator_idx"] = $details['uid_idx'];
}
if (isset($details['approved']) && $details['approved'] != "") {
$blob["approved"] = $details["approved"];
}
else {
$blob["approved"] = null;
}
$blob["count"] = $details['nodes'];
$blob["type"] = $details['type'];
$blob["start"] = $details['start'];
......@@ -423,12 +478,45 @@ function Do_GetReservation()
$blob["end"] = $details['end'];
$blob["notes"] = $details['notes'];
$blob["cluster"] = $aggregate->urn();
if (isset($details['approved']) && $details['approved'] != "") {
$blob["approved"] = $details["approved"];
}
else {
$blob["approved"] = null;
}
# For display.
$blob["cluster_id"] = $ajax_args["cluster"];
$webtask->Delete();
SPITAJAX_RESPONSE($blob);
}
#
# Ask for reservation system info, for a specific aggregate
#
function Do_ReservationInfo()
{
global $this_user;
global $ajax_args;
global $PORTAL_GENESIS;
$webtask = WebTask::CreateAnonymous();
$webtask_id = $webtask->task_id();
$retval = SUEXEC($this_user->uid(), "nobody",
"webmanage_reservations ".
" -t $webtask_id systeminfo -p '$PORTAL_GENESIS'",
SUEXEC_ACTION_CONTINUE);
if ($retval) {
$webtask->Delete();
SPITAJAX_ERROR(-1, $suexec_output);
return;
}
$webtask->Refresh();
$blob = $webtask->TaskValue("value");
$webtask->Delete();
SPITAJAX_RESPONSE($blob);
}
# Local Variables:
# mode:php
# End:
......
......@@ -142,6 +142,7 @@ echo "<script type='text/javascript'>\n";
if ($edit) {
echo " window.EDITING = true;\n";
echo " window.CLUSTER = '$cluster';\n";
echo " window.ISADMIN = $isadmin;\n";
echo " window.IDX = $idx;\n";
}
else {
......
......@@ -38,6 +38,7 @@
<th>Count</th>
<th>Starts</th>
<th>Ends</th>
<th>Pending</th>
</tr>
</thead>
<tbody>
......@@ -83,6 +84,11 @@
<td><%- value.count %></td>
<td class="format-date"><%- value.start %></td>
<td class="format-date"><%- value.end %></td>
<% if (value.approved) { %>
<td>No</td>
<% } else {%>
<td><span class="text-danger">Yes</span></td>
<% } %>
</tr>
<% }); %>
</tbody>
......
......@@ -4,7 +4,14 @@
<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'>
<% if (editing) { %>Modify <% } %>Reservation Request</h3>
<% if (editing) { %>Modify <% } %>Reservation Request
<% if (editing) { %>
<span class="hidden pull-right text-danger small"
id="unapproved-warning">
<span class="text-danger">This reservation is unapproved!</span>
</span>
<% } %>
</h3>
</div>
<div class='panel-body'>
<div>
......@@ -241,6 +248,12 @@
<button class='btn btn-primary btn-sm pull-right' disabled
id='reserve-submit-button'
type='submit' name='submit'>Check</button>
<% if (editing) { %>
<button class='hidden btn btn-primary btn-sm pull-right'
style="margin-right: 10px"
id='reserve-approve-button'
type='submit' name='submit'>Approve</button>
<% } %>
</div>
</div>
</form>
......
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