diff --git a/js/wisegui-reservation-observer.js b/js/wisegui-reservation-observer.js index 594907a..836b0b3 100644 --- a/js/wisegui-reservation-observer.js +++ b/js/wisegui-reservation-observer.js @@ -41,10 +41,6 @@ WiseGuiReservationObserver.prototype.processReservationsFetched = function(reser } } - if (newReservations.length > 0) { - $(window).trigger('wisegui-reservations-changed', [reservations]); - } - for (var k=0; k

Current and Future Reservations

'); + var currentAndFutureDiv = currentAndFuture.find('div.WiseGuiReservationTableDiv'); + + parent.empty(); + parent.append(currentAndFuture); + wisebed.reservations.getFederatable( - null, - null, - function(federatableReservations) { buildPersonalReservationsTable(tab, federatableReservations); }, - WiseGui.showAjaxError + moment(), + null, + function(federatableReservations) { + buildPersonalReservationsTable(currentAndFutureDiv, federatableReservations); + }, + WiseGui.showAjaxError ); } function buildMyReservationTable(parent) { - wisebed.reservations.getPersonal( - null, - null, - function(wisebedReservationList) { - buildPersonalReservationsTable(parent, wisebedReservationList); - }, - WiseGui.showAjaxError - ); + + var currentAndFuture = $('

Current and Future Reservations

'); + var past = $('

Past Reservations

'); + var currentAndFutureDiv = currentAndFuture.find('div.WiseGuiReservationTableDiv'); + var pastDiv = past.find('div.WiseGuiReservationTableDiv'); + + parent.empty(); + parent.append(currentAndFuture, past); + + wisebed.reservations.getPersonal(moment(), null, function(reservations) { buildPersonalReservationsTable(currentAndFutureDiv, reservations); }, WiseGui.showAjaxError); + wisebed.reservations.getPersonal(null, moment(), function(reservations) { buildPersonalReservationsTable(pastDiv, reservations); }, WiseGui.showAjaxError); }; function buildPersonalReservationsTable(parent, reservations) { @@ -363,6 +367,7 @@ function buildPersonalReservationsTable(parent, reservations) { var tableRows = []; var nop = function(event){ event.preventDefault(); }; var reservation, from, to, nodes, btn; + var rand = Math.floor(Math.random() * 100000); for (var i=0; i' + reservation.to.format("YYYY-MM-DD HH:mm:ss") + '').tooltip('show').click(nop); nodes = $( '
' - + ' '+ reservation.nodeUrns.length + ' nodes' - + '
' + reservation.nodeUrns.join("
") + '
' + + ' '+reservation.nodeUrns.length+' nodes' + + '
'+reservation.nodeUrns.join("
")+'
' + '
' ); btn = $('Open').bind('click', reservation, function(e) { @@ -392,60 +397,72 @@ function buildPersonalReservationsTable(parent, reservations) { var noEntriesMessage = 'No reservations available'; var table = buildTable(tableHead, tableRows, noEntriesMessage); + parent.empty(); parent.append(table); + if (tableRows.length > 0) { table.tablesorter({ sortList: [[0,1]] }); } } -function buildReservationTable(reservationsTab) { - wisebed.reservations.getPublic( - null, - null, - function(reservations) { - - var tableHead = [ - "From", - "Until", - "Testbed Prefix(es)", - "Nodes" - ]; - - var tableRows = []; - var reservation; - var nop = function(event){ event.preventDefault(); }; - var from, to, nodes; - - for (var i=0; i' + reservation.from.format("YYYY-MM-DD HH:mm:ss") + '').tooltip('show').click(nop); - to = $('' + reservation.to.format("YYYY-MM-DD HH:mm:ss") + '').tooltip('show').click(nop); - nodes = $( - '
' - + ' '+ reservation.nodeUrns.length + ' nodes' - + '
' + reservation.nodeUrns.join("
") + '
' - + '
' - ); - - tableRows[i] = []; - tableRows[i][0] = from; - tableRows[i][1] = to; - tableRows[i][2] = reservation.nodeUrnPrefixes.join("
"); - tableRows[i][3] = nodes; - } +function buildReservationTableInternal(parent, reservations) { - var noEntriesMessage = 'There are no reservations for the next week yet!'; - var table = buildTable(tableHead, tableRows, noEntriesMessage); - reservationsTab.empty(); - reservationsTab.append(table); - if (tableRows.length > 0) { - table.tablesorter({ sortList: [[0,1]] }); - } - }, - WiseGui.showAjaxError - ); + var tableHead = [ + "From", + "Until", + "Testbed Prefix(es)", + "Nodes" + ]; + + var tableRows = []; + var reservation; + var nop = function(event){ event.preventDefault(); }; + var from, to, nodes; + var rand = Math.floor(Math.random() * 100000); + + for (var i=0; i' + reservation.from.format("YYYY-MM-DD HH:mm:ss") + '').tooltip('show').click(nop); + to = $('' + reservation.to.format("YYYY-MM-DD HH:mm:ss") + '').tooltip('show').click(nop); + nodes = $( + '
' + + ' '+ reservation.nodeUrns.length + ' nodes' + + '
' + reservation.nodeUrns.join("
") + '
' + + '
' + ); + + tableRows[i] = []; + tableRows[i][0] = from; + tableRows[i][1] = to; + tableRows[i][2] = reservation.nodeUrnPrefixes.join("
"); + tableRows[i][3] = nodes; + } + + var noEntriesMessage = 'There are no reservations for the next week yet!'; + var table = buildTable(tableHead, tableRows, noEntriesMessage); + + parent.empty(); + parent.append(table); + + if (tableRows.length > 0) { + table.tablesorter({ sortList: [[0,1]] }); + }; +} + +function buildReservationTable(parent) { + + var currentAndFuture = $('

Current and Future Reservations

'); + var past = $('

Past Reservations

'); + var currentAndFutureDiv = currentAndFuture.find('div.WiseGuiReservationTableDiv'); + var pastDiv = past.find('div.WiseGuiReservationTableDiv'); + + parent.empty(); + parent.append(currentAndFuture, past); + + wisebed.reservations.getPublic(moment(), null, function(reservations) { buildReservationTableInternal(currentAndFutureDiv, reservations); }, WiseGui.showAjaxError); + wisebed.reservations.getPublic(null, moment(), function(reservations) { buildReservationTableInternal(pastDiv, reservations); }, WiseGui.showAjaxError); }