Commit f8d3f970 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add a tab on the showexp page (when showing an instance) to edit the

annotation.
parent 9a903e38
...@@ -9,7 +9,7 @@ require("Sajax.php"); ...@@ -9,7 +9,7 @@ require("Sajax.php");
include("showstuff.php3"); include("showstuff.php3");
include("template_defs.php"); include("template_defs.php");
sajax_init(); sajax_init();
sajax_export("GetExpState", "Show"); sajax_export("GetExpState", "Show", "ModifyAnno");
# #
# Only known and logged in users can look at experiments. # Only known and logged in users can look at experiments.
...@@ -46,6 +46,18 @@ if (!$experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) { ...@@ -46,6 +46,18 @@ if (!$experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to view experiment $exp_eid!", 1); USERERROR("You do not have permission to view experiment $exp_eid!", 1);
} }
# Template Instance Experiments get special treatment in this page.
$instance = NULL;
if ($EXPOSETEMPLATES) {
$instance = TemplateInstance::LookupByExptidx($experiment->idx());
if (! is_null($instance)) {
$tag = "Instance";
$guid = $instance->guid();
$vers = $instance->vers();
}
}
# #
# For the Sajax Interface # For the Sajax Interface
# #
...@@ -56,9 +68,17 @@ function GetExpState($a, $b) ...@@ -56,9 +68,17 @@ function GetExpState($a, $b)
return $experiment->state(); return $experiment->state();
} }
function ModifyAnno($newtext)
{
global $this_user, $instance;
$instance->SetAnnotation($this_user, $newtext);
return 0;
}
function Show($which, $arg1, $arg2) function Show($which, $arg1, $arg2)
{ {
global $experiment, $uid, $TBSUEXEC_PATH, $TBADMINGROUP; global $experiment, $instance, $uid, $TBSUEXEC_PATH, $TBADMINGROUP;
$pid = $experiment->pid(); $pid = $experiment->pid();
$eid = $experiment->eid(); $eid = $experiment->eid();
$html = ""; $html = "";
...@@ -69,6 +89,14 @@ function Show($which, $arg1, $arg2) ...@@ -69,6 +89,14 @@ function Show($which, $arg1, $arg2)
$html = ob_get_contents(); $html = ob_get_contents();
ob_end_clean(); ob_end_clean();
} }
if ($which == "anno") {
if (isset($instance)) {
ob_start();
$instance->ShowAnnotation(1);
$html = ob_get_contents();
ob_end_clean();
}
}
elseif ($which == "details") { elseif ($which == "details") {
$showevents = $arg1; $showevents = $arg1;
$output = array(); $output = array();
...@@ -250,18 +278,6 @@ $paniced = $row["paniced"]; ...@@ -250,18 +278,6 @@ $paniced = $row["paniced"];
$panic_date = $row["panic_date"]; $panic_date = $row["panic_date"];
$lockdown = $row["lockdown"]; $lockdown = $row["lockdown"];
# Template Instance Experiments get special treatment in this page.
$instance = NULL;
if ($EXPOSETEMPLATES) {
$instance = TemplateInstance::LookupByExptidx($expindex);
if (! is_null($instance)) {
$tag = "Instance";
$guid = $instance->guid();
$vers = $instance->vers();
}
}
# #
# Standard Testbed Header. # Standard Testbed Header.
# #
...@@ -613,6 +629,12 @@ echo "<script type='text/javascript' language='javascript'> ...@@ -613,6 +629,12 @@ echo "<script type='text/javascript' language='javascript'>
function FullScreenVis() { function FullScreenVis() {
window.location.replace('shownsfile.php3?pid=$pid&eid=$eid'); window.location.replace('shownsfile.php3?pid=$pid&eid=$eid');
} }
function ModifyAnno() {
textarea = getObjbyName('annotation');
x_ModifyAnno(textarea.value, ModifyAnno_cb);
}
function ModifyAnno_cb(val) {
}
</script>\n"; </script>\n";
# #
...@@ -634,10 +656,10 @@ echo "<li> ...@@ -634,10 +656,10 @@ echo "<li>
<a href=\"#D\" id=\"li_details\" onclick=\"Show('details');\">". <a href=\"#D\" id=\"li_details\" onclick=\"Show('details');\">".
"Details</a></li>\n"; "Details</a></li>\n";
if ($instance && $expstate == $TB_EXPTSTATE_ACTIVE) { if ($instance) {
echo "<li> echo "<li>
<a href=\"#E\" id=\"li_graphs\" onclick=\"Show('graphs');\">". <a href=\"#E\" id=\"li_anno\" onclick=\"Show('anno');\">".
"Graphs</a></li>\n"; "Annotation</a></li>\n";
} }
echo "</ul>\n"; echo "</ul>\n";
......
...@@ -1506,8 +1506,9 @@ class TemplateInstance ...@@ -1506,8 +1506,9 @@ class TemplateInstance
# #
# Display annotation in text box with button to change. # Display annotation in text box with button to change.
# #
function ShowAnnotation() { function ShowAnnotation($longform = 0) {
$annotation = $this->GetAnnotation(); $annotation = $this->GetAnnotation();
$cols = ($longform ? 25 : 5);
if (! $annotation) { if (! $annotation) {
$annotation = ""; $annotation = "";
} }
...@@ -1515,19 +1516,21 @@ class TemplateInstance ...@@ -1515,19 +1516,21 @@ class TemplateInstance
echo "<center>"; echo "<center>";
echo "<b>Annotation</b><br>\n"; echo "<b>Annotation</b><br>\n";
echo "<form action='fee' method=post>\n"; echo "<form action='fee' method=post>\n";
echo "<textarea id='annotation' rows=5 cols=80>$annotation". echo "<textarea id='annotation' rows=$cols cols=80>$annotation".
"</textarea></form>"; "</textarea></form>";
echo "<button name=submit type=button value=submit ". echo "<button name=submit type=button value=submit ".
"onclick=\"ModifyAnno();\">Submit Changes</button>\n"; "onclick=\"ModifyAnno();\">Submit Changes</button>\n";
echo "<center>"; echo "<center>";
echo "<script type='text/javascript' language='javascript'> if (! $longform) {
function ModifyAnno() { echo "<script type='text/javascript' language='javascript'>
textarea = getObjbyName('annotation'); function ModifyAnno() {
x_ModifyAnno(textarea.value, ModifyAnno_cb); textarea = getObjbyName('annotation');
} x_ModifyAnno(textarea.value, ModifyAnno_cb);
function ModifyAnno_cb(val) { }
} function ModifyAnno_cb(val) {
</script>\n"; }
</script>\n";
}
} }
function ShowRunAnnotation($runidx) { function ShowRunAnnotation($runidx) {
$annotation = $this->GetRunAnnotation($runidx); $annotation = $this->GetRunAnnotation($runidx);
......
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