Add the judges scheduler status page, updated automagically using AJAX

Redirect the scheduler link to a launcher link that lauches the scheduler then goes to the status page
This commit is contained in:
james 2006-10-25 02:41:41 +00:00
parent 5cf008adf6
commit a871759129
3 changed files with 137 additions and 7 deletions

View File

@ -0,0 +1,119 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this pr<input type=\"submit\" value=\"".i18n("Save Configuration")."\" />\n";
ogram; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
send_header("Judges - Scheduler Status");
?>
<script type="text/javascript">
function getHTTPObject()
{
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
try {
xmlhttp = new XMLHttpRequest();
} catch (e)
{
xmlhttp = false;
}
}
return xmlhttp;
}
var http=getHTTPObject();
function updateStatus()
{
var url="judges_scheduler_status_output.php";
http.open("GET",url,true);
http.onreadystatechange=handleResponse;
http.send(null);
}
function handleResponse()
{
try {
if(http.readyState==4)
{
var obj=http.responseText.split(":");
document.getElementById('schedulerstatus').innerHTML=obj[1];
document.getElementById('schedulerpercent').innerHTML=obj[0]+"%";
setTimeout('updateStatus()',5000);
}
}
catch(e)
{
alert('caught error'+e);
}
}
</script>
<?
if($config['judge_scheduler_percent']=="-1")
//|| $config['judge_scheduler_percent']=="0")
{
echo i18n("The judge scheduler is not currently running");
echo $config['judge_scheduler_percent'];
echo $config['judge_scheduler_activity'];
echo "<br />";
echo "<br />";
echo "<a href=\"judges_schedulerconfig.php\">".i18n("Judges Scheduler Configuration")."</a>";
}
else
{
echo "<table>";
echo "<tr><td>".i18n("Scheduler status").":</td><td><div id=\"schedulerstatus\" style=\"font-weight: bold;\"></div></td></tr>";
echo "<tr><td>".i18n("Scheduler percent").":</td><td><div id=\"schedulerpercent\" style=\"font-weight: bold;\"></div></td></tr>";
echo "</table>";
?>
<script type="text/javascript">updateStatus()</script>
<?
}
send_footer();
?>

View File

@ -0,0 +1,14 @@
<?
include "../data/config.inc.php";
mysql_connect($DBHOST,$DBUSER,$DBPASS);
mysql_select_db($DBNAME);
$q=mysql_query("SELECT val FROM config WHERE year='0' AND var='judge_scheduler_percent'");
$r=mysql_fetch_object($q);
$percent=$r->val;
$q=mysql_query("SELECT val FROM config WHERE year='0' AND var='judge_scheduler_activity'");
$r=mysql_fetch_object($q);
$status=$r->val;
echo "$percent:$status\n";
?>

View File

@ -97,17 +97,14 @@ ogram; see the file COPYING. If not, write to
if($ok)
{
echo i18n("Everything looks in order, we're ready to create the
divisional awards judging teams. Click 'Create Divisional Awards
Judging Teams' below to start the scheduler. Please be patient as it
may take several minutes find an good solution to the judging team
assignments.");
divisional awards judging teams. Click link below to start the scheduler.
Please be patient as it may take several minutes find an good solution to
the judging team assignments.");
echo "<br />";
echo "<br />";
echo "<a href=\"judges_sa.php\">".i18n("Create Divisional Awards Judging Teams")."</a>";
echo "<a href=\"judges_sa_launcher.php\">".i18n("Start the judging scheduler to create divisional awards judging teams and team project assignments")."</a>";
}