Commit afbda60a authored by Mike Hibler's avatar Mike Hibler

Add option to display node history with most recent records first.

parent 6109280f
...@@ -1396,7 +1396,7 @@ class Node ...@@ -1396,7 +1396,7 @@ class Node
# Show history. # Show history.
# #
function ShowNodeHistory($node_id = null, $record = null, function ShowNodeHistory($node_id = null, $record = null,
$count = 200, $showall = 0, $count = 200, $showall = 0, $reverse = 0,
$date = null, $IP = null, $mac = null, $date = null, $IP = null, $mac = null,
$node_opt = "") { $node_opt = "") {
global $TBSUEXEC_PATH; global $TBSUEXEC_PATH;
...@@ -1411,6 +1411,9 @@ function ShowNodeHistory($node_id = null, $record = null, ...@@ -1411,6 +1411,9 @@ function ShowNodeHistory($node_id = null, $record = null,
if (!$showall) { if (!$showall) {
$opt .= " -a"; $opt .= " -a";
} }
if ($reverse) {
$opt .= " -r";
}
if ($date) { if ($date) {
$date = date("Y-m-d H:i:s", strtotime($date)); $date = date("Y-m-d H:i:s", strtotime($date));
$opt .= " -d " . escapeshellarg($date); $opt .= " -d " . escapeshellarg($date);
......
<?php <?php
# #
# Copyright (c) 2000-2012 University of Utah and the Flux Group. # Copyright (c) 2000-2013 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -39,6 +39,7 @@ if (! ($isadmin || OPSGUY() || STUDLY())) { ...@@ -39,6 +39,7 @@ if (! ($isadmin || OPSGUY() || STUDLY())) {
# Verify page arguments. # Verify page arguments.
# #
$optargs = OptionalPageArguments("showall", PAGEARG_BOOLEAN, $optargs = OptionalPageArguments("showall", PAGEARG_BOOLEAN,
"reverse", PAGEARG_BOOLEAN,
"datetime", PAGEARG_STRING, "datetime", PAGEARG_STRING,
"record", PAGEARG_INTEGER, "record", PAGEARG_INTEGER,
"count", PAGEARG_INTEGER, "count", PAGEARG_INTEGER,
...@@ -57,6 +58,9 @@ PAGEHEADER("Node History"); ...@@ -57,6 +58,9 @@ PAGEHEADER("Node History");
if (!isset($showall)) { if (!isset($showall)) {
$showall = 0; $showall = 0;
} }
if (!isset($reverse)) {
$reverse = 0;
}
if (!isset($count)) { if (!isset($count)) {
$count = 200; $count = 200;
} }
...@@ -149,16 +153,28 @@ else { ...@@ -149,16 +153,28 @@ else {
} }
$opts="$node_opt$dateopt"; $opts="$node_opt$dateopt";
echo "<b>Show records:</b> "; $revopt="&reverse=" . ($reverse ? "1" : "0");
$showopt="&showall=" . ($showall ? "1" : "0");
echo "<b>Order records:</b> ";
if ($reverse) {
echo "<a href='shownodehistory.php3?$opts$showopt'>oldest first</a>,
newest first";
} else {
echo "oldest first,
<a href='shownodehistory.php3?$opts$showopt&reverse=1'>newest first</a>";
}
echo "<br><b>Show records:</b> ";
if ($showall) { if ($showall) {
echo "<a href='shownodehistory.php3?$opts'>allocated only</a>, echo "<a href='shownodehistory.php3?$opts$revopt'>allocated only</a>,
all"; all";
} else { } else {
echo "allocated only, echo "allocated only,
<a href='shownodehistory.php3?$opts&showall=1'>all</a>"; <a href='shownodehistory.php3?$opts$revopt&showall=1'>all</a>";
} }
$opts="$node_opt&showall=$showall$dateopt"; $opts="$node_opt$revopt$showopt$dateopt";
echo "<br><b>Show:</b> "; echo "<br><b>Show:</b> ";
if ($when == "lastmonth") { if ($when == "lastmonth") {
echo "Last Month, "; echo "Last Month, ";
...@@ -197,6 +213,7 @@ echo "<tr><form action=shownodehistory.php3 method=get> ...@@ -197,6 +213,7 @@ echo "<tr><form action=shownodehistory.php3 method=get>
size=20 size=20
value=\"" . ($datetime ? $datetime : "mm/dd/yy HH:MM") . "\"></td> value=\"" . ($datetime ? $datetime : "mm/dd/yy HH:MM") . "\"></td>
<input type=hidden name=showall value=$showall> <input type=hidden name=showall value=$showall>
<input type=hidden name=reverse value=$reverse>
<input type=hidden name=when value=$when> <input type=hidden name=when value=$when>
$form_opt $form_opt
<td class=stealth> <td class=stealth>
...@@ -209,6 +226,7 @@ echo "<tr><form action=shownodehistory.php3 method=get> ...@@ -209,6 +226,7 @@ echo "<tr><form action=shownodehistory.php3 method=get>
size=20 size=20
value=\"$node_id\"></td> value=\"$node_id\"></td>
<input type=hidden name=showall value=$showall> <input type=hidden name=showall value=$showall>
<input type=hidden name=reverse value=$reverse>
<input type=hidden name=when value=$when> <input type=hidden name=when value=$when>
<td class=stealth> <td class=stealth>
<b><input type=submit name=search2 value=Search></b></td>\n"; <b><input type=submit name=search2 value=Search></b></td>\n";
...@@ -220,6 +238,7 @@ echo "<tr><form action=shownodehistory.php3 method=get> ...@@ -220,6 +238,7 @@ echo "<tr><form action=shownodehistory.php3 method=get>
size=20 size=20
value=\"$IP\"></td> value=\"$IP\"></td>
<input type=hidden name=showall value=$showall> <input type=hidden name=showall value=$showall>
<input type=hidden name=reverse value=$reverse>
<input type=hidden name=when value=$when> <input type=hidden name=when value=$when>
<td class=stealth> <td class=stealth>
<b><input type=submit name=search3 value=Search></b></td>\n"; <b><input type=submit name=search3 value=Search></b></td>\n";
...@@ -231,13 +250,14 @@ echo "<tr><form action=shownodehistory.php3 method=get> ...@@ -231,13 +250,14 @@ echo "<tr><form action=shownodehistory.php3 method=get>
size=12 size=12
value=\"$mac\"></td> value=\"$mac\"></td>
<input type=hidden name=showall value=$showall> <input type=hidden name=showall value=$showall>
<input type=hidden name=reverse value=$reverse>
<input type=hidden name=when value=$when> <input type=hidden name=when value=$when>
<td class=stealth> <td class=stealth>
<b><input type=submit name=search3 value=Search></b></td>\n"; <b><input type=submit name=search3 value=Search></b></td>\n";
echo "</form></tr>\n"; echo "</form></tr>\n";
echo "</table><br>\n"; echo "</table><br>\n";
ShowNodeHistory($node_id, $record, $count, $showall, $datetime, ShowNodeHistory($node_id, $record, $count, $showall, $reverse, $datetime,
$IP, $mac, $node_opt); $IP, $mac, $node_opt);
# #
......
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