Commit 3c911bb2 authored by Leigh Stoller's avatar Leigh Stoller

Add red-dot extend mode, which simply asks for the number of days

to extend by.
parent 6a175dae
......@@ -20,6 +20,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
var ajaxurl = null;
var uuid = null;
var oneonly = 0;
var isadmin = 0;
var status_collapsed = false;
var status_message = "";
var statusTemplate = _.template(statusString);
......@@ -36,6 +37,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
ajaxurl = window.APT_OPTIONS.AJAXURL;
uuid = window.APT_OPTIONS.uuid;
oneonly = window.APT_OPTIONS.oneonly;
isadmin = window.APT_OPTIONS.isadmin;
var instanceStatus = window.APT_OPTIONS.instanceStatus;
// Generate the templates.
......@@ -48,6 +50,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
creatorUid: window.APT_OPTIONS.creatorUid,
creatorEmail: window.APT_OPTIONS.creatorEmail,
registered: window.APT_OPTIONS.registered,
isadmin: window.APT_OPTIONS.isadmin,
// The status panel starts out collapsed.
status_panel_show: (instanceStatus == "ready" ? false : true),
};
......@@ -513,11 +516,18 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
//
function RequestExtension(uuid)
{
var reason = $("#why_extend").val();
// console.info(reason);
if (reason.length < 30) {
alert("Your reason is too short! Say more please.");
return;
var reason = "";
var howlong = "";
if (isadmin) {
howlong = $("#howlong_extend").val();
}
else {
reason = $("#why_extend").val();
if (reason.length < 100) {
alert("Your reason is too short! Say more please.");
return;
}
}
var callback = function(json) {
sup.HideModal("#waitwait-modal");
......@@ -547,7 +557,8 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
"status",
"RequestExtension",
{"uuid" : uuid,
"reason" : reason});
"howlong": howlong,
"reason" : reason});
xmlthing.done(callback);
}
......
......@@ -151,15 +151,11 @@ function Do_GetSSHAuthObject()
#
function Do_RequestExtension()
{
global $instance, $creator;
global $instance, $creator, $this_user;
global $ajax_args;
global $TBMAIL_OPS, $APTMAIL;
if (!isset($ajax_args["reason"])) {
SPITAJAX_ERROR(1, "Missing reason");
return 1;
}
$reason = $ajax_args["reason"];
$howlong = 3600 * 24;
$reason = "";
if (StatusSetupAjax()) {
return;
......@@ -170,15 +166,42 @@ function Do_RequestExtension()
SPITAJAX_ERROR(1, "no slice for instance");
return 1;
}
# Only extend for 24 hours. More later.
$expires_time = strtotime($slice->expires());
if ($expires_time > time() + (3600 * 24)) {
sleep(2);
SPITAJAX_ERROR(1, "You still have lots of time left!");
return;
if (ISADMIN()) {
if (!isset($ajax_args["howlong"]) || $ajax_args["howlong"] == "") {
SPITAJAX_ERROR(1, "Missing number of days");
return 1;
}
$howlong = $ajax_args["howlong"];
if (! preg_match("/^\d+$/", $howlong)) {
SPITAJAX_ERROR(1, "Invalid characters in days");
return 1;
}
if ($howlong < 1 || $howlong > 365) {
SPITAJAX_ERROR(1, "Must be an integer 1 <= days <= 365");
return 1;
}
$howlong = $howlong * (3600 * 24);
$reason = "Extended by site administrator";
}
else {
if (!isset($ajax_args["reason"]) || $ajax_args["reason"] == "") {
SPITAJAX_ERROR(1, "Missing reason");
return 1;
}
$reason = $ajax_args["reason"];
$howlong = 3600 * 24;
# Only extend for 24 hours. More later.
if ($expires_time > time() + $howlong) {
sleep(2);
SPITAJAX_ERROR(1, "You still have lots of time left!");
return;
}
}
$retval = SUEXEC("nobody", "nobody",
"webquickvm -e " . 3600 * 24 . " $uuid",
"webquickvm -e $howlong $uuid",
SUEXEC_ACTION_CONTINUE);
if ($retval == 0) {
......
......@@ -130,6 +130,7 @@ $canclone = (($profile->published() && isset($this_user) &&
ISADMIN() ? 1 : 0);
$snapping = 0;
$oneonly = (isset($oneonly) && $oneonly ? 1 : 0);
$isadmin = (ISADMIN() ? 1 : 0);
#
# See if we have a task running in the background for this instance.
......@@ -164,6 +165,7 @@ echo " window.APT_OPTIONS.sliceExpiresText = '" . $slice_expires_text . "';\n";
echo " window.APT_OPTIONS.creatorUid = '" . $creator_uid . "';\n";
echo " window.APT_OPTIONS.creatorEmail = '" . $creator_email . "';\n";
echo " window.APT_OPTIONS.registered = $registered;\n";
echo " window.APT_OPTIONS.isadmin = $isadmin;\n";
echo " window.APT_OPTIONS.cansnap = $cansnap;\n";
echo " window.APT_OPTIONS.canclone = $canclone;\n";
echo " window.APT_OPTIONS.snapping = $snapping;\n";
......
......@@ -16,11 +16,20 @@
style='padding-right:20px; border-right: 1px solid #ccc;'
<% } %>
>
<h4>Extend for 24 hours</h4>
If you need to keep these resources for longer, tell
us why and we'll extend it for another 24 hours.
Watch for a confirmation message via email.
<form id='extend_request_form' role='form'>
<% if (isadmin) { %>
<center><h4>How many Days? Default is 24 hours</h4></center>
<div class='row'>
<div class='col-sm-2 col-sm-offset-5'>
<input id='howlong_extend' type='text'
class='form-control'>
</div>
</div>
<% } else { %>
<h4>Extend for 24 hours</h4>
If you need to keep these resources for longer, tell
us why and we'll extend it for another 24 hours.
Watch for a confirmation message via email.
<div class='row'>
<div class='col-lg-12 col-md-12'>
<textarea id='why_extend' name='why_extend'
......@@ -34,10 +43,11 @@
<span style="font:normal 11px sans-serif;color:#B00400;">
<span id='extend_counter_msg'>&nbsp</span>
</span>
<br>
<button class='btn btn-primary btn-sm align-center'
id='request-extension'
type='submit' name='request'>Request Extension</button>
<% } %>
<br>
<button class='btn btn-primary btn-sm align-center'
id='request-extension'
type='submit' name='request'>Request Extension</button>
</form>
</div>
<% if (! registered) { %>
......
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