Commit 97c36a04 authored by Leigh Stoller's avatar Leigh Stoller

Rework Jon's logfile fixes (thanks Jon!) so that we do not need to

change any links. spewlogfile will operate as before, but if the
logfile is open, instead of a plain text page, use Jon's javascript
code by return that instead, which will then request the real spew
with ajax.

There is no longer any use of the mungelog.js code, it can be flushed
to the archive at some point.
parent 8b79af3f
<?php
header("Content-type: text/html; charset=utf-8");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
?>
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'
'http://www.w3.org/TR/html4/loose.dtd'> 'http://www.w3.org/TR/html4/loose.dtd'>
<html> <html>
...@@ -18,8 +11,8 @@ ...@@ -18,8 +11,8 @@
// the current path. // the current path.
var url = window.location.protocol + '//' + var url = window.location.protocol + '//' +
window.location.host + window.location.host +
'/spewlogfile.php3' + '/spewlogfile.php3' +
window.location.search; window.location.search + '&isajax=1';
// Fetch spewlogfile via AJAX call // Fetch spewlogfile via AJAX call
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
...@@ -45,6 +38,18 @@ ...@@ -45,6 +38,18 @@
window.scroll(window.scrollX, document.body.scrollHeight); window.scroll(window.scrollX, document.body.scrollHeight);
} }
} }
//
// Request is done, we got everything.
//
if (xhr.readyState == 4) {
#
# This will clear th busy indicators in the outer page,
# if there are any.
#
if (typeof(parent.loadFinished) == "function") {
parent.loadFinished();
}
}
}; };
// Invoke the AJAX // Invoke the AJAX
xhr.open('get', url, true); xhr.open('get', url, true);
......
<?php <?php
# #
# Copyright (c) 2005-2010 University of Utah and the Flux Group. # Copyright (c) 2005-2014 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -127,28 +127,33 @@ function STARTLOG($object) ...@@ -127,28 +127,33 @@ function STARTLOG($object)
if (!is_a($object, 'Logfile')) { if (!is_a($object, 'Logfile')) {
$object = $object->GetLogfile(); $object = $object->GetLogfile();
} }
$url = CreateURL("fetchlogfile", $object); $url = CreateURL("spewlogfile", $object);
echo "<center>\n"; #
echo "<img id='load_busy' src='busy.gif'> # If the logfile is open, put up the spinner.
#
if ($object->isopen()) {
echo "<center>\n";
echo "<img id='load_busy' src='busy.gif'>
<span id='load_loading'> Working ...</span>"; <span id='load_loading'> Working ...</span>";
echo "</center>\n"; echo "</center>\n";
echo "<br>\n"; echo "<br>\n";
echo "<div align=center><iframe class='outputframe' ". echo "<script>
"id='outputframe' name='outputframe'></iframe></div>\n"; function loadFinished() {
var busyimg = getObjbyName('load_busy');
echo "<script type='text/javascript' language='javascript' src='json.js'> var loadingspan = getObjbyName('load_loading');
</script>".
"<script type='text/javascript' language='javascript' busyimg.style.display = 'none';
src='mungelog.js'> busyimg.src = '1px.gif';
</script>\n"; loadingspan.innerHTML = '<center><b>Done!</b></center>';
}
</script>\n";
}
echo "<iframe id='downloader' name='downloader' echo "<iframe id='downloader' name='downloader'
class='downloader' src='$url' class='downloader' src='$url'>
onload='ml_handleReadyState(LOG_STATE_LOADED);'>
</iframe></div>\n"; </iframe></div>\n";
echo "<script type='text/javascript' language='javascript'>\n"; echo "<script type='text/javascript' language='javascript'>\n";
echo " HideFrame('outputframe');\n";
echo " ShowDownLoader('downloader');\n"; echo " ShowDownLoader('downloader');\n";
echo "</script>"; echo "</script>";
} }
......
<?php <?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 # {{{EMULAB-LICENSE
# #
...@@ -33,7 +33,8 @@ $anonopt = ($this_user ? "" : "-a"); ...@@ -33,7 +33,8 @@ $anonopt = ($this_user ? "" : "-a");
# #
# Verify page arguments. # Verify page arguments.
# #
$reqargs = RequiredPageArguments("logfile", PAGEARG_LOGFILE); $reqargs = RequiredPageArguments("logfile", PAGEARG_LOGFILE);
$optargs = OptionalPageArguments("asajax", PAGEARG_BOOLEAN);
if (! isset($logfile)) { if (! isset($logfile)) {
PAGEARGERROR("Must provide either a logfile ID"); PAGEARGERROR("Must provide either a logfile ID");
...@@ -42,6 +43,22 @@ if (! isset($logfile)) { ...@@ -42,6 +43,22 @@ if (! isset($logfile)) {
# Check permission in the backend. # Check permission in the backend.
$logfileid = $logfile->logid(); $logfileid = $logfile->logid();
#
# Spew is broken in Chrome, so we have switched to a pure ajax
# approach (thanks Jon!). If the logfile is currently open, we
# return an HTML fragment that requests this page again, but as
# an ajax request, so that the client gets periodic updates.
#
if (!isset($asajax) && $logfile->isopen()) {
header("Content-type: text/html; charset=utf-8");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
readfile("fetchlogfile.php3");
return;
}
# #
# A cleanup function to keep the child from becoming a zombie, since # A cleanup function to keep the child from becoming a zombie, since
# the script is terminated, but the children are left to roam. # the script is terminated, but the children are left to roam.
......
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