Commit 2dcba9ff authored by Leigh Stoller's avatar Leigh Stoller

Checkpoint reservation group listing page, before I change it all.

parent c214f562
This diff is collapsed.
<?php
#
# Copyright (c) 2000-2019 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
chdir("..");
include("defs.php3");
include("webtask.php");
chdir("apt");
include("quickvm_sup.php");
$page_title = "List Reservations";
#
# Get current user.
#
RedirectSecure();
$this_user = CheckLoginOrRedirect();
$this_uid = $this_user->uid();
$isadmin = (ISADMIN() ? 1 : 0);
SPITHEADER(1);
# List of clusters so we have info in the page
$ams = Aggregate::SupportsReservations();
$amlist = array();
while (list($index, $aggregate) = each($ams)) {
$amlist[$aggregate->nickname()] = $aggregate->urn();
}
if (!count($amlist)) {
SPITUSERERROR("No clusters support reservations.");
exit();
}
echo "<script type='text/plain' id='amlist-json'>\n";
echo htmlentities(json_encode($amlist));
echo "</script>\n";
echo "<link rel='stylesheet'
href='css/tablesorter.css'>\n";
echo "<link rel='stylesheet'
href='css/nv.d3.css'>\n";
# Place to hang the toplevel template.
echo "<div id='main-body'></div>\n";
echo "<script type='text/javascript'>\n";
echo " window.ISADMIN = $isadmin;\n";
echo "</script>\n";
REQUIRE_UNDERSCORE();
REQUIRE_SUP();
REQUIRE_MOMENT();
AddLibrary("js/resgraphs.js");
AddTemplateList(array("list-resgroups", "resgroup-list",
"confirm-modal", "resusage-list", "resusage-graph",
"oops-modal", "waitwait-modal"));
SPITREQUIRE("js/list-resgroups.js",
"<script src='js/lib/d3.v3.js'></script>\n".
"<script src='js/lib/nv.d3.js'></script>\n".
"<script src='js/lib/jquery.tablesorter.min.js'></script>\n".
"<script src='js/lib/jquery.tablesorter.widgets.min.js'></script>".
"<script src='js/lib/sugar.min.js'></script>".
"<script src='js/lib/jquery.tablesorter.parser-date.js'></script>");
SPITFOOTER();
?>
<style>
.panel-body-dashboard {
padding: 2px;
}
.table-dashboard {
margin: 1px;
}
.popover{
max-width: 800px;
}
.fixedsize-panel {
max-height:350px;
height:350px;
}
.table-condensed > thead > tr > th,
.table-condensed > tbody > tr > th,
.table-condensed > tfoot > tr > th,
.table-condensed > thead > tr > td,
.table-condensed > tbody > tr > td,
.table-condensed > tfoot > tr > td {
padding: 2px;
}
.panel-heading-list {
padding: 2px;
}
.tablesorter-green th.sorter-false .tablesorter-header-inner {
padding-left: 4px;
}
</style>
<div class='col-sm-12'>
<div class='panel panel-default'>
<div class='panel-heading'>
<h4 class="text-center">Reservations</h4>
</div>
<div class='panel-body'>
<div id='nogroups' class=hidden>
You do not have any reservations. Would you like to
<a href='resgroup.php'>create</a> one?
</div>
<div id="groups"></div>
</div>
</div>
</div>
<div id='deny-modal' class='modal fade'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>&times;</button>
<center><h4>Confirm to Deny Reservation</h4>
Message to send to user
<div>
<textarea id='deny-reason'
class='form-control'
rows=5></textarea>
</div>
<br>
<button class='btn btn-danger btn-sm'
id='confirm-deny'>Confirm</a>
</center>
</div>
</div>
</div>
</div>
<div id='approve-modal' class='modal fade'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>&times;</button>
<center><h4>Confirm to Approve Reservation</h4>
Additional text to send with approval (no text is okay):
<div>
<textarea class='form-control user-message'
rows=5></textarea>
</div>
<br>
<button class='btn btn-danger btn-sm'
id='confirm-approve'>Confirm</a>
</center>
</div>
</div>
</div>
</div>
<div id='info-modal' class='modal fade'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>&times;</button>
<center><h4>Confirm to Send Message</h4>
<span class="hidden nomessage-error text-danger">Give me Text!</span>
<div>
<textarea class='form-control user-message'
rows=5></textarea>
</div>
<br>
<button class='btn btn-danger btn-sm confirm-button'>Confirm</button>
</center>
</div>
</div>
</div>
</div>
<div id='warn-modal' class='modal fade'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>&times;</button>
<center><h4>Confirm to Send Warning Message</h4>
Additional text to send with warning (no text is okay):
<div>
<textarea class='form-control user-message'
rows=5></textarea>
</div>
<input type=checkbox id='schedule-cancellation' value=yes>
Cancel reservation in 24 hours?
<div style="margin-top:10px;">
<button class='btn btn-danger btn-sm confirm-button'>Confirm</button>
</div>
</center>
</div>
</div>
</div>
</div>
<div id='cancel-cancel-modal' class='modal fade'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>&times;</button>
<center><h4>Confirm to Cancel Cancellation</h4>
<div style="margin-top:10px;">
<button id="confirm-cancel-cancel-button"
class='btn btn-danger btn-sm confirm-button'>
Confirm</button>
</div>
</center>
</div>
</div>
</div>
</div>
<div class='modal fade' id="resusage-graph-modal">
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-body'>
<div class='panel panel-default'>
<div class="panel-heading panel-heading-list">
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>&times;</button>
<center>
<h5>Reservation Usage
<span class="resusage-graph-details"></span></h5>
</center>
</div>
<div class='panel-body panel-body-dashboard'>
<svg style="height: 75%; padding: 0px;"></svg>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="resusage-modals"></div>
<div id='waitwait_div'></div>
<div id='oops_div'></div>
<div id='confirm_div'></div>
<style>
.popover{
max-width: 800px;
}
.tablesorter-green .tablesorter-header-inner {
padding-left: 17px !important;
}
.tablesorter-green th.sorter-false .tablesorter-header-inner {
padding-left: 4px !important;
}
</style>
<div>
<table class='tablesorter'>
<thead>
<tr>
<th class="sorter-false">&nbsp</th>
<% if (showuser) { %><th>Creator</th><% } %>
<% if (showproject) { %><th>Project</th><% } %>
<th>Created</th>
<th>Starts</th>
<th>Ends</th>
<% if (showstatus) { %><th>Status</th><% } %>
<th class="sorter-false">Notes</th>
</tr>
</thead>
<tbody>
<% _.each(groups, function(value, uuid) { %>
<% var expando = "collapse-" + value.uuid; %>
<tr data-uuid="<%- value.uuid %>"
data-uid_idx="<%- value.uid_idx %>">
<td rowspan="2" style='white-space: nowrap;'
class="show-childrow">
<a href="#">
<span class='glyphicon glyphicon-chevron-right pull-left expando'
style='margin-left: 0px; margin-right: 8px;
margin-bottom: 4px;'
data-toggle='tooltip'
data-container="body"
data-trigger="hover"
title='Click to show details'></span></a>
<% if (showcontrols) { %>
<% if (isadmin) { %>
<a href="#" class="deny-button invisible">
<span class='glyphicon glyphicon-thumbs-down pull-left'
style='color: red; margin-left: 0px;
margin-bottom: 4px;'
data-toggle='tooltip'
data-container="body"
data-trigger="hover"
title='Deny with reason'></span>
</a>
<a href="#" class="approve-button invisible">
<span class='glyphicon glyphicon-thumbs-up pull-left'
style='color: red; margin-left: 5px;
margin-bottom: 4px;'
data-toggle='tooltip'
data-container="body"
data-trigger="hover"
title='Approve reservation'></span>
</a>
<% } %>
<a href="#" class="delete-button">
<span class='glyphicon glyphicon-remove pull-left'
style='color: red; margin-left: 5px;
margin-bottom: 4px;'
data-toggle='tooltip'
data-container="body"
data-trigger="hover"
title='Delete reservation'></span>
</a>
<a href="resgroup.php?edit=1&uuid=<%- value.uuid %>"
class="edit-button">
<span class='glyphicon glyphicon-pencil pull-left text-primary'
style='margin-left: 5px;
margin-bottom: 4px;'
data-toggle='tooltip'
data-container="body"
data-trigger="hover"
title='Edit reservation details'></span>
</a>
<% if (isadmin) { %>
<% if (value.uid_idx) { %>
<a href="#" class="info-button">
<span class='glyphicon glyphicon-info-sign pull-left
text-warning'
style='margin-bottom: 4px;
margin-left: 5px;'
data-toggle='tooltip'
data-container="body"
data-trigger="hover"
title='Send a message to user'></span>
</a>
<a href="#" class="warn-button">
<span class='glyphicon glyphicon-warning-sign pull-left
text-warning'
style='margin-bottom: 4px;
margin-left: 5px;'
data-toggle='tooltip'
data-container="body"
data-trigger="hover"
title='Warn user about unused reservaton'></span>
</a>
<% } %>
<% } %>
<% } %>
</td>
<% if (showuser) { %>
<td style='white-space: nowrap;'>
<% if (value.uid_idx) { %>
<a href='user-dashboard.php?user=<%- value.uid %>'>
<%- value.uid %></a>
<% } else { %>
<%- value.remote_uid %>
<% } %>
</td>
<% } %>
<% if (showproject) { %>
<td style='white-space: nowrap;'>
<% if (value.pid_idx) { %>
<a href='show-project.php?project=<%- value.pid %>'>
<%- value.pid %></a>
<% } else { %>
<%- value.remote_pid %>
<% } %>
</td>
<% } %>
<td class="format-date"><%- value.created %></td>
<td>
<% if (!value.start) { %>
&nbsp
<% } else if (new Date().getTime() >
new Date(value.start).getTime()) { %>
<span class="format-date"
style="color: green;"><%- value.start %></span>
<% } else { %>
<span class="format-date"><%- value.start %></span>
<% } %>
</td>
<td>
<% if (!value.end) { %>
&nbsp
<% } else { %>
<span class="format-date"><%- value.end %></span>
<% } %>
</td>
<% if (showstatus) { %>
<td class="group-status-column">
<span class="status-approved hidden">Approved</span>
<span class="status-pending hidden text-danger">Pending</span>
<span class="status-canceled hidden">
<span class="text-danger">Canceled</span>
<% if (isadmin && showcontrols) { %>
<a href="#" class="cancel-cancel-button">
<span class='glyphicon glyphicon-thumbs-up'
style='color: green; margin-left: 5px;
margin-bottom: 4px;'
data-toggle='tooltip'
data-container="body"
data-trigger="hover"
title='Cancel Cancellation'></span>
</a>
<% } %>
</span>
</td>
<% } %>
<td align="center">
<a href="#"
data-toggle='popover'
data-html='true'
data-trigger='hover'
data-title="Reservation Notes"
data-content="<div class='form-control'
style='height: auto;'><%- value.notes %></div>">
<span>&#8230;</span>
</a>
</td>
</tr>
<tr class="tablesorter-childRow">
<td colspan=12>
<% if (_.size(value.reservations)) { %>
<div style="width: 500px;">
<table class='tablesorter'>
<thead>
<th>Cluster</th>
<th>Type</th>
<th>Count</th>
<th>Status</th>
<% if (isadmin) { %>
<th class="sorter-false"></th>
<% } %>
</thead>
<tbody>
<% _.each(value.reservations, function(info) { %>
<tr data-uuid="<%- info.remote_uuid %>">
<td><%- info.cluster_id %></td>
<td><%- info.type %></td>
<td><%- info.count %></td>
<td class="reservation-status-column">
<span class="status-approved hidden">
Approved</span>
<span class="status-pending hidden text-danger">
Pending</span>
<span class="status-canceled hidden">
<span class="text-danger">Canceled</span></span>
</td>
<% if (isadmin) { %>
<td>
<a href="reserve.php?edit=1&cluster=<%- info.cluster_id %>&uuid=<%- info.remote_uuid %>"
target="_blank"
class="edit-button">
<span class='glyphicon glyphicon-eye-open'
style='margin-left: 5px;
margin-bottom: 4px;'></span>
</a>
</td>
<% } %>
</tr>
<% }); %>
</tbody>
</table>
</div>
<% } %>
</td>
</tr>
<% }); %>
</tbody>
</table>
</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