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

Store the extension reason in the database, and give that back to the user

at the next extension, to avoid user aggravation. Also show the reason on
the termination modal if the experiment has been locked down.
parent e65109f5
......@@ -249,8 +249,16 @@ define(['underscore', 'js/quickvm_sup',
howlong = 1;
}
reason = $("#why_extend").val();
if (reason.trim().length == 0) {
$("#why_extend").val("");
DisableSubmitButton();
alert("Come on, say something useful please, " +
"we really do read these!");
return;
}
if (reason.length < minchars) {
alert("Your reason is too short! Say more please.");
alert("Your reason is too short. Say more please, " +
"we really do read these!");
return;
}
}
......@@ -298,13 +306,16 @@ define(['underscore', 'js/quickvm_sup',
adminExtendString : isguest ?
guestExtendString : userExtendString);
// We have to wait till it is shown to actually set up
// We have to wait till the modal is shown to actually set up
// some of the content, since we need to know its width.
$(modalname).on('shown.bs.modal', function (e) {
Initialize();
if (extendfor && isadmin) {
$("#howlong_extend").val(extendfor);
}
if ($('#extension_reason').length && !isadmin) {
$("#why_extend").val($('#extension_reason').val());
}
$(modalname).off('shown.bs.modal');
});
$(modalname).modal('show');
......
......@@ -30,7 +30,10 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
var status_collapsed = false;
var status_message = "";
var statusTemplate = _.template(statusString);
var terminateTemplate = _.template(terminateString);
var lastStatus = "";
var lockdown = 0;
var lockdown_code = "";
var EMULAB_NS = "http://www.protogeni.net/resources/rspec/ext/emulab/1";
function initialize()
......@@ -44,6 +47,8 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
dossh = window.APT_OPTIONS.dossh;
extend = window.APT_OPTIONS.extend || null;
profile_uuid = window.APT_OPTIONS.profileUUID;
lockdown = window.APT_OPTIONS.lockdown;
lockdown_code= uuid.substr(2, 5);
var instanceStatus = window.APT_OPTIONS.instanceStatus;
var errorURL = (window.ISCLOUD ?
"cloudlab-ops@cloudlab.us" : "aptlab-ops@aptlab.net") +
......@@ -65,6 +70,8 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
registered: window.APT_OPTIONS.registered,
isadmin: window.APT_OPTIONS.isadmin,
errorURL: errorURL,
lockdown: lockdown,
lockdown_code: lockdown_code,
// The status panel starts out collapsed.
status_panel_show: (instanceStatus == "ready" ? false : true),
};
......@@ -73,7 +80,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
$('#waitwait_div').html(waitwaitString);
$('#oops_div').html(oopsString);
$('#register_div').html(registerString);
$('#terminate_div').html(terminateString);
$('#terminate_div').html(terminateTemplate(template_args));
$('#oneonly_div').html(oneonlyString);
$('#approval_div').html(approvalString);
......@@ -132,7 +139,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
// Setup the extend modal.
$('button#extend_button').click(function (event) {
event.preventDefault();
ShowExtendModal(uuid, RequestExtensionCallback, isadmin, isguest, extend);
ShowExtendModal(uuid, RequestExtensionCallback, isadmin, isguest);
});
// Handler for the refresh button
......@@ -214,12 +221,26 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
// Terminate an experiment.
$('button#terminate').click(function (event) {
var lockdown_override = "";
event.preventDefault();
sup.HideModal('#terminate_modal');
if (lockdown) {
if (lockdown_code != $('#terminate_lockdown_code').val()) {
sup.SpitOops("oops", "Refusing to terminate; wrong code");
return;
}
lockdown_override = $('#terminate_lockdown_code').val();
}
DisableButtons();
var callback = function(json) {
sup.HideModal("#waitwait-modal");
if (json.code) {
EnableButtons();
sup.SpitOops("oops", "Failed to terminate: " + json.value);
return;
}
// This is considered the home page, for now.
window.location.replace('instantiate.php?default=' +
profile_uuid);
......@@ -229,7 +250,9 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
var xmlthing = sup.CallServerMethod(ajaxurl,
"status",
"TerminateInstance",
{"uuid" : uuid});
{"uuid" : uuid,
"lockdown_override" :
lockdown_override});
xmlthing.done(callback);
});
......@@ -957,7 +980,6 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
// Change the ID of the clone so its unique.
clone.attr('id', 'listview-row-' + node);
console.info(clone);
// Insert into the table, we will attach the handlers below.
$('#listview_table > tbody:last').append(clone);
// Set the client_id in the first column.
......
......@@ -273,15 +273,17 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
<li class='divider'></li>
<li><a href='ssh-keys.php'>Manage SSH Keys</a></li>
<li><a href='getcreds.php'>Download Credentials</a></li>
<li><a href='signup.php'>Start/Join Project</a></li>
<li><a href='changepswd.php'>Change Password</a></li>
<li><a href='logout.php'>Logout</a></li>";
if (1 || ISADMIN() || STUDLY()) {
echo " <li class='divider'></li>
<li><a href='activity.php'>Activity</a></li>
echo " <li class='divider'></li>
<li><a href='list-datasets.php?all=1'>List Datasets</a></li>
<li><a href='create-dataset.php'>Create Dataset</a></li>";
}
echo " </ul>
if (ISADMIN()) {
echo " <li class='divider'></li>
<li><a href='activity.php'>Activity</a></li>";
}
echo " </ul>
</li>\n";
}
echo " </ul>
......
......@@ -110,9 +110,9 @@ $slice = GeniSlice::Lookup("sa", $instance->slice_uuid());
$instance_status = $instance->status();
$creator_uid = $creator->uid();
$creator_email = $creator->email();
if ($instance->profile_id()) {
if ($instance->profile_id() &&
$profile = Profile::Lookup($instance->profile_id(),
$instance->profile_version());
$instance->profile_version())) {
$profile_name = $profile->name();
$profile_uuid = $profile->uuid();
$profile_public = ($profile->ispublic() ? "true" : "false");
......@@ -149,6 +149,10 @@ $registered = (isset($this_user) ? "true" : "false");
$snapping = 0;
$oneonly = (isset($oneonly) && $oneonly ? 1 : 0);
$isadmin = (ISADMIN() ? 1 : 0);
$lockdown = ($instance->admin_lockdown() ||
$instance->user_lockdown() ? 1 : 0);
$extension_reason= ($instance->extension_reason() ?
CleanString($instance->extension_reason()) : "");
#
# We give ssh to the creator (real user or guest user).
......@@ -199,6 +203,7 @@ echo " window.APT_OPTIONS.snapping = $snapping;\n";
echo " window.APT_OPTIONS.oneonly = $oneonly;\n";
echo " window.APT_OPTIONS.dossh = $dossh;\n";
echo " window.APT_OPTIONS.publicURL = $public_url;\n";
echo " window.APT_OPTIONS.lockdown = $lockdown;\n";
echo " window.APT_OPTIONS.AJAXURL = 'server-ajax.php';\n";
if (isset($extend) && $extend != "") {
echo " window.APT_OPTIONS.extend = $extend;\n";
......@@ -214,6 +219,7 @@ echo "<link rel='stylesheet'
# For progress bubbles in the imaging modal.
echo "<link rel='stylesheet' href='css/progress.css'>\n";
echo "<link rel='stylesheet' href='css/codemirror.css'>\n";
echo "<div class='hidden'><textarea id='extension_reason'>$extension_reason</textarea></div>\n";
SPITFOOTER();
?>
......@@ -53,9 +53,14 @@
<% } %>
<tr>
<td class='border-none'>Expires:</td>
<td class='border-none' id='instance_expiration'>
<span id='quickvm_expires'><%- sliceExpiresText %></span>
(<span id='quickvm_countdown'></span>)
<td class='border-none'>
<span id='instance_expiration'>
<span id='quickvm_expires'><%- sliceExpiresText %></span>
(<span id='quickvm_countdown'></span>)
</span>
<% if (isadmin && lockdown) { %>
<span class='text-danger'><small>locked down</small></span>
<% } %>
</td>
</tr>
</table>
......@@ -76,6 +81,7 @@
id='snapshot_button' type=button
data-toggle='modal' data-target='#snapshot_modal'>
Snapshot</button>
<% if (profileUUID && profileUUID != "") { %>
<a class='btn btn-xs btn-primary'
href='manage_profile.php?action=copy&uuid=<%= profileUUID %>'
id='copy_button' type=button
......@@ -90,6 +96,7 @@
whatever images the original profile uses.">
Copy</a>
<% } %>
<% } %>
<button class='btn btn-xs btn-success' disabled
id='extend_button' type=button>
Extend</button>
......
......@@ -6,7 +6,28 @@
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>&times;</button>
<p>Are you sure you want to terminate this experiment?
Click on the button below if you are really sure.</p><br>
Click on the button below if you are really sure.
</p>
<% if (lockdown) { %>
<p class='text-warning'>
This experiment has been flagged as important, possibly because
it was granted an extension by an administrator; please confirm
that you <b>REALLY</b> want to terminate by copying the text in
the left box into the right box:
</p>
<center>
<input size=5 readonly value='<%- lockdown_code %>'>
<input size=5 id='terminate_lockdown_code'>
</center>
<% if ($('#extension_reason').length) { %>
<br>
<div class='text-center'>Most recent extension request reason</div>
<div style='border: solid #000 1px;'>
<div style='padding-left: 2px; padding-right: 2px;'><%- $('#extension_reason').val() %></div>
</div>
<% } %>
<% } %>
<br>
<button class='btn btn-primary align-center' id='terminate'
type='submit' name='terminate'>Terminate</button>
</div>
......
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