Commit 099f0cfa authored by Leigh Stoller's avatar Leigh Stoller

Minor changes to experiment image handling. Spit back Mac's Coming

Soon image when the image is not available (cause the renderer is not
finished yet).

The default thumbsize is now 160, so do not call out to the renderer
to generate the thumb on the showexp page; just take it from the DB.
parent a3aae832
......@@ -1294,6 +1294,21 @@ function TBExptIndex($pid, $eid)
return $idx;
}
function TBrsrcIndex($pid, $eid)
{
$query_result =
DBQueryFatal("select s.rsrcidx from experiments as e ".
"left join experiment_stats as s on s.exptidx=e.idx ".
"where e.pid='$pid' and e.eid='$eid'");
if (mysql_num_rows($query_result) == 0) {
return -1;
}
$row = mysql_fetch_array($query_result);
$idx = $row[rsrcidx];
return $idx;
}
function TBUidNodeLastLogin($uid)
{
$query_result =
......
......@@ -48,9 +48,19 @@ if (! TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to view experiment $exp_eid!", 1);
}
$expindex = TBExptIndex($exp_pid, $exp_eid);
$expstate = TBExptState($exp_pid, $exp_eid);
$isbatch = TBExptBatchState($exp_pid, $exp_eid, $batchstate);
#
# Need some DB info.
#
$query_result =
DBQueryFatal("select e.idx,e.state,e.batchmode,s.rsrcidx ".
" from experiments as e ".
"left join experiment_stats as s on s.exptidx=e.idx ".
"where e.eid='$eid' and e.pid='$pid'");
$row = mysql_fetch_array($query_result);
$expindex = $row["idx"];
$expstate = $row["state"];
$rsrcidx = $row["rsrcidx"];
$isbatch = $row["batchmode"];
echo "<font size=+2>Experiment <b>".
"<a href='showproject.php3?pid=$pid'>$pid</a>/".
......@@ -163,8 +173,8 @@ SUBMENUEND_2A();
echo "<br>
<a href='shownsfile.php3?pid=$exp_pid&eid=$exp_eid'>
<img width=160 height=160 border=1 alt='experiment vis'
src='top2image.php3?pid=$pid&eid=$eid&thumb=160'></a>\n";
<img border=1 alt='experiment vis'
src='showthumb.php3?idx=$rsrcidx'></a>\n";
SUBMENUEND_2B();
......
......@@ -26,14 +26,21 @@ if (!isset($idx) ||
$query_result =
DBQueryFatal("select thumbnail from experiment_resources ".
"where idx='$idx'");
if (!$query_result || (mysql_num_rows($query_result) == 0)) {
USERERROR("No such thumbnail on file!", 1);
if ($query_result && mysql_num_rows($query_result)) {
$row = mysql_fetch_array($query_result);
$data = $row[thumbnail];
if (strlen($data)) {
header("Content-type: image/png");
echo "$data";
return;
}
}
$row = mysql_fetch_array($query_result);
$data = $row[thumbnail];
header("Content-type: image/png");
echo "$data";
# No Data. Spit back a stub image.
header("Content-type: image/gif");
readfile("coming-soon-thumb.gif");
#
# No Footer!
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -59,18 +59,26 @@ if (! TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_READINFO)) {
}
#
# XXX If an admin type, then use an appropriate gid so that we can get
# get to the top file. This needs more thought.
# See if any vis data. If not, then the renderer has not finished yet.
#
$gid = "nobody";
$query_result =
DBQueryFatal("select vname from vis_nodes ".
"where pid='$pid' and eid='$eid' limit 1");
if (ISADMIN($uid)) {
$gid = $exp_pid;
if (!$query_result || !mysql_num_rows($query_result)) {
# No Data. Spit back a stub image.
header("Content-type: image/gif");
readfile("coming-soon-thumb.gif");
return;
}
#
# Run in the project group.
#
$gid = $pid;
$arguments = "";
# note that we've already ensured that $detail and $thumb are numeric above.
# note that we already ensured that $detail and $thumb are numeric above.
if ($detail != 0) { $arguments .= " -d $detail"; }
if ($thumb != 0) { $arguments .= " -t $thumb"; }
......@@ -83,6 +91,11 @@ if ($fp = popen("$TBSUEXEC_PATH $uid $gid webvistopology " .
header("Content-type: image/png");
fpassthru($fp);
}
else {
# No Data. Spit back a stub image.
header("Content-type: image/gif");
readfile("coming-soon-thumb.gif");
}
#
# No Footer!
......
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