Paginate history.

This commit is contained in:
Michael Jumper
2013-03-03 19:14:49 -08:00
parent 1fce03279e
commit 7046bd76e3
2 changed files with 20 additions and 4 deletions

View File

@@ -704,8 +704,8 @@ GuacAdmin.addConnection = function(connection) {
if (connection.history.length > 0) { if (connection.history.length > 0) {
// History section // History section
var history_table = GuacUI.createChildElement( var history_section = GuacUI.createChildElement(sections, "dd");
GuacUI.createChildElement(sections, "dd"), var history_table = GuacUI.createChildElement(history_section,
"table", "history section"); "table", "history section");
var history_table_header = GuacUI.createChildElement( var history_table_header = GuacUI.createChildElement(
@@ -720,6 +720,12 @@ GuacAdmin.addConnection = function(connection) {
GuacUI.createChildElement(history_table_header, "th").textContent = GuacUI.createChildElement(history_table_header, "th").textContent =
"Duration"; "Duration";
// Paginated body of history
var history_buttons = GuacUI.createChildElement(history_section, "div",
"list-pager-buttons");
var history_body = GuacUI.createChildElement(history_table, "tbody");
var history_pager = new GuacUI.Pager(history_body);
// Add history // Add history
for (i=0; i<connection.history.length; i++) { for (i=0; i<connection.history.length; i++) {
@@ -727,7 +733,7 @@ GuacAdmin.addConnection = function(connection) {
var record = connection.history[i]; var record = connection.history[i];
// Create record elements // Create record elements
var row = GuacUI.createChildElement(history_table, "tr"); var row = GuacUI.createElement("tr");
var user = GuacUI.createChildElement(row, "td", "username"); var user = GuacUI.createChildElement(row, "td", "username");
var start = GuacUI.createChildElement(row, "td", "start"); var start = GuacUI.createChildElement(row, "td", "start");
var duration = GuacUI.createChildElement(row, "td", "duration"); var duration = GuacUI.createChildElement(row, "td", "duration");
@@ -740,8 +746,18 @@ GuacAdmin.addConnection = function(connection) {
else else
duration.textContent = "Active now"; duration.textContent = "Active now";
// Add record to pager
history_pager.addElement(row);
} }
// Init pager
history_pager.setPage(0);
// Add pager if more than one page
if (history_pager.last_page != 0)
history_buttons.appendChild(history_pager.getElement());
} }
else else
GuacUI.createChildElement( GuacUI.createChildElement(

View File

@@ -197,7 +197,7 @@ div.section {
background: #DEB; background: #DEB;
} }
.list-item.selected .icon { .list-item.selected > .icon {
opacity: 1.0; opacity: 1.0;
} }