Web: add active/all button in host_app_versions.php

This commit is contained in:
David Anderson 2015-11-12 18:14:47 -08:00
parent 45a27257bf
commit 920ee2777c
1 changed files with 24 additions and 9 deletions

View File

@ -18,8 +18,6 @@
require_once("../inc/util.inc"); require_once("../inc/util.inc");
check_get_args(array("hostid"));
function rsc_name($t) { function rsc_name($t) {
switch ($t) { switch ($t) {
case 2: return tra("CPU"); case 2: return tra("CPU");
@ -30,11 +28,16 @@ function rsc_name($t) {
return tra("Unknown"); return tra("Unknown");
} }
function av_desc($gavid) { function av_desc($gavid, $show_dep) {
if ($gavid >= 1000000) { if ($gavid >= 1000000) {
// anonymous platform
//
$appid = (int)($gavid/1000000); $appid = (int)($gavid/1000000);
$app = BoincApp::lookup_id($appid); $app = BoincApp::lookup_id($appid);
if (!$app || $app->deprecated) { if (!$app) {
return null;
}
if (!$show_dep && $app->deprecated) {
return null; return null;
} }
$rsc_type = $gavid % 1000000; $rsc_type = $gavid % 1000000;
@ -42,11 +45,17 @@ function av_desc($gavid) {
return "$app->user_friendly_name (".tra("anonymous platform").", $r)"; return "$app->user_friendly_name (".tra("anonymous platform").", $r)";
} else { } else {
$av = BoincAppVersion::lookup_id($gavid); $av = BoincAppVersion::lookup_id($gavid);
if (!$av || $av->deprecated) { if (!$av) {
return null;
}
if (!$show_dep && $av->deprecated) {
return null; return null;
} }
$app = BoincApp::lookup_id($av->appid); $app = BoincApp::lookup_id($av->appid);
if (!$app || $app->deprecated) { if (!$app) {
return null;
}
if (!$show_dep && $app->deprecated) {
return null; return null;
} }
$platform = BoincPlatform::lookup_id($av->platformid); $platform = BoincPlatform::lookup_id($av->platformid);
@ -57,8 +66,8 @@ function av_desc($gavid) {
} }
} }
function show_hav($hav) { function show_hav($hav, $show_dep) {
$desc = av_desc($hav->app_version_id); $desc = av_desc($hav->app_version_id, $show_dep);
if (!$desc) return; if (!$desc) return;
row1($desc); row1($desc);
row2(tra("Number of tasks completed"), $hav->et_n); row2(tra("Number of tasks completed"), $hav->et_n);
@ -74,6 +83,7 @@ function show_hav($hav) {
} }
$hostid = get_int('hostid'); $hostid = get_int('hostid');
$show_dep = get_int('show_dep', true);
$havs = BoincHostAppVersion::enum("host_id=$hostid"); $havs = BoincHostAppVersion::enum("host_id=$hostid");
@ -81,9 +91,14 @@ page_head(tra("Application details for host %1", $hostid));
start_table(); start_table();
foreach ($havs as $hav) { foreach ($havs as $hav) {
//if (!$hav->pfc_n) continue; //if (!$hav->pfc_n) continue;
show_hav($hav); show_hav($hav, $show_dep);
} }
end_table(); end_table();
if ($show_dep) {
show_button("host_app_versions.php?hostid=$hostid", "Show active versions");
} else {
show_button("host_app_versions.php?hostid=$hostid&show_dep=1", "Show all versions");
}
page_tail(); page_tail();
?> ?>