diff --git a/html/user/submit.php b/html/user/submit.php new file mode 100644 index 0000000000..84425d67c7 --- /dev/null +++ b/html/user/submit.php @@ -0,0 +1,295 @@ +. + +require_once("../inc/submit_db.inc"); +require_once("../inc/util.inc"); +require_once("../inc/submit_util.inc"); +require_once("../project/project.inc"); + +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 +// +function handle_main($user) { + page_head("Job submission and control"); + + $first = true; + $batches = BoincBatch::enum("user_id = $user->id"); + + foreach ($batches as $batch) { + if ($batch->state < BATCH_STATE_COMPLETE) { + $wus = BoincWorkunit::enum("batch = $batch->id"); + $batch = get_batch_params($batch, $wus); + } + } + + 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"); + } + $pct_done = (int)($batch->fraction_done*100); + table_row( + "id>$batch->name", + "id>$batch->id", + $batch->app_name, + $batch->njobs, + "$pct_done%", + local_time_str($batch->create_time) + ); + } + if ($first) { + echo "

You have no in-progress batches.\n"; + } else { + end_table(); + } + + $first = true; + foreach ($batches as $batch) { + if ($batch->state != BATCH_STATE_COMPLETE) continue; + if ($first) { + $first = false; + echo "

Completed batches

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

You have no completed batches.\n"; + } else { + end_table(); + } + + $first = true; + foreach ($batches as $batch) { + if ($batch->state != BATCH_STATE_ABORTED) continue; + if ($first) { + $first = false; + echo "

Aborted batches

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

Return to job control page\n"; + page_tail(); +} + +// show the details of an existing batch +// +function handle_query_batch($user) { + $batch_id = get_int('batch_id'); + $batch = BoincBatch::lookup_id($batch_id); + $app = BoincApp::lookup_id($batch->app_id); + + page_head("Batch $batch_id"); + start_table(); + row2("name", $batch->name); + row2("application", $app->name); + row2("state", batch_state_string($batch->state)); + row2("# jobs", $batch->njobs); + row2("# error jobs", $batch->nerror_jobs); + row2("progress", sprintf("%.0f%%", $batch->fraction_done*100)); + if ($batch->completion_time) { + row2("completed", local_time_str($batch->completion_time)); + } + row2("GFLOP/hours, estimated", number_format(credit_to_gflop_hours($batch->credit_estimate), 2)); + row2("GFLOP/hours, actual", number_format(credit_to_gflop_hours($batch->credit_canonical), 2)); + end_table(); + $url = boinc_get_output_files_url($user, $batch_id); + show_button($url, "Get zipped output files"); + switch ($batch->state) { + case BATCH_STATE_IN_PROGRESS: + echo "
"; + show_button( + "submit.php?action=abort_batch_confirm&batch_id=$batch_id", + "Abort batch" + ); + break; + case BATCH_STATE_COMPLETE: + case BATCH_STATE_ABORTED: + echo "
"; + show_button( + "submit.php?action=retire_batch_confirm&batch_id=$batch_id", + "Retire batch" + ); + break; + } + + echo "

Jobs

\n"; + start_table(); + table_header( + "Job ID
click for details or to get output files", + "status", + "Canonical instance
click to see result page on BOINC server" + ); + $wus = BoincWorkunit::enum("batch = $batch->id"); + foreach($wus as $wu) { + $resultid = $wu->canonical_instance_id; + if ($resultid) { + $x = "$resultid"; + $y = "completed"; + } else { + $x = "---"; + $y = "in progress"; + } + + echo " + $id + $y + $x + + "; + } + end_table(); + echo "

Return to job control page\n"; + page_tail(); +} + +// show the details of a job, including links to see the output files +// +function handle_query_job() { + $wuid = get_int('wuid'); + + page_head("Job $wuid"); + echo "View workunit page\n"; + echo "

Instances

\n"; + start_table(); + table_header( + "Instance ID
click for result page", + "State", "Output files" + ); + $results = BoincResult::enum("workunitid=$job_id"); + foreach($results as $result) { + echo " + id>$result->id + ".state_string($result)." + +"; + $i = 0; + if ($result->server_state == 5) { + $paths = get_outfile_paths($result); + foreach ($paths as $path) { + echo "$outfile->size bytes"; + } + $i++; + } + echo "\n"; + } + end_table(); + echo "

Return to job control page\n"; + page_tail(); +} + +function handle_abort_batch_confirm() { + $batch_id = get_int('batch_id'); + page_head("Confirm abort batch"); + echo " + Aborting a batch will cancel all unstarted jobs. + Are you sure you want to do this? +

+ "; + show_button( + "submit.php?action=abort_batch&batch_id=$batch_id", + "Yes - abort batch" + ); + echo "

Return to job control page\n"; + page_tail(); +} + +function handle_abort_batch() { + $batch_id = get_int('batch_id'); + $batch = BoincBatch::lookup_id($batch_id); + if (!$batch) error("no such batch"); + if ($batch->user_id != $user->id) { + error("not owner"); + } + abort_batch($batch); + page_head("Batch aborted"); + echo "

Return to job control page\n"; + page_tail(); +} + +function handle_retire_batch_confirm() { + $batch_id = get_int('batch_id'); + page_head("Confirm retire batch"); + echo " + Retiring a batch will remove all of its output files. + Are you sure you want to do this? +

+ "; + show_button( + "submit.php?action=retire_batch&batch_id=$batch_id", + "Yes - retire batch" + ); + echo "

Return to job control page\n"; + page_tail(); +} + +function handle_retire_batch() { + $batch_id = get_int('batch_id'); + $batch = BoincBatch::lookup_id($batch_id); + if ($batch->user_id != $user->id) { + error_page("not owner"); + } + retire_batch($batch); + page_head("Batch retired"); + echo "

Return to job control page\n"; + page_tail(); +} + +$user = get_logged_in_user(); + +$action = get_str('action', true); + +switch ($action) { +case '': handle_main($user); break; +case 'abort_batch': handle_abort_batch(); break; +case 'abort_batch_confirm': handle_abort_batch_confirm(); break; +case 'query_batch': handle_query_batch($user); break; +case 'query_job': handle_query_job(); break; +case 'retire_batch': handle_retire_batch(); break; +case 'retire_batch_confirm': handle_retire_batch_confirm(); break; +default: + error_page('no such action'); +} + +?>