Commit 288a22a6 authored by Mike Hibler's avatar Mike Hibler

Default to reverse order in node_history.

I always want to see the most recent entries, not the oldest.
This turned out to be more involved than I thought!
parent f5cbc8d5
#!/usr/bin/perl -w
#
# Copyright (c) 2005-2013 University of Utah and the Flux Group.
# Copyright (c) 2005-2014 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -333,7 +333,11 @@ if (@nodes > 0) {
my $querymod = "";
if ($startrecord) {
$querymod = " AND history_id>='$startrecord'";
if ($revorder) {
$querymod = " AND history_id<='$startrecord'";
} else {
$querymod = " AND history_id>='$startrecord'";
}
}
if (@nodes) {
$querymod .= " AND (" . join(" or ", map {"node_id='$_'"} @nodes) . ")";
......
......@@ -1552,6 +1552,7 @@ function ShowNodeHistory($node_id = null, $record = null,
# Keep track of history record bounds, for paging through.
$max_history_id = 0;
$min_history_id = 1000000000;
# Build up table contents
ob_start();
......@@ -1593,9 +1594,12 @@ function ShowNodeHistory($node_id = null, $record = null,
$uid = $results[4];
$pid = $results[5];
$thisid = intval($results[8]);
if ($thisid >= $max_history_id) {
if ($thisid > $max_history_id) {
$max_history_id = $thisid;
}
if ($thisid < $min_history_id) {
$min_history_id = $thisid;
}
$slice = "--";
$expurl = null;
if ($pid == "FREE") {
......@@ -1670,8 +1674,12 @@ function ShowNodeHistory($node_id = null, $record = null,
$table_html = ob_get_contents();
ob_end_clean();
echo "<center><a href='shownodehistory.php3?record=$max_history_id".
"&count=$count&$node_opt'>Next $count records</a></center>\n";
$hid = $max_history_id;
if ($reverse) {
$hid = $min_history_id;
}
echo "<center><a href='shownodehistory.php3?record=$hid".
"&reverse=$reverse&count=$count&$node_opt'>Next $count records</a></center>\n";
echo "<table border=1 cellpadding=2 cellspacing=2 align='center'>\n";
echo "<tr>
$nodestr
......
<?php
#
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -59,7 +59,7 @@ if (!isset($showall)) {
$showall = 0;
}
if (!isset($reverse)) {
$reverse = 0;
$reverse = 1;
}
if (!isset($count)) {
$count = 200;
......@@ -158,7 +158,7 @@ $showopt="&showall=" . ($showall ? "1" : "0");
echo "<b>Order records:</b> ";
if ($reverse) {
echo "<a href='shownodehistory.php3?$opts$showopt'>oldest first</a>,
echo "<a href='shownodehistory.php3?$opts$showopt&reverse=0'>oldest first</a>,
newest first";
} else {
echo "oldest first,
......
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