From 62d12c946e3d1fa2a022f940660c1da0597fccac Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 29 May 2012 04:47:48 +0000 Subject: [PATCH] - user web: job submission home page has 1) links to job submission pages for relevant apps 2) links to Admin pages for relevant apps svn path=/trunk/boinc/; revision=25723 --- checkin_notes | 8 ++++ html/user/submit.php | 92 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 80 insertions(+), 20 deletions(-) diff --git a/checkin_notes b/checkin_notes index f973b58d8b..8ffd69ec36 100644 --- a/checkin_notes +++ b/checkin_notes @@ -4079,3 +4079,11 @@ David 26 May 2012 html/user/ am_set_info.php + +David 28 May 2012 + - user web: job submission home page has + 1) links to job submission pages for relevant apps + 2) links to Admin pages for relevant apps + + html/user/ + submit.php diff --git a/html/user/submit.php b/html/user/submit.php index f045629832..67377955b8 100644 --- a/html/user/submit.php +++ b/html/user/submit.php @@ -27,16 +27,9 @@ error_reporting(E_ALL); ini_set('display_errors', true); ini_set('display_startup_errors', true); -// the job submission "home page": -// show the user's in-progress and completed batches, -// and a button for creating a new batch +// show a set of batches // -function handle_main($user) { - page_head("Job submission and control"); - - $first = true; - $batches = BoincBatch::enum("user_id = $user->id order by id desc"); - +function show_batches($batches) { foreach ($batches as $batch) { if ($batch->state < BATCH_STATE_COMPLETE) { $wus = BoincWorkunit::enum("batch = $batch->id"); @@ -48,20 +41,24 @@ function handle_main($user) { } else { $batch->app_name = "unknown"; } + $user = BoincUser::lookup_id($batch->user_id); + $batch->user_name = $user->name; } + $first = true; foreach ($batches as $batch) { if ($batch->state != BATCH_STATE_IN_PROGRESS) continue; if ($first) { $first = false; echo "

Batches in progress

\n"; start_table(); - table_header("name", "ID", "app", "# jobs", "progress", "submitted"); + table_header("name", "ID", "user", "app", "# jobs", "progress", "submitted"); } $pct_done = (int)($batch->fraction_done*100); table_row( "id>$batch->name", "id>$batch->id", + $batch->user_name, $batch->app_name, $batch->njobs, "$pct_done%", @@ -69,7 +66,7 @@ function handle_main($user) { ); } if ($first) { - echo "

You have no in-progress batches.\n"; + echo "

No in-progress batches.\n"; } else { end_table(); } @@ -81,18 +78,19 @@ function handle_main($user) { $first = false; echo "

Completed batches

\n"; start_table(); - table_header("name", "ID", "app", "# jobs", "submitted"); + table_header("name", "ID", "user", "app", "# jobs", "submitted"); } table_row( "id>$batch->name", "id>$batch->id", + $batch->user_name, $batch->app_name, $batch->njobs, local_time_str($batch->create_time) ); } if ($first) { - echo "

You have no completed batches.\n"; + echo "

No completed batches.\n"; } else { end_table(); } @@ -104,11 +102,12 @@ function handle_main($user) { $first = false; echo "

Aborted batches

\n"; start_table(); - table_header("name", "ID", "app", "# jobs", "submitted"); + table_header("name", "ID", "user", "app", "# jobs", "submitted"); } table_row( "id>$batch->name", "id>$batch->id", + $batch->user_name, $batch->app_name, $batch->njobs, local_time_str($batch->create_time) @@ -117,11 +116,63 @@ function handle_main($user) { if (!$first) { end_table(); } +} - echo "

- File sandbox - | Job submission - | Job control "; +// the job submission "home page": +// show the user's in-progress and completed batches, +// and a button for creating a new batch +// +function handle_main($user) { + global $submit_urls; + $user_submit = BoincUserSubmit::lookup_userid($user->id); + if (!$user_submit) { + error_page("Ask the project admins for permission to submit jobs"); + } + + page_head("Job submission and control"); + foreach ($submit_urls as $appname=>$submit_url) { + $app = BoincApp::lookup("name='$appname'"); + if (!$app) error_page("bad submit_url name: $appname"); + $usa = BoincUserSubmitApp::lookup("user_id=$user->id and app_id=$app->id"); + if ($usa || $user_submit->manage_all) { + echo "
$app->user_friendly_name: Submit jobs"; + if ($user_submit->manage_all || $usa->manage) { + echo " · id>Administer + "; + } + } + } + if ($user_submit->manage_all) { + echo "
Administer all apps + "; + } + + $batches = BoincBatch::enum("user_id = $user->id order by id desc"); + show_batches($batches); + + page_tail(); +} + +function handle_admin($user) { + $app_id = get_int("app_id"); + $user_submit = BoincUserSubmit::lookup_userid($user->id); + if (!$user_submit) error_page("no access"); + if ($app_id) { + if (!$user_submit->manage_all) { + $usa = BoincUserSubmitApp::lookup("user_id = $user->id and app_id=$app_id"); + if (!$usa) error_page("no access"); + } + $app = BoincApp::lookup_id($app_id); + if (!$app) error_page("no such app"); + page_head("Administer $app->user_friendly_name"); + $batches = BoincBatch::enum("app_id = $app_id order by id desc"); + show_batches($batches); + } else { + if (!$user_submit->manage_all) error_page("no access"); + page_head("Administer all apps"); + $batches = BoincBatch::enum("true order by id desc"); + show_batches($batches); + } page_tail(); } @@ -169,7 +220,7 @@ function handle_query_batch($user) { echo "

Jobs

\n"; start_table(); table_header( - "Job ID
click for details or to get output files", + "Job ID and name
click for details or to get output files", "status", "Canonical instance
click to see result page on BOINC server" ); @@ -185,7 +236,7 @@ function handle_query_batch($user) { } echo " - id>$wu->id + id>$wu->id · $wu->name $y $x @@ -332,6 +383,7 @@ switch ($action) { case '': handle_main($user); break; case 'abort_batch': handle_abort_batch($user); break; case 'abort_batch_confirm': handle_abort_batch_confirm(); break; +case 'admin': handle_admin($user); break; case 'query_batch': handle_query_batch($user); break; case 'query_job': handle_query_job($user); break; case 'retire_batch': handle_retire_batch($user); break;