Commit d3eeb1bb authored by Leigh B Stoller's avatar Leigh B Stoller

Minor changes:

1. Do not say "you have a reservation", say which of the user's projects
   has a reservation. Both popups and warning message under the cluster
   selector.

2. Get rid of handrolled date formatting code, just use moment.js.

3. Minor format changes.
parent 7e33de51
......@@ -1055,6 +1055,7 @@ $(function ()
}
if (start != null) {
$(this).attr('data-res-pid', project);
$(this).attr('data-res-start', start);
if (end != null) {
$(this).removeAttr('data-now');
......@@ -1069,16 +1070,17 @@ $(function ()
if (startTime < now) {
$(this).attr('data-now', 'true');
target.append(wt.HasReservationHTML());
target.append(wt.HasReservationHTML(project));
}
else {
$(this).attr('data-now', 'false');
target.append(wt.FutureReservationHTML());
target.append(wt.FutureReservationHTML(project));
}
}
$('.reservation_tooltip > div').tooltip();
}
else {
$(this).removeAttr('data-res-pid');
$(this).removeAttr('data-res-start');
$(this).removeAttr('data-res-end');
}
......
......@@ -94,20 +94,19 @@ window.wt = (function() {
$(that).parent().addClass('selected');
if ($(that).parent().attr('data-res-start')) {
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var start = new Date(parseInt($(that).parent().attr('data-res-start')) * 1000);
var startHours = start.getHours() < 10 ? '0' + start.getHours() : '' + start.getHours();
var startMinutes = start.getMinutes() < 10 ? '0' + start.getMinutes() : '' + start.getMinutes();
var project = $(that).parent().attr('data-res-pid');
var start = new Date(parseInt($(that).parent()
.attr('data-res-start')) * 1000);
if ($(that).parent().attr('data-res-end')) {
$('#reservation_confirmation').addClass('hidden');
var end = new Date(parseInt($(that).parent().attr('data-res-end')) * 1000);
var end = new Date(parseInt($(that).parent()
.attr('data-res-end')) * 1000);
var endHours = end.getHours() < 10 ? '0' + end.getHours() : '' + end.getHours();
var endMinutes = end.getMinutes() < 10 ? '0' + end.getMinutes() : '' + end.getMinutes();
$('#reservation_warning .reservation_start').html(startHours + ':' + startMinutes + ', ' + months[start.getMonth()] + ' ' + start.getDate());
$('#reservation_warning .reservation_end').html(endHours + ':' + endMinutes + ', ' + months[end.getMonth()] + ' ' + end.getDate());
$('#reservation_warning .reservation_start')
.html(moment(start).format('lll'));
$('#reservation_warning .reservation_end')
.html(moment(end).format('lll'));
$('#reservation_warning').removeClass('hidden');
}
else {
......@@ -116,13 +115,19 @@ window.wt = (function() {
if ($(that).parent().attr('data-now') == 'true') {
$('#reservation_future').addClass('hidden');
$('#reservation_confirmation .reservation_start').html(startHours + ':' + startMinutes + ', ' + months[start.getMonth()] + ' ' + start.getDate());
$('#reservation_confirmation .reservation_start')
.html(moment(start).format('lll'));
$('#reservation_confirmation .reservation_project')
.html(project);
$('#reservation_confirmation').removeClass('hidden');
}
else {
$('#reservation_confirmation').addClass('hidden');
$('#reservation_future .reservation_start').html(startHours + ':' + startMinutes + ', ' + months[start.getMonth()] + ' ' + start.getDate());
$('#reservation_future .reservation_start')
.html(moment(start).format('lll'));
$('#reservation_future .reservation_project')
.html(project);
$('#reservation_future').removeClass('hidden');
}
......@@ -241,23 +246,25 @@ window.wt = (function() {
+'</div></div>'
}
function HasReservationHTML() {
function HasReservationHTML(project) {
return '<div class="reservation_tooltip has_reservation">'
+'<div class="warning_icon confirm" '
+'data-toggle="tooltip" '
+'data-placement="right" '
+'title="You have an active reservation on this cluster.">'
+'title="Your project ' + project + ' has '
+'an active reservation on this cluster.">'
+'<span class="glyphicon glyphicon-calendar '
+'pull-right"></span>'
+'</div></div>'
}
function FutureReservationHTML() {
function FutureReservationHTML(project) {
return '<div class="reservation_tooltip future_reservation">'
+'<div class="warning_icon warn" '
+'data-toggle="tooltip" '
+'data-placement="right" '
+'title="You have an upcoming reservation on this cluster.">'
+'title="Your project ' + project + ' has '
+'an upcoming reservation on this cluster.">'
+'<span class="glyphicon glyphicon-calendar '
+'pull-right"></span>'
+'</div></div>'
......
......@@ -354,13 +354,13 @@
<!-- The JS code fills this in -->
<div id='cluster_selector' class='hidden'></div>
<div id='reservation_warning' class='hidden col-sm-12'>
<label id='reservation_text' class='alert-warning col-sm-8 col-sm-offset-2'>There is an upcoming reservation on this cluster that may impact your ability to reserve or extend resources. This reservation is from <span class='reservation_start'>start</span> until <span class='reservation_end'>end</span>.</label>
<label id='reservation_text' class='alert-warning col-sm-10 col-sm-offset-1'>There is an upcoming reservation on this cluster that may impact your ability to reserve or extend resources. This reservation is from <span class='reservation_start'>start</span> until <span class='reservation_end'>end</span>.</label>
</div>
<div id='reservation_confirmation' class='hidden col-sm-12'>
<label id='reservation_text' class='alert-success col-sm-8 col-sm-offset-2'>You have a reservation on this cluster that began at <span class='reservation_start'>start</span>.</label>
<label id='reservation_text' class='alert-success col-sm-10 col-sm-offset-1'>Your project <span class="reservation_project"></span> has a reservation on this cluster that began <span class='reservation_start'>start</span>.</label>
</div>
<div id='reservation_future' class='hidden col-sm-12'>
<label id='reservation_text' class='alert-warning col-sm-8 col-sm-offset-2'>You have a reservation on this cluster beginning at <span class='reservation_start'>start</span>.</label>
<label id='reservation_text' class='alert-warning col-sm-10 col-sm-offset-1'>Your project <span class="reservation_project"></span> has a reservation on this cluster beginning <span class='reservation_start'>start</span>.</label>
</div>
</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