Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Displayed cancellation and finalization state in reservations overview (
Browse files Browse the repository at this point in the history
  • Loading branch information
danbim committed Sep 17, 2014
1 parent 59c2fdf commit e947109
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 21 deletions.
22 changes: 18 additions & 4 deletions js/wisebed.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var WisebedPublicReservationData = function(prd) {
this.from = moment(prd.from);
this.to = moment(prd.to);
this.cancelled = prd.cancelled ? moment(prd.cancelled) : undefined;
this.finalized = prd.finalized ? moment(prd.finalized) : undefined;
this.nodeUrns = prd.nodeUrns;
this.nodeUrnPrefixes = [];

Expand All @@ -34,6 +35,7 @@ var WisebedConfidentialReservationData = function(crd) {
this.from = moment(crd.from);
this.to = moment(crd.to);
this.cancelled = crd.cancelled ? moment(crd.cancelled) : undefined;
this.finalized = crd.finalized ? moment(crd.finalized) : undefined;
this.nodeUrns = crd.nodeUrns;
this.nodeUrnPrefixes = [];
this.options = crd.options;
Expand All @@ -57,6 +59,7 @@ var WisebedReservation = function(confidentialReservationDataList) {
this.from = null;
this.to = null;
this.cancelled = null;
this.finalized = null;
this.nodeUrns = [];
this.nodeUrnPrefixes = [];
this.confidentialReservationDataList = [];
Expand All @@ -68,10 +71,21 @@ var WisebedReservation = function(confidentialReservationDataList) {

confidentialReservationDataList.forEach(function(confidentialReservationData) {
var crd = new WisebedConfidentialReservationData(confidentialReservationData);
if (crd.description && crd.description != '') { self.descriptions.push(crd.description); }
if (self.from == null || crd.from >= self.from) { self.from = crd.from; }
if (self.to == null || crd.to <= self.to ) { self.to = crd.to; }
if (self.cancelled == null || crd.cancelled <= self.cancelled) { self.cancelled = crd.cancelled; }
if (crd.description && crd.description != '') {
self.descriptions.push(crd.description);
}
if (self.from == null || crd.from >= self.from) {
self.from = crd.from;
}
if (self.to == null || crd.to <= self.to ) {
self.to = crd.to;
}
if (self.cancelled == null || crd.cancelled <= self.cancelled) {
self.cancelled = crd.cancelled;
}
if (self.finalized == null || crd.finalized <= self.finalized) {
self.finalized = crd.finalized;
}
crd.nodeUrns.forEach(function(nodeUrn) {
self.nodeUrns.push(nodeUrn);
var nodeUrnPrefix = nodeUrn.substring(0, nodeUrn.lastIndexOf(':') + 1);
Expand Down
116 changes: 99 additions & 17 deletions js/wisegui.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,26 +493,86 @@ function buildPersonalReservationsTable(parent, reservations, past) {
+ '</div>'
));
rowData.push(reservation.description);
rowData.push($('<a class="btn btn-primary">Open</a>').bind('click', reservation, function(e) {
var openButton = $('<a class="btn btn-primary">Open</a>').bind('click', reservation, function(e) {
e.preventDefault();
navigateTo(e.data.experimentId);
}));
if (openButton.attr('disabled') != 'disabled') {
navigateTo(e.data.experimentId);
}
});
if (reservation.finalized) {
openButton.attr('disabled', 'disabled');
}
rowData.push(openButton);
rowData.push($('<button class="btn" title="Download Log"><i class="icon-download"></i> Log</button>').bind('click', reservation, function(e) {
var url = wisebedBaseUrl + '/events/' + e.data.experimentId + '.json';
window.open(url, '_blank');
}));
if (!past) {
rowData.push($('<a class="btn btn-danger">Delete</a>').bind('click', reservation, function(e) {
e.preventDefault();
wisebed.reservations.delete(
e.data.experimentId,
function() { alert('deleted!'); },
WiseGui.showAjaxError
);
}));
} else {
rowData.push(reservation.cancelled ? '<span class="label label-important">Cancelled</span>' : '&nbsp;');
}

var cancelButton = undefined;
var cancelledLabel = undefined;
var finalizedLabel = undefined;

if (reservation.cancelled) {
cancelledLabel = $('<span class="label label-important">Cancelled</span><br/><span class="label label-important">' + reservation.cancelled.format("YYYY-MM-DD HH:mm:ss") + '</span>');
cancelledLabel.popover({
placement : 'top',
title : 'Cancelled Reservation',
content : '<p>This reservation has been <b>cancelled</b>.</p><p>A reservation ends '+
'either because the end of the reservaiton time span has been reached or because it has '+
'been cancelled. Due to network delays or temporary network disconnections in the testbed '+
'backend node outputs might still arrive delayed. After a couple of minutes after the '+
'last delayed node output was received the reservation is finalized, i.e. it is '+
'guaranteed that there will not be any more outputs attached to the reservations log.</p>'
});
}

if (reservation.finalized) {
finalizedLabel = $('<span class="label label-info">Finalized</span>');
finalizedLabel.popover({
placement : 'top',
title : 'Finalized Reservation',
content : '<p>This reservation has been <b>finalized</b>.</p><p>A reservation ends '+
'either because the end of the reservaiton time span has been reached or because it has '+
'been cancelled. Due to network delays or temporary network disconnections in the testbed '+
'backend node outputs might still arrive delayed. After a couple of minutes after the '+
'last delayed node output was received the reservation is finalized, i.e. it is '+
'guaranteed that there will not be any more outputs attached to the reservations log.</p>'
});
}

if (!reservation.cancelled && !reservation.finalized && !past) {
cancelButton = $('<a class="btn btn-danger">Cancel</a>').bind('click', reservation, function(e) {
e.preventDefault();
wisebed.reservations.delete(
e.data.experimentId,
function() {
cancelButton.popover('hide');
$(window).trigger('hashchange');
},
WiseGui.showAjaxError
);
});
cancelButton.popover({
placement : 'top',
title : 'Cancelling Reservations',
content : 'Cancelling a reservation will free the resources bound to the reservation so that '
+ 'e.g. other users can reserve the nodes. If a reservation gets cancelled while it is '
+ 'active all reservation events (such as node outputs) until the cancellation will still '
+ 'be persisted in the reservation log and available for download.'
})
}

if (reservation.cancelled && reservation.finalized) {
rowData.push($('<span/>').append(cancelledLabel).append(' ').append(finalizedLabel));
} else if (reservation.cancelled) {
rowData.push(cancelledLabel);
} else if (reservation.finalized) {
rowData.push(finalizedLabel);
} else if (!past) {
rowData.push(cancelButton);
} else {
rowData.push('&nbsp;');
}

return rowData;
};
Expand All @@ -536,7 +596,7 @@ function buildReservationTableInternal(parent, reservations) {

var nop = function(event){ event.preventDefault(); };

var headers = ['From', 'Until', 'Testbed Prefix(es)', 'Nodes'];
var headers = ['From', 'Until', 'Testbed Prefix(es)', 'Nodes', ' '];
var model = reservations;
var rowProducer = function(reservation) {

Expand All @@ -553,6 +613,28 @@ function buildReservationTableInternal(parent, reservations) {
+ '</div>'
));

var cancelledLabel = undefined;

if (reservation.cancelled) {
cancelledLabel = $('<span class="label label-important">Cancelled</span><br/><span class="label label-important">' + reservation.cancelled.format("YYYY-MM-DD HH:mm:ss") + '</span>');
cancelledLabel.popover({
placement : 'top',
title : 'Cancelled Reservation',
content : '<p>This reservation has been <b>cancelled</b>.</p><p>A reservation ends '+
'either because the end of the reservaiton time span has been reached or because it has '+
'been cancelled. Due to network delays or temporary network disconnections in the testbed '+
'backend node outputs might still arrive delayed. After a couple of minutes after the '+
'last delayed node output was received the reservation is finalized, i.e. it is '+
'guaranteed that there will not be any more outputs attached to the reservations log.</p>'
});
}

if (reservation.cancelled) {
rowData.push(cancelledLabel);
} else {
rowData.push('&nbsp;');
}

return rowData;
}
var preFilterFun = null;
Expand Down Expand Up @@ -604,7 +686,7 @@ function buildReservationTable(parent) {

pills.find('a[href="#WiseGuiPublicReservationsCurrentFuture"]').click(function(e) {
e.preventDefault();
loadPublicReservations(false);
loadPublicReservations(true);
$(this).tab('show');
});

Expand Down

0 comments on commit e947109

Please sign in to comment.