Skip to content

Commit ccc8da7

Browse files
committed
Merge pull request #6250 from BOINC/dpa_submit20
web: improve job submission interface
1 parent 712421a commit ccc8da7

File tree

3 files changed

+98
-94
lines changed

3 files changed

+98
-94
lines changed

html/inc/bootstrap.inc

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,34 @@ function sample_navbar(
182182
array(tra("CPU models"), $url_prefix."cpu_list.php"),
183183
array(tra("Computer types"), $url_prefix."host_stats.php"),
184184
);
185-
if (defined('REMOTE_JOB_SUBMISSION') && REMOTE_JOB_SUBMISSION) {
186-
if ($user && BoincUserSubmit::lookup_userid($user->id)) {
187-
$x[] = array("Job submission", $url_prefix."submit.php");
185+
navbar_menu(tra("Computing"), $x);
186+
187+
if (!empty('REMOTE_JOB_SUBMISSION')) {
188+
$user_submit = null;
189+
if ($user) {
190+
$user_submit = BoincUserSubmit::lookup_userid($user->id);
191+
}
192+
if ($user_submit) {
193+
$x = [];
188194
$x[] = ["File sandbox", "sandbox.php"];
195+
$x[] = ["Submit jobs", $url_prefix."submit.php"];
196+
$x[] = ["Job status", $url_prefix."submit.php?action=status"];
197+
$is_admin = $user_submit->manage_all;
198+
if (!$is_admin) {
199+
$usas = BoincUserSubmitApp::enum("user_id=$user->id");
200+
foreach ($usas as $usa) {
201+
if ($usa->manage) {
202+
$is_admin = true;
203+
break;
204+
}
205+
}
206+
}
207+
if ($is_admin) {
208+
$x[] = ["Administer", $url_prefix."submit.php?action=admin"];
209+
}
210+
navbar_menu(tra("Job submission"), $x);
189211
}
190212
}
191-
navbar_menu(tra("Computing"), $x);
192213
}
193214

194215
navbar_menu(tra("Community"), array(

html/user/buda.php

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,22 @@ function app_list($notice=null) {
6363
if (!is_dir($buda_root)) {
6464
mkdir($buda_root);
6565
}
66-
page_head('BUDA science apps');
66+
page_head('BOINC Universal Docker App (BUDA)');
6767
if ($notice) {
6868
echo "$notice <p>\n";
6969
}
7070
text_start();
7171
echo "
72-
<p>BUDA (BOINC Universal Docker App)
73-
lets you submit Docker jobs using a web interface.
74-
<a href=https://github.com/BOINC/boinc/wiki/BUDA-overview>BUDA overview</a>.
72+
<p>BUDA lets you submit Docker jobs using a web interface.
73+
<a href=https://github.com/BOINC/boinc/wiki/BUDA-overview>Learn more</a>.
74+
<p>
75+
BUDA science apps:
7576
";
7677

7778
$dirs = scandir($buda_root);
7879
foreach ($dirs as $dir) {
7980
if ($dir[0] == '.') continue;
80-
panel("Science app: <b>$dir</b>",
81+
panel("$dir",
8182
function() use ($dir) {
8283
show_app($dir);
8384
}
@@ -93,8 +94,10 @@ function show_app($dir) {
9394
start_table('table-striped');
9495
table_header('Variant<br><small>click for details</small>', 'Submit jobs');
9596
$pcs = scandir("$buda_root/$dir");
97+
$have_var = false;
9698
foreach ($pcs as $pc) {
9799
if ($pc[0] == '.') continue;
100+
$have_var = true;
98101
table_row(
99102
"<a href=buda.php?action=variant_view&app=$dir&variant=$pc>$pc</href>",
100103
button_text(
@@ -105,13 +108,15 @@ function show_app($dir) {
105108
end_table();
106109
echo "<p>";
107110
show_button_small("buda.php?action=variant_form&app=$dir", 'Add variant');
108-
echo "<p>";
109-
show_button(
110-
"buda.php?action=app_delete&app=$dir",
111-
"Delete science app '$dir'",
112-
null,
113-
'btn btn-xs btn-warning'
114-
);
111+
if (!$have_var) {
112+
echo "<p>";
113+
show_button(
114+
"buda.php?action=app_delete&app=$dir",
115+
"Delete app",
116+
null,
117+
'btn btn-xs btn-warning'
118+
);
119+
}
115120
}
116121

117122
function variant_view() {

html/user/submit.php

Lines changed: 56 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// - Admin (if privileged user)
2323
// - manage batches
2424
// view status, get output files, abort, retire
25-
// - toggle 'use only my computers'
25+
// - set 'use only my computers'
2626

2727
require_once("../inc/submit_db.inc");
2828
require_once("../inc/util.inc");
@@ -222,9 +222,7 @@ function show_batches($batches, $limit, $user, $app) {
222222
show_aborted($batches, $limit, $user, $app);
223223
}
224224

225-
// the job submission "home page":
226-
// show the user's in-progress and completed batches,
227-
// and a button for creating a new batch
225+
// show links to per-app job submission forms
228226
//
229227
function handle_main($user) {
230228
global $web_apps;
@@ -233,76 +231,53 @@ function handle_main($user) {
233231
error_page("Ask the project admins for permission to submit jobs");
234232
}
235233

236-
page_head("Job submission");
234+
page_head("Submit jobs");
237235

238-
if (isset($web_apps) && $web_apps) {
236+
if (!empty($web_apps)) {
239237
// show links to per-app job submission pages
240238
//
241-
echo "<h3>Submit jobs</h3>
242-
<ul>
243-
";
244-
foreach ($web_apps as $appname => $web_app) {
245-
$appname = BoincDb::escape_string($appname);
246-
$app = BoincApp::lookup("name='$appname'");
247-
if (!$app) error_page("bad web app name: $appname");
248-
$usa = BoincUserSubmitApp::lookup("user_id=$user->id and app_id=$app->id");
249-
if ($usa || $user_submit->submit_all) {
250-
echo "<li> <a href=$web_app->submit_url> $app->user_friendly_name </a>";
251-
}
239+
foreach ($web_apps as $area => $apps) {
240+
panel($area,
241+
function() use ($apps) {
242+
foreach ($apps as $app) {
243+
echo sprintf(
244+
'<a href=%s><img width=100 src=%s></a>&nbsp;',
245+
$app[1], $app[2]
246+
);
247+
}
248+
}
249+
);
252250
}
253-
echo "</ul>\n";
254-
}
255-
256-
echo '<h3>Where your jobs run</h3>';
257-
if ($user->seti_id) {
258-
echo "<p>
259-
Jobs you submit can run only on your computers.
260-
<p>
261-
";
262-
show_button(
263-
'submit.php?action=toggle_loc',
264-
'Allow them to run on any computer.'
265-
);
266-
} else {
267-
echo "<p>
268-
Jobs you submit can run on any computer.
269-
<p>
270-
";
271-
show_button(
272-
'submit.php?action=toggle_loc',
273-
'Allow them to run only on your computers.'
274-
);
275251
}
276252

277-
// show links to admin pages if relevant
278-
//
279-
$usas = BoincUserSubmitApp::enum("user_id=$user->id");
280-
$app_admin = false;
281-
foreach ($usas as $usa) {
282-
if ($usa->manage) {
283-
$app_admin = true;
284-
break;
285-
}
286-
}
287-
if ($user_submit->manage_all || $app_admin) {
288-
echo "<h3>Administer job submission</h3>\n";
289-
show_button('submit.php?action=admin', 'Administer');
290-
}
253+
form_start('submit.php');
254+
form_input_hidden('action', 'update_only_own');
255+
form_radio_buttons(
256+
'Jobs you submit can run', 'only_own',
257+
[
258+
[0, 'on any computer'],
259+
[1, 'only on your computers']
260+
],
261+
$user->seti_id
262+
);
263+
form_submit('Update');
264+
form_end();
265+
page_tail();
266+
}
291267

268+
function handle_show_status($user) {
269+
page_head("Job status");
292270
$batches = BoincBatch::enum("user_id = $user->id order by id desc");
293271
get_batches_params($batches);
294272
show_batches($batches, PAGE_SIZE, $user, null);
295273

296274
page_tail();
297275
}
298276

299-
function handle_toggle_loc($user) {
300-
if ($user->seti_id) {
301-
$user->update('seti_id=0');
302-
} else {
303-
$user->update('seti_id=1');
304-
}
305-
handle_main($user);
277+
function handle_update_only_own($user) {
278+
$val = get_int('only_own');
279+
$user->update("seti_id=$val");
280+
header("Location: submit.php");
306281
}
307282

308283
// show links for everything the user has admin access to
@@ -482,7 +457,7 @@ function handle_query_batch($user) {
482457
$owner = BoincUser::lookup_id($batch->user_id);
483458
}
484459

485-
$web_app = get_web_app($app);
460+
$is_assim_move = is_assim_move($app);
486461

487462
page_head("Batch $batch_id");
488463
text_start(800);
@@ -510,15 +485,15 @@ function handle_query_batch($user) {
510485
}
511486
row2("GFLOP/hours, estimated", number_format(credit_to_gflop_hours($batch->credit_estimate), 2));
512487
row2("GFLOP/hours, actual", number_format(credit_to_gflop_hours($batch->credit_canonical), 2));
513-
if (!$web_app->assim_move) {
488+
if (!$is_assim_move) {
514489
row2("Total size of output files",
515490
size_string(batch_output_file_size($batch->id))
516491
);
517492
}
518493
end_table();
519494
echo "<p>";
520495

521-
if ($web_app->assim_move) {
496+
if ($is_assim_move) {
522497
$url = "get_output3.php?action=get_batch&batch_id=$batch->id";
523498
} else {
524499
$url = "get_output2.php?cmd=batch&batch_id=$batch->id";
@@ -552,7 +527,7 @@ function handle_query_batch($user) {
552527
"Name <br><small>click for details</small>",
553528
"status"
554529
];
555-
if (!$web_app->assim_move) {
530+
if (!$is_assim_move) {
556531
$x[] = "Download Results";
557532
}
558533
row_heading_array($x);
@@ -573,7 +548,7 @@ function handle_query_batch($user) {
573548
"<a href=submit.php?action=query_job&wuid=$wu->id>$wu->name</a>",
574549
$y,
575550
];
576-
if (!$web_app->assim_move) {
551+
if (!$is_assim_move) {
577552
$x[] = $text;
578553
}
579554
row_array($x);
@@ -584,19 +559,21 @@ function handle_query_batch($user) {
584559
page_tail();
585560
}
586561

587-
// get the 'web app' structure (from project.inc) for the given app.
588-
// This says what output file scheme it uses and what the submit page URL is.
589-
// If not listed, return a default structure
562+
// Does the assimilator for the given app move output files
563+
// to a results/<batchid>/ directory?
564+
// This info is stored in the $web_apps data structure in project.inc
590565
//
591-
function get_web_app($app) {
566+
function is_assim_move($app) {
592567
global $web_apps;
593-
if (isset($web_apps) && array_key_exists($app->name, $web_apps)) {
594-
return $web_apps[$app->name];
568+
if (empty($web_apps)) return false;
569+
foreach ($web_apps as $name => $apps) {
570+
foreach ($apps as $web_app) {
571+
if ($web_app[0] == $app->name) {
572+
return $web_app[3];
573+
}
574+
}
595575
}
596-
$x = new StdClass;
597-
$x->submit_url = null;
598-
$x->assim_move = false;
599-
return $x;
576+
return false;
600577
}
601578

602579
// show the details of a job, including links to see the output files
@@ -607,7 +584,7 @@ function handle_query_job($user) {
607584
if (!$wu) error_page("no such job");
608585

609586
$app = BoincApp::lookup_id($wu->appid);
610-
$web_app = get_web_app($app);
587+
$is_assim_move = is_assim_move($app);
611588

612589
page_head("Job '$wu->name'");
613590
text_start(800);
@@ -638,7 +615,7 @@ function handle_query_job($user) {
638615
$phys_names = get_outfile_phys_names($result);
639616
$log_names = get_outfile_log_names($result);
640617
for ($i=0; $i<count($phys_names); $i++) {
641-
if ($web_app->assim_move) {
618+
if ($is_assim_move) {
642619
// file is in
643620
// project/results/<batchid>/<wu_name>__file_<log_name>
644621
$path = sprintf('results/%s/%s__file_%s',
@@ -844,7 +821,8 @@ function handle_show_all($user) {
844821
case 'retire_batch': handle_retire_batch($user); break;
845822
case 'retire_multi': handle_retire_multi($user); break;
846823
case 'show_all': handle_show_all($user); break;
847-
case 'toggle_loc': handle_toggle_loc($user); break;
824+
case 'status': handle_show_status($user); break;
825+
case 'update_only_own': handle_update_only_own($user); break;
848826
default:
849827
error_page("no such action $action");
850828
}

0 commit comments

Comments
 (0)