Commit 99a15ab0 authored by David Anderson's avatar David Anderson

- web: in lists of tasks, give the option of showing names instead of IDs


svn path=/trunk/boinc/; revision=17308
parent 65679139
......@@ -1715,3 +1715,14 @@ David 18 Feb 2009
boinc_db.h
sched/
server_types.cpp
David 18 Feb 2009
- web: in lists of tasks, give the option of showing names instead of IDs
html/
inc/
host.inc
result.inc
user/
results.php
workunit.php
......@@ -293,12 +293,13 @@ function show_host_row($host, $i, $private, $show_owner) {
// This is used in the "top computers" display
//
printf("
<td>%s</td>
<td>%s</td>
<td align=right>%s</td>
<td align=right>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s <br> %s</td>",
format_credit($host->expavg_credit), format_credit_large($host->total_credit),
format_credit($host->expavg_credit),
format_credit_large($host->total_credit),
cpu_desc($host),
gpu_desc($host->serialnum),
$host->os_name, $host->os_version
......
......@@ -140,12 +140,29 @@ function wu_error_mask_str($s) {
return $x;
}
function result_table_start($show_wu_link, $show_host_link, $show_result_link) {
function result_page_url($info) {
$c = $info->clause;
$o = $info->offset;
$sn = $info->show_names;
return "results.php?$c&amp;offset=$o&amp;show_names=$sn";
}
function result_table_start($show_wu_link, $show_host_link, $info) {
start_table();
echo "
<tr>
";
if ($show_result_link) {
echo "<tr>";
if ($info) {
if ($info->show_names) {
$i2 = clone $info;
$i2->show_names = 0;
$url = result_page_url($i2);
echo "<th>Task name<br><span class=\"smalltext\">click for details<br><a href=$url>Show IDs</a></span></th>\n";
} else {
$i2 = clone $info;
$i2->show_names = 1;
$url = result_page_url($i2);
echo "<th>Task ID<br><span class=\"smalltext\">click for details<br><a href=$url>Show names</a></span></th>\n";
}
} else {
echo "<th>Task ID<br><span class=\"smalltext\">click for details</span></th>\n";
}
if ($show_wu_link) {
......@@ -185,10 +202,10 @@ function bad_result($result) {
}
function show_result_row(
$result, $show_wu_link, $show_host_link, $show_result_link, $i
$result, $show_wu_link, $show_host_link, $show_name, $i
) {
$s = time_str($result->sent_time);
// if result has been received, show the received time,
// if result has been reported, show the received time,
// else show the reporting deadline in green if in the future
// and in red if in the past.
//
......@@ -212,9 +229,12 @@ function show_result_row(
$result_granted_credit = result_granted_credit_string($result, $result_granted_credit);
$j = $i % 2;
echo "<tr class=row$j>";
if ($show_result_link) {
echo "<td><a href=\"result.php?resultid=$result->id\" title=\"Name: ".$result->name."\">$result->id</a></td>\n";
if ($show_name) {
$x = $result->name;
} else {
$x = $result->id;
}
echo "<td><a href=\"result.php?resultid=$result->id\">$x</a></td>\n";
if ($show_wu_link) {
echo "<td><a href=\"workunit.php?wuid=$result->workunitid\">$result->workunitid</a></td>\n";
}
......@@ -232,9 +252,9 @@ function show_result_row(
<td>$ss</td>
<td>$out</td>
<td>$cl</td>
<td>$cpu_time</td>
<td>$result_claimed_credit</td>
<td>$result_granted_credit</td>
<td align=right>$cpu_time</td>
<td align=right>$result_claimed_credit</td>
<td align=right>$result_granted_credit</td>
</tr>
";
}
......@@ -279,23 +299,26 @@ function show_result($result) {
end_table();
}
function show_result_navigation(
$clause, $number_of_results, $offset, $results_per_page
) {
function show_result_navigation($info) {
echo "<br><center>";
if ($offset >= $results_per_page) {
$offset_p = $offset-$results_per_page;
echo "<a href=results.php?$clause&amp;offset=$offset_p>Previous $results_per_page</a>";
$show_prev = ($info->offset >= $info->results_per_page);
$show_next = ($info->number_of_results > $info->results_per_page);
if ($show_prev) {
$i2 = clone $info;
$i2->offset = $info->offset - $info->results_per_page;
$url = result_page_url($i2);
echo "<a href=$url>Previous ".$info->results_per_page."</a>";
}
if (($offset >= $results_per_page) && ($number_of_results > $results_per_page)) {
if ($show_prev && $show_next) {
echo "&nbsp;|&nbsp;";
}
if ($number_of_results > $results_per_page) {
$offset_n = $offset+$results_per_page;
echo "<a href=results.php?$clause&amp;offset=$offset_n>Next $results_per_page</a></center><br>";
} else {
echo "</center><br><br>";
if ($show_next) {
$i2 = clone $info;
$i2->offset = $info->offset + $info->results_per_page;
$url = result_page_url($i2);
echo "<a href=$url>Next ".$info->results_per_page."</a>";
}
echo "</center><br>";
}
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
......
......@@ -33,40 +33,46 @@ $hostid = get_int("hostid", true);
$userid = get_int("userid", true);
$offset = get_int("offset", true);
if (!$offset) $offset=0;
$show_names = get_int("show_names", true);
if (!$show_names) $show_names=0;
if ($hostid) {
$host = BoincHost::lookup_id($hostid);
if (!$host) error_page(tra("No host with hostid %1 found", $hostid));
if (!$host) error_page(tra("No computer with ID %1 found", $hostid));
$clause = "hostid=$hostid";
page_head(tra("Tasks for host %1", $host->id));
page_head(tra("Tasks for computer %1", $host->id));
} else if ($userid){
$user = get_logged_in_user();
if ($userid != $user->id) {
error_page(tra("No access"));
}
$clause = "userid=$userid";
page_head(tra("Tasks for user"));
page_head(tra("Tasks for $user->name"));
} else {
error_page(tra("You must provide either a hostid or a userid as parameter"));
}
result_table_start(true, false, true);
$query = "$clause order by id desc limit $offset,".($results_per_page+1);
$results = BoincResult::enum($query);
$number_of_results = count($results);
echo show_result_navigation(
$clause, $number_of_results, $offset, $results_per_page
);
$info = null;
$info->number_of_results = count($results);
$info->clause = $clause;
$info->results_per_page = $results_per_page;
$info->offset = $offset;
$info->show_names = $show_names;
echo show_result_navigation($info);
result_table_start(true, false, $info);
$i = 0;
foreach ($results as $result) {
if ($i >= $results_per_page) break;
show_result_row($result, true, false, true, $i);
show_result_row($result, true, false, $show_names, $i);
$i++;
}
echo "</table>\n";
echo show_result_navigation(
$clause, $number_of_results, $offset, $results_per_page
);
echo show_result_navigation($info);
page_tail();
?>
......@@ -64,11 +64,11 @@ if ($app->target_nresults>0 && !$wu->canonical_resultid) {
end_table();
project_workunit($wu);
result_table_start(false, true, true);
result_table_start(false, true, null);
$results = BoincResult::enum("workunitid=$wuid");
$i = 0;
foreach ($results as $result) {
show_result_row($result, false, true, true, $i++);
show_result_row($result, false, true, false, $i++);
}
echo "</table>\n";
}
......
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